1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/fs/ext4/super.c 4 * 5 * Copyright (C) 1992, 1993, 1994, 1995 6 * Remy Card (card@masi.ibp.fr) 7 * Laboratoire MASI - Institut Blaise Pascal 8 * Universite Pierre et Marie Curie (Paris VI) --- 1092 unchanged lines hidden (view full) --- 1101 * superblock, we need to actually destroy the kobject. 1102 */ 1103 kobject_put(&sbi->s_kobj); 1104 wait_for_completion(&sbi->s_kobj_unregister); 1105 if (sbi->s_chksum_driver) 1106 crypto_free_shash(sbi->s_chksum_driver); 1107 kfree(sbi->s_blockgroup_lock); 1108 fs_put_dax(sbi->s_daxdev); |
1109 fscrypt_free_dummy_context(&sbi->s_dummy_enc_ctx); |
1110#ifdef CONFIG_UNICODE 1111 utf8_unload(sbi->s_encoding); 1112#endif 1113 kfree(sbi); 1114} 1115 1116static struct kmem_cache *ext4_inode_cachep; 1117 --- 267 unchanged lines hidden (view full) --- 1385 1386 if (res == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 1387 goto retry; 1388 if (!res) 1389 res = res2; 1390 return res; 1391} 1392 |
1393static const union fscrypt_context * 1394ext4_get_dummy_context(struct super_block *sb) |
1395{ |
1396 return EXT4_SB(sb)->s_dummy_enc_ctx.ctx; |
1397} 1398 1399static bool ext4_has_stable_inodes(struct super_block *sb) 1400{ 1401 return ext4_has_feature_stable_inodes(sb); 1402} 1403 1404static void ext4_get_ino_and_lblk_bits(struct super_block *sb, 1405 int *ino_bits_ret, int *lblk_bits_ret) 1406{ 1407 *ino_bits_ret = 8 * sizeof(EXT4_SB(sb)->s_es->s_inodes_count); 1408 *lblk_bits_ret = 8 * sizeof(ext4_lblk_t); 1409} 1410 1411static const struct fscrypt_operations ext4_cryptops = { 1412 .key_prefix = "ext4:", 1413 .get_context = ext4_get_context, 1414 .set_context = ext4_set_context, |
1415 .get_dummy_context = ext4_get_dummy_context, |
1416 .empty_dir = ext4_empty_dir, 1417 .max_namelen = EXT4_NAME_LEN, 1418 .has_stable_inodes = ext4_has_stable_inodes, 1419 .get_ino_and_lblk_bits = ext4_get_ino_and_lblk_bits, 1420}; 1421#endif 1422 1423#ifdef CONFIG_QUOTA --- 178 unchanged lines hidden (view full) --- 1602 {Opt_dioread_lock, "nodioread_nolock"}, 1603 {Opt_dioread_lock, "dioread_lock"}, 1604 {Opt_discard, "discard"}, 1605 {Opt_nodiscard, "nodiscard"}, 1606 {Opt_init_itable, "init_itable=%u"}, 1607 {Opt_init_itable, "init_itable"}, 1608 {Opt_noinit_itable, "noinit_itable"}, 1609 {Opt_max_dir_size_kb, "max_dir_size_kb=%u"}, |
1610 {Opt_test_dummy_encryption, "test_dummy_encryption=%s"}, |
1611 {Opt_test_dummy_encryption, "test_dummy_encryption"}, 1612 {Opt_nombcache, "nombcache"}, 1613 {Opt_nombcache, "no_mbcache"}, /* for backward compatibility */ 1614 {Opt_removed, "check=none"}, /* mount option from ext2/3 */ 1615 {Opt_removed, "nocheck"}, /* mount option from ext2/3 */ 1616 {Opt_removed, "reservation"}, /* mount option from ext2/3 */ 1617 {Opt_removed, "noreservation"}, /* mount option from ext2/3 */ 1618 {Opt_removed, "journal=%u"}, /* mount option from ext2/3 */ --- 195 unchanged lines hidden (view full) --- 1814 {Opt_usrjquota, 0, MOPT_Q}, 1815 {Opt_grpjquota, 0, MOPT_Q}, 1816 {Opt_offusrjquota, 0, MOPT_Q}, 1817 {Opt_offgrpjquota, 0, MOPT_Q}, 1818 {Opt_jqfmt_vfsold, QFMT_VFS_OLD, MOPT_QFMT}, 1819 {Opt_jqfmt_vfsv0, QFMT_VFS_V0, MOPT_QFMT}, 1820 {Opt_jqfmt_vfsv1, QFMT_VFS_V1, MOPT_QFMT}, 1821 {Opt_max_dir_size_kb, 0, MOPT_GTE0}, |
1822 {Opt_test_dummy_encryption, 0, MOPT_STRING}, |
1823 {Opt_nombcache, EXT4_MOUNT_NO_MBCACHE, MOPT_SET}, 1824 {Opt_err, 0, 0} 1825}; 1826 1827#ifdef CONFIG_UNICODE 1828static const struct ext4_sb_encodings { 1829 __u16 magic; 1830 char *name; --- 18 unchanged lines hidden (view full) --- 1849 1850 *encoding = &ext4_sb_encoding_map[i]; 1851 *flags = le16_to_cpu(es->s_encoding_flags); 1852 1853 return 0; 1854} 1855#endif 1856 |
1857static int ext4_set_test_dummy_encryption(struct super_block *sb, 1858 const char *opt, 1859 const substring_t *arg, 1860 bool is_remount) 1861{ 1862#ifdef CONFIG_FS_ENCRYPTION 1863 struct ext4_sb_info *sbi = EXT4_SB(sb); 1864 int err; 1865 1866 /* 1867 * This mount option is just for testing, and it's not worthwhile to 1868 * implement the extra complexity (e.g. RCU protection) that would be 1869 * needed to allow it to be set or changed during remount. We do allow 1870 * it to be specified during remount, but only if there is no change. 1871 */ 1872 if (is_remount && !sbi->s_dummy_enc_ctx.ctx) { 1873 ext4_msg(sb, KERN_WARNING, 1874 "Can't set test_dummy_encryption on remount"); 1875 return -1; 1876 } 1877 err = fscrypt_set_test_dummy_encryption(sb, arg, &sbi->s_dummy_enc_ctx); 1878 if (err) { 1879 if (err == -EEXIST) 1880 ext4_msg(sb, KERN_WARNING, 1881 "Can't change test_dummy_encryption on remount"); 1882 else if (err == -EINVAL) 1883 ext4_msg(sb, KERN_WARNING, 1884 "Value of option \"%s\" is unrecognized", opt); 1885 else 1886 ext4_msg(sb, KERN_WARNING, 1887 "Error processing option \"%s\" [%d]", 1888 opt, err); 1889 return -1; 1890 } 1891 ext4_msg(sb, KERN_WARNING, "Test dummy encryption mode enabled"); 1892#else 1893 ext4_msg(sb, KERN_WARNING, 1894 "Test dummy encryption mount option ignored"); 1895#endif 1896 return 1; 1897} 1898 |
1899static int handle_mount_opt(struct super_block *sb, char *opt, int token, 1900 substring_t *args, unsigned long *journal_devnum, 1901 unsigned int *journal_ioprio, int is_remount) 1902{ 1903 struct ext4_sb_info *sbi = EXT4_SB(sb); 1904 const struct mount_opts *m; 1905 kuid_t uid; 1906 kgid_t gid; --- 180 unchanged lines hidden (view full) --- 2087 if (arg > 7) { 2088 ext4_msg(sb, KERN_ERR, "Invalid journal IO priority" 2089 " (must be 0-7)"); 2090 return -1; 2091 } 2092 *journal_ioprio = 2093 IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, arg); 2094 } else if (token == Opt_test_dummy_encryption) { |
2095 return ext4_set_test_dummy_encryption(sb, opt, &args[0], 2096 is_remount); |
2097 } else if (m->flags & MOPT_DATAJ) { 2098 if (is_remount) { 2099 if (!sbi->s_journal) 2100 ext4_msg(sb, KERN_WARNING, "Remounting file system with no journal so ignoring journalled data option"); 2101 else if (test_opt(sb, DATA_FLAGS) != m->mount_opt) { 2102 ext4_msg(sb, KERN_ERR, 2103 "Cannot change data mode on remount"); 2104 return -1; --- 240 unchanged lines hidden (view full) --- 2345 2346 if (test_opt(sb, INIT_INODE_TABLE) && (nodefs || 2347 (sbi->s_li_wait_mult != EXT4_DEF_LI_WAIT_MULT))) 2348 SEQ_OPTS_PRINT("init_itable=%u", sbi->s_li_wait_mult); 2349 if (nodefs || sbi->s_max_dir_size_kb) 2350 SEQ_OPTS_PRINT("max_dir_size_kb=%u", sbi->s_max_dir_size_kb); 2351 if (test_opt(sb, DATA_ERR_ABORT)) 2352 SEQ_OPTS_PUTS("data_err=abort"); |
2353 |
2354 fscrypt_show_test_dummy_encryption(seq, sep, sb); 2355 |
2356 ext4_show_quota_options(seq, sb); 2357 return 0; 2358} 2359 2360static int ext4_show_options(struct seq_file *seq, struct dentry *root) 2361{ 2362 return _ext4_show_options(seq, root->d_sb, 0); 2363} --- 1349 unchanged lines hidden (view full) --- 3713 unsigned long journal_devnum = 0; 3714 unsigned long def_mount_opts; 3715 struct inode *root; 3716 const char *descr; 3717 int ret = -ENOMEM; 3718 int blocksize, clustersize; 3719 unsigned int db_count; 3720 unsigned int i; |
3721 int needs_recovery, has_huge_files, has_bigalloc; |
3722 __u64 blocks_count; 3723 int err = 0; 3724 unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; 3725 ext4_group_t first_not_zeroed; 3726 3727 if ((data && !orig_data) || !sbi) 3728 goto out_free_base; 3729 --- 275 unchanged lines hidden (view full) --- 4005 4006 sbi->s_encoding = encoding; 4007 sbi->s_encoding_flags = encoding_flags; 4008 } 4009#endif 4010 4011 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { 4012 printk_once(KERN_WARNING "EXT4-fs: Warning: mounting with data=journal disables delayed allocation, dioread_nolock, and O_DIRECT support!\n"); |
4013 clear_opt(sb, DIOREAD_NOLOCK); 4014 if (test_opt2(sb, EXPLICIT_DELALLOC)) { 4015 ext4_msg(sb, KERN_ERR, "can't mount with " 4016 "both data=journal and delalloc"); 4017 goto failed_mount; 4018 } |
4019 if (test_opt(sb, DIOREAD_NOLOCK)) { 4020 ext4_msg(sb, KERN_ERR, "can't mount with " 4021 "both data=journal and dioread_nolock"); 4022 goto failed_mount; 4023 } |
4024 if (test_opt(sb, DAX)) { 4025 ext4_msg(sb, KERN_ERR, "can't mount with " 4026 "both data=journal and dax"); 4027 goto failed_mount; 4028 } 4029 if (ext4_has_feature_encrypt(sb)) { 4030 ext4_msg(sb, KERN_WARNING, 4031 "encrypted files will use data=ordered " --- 200 unchanged lines hidden (view full) --- 4232 es->s_flags |= 4233 cpu_to_le32(EXT2_FLAGS_SIGNED_HASH); 4234#endif 4235 } 4236 } 4237 4238 /* Handle clustersize */ 4239 clustersize = BLOCK_SIZE << le32_to_cpu(es->s_log_cluster_size); |
4240 has_bigalloc = ext4_has_feature_bigalloc(sb); 4241 if (has_bigalloc) { |
4242 if (clustersize < blocksize) { 4243 ext4_msg(sb, KERN_ERR, 4244 "cluster size (%d) smaller than " 4245 "block size (%d)", clustersize, blocksize); 4246 goto failed_mount; 4247 } 4248 sbi->s_cluster_bits = le32_to_cpu(es->s_log_cluster_size) - 4249 le32_to_cpu(es->s_log_block_size); --- 564 unchanged lines hidden (view full) --- 4814#ifdef CONFIG_UNICODE 4815 utf8_unload(sbi->s_encoding); 4816#endif 4817 4818#ifdef CONFIG_QUOTA 4819 for (i = 0; i < EXT4_MAXQUOTAS; i++) 4820 kfree(get_qf_name(sb, sbi, i)); 4821#endif |
4822 fscrypt_free_dummy_context(&sbi->s_dummy_enc_ctx); |
4823 ext4_blkdev_remove(sbi); 4824 brelse(bh); 4825out_fail: 4826 sb->s_fs_info = NULL; 4827 kfree(sbi->s_blockgroup_lock); 4828out_free_base: 4829 kfree(sbi); 4830 kfree(orig_data); --- 1485 unchanged lines hidden --- |