super.c (87a0b2fafc09766d8c55461a18345a1cfb10a7fe) | super.c (5298d4bfe80f6ae6ae2777bcd1357b0022d98573) |
---|---|
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) --- 33 unchanged lines hidden (view full) --- 42#include <linux/cleancache.h> 43#include <linux/uaccess.h> 44#include <linux/iversion.h> 45#include <linux/unicode.h> 46#include <linux/part_stat.h> 47#include <linux/kthread.h> 48#include <linux/freezer.h> 49#include <linux/fsnotify.h> | 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) --- 33 unchanged lines hidden (view full) --- 42#include <linux/cleancache.h> 43#include <linux/uaccess.h> 44#include <linux/iversion.h> 45#include <linux/unicode.h> 46#include <linux/part_stat.h> 47#include <linux/kthread.h> 48#include <linux/freezer.h> 49#include <linux/fsnotify.h> |
50#include <linux/fs_context.h> 51#include <linux/fs_parser.h> |
|
50 51#include "ext4.h" 52#include "ext4_extents.h" /* Needed for trace points definition */ 53#include "ext4_jbd2.h" 54#include "xattr.h" 55#include "acl.h" 56#include "mballoc.h" 57#include "fsmap.h" --- 10 unchanged lines hidden (view full) --- 68static int ext4_show_options(struct seq_file *seq, struct dentry *root); 69static void ext4_update_super(struct super_block *sb); 70static int ext4_commit_super(struct super_block *sb); 71static int ext4_mark_recovery_complete(struct super_block *sb, 72 struct ext4_super_block *es); 73static int ext4_clear_journal_err(struct super_block *sb, 74 struct ext4_super_block *es); 75static int ext4_sync_fs(struct super_block *sb, int wait); | 52 53#include "ext4.h" 54#include "ext4_extents.h" /* Needed for trace points definition */ 55#include "ext4_jbd2.h" 56#include "xattr.h" 57#include "acl.h" 58#include "mballoc.h" 59#include "fsmap.h" --- 10 unchanged lines hidden (view full) --- 70static int ext4_show_options(struct seq_file *seq, struct dentry *root); 71static void ext4_update_super(struct super_block *sb); 72static int ext4_commit_super(struct super_block *sb); 73static int ext4_mark_recovery_complete(struct super_block *sb, 74 struct ext4_super_block *es); 75static int ext4_clear_journal_err(struct super_block *sb, 76 struct ext4_super_block *es); 77static int ext4_sync_fs(struct super_block *sb, int wait); |
76static int ext4_remount(struct super_block *sb, int *flags, char *data); | |
77static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf); 78static int ext4_unfreeze(struct super_block *sb); 79static int ext4_freeze(struct super_block *sb); | 78static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf); 79static int ext4_unfreeze(struct super_block *sb); 80static int ext4_freeze(struct super_block *sb); |
80static struct dentry *ext4_mount(struct file_system_type *fs_type, int flags, 81 const char *dev_name, void *data); | |
82static inline int ext2_feature_set_ok(struct super_block *sb); 83static inline int ext3_feature_set_ok(struct super_block *sb); 84static void ext4_destroy_lazyinit_thread(void); 85static void ext4_unregister_li_request(struct super_block *sb); 86static void ext4_clear_request_list(void); 87static struct inode *ext4_get_journal_inode(struct super_block *sb, 88 unsigned int journal_inum); | 81static inline int ext2_feature_set_ok(struct super_block *sb); 82static inline int ext3_feature_set_ok(struct super_block *sb); 83static void ext4_destroy_lazyinit_thread(void); 84static void ext4_unregister_li_request(struct super_block *sb); 85static void ext4_clear_request_list(void); 86static struct inode *ext4_get_journal_inode(struct super_block *sb, 87 unsigned int journal_inum); |
88static int ext4_validate_options(struct fs_context *fc); 89static int ext4_check_opt_consistency(struct fs_context *fc, 90 struct super_block *sb); 91static int ext4_apply_options(struct fs_context *fc, struct super_block *sb); 92static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param); 93static int ext4_get_tree(struct fs_context *fc); 94static int ext4_reconfigure(struct fs_context *fc); 95static void ext4_fc_free(struct fs_context *fc); 96static int ext4_init_fs_context(struct fs_context *fc); 97static const struct fs_parameter_spec ext4_param_specs[]; |
|
89 90/* 91 * Lock ordering 92 * 93 * page fault path: 94 * mmap_lock -> sb_start_pagefault -> invalidate_lock (r) -> transaction start 95 * -> page lock -> i_data_sem (rw) 96 * --- 11 unchanged lines hidden (view full) --- 108 * direct IO: 109 * sb_start_write -> i_mutex -> mmap_lock 110 * sb_start_write -> i_mutex -> transaction start -> i_data_sem (rw) 111 * 112 * writepages: 113 * transaction start -> page lock(s) -> i_data_sem (rw) 114 */ 115 | 98 99/* 100 * Lock ordering 101 * 102 * page fault path: 103 * mmap_lock -> sb_start_pagefault -> invalidate_lock (r) -> transaction start 104 * -> page lock -> i_data_sem (rw) 105 * --- 11 unchanged lines hidden (view full) --- 117 * direct IO: 118 * sb_start_write -> i_mutex -> mmap_lock 119 * sb_start_write -> i_mutex -> transaction start -> i_data_sem (rw) 120 * 121 * writepages: 122 * transaction start -> page lock(s) -> i_data_sem (rw) 123 */ 124 |
125static const struct fs_context_operations ext4_context_ops = { 126 .parse_param = ext4_parse_param, 127 .get_tree = ext4_get_tree, 128 .reconfigure = ext4_reconfigure, 129 .free = ext4_fc_free, 130}; 131 132 |
|
116#if !defined(CONFIG_EXT2_FS) && !defined(CONFIG_EXT2_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT2) 117static struct file_system_type ext2_fs_type = { | 133#if !defined(CONFIG_EXT2_FS) && !defined(CONFIG_EXT2_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT2) 134static struct file_system_type ext2_fs_type = { |
118 .owner = THIS_MODULE, 119 .name = "ext2", 120 .mount = ext4_mount, 121 .kill_sb = kill_block_super, 122 .fs_flags = FS_REQUIRES_DEV, | 135 .owner = THIS_MODULE, 136 .name = "ext2", 137 .init_fs_context = ext4_init_fs_context, 138 .parameters = ext4_param_specs, 139 .kill_sb = kill_block_super, 140 .fs_flags = FS_REQUIRES_DEV, |
123}; 124MODULE_ALIAS_FS("ext2"); 125MODULE_ALIAS("ext2"); 126#define IS_EXT2_SB(sb) ((sb)->s_bdev->bd_holder == &ext2_fs_type) 127#else 128#define IS_EXT2_SB(sb) (0) 129#endif 130 131 132static struct file_system_type ext3_fs_type = { | 141}; 142MODULE_ALIAS_FS("ext2"); 143MODULE_ALIAS("ext2"); 144#define IS_EXT2_SB(sb) ((sb)->s_bdev->bd_holder == &ext2_fs_type) 145#else 146#define IS_EXT2_SB(sb) (0) 147#endif 148 149 150static struct file_system_type ext3_fs_type = { |
133 .owner = THIS_MODULE, 134 .name = "ext3", 135 .mount = ext4_mount, 136 .kill_sb = kill_block_super, 137 .fs_flags = FS_REQUIRES_DEV, | 151 .owner = THIS_MODULE, 152 .name = "ext3", 153 .init_fs_context = ext4_init_fs_context, 154 .parameters = ext4_param_specs, 155 .kill_sb = kill_block_super, 156 .fs_flags = FS_REQUIRES_DEV, |
138}; 139MODULE_ALIAS_FS("ext3"); 140MODULE_ALIAS("ext3"); 141#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type) 142 143 144static inline void __ext4_read_bh(struct buffer_head *bh, int op_flags, 145 bh_end_io_t *end_io) --- 109 unchanged lines hidden (view full) --- 255 struct ext4_super_block *es) 256{ 257 if (!ext4_has_feature_metadata_csum(sb)) 258 return 1; 259 260 return es->s_checksum_type == EXT4_CRC32C_CHKSUM; 261} 262 | 157}; 158MODULE_ALIAS_FS("ext3"); 159MODULE_ALIAS("ext3"); 160#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type) 161 162 163static inline void __ext4_read_bh(struct buffer_head *bh, int op_flags, 164 bh_end_io_t *end_io) --- 109 unchanged lines hidden (view full) --- 274 struct ext4_super_block *es) 275{ 276 if (!ext4_has_feature_metadata_csum(sb)) 277 return 1; 278 279 return es->s_checksum_type == EXT4_CRC32C_CHKSUM; 280} 281 |
263static __le32 ext4_superblock_csum(struct super_block *sb, 264 struct ext4_super_block *es) | 282__le32 ext4_superblock_csum(struct super_block *sb, 283 struct ext4_super_block *es) |
265{ 266 struct ext4_sb_info *sbi = EXT4_SB(sb); 267 int offset = offsetof(struct ext4_super_block, s_checksum); 268 __u32 csum; 269 270 csum = ext4_chksum(sbi, ~0, (char *)es, offset); 271 272 return cpu_to_le32(csum); --- 634 unchanged lines hidden (view full) --- 907} 908 909void __ext4_msg(struct super_block *sb, 910 const char *prefix, const char *fmt, ...) 911{ 912 struct va_format vaf; 913 va_list args; 914 | 284{ 285 struct ext4_sb_info *sbi = EXT4_SB(sb); 286 int offset = offsetof(struct ext4_super_block, s_checksum); 287 __u32 csum; 288 289 csum = ext4_chksum(sbi, ~0, (char *)es, offset); 290 291 return cpu_to_le32(csum); --- 634 unchanged lines hidden (view full) --- 926} 927 928void __ext4_msg(struct super_block *sb, 929 const char *prefix, const char *fmt, ...) 930{ 931 struct va_format vaf; 932 va_list args; 933 |
915 atomic_inc(&EXT4_SB(sb)->s_msg_count); 916 if (!___ratelimit(&(EXT4_SB(sb)->s_msg_ratelimit_state), "EXT4-fs")) 917 return; | 934 if (sb) { 935 atomic_inc(&EXT4_SB(sb)->s_msg_count); 936 if (!___ratelimit(&(EXT4_SB(sb)->s_msg_ratelimit_state), 937 "EXT4-fs")) 938 return; 939 } |
918 919 va_start(args, fmt); 920 vaf.fmt = fmt; 921 vaf.va = &args; | 940 941 va_start(args, fmt); 942 vaf.fmt = fmt; 943 vaf.va = &args; |
922 printk("%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf); | 944 if (sb) 945 printk("%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf); 946 else 947 printk("%sEXT4-fs: %pV\n", prefix, &vaf); |
923 va_end(args); 924} 925 926static int ext4_warning_ratelimit(struct super_block *sb) 927{ 928 atomic_inc(&EXT4_SB(sb)->s_warning_count); 929 return ___ratelimit(&(EXT4_SB(sb)->s_warning_ratelimit_state), 930 "EXT4-fs warning"); --- 341 unchanged lines hidden (view full) --- 1272 */ 1273 kobject_put(&sbi->s_kobj); 1274 wait_for_completion(&sbi->s_kobj_unregister); 1275 if (sbi->s_chksum_driver) 1276 crypto_free_shash(sbi->s_chksum_driver); 1277 kfree(sbi->s_blockgroup_lock); 1278 fs_put_dax(sbi->s_daxdev); 1279 fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy); | 948 va_end(args); 949} 950 951static int ext4_warning_ratelimit(struct super_block *sb) 952{ 953 atomic_inc(&EXT4_SB(sb)->s_warning_count); 954 return ___ratelimit(&(EXT4_SB(sb)->s_warning_ratelimit_state), 955 "EXT4-fs warning"); --- 341 unchanged lines hidden (view full) --- 1297 */ 1298 kobject_put(&sbi->s_kobj); 1299 wait_for_completion(&sbi->s_kobj_unregister); 1300 if (sbi->s_chksum_driver) 1301 crypto_free_shash(sbi->s_chksum_driver); 1302 kfree(sbi->s_blockgroup_lock); 1303 fs_put_dax(sbi->s_daxdev); 1304 fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy); |
1280#ifdef CONFIG_UNICODE | 1305#if IS_ENABLED(CONFIG_UNICODE) |
1281 utf8_unload(sb->s_encoding); 1282#endif 1283 kfree(sbi); 1284} 1285 1286static struct kmem_cache *ext4_inode_cachep; 1287 1288/* --- 353 unchanged lines hidden (view full) --- 1642 .dirty_inode = ext4_dirty_inode, 1643 .drop_inode = ext4_drop_inode, 1644 .evict_inode = ext4_evict_inode, 1645 .put_super = ext4_put_super, 1646 .sync_fs = ext4_sync_fs, 1647 .freeze_fs = ext4_freeze, 1648 .unfreeze_fs = ext4_unfreeze, 1649 .statfs = ext4_statfs, | 1306 utf8_unload(sb->s_encoding); 1307#endif 1308 kfree(sbi); 1309} 1310 1311static struct kmem_cache *ext4_inode_cachep; 1312 1313/* --- 353 unchanged lines hidden (view full) --- 1667 .dirty_inode = ext4_dirty_inode, 1668 .drop_inode = ext4_drop_inode, 1669 .evict_inode = ext4_evict_inode, 1670 .put_super = ext4_put_super, 1671 .sync_fs = ext4_sync_fs, 1672 .freeze_fs = ext4_freeze, 1673 .unfreeze_fs = ext4_unfreeze, 1674 .statfs = ext4_statfs, |
1650 .remount_fs = ext4_remount, | |
1651 .show_options = ext4_show_options, 1652#ifdef CONFIG_QUOTA 1653 .quota_read = ext4_quota_read, 1654 .quota_write = ext4_quota_write, 1655 .get_dquots = ext4_get_dquots, 1656#endif 1657}; 1658 1659static const struct export_operations ext4_export_ops = { 1660 .fh_to_dentry = ext4_fh_to_dentry, 1661 .fh_to_parent = ext4_fh_to_parent, 1662 .get_parent = ext4_get_parent, 1663 .commit_metadata = ext4_nfs_commit_metadata, 1664}; 1665 1666enum { 1667 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, | 1675 .show_options = ext4_show_options, 1676#ifdef CONFIG_QUOTA 1677 .quota_read = ext4_quota_read, 1678 .quota_write = ext4_quota_write, 1679 .get_dquots = ext4_get_dquots, 1680#endif 1681}; 1682 1683static const struct export_operations ext4_export_ops = { 1684 .fh_to_dentry = ext4_fh_to_dentry, 1685 .fh_to_parent = ext4_fh_to_parent, 1686 .get_parent = ext4_get_parent, 1687 .commit_metadata = ext4_nfs_commit_metadata, 1688}; 1689 1690enum { 1691 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, |
1668 Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro, | 1692 Opt_resgid, Opt_resuid, Opt_sb, |
1669 Opt_nouid32, Opt_debug, Opt_removed, 1670 Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, 1671 Opt_auto_da_alloc, Opt_noauto_da_alloc, Opt_noload, 1672 Opt_commit, Opt_min_batch_time, Opt_max_batch_time, Opt_journal_dev, 1673 Opt_journal_path, Opt_journal_checksum, Opt_journal_async_commit, 1674 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, 1675 Opt_data_err_abort, Opt_data_err_ignore, Opt_test_dummy_encryption, 1676 Opt_inlinecrypt, | 1693 Opt_nouid32, Opt_debug, Opt_removed, 1694 Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, 1695 Opt_auto_da_alloc, Opt_noauto_da_alloc, Opt_noload, 1696 Opt_commit, Opt_min_batch_time, Opt_max_batch_time, Opt_journal_dev, 1697 Opt_journal_path, Opt_journal_checksum, Opt_journal_async_commit, 1698 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, 1699 Opt_data_err_abort, Opt_data_err_ignore, Opt_test_dummy_encryption, 1700 Opt_inlinecrypt, |
1677 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, 1678 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota, | 1701 Opt_usrjquota, Opt_grpjquota, Opt_quota, |
1679 Opt_noquota, Opt_barrier, Opt_nobarrier, Opt_err, 1680 Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_i_version, 1681 Opt_dax, Opt_dax_always, Opt_dax_inode, Opt_dax_never, 1682 Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_warn_on_error, | 1702 Opt_noquota, Opt_barrier, Opt_nobarrier, Opt_err, 1703 Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_i_version, 1704 Opt_dax, Opt_dax_always, Opt_dax_inode, Opt_dax_never, 1705 Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_warn_on_error, |
1683 Opt_nowarn_on_error, Opt_mblk_io_submit, 1684 Opt_lazytime, Opt_nolazytime, Opt_debug_want_extra_isize, | 1706 Opt_nowarn_on_error, Opt_mblk_io_submit, Opt_debug_want_extra_isize, |
1685 Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity, 1686 Opt_inode_readahead_blks, Opt_journal_ioprio, 1687 Opt_dioread_nolock, Opt_dioread_lock, 1688 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable, 1689 Opt_max_dir_size_kb, Opt_nojournal_checksum, Opt_nombcache, 1690 Opt_no_prefetch_block_bitmaps, Opt_mb_optimize_scan, | 1707 Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity, 1708 Opt_inode_readahead_blks, Opt_journal_ioprio, 1709 Opt_dioread_nolock, Opt_dioread_lock, 1710 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable, 1711 Opt_max_dir_size_kb, Opt_nojournal_checksum, Opt_nombcache, 1712 Opt_no_prefetch_block_bitmaps, Opt_mb_optimize_scan, |
1713 Opt_errors, Opt_data, Opt_data_err, Opt_jqfmt, Opt_dax_type, |
|
1691#ifdef CONFIG_EXT4_DEBUG 1692 Opt_fc_debug_max_replay, Opt_fc_debug_force 1693#endif 1694}; 1695 | 1714#ifdef CONFIG_EXT4_DEBUG 1715 Opt_fc_debug_max_replay, Opt_fc_debug_force 1716#endif 1717}; 1718 |
1696static const match_table_t tokens = { 1697 {Opt_bsd_df, "bsddf"}, 1698 {Opt_minix_df, "minixdf"}, 1699 {Opt_grpid, "grpid"}, 1700 {Opt_grpid, "bsdgroups"}, 1701 {Opt_nogrpid, "nogrpid"}, 1702 {Opt_nogrpid, "sysvgroups"}, 1703 {Opt_resgid, "resgid=%u"}, 1704 {Opt_resuid, "resuid=%u"}, 1705 {Opt_sb, "sb=%u"}, 1706 {Opt_err_cont, "errors=continue"}, 1707 {Opt_err_panic, "errors=panic"}, 1708 {Opt_err_ro, "errors=remount-ro"}, 1709 {Opt_nouid32, "nouid32"}, 1710 {Opt_debug, "debug"}, 1711 {Opt_removed, "oldalloc"}, 1712 {Opt_removed, "orlov"}, 1713 {Opt_user_xattr, "user_xattr"}, 1714 {Opt_nouser_xattr, "nouser_xattr"}, 1715 {Opt_acl, "acl"}, 1716 {Opt_noacl, "noacl"}, 1717 {Opt_noload, "norecovery"}, 1718 {Opt_noload, "noload"}, 1719 {Opt_removed, "nobh"}, 1720 {Opt_removed, "bh"}, 1721 {Opt_commit, "commit=%u"}, 1722 {Opt_min_batch_time, "min_batch_time=%u"}, 1723 {Opt_max_batch_time, "max_batch_time=%u"}, 1724 {Opt_journal_dev, "journal_dev=%u"}, 1725 {Opt_journal_path, "journal_path=%s"}, 1726 {Opt_journal_checksum, "journal_checksum"}, 1727 {Opt_nojournal_checksum, "nojournal_checksum"}, 1728 {Opt_journal_async_commit, "journal_async_commit"}, 1729 {Opt_abort, "abort"}, 1730 {Opt_data_journal, "data=journal"}, 1731 {Opt_data_ordered, "data=ordered"}, 1732 {Opt_data_writeback, "data=writeback"}, 1733 {Opt_data_err_abort, "data_err=abort"}, 1734 {Opt_data_err_ignore, "data_err=ignore"}, 1735 {Opt_offusrjquota, "usrjquota="}, 1736 {Opt_usrjquota, "usrjquota=%s"}, 1737 {Opt_offgrpjquota, "grpjquota="}, 1738 {Opt_grpjquota, "grpjquota=%s"}, 1739 {Opt_jqfmt_vfsold, "jqfmt=vfsold"}, 1740 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"}, 1741 {Opt_jqfmt_vfsv1, "jqfmt=vfsv1"}, 1742 {Opt_grpquota, "grpquota"}, 1743 {Opt_noquota, "noquota"}, 1744 {Opt_quota, "quota"}, 1745 {Opt_usrquota, "usrquota"}, 1746 {Opt_prjquota, "prjquota"}, 1747 {Opt_barrier, "barrier=%u"}, 1748 {Opt_barrier, "barrier"}, 1749 {Opt_nobarrier, "nobarrier"}, 1750 {Opt_i_version, "i_version"}, 1751 {Opt_dax, "dax"}, 1752 {Opt_dax_always, "dax=always"}, 1753 {Opt_dax_inode, "dax=inode"}, 1754 {Opt_dax_never, "dax=never"}, 1755 {Opt_stripe, "stripe=%u"}, 1756 {Opt_delalloc, "delalloc"}, 1757 {Opt_warn_on_error, "warn_on_error"}, 1758 {Opt_nowarn_on_error, "nowarn_on_error"}, 1759 {Opt_lazytime, "lazytime"}, 1760 {Opt_nolazytime, "nolazytime"}, 1761 {Opt_debug_want_extra_isize, "debug_want_extra_isize=%u"}, 1762 {Opt_nodelalloc, "nodelalloc"}, 1763 {Opt_removed, "mblk_io_submit"}, 1764 {Opt_removed, "nomblk_io_submit"}, 1765 {Opt_block_validity, "block_validity"}, 1766 {Opt_noblock_validity, "noblock_validity"}, 1767 {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, 1768 {Opt_journal_ioprio, "journal_ioprio=%u"}, 1769 {Opt_auto_da_alloc, "auto_da_alloc=%u"}, 1770 {Opt_auto_da_alloc, "auto_da_alloc"}, 1771 {Opt_noauto_da_alloc, "noauto_da_alloc"}, 1772 {Opt_dioread_nolock, "dioread_nolock"}, 1773 {Opt_dioread_lock, "nodioread_nolock"}, 1774 {Opt_dioread_lock, "dioread_lock"}, 1775 {Opt_discard, "discard"}, 1776 {Opt_nodiscard, "nodiscard"}, 1777 {Opt_init_itable, "init_itable=%u"}, 1778 {Opt_init_itable, "init_itable"}, 1779 {Opt_noinit_itable, "noinit_itable"}, 1780#ifdef CONFIG_EXT4_DEBUG 1781 {Opt_fc_debug_force, "fc_debug_force"}, 1782 {Opt_fc_debug_max_replay, "fc_debug_max_replay=%u"}, 1783#endif 1784 {Opt_max_dir_size_kb, "max_dir_size_kb=%u"}, 1785 {Opt_test_dummy_encryption, "test_dummy_encryption=%s"}, 1786 {Opt_test_dummy_encryption, "test_dummy_encryption"}, 1787 {Opt_inlinecrypt, "inlinecrypt"}, 1788 {Opt_nombcache, "nombcache"}, 1789 {Opt_nombcache, "no_mbcache"}, /* for backward compatibility */ 1790 {Opt_removed, "prefetch_block_bitmaps"}, 1791 {Opt_no_prefetch_block_bitmaps, "no_prefetch_block_bitmaps"}, 1792 {Opt_mb_optimize_scan, "mb_optimize_scan=%d"}, 1793 {Opt_removed, "check=none"}, /* mount option from ext2/3 */ 1794 {Opt_removed, "nocheck"}, /* mount option from ext2/3 */ 1795 {Opt_removed, "reservation"}, /* mount option from ext2/3 */ 1796 {Opt_removed, "noreservation"}, /* mount option from ext2/3 */ 1797 {Opt_removed, "journal=%u"}, /* mount option from ext2/3 */ 1798 {Opt_err, NULL}, | 1719static const struct constant_table ext4_param_errors[] = { 1720 {"continue", EXT4_MOUNT_ERRORS_CONT}, 1721 {"panic", EXT4_MOUNT_ERRORS_PANIC}, 1722 {"remount-ro", EXT4_MOUNT_ERRORS_RO}, 1723 {} |
1799}; 1800 | 1724}; 1725 |
1801static ext4_fsblk_t get_sb_block(void **data) 1802{ 1803 ext4_fsblk_t sb_block; 1804 char *options = (char *) *data; | 1726static const struct constant_table ext4_param_data[] = { 1727 {"journal", EXT4_MOUNT_JOURNAL_DATA}, 1728 {"ordered", EXT4_MOUNT_ORDERED_DATA}, 1729 {"writeback", EXT4_MOUNT_WRITEBACK_DATA}, 1730 {} 1731}; |
1805 | 1732 |
1806 if (!options || strncmp(options, "sb=", 3) != 0) 1807 return 1; /* Default location */ | 1733static const struct constant_table ext4_param_data_err[] = { 1734 {"abort", Opt_data_err_abort}, 1735 {"ignore", Opt_data_err_ignore}, 1736 {} 1737}; |
1808 | 1738 |
1809 options += 3; 1810 /* TODO: use simple_strtoll with >32bit ext4 */ 1811 sb_block = simple_strtoul(options, &options, 0); 1812 if (*options && *options != ',') { 1813 printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n", 1814 (char *) *data); 1815 return 1; 1816 } 1817 if (*options == ',') 1818 options++; 1819 *data = (void *) options; | 1739static const struct constant_table ext4_param_jqfmt[] = { 1740 {"vfsold", QFMT_VFS_OLD}, 1741 {"vfsv0", QFMT_VFS_V0}, 1742 {"vfsv1", QFMT_VFS_V1}, 1743 {} 1744}; |
1820 | 1745 |
1821 return sb_block; 1822} | 1746static const struct constant_table ext4_param_dax[] = { 1747 {"always", Opt_dax_always}, 1748 {"inode", Opt_dax_inode}, 1749 {"never", Opt_dax_never}, 1750 {} 1751}; |
1823 | 1752 |
1753/* String parameter that allows empty argument */ 1754#define fsparam_string_empty(NAME, OPT) \ 1755 __fsparam(fs_param_is_string, NAME, OPT, fs_param_can_be_empty, NULL) 1756 1757/* 1758 * Mount option specification 1759 * We don't use fsparam_flag_no because of the way we set the 1760 * options and the way we show them in _ext4_show_options(). To 1761 * keep the changes to a minimum, let's keep the negative options 1762 * separate for now. 1763 */ 1764static const struct fs_parameter_spec ext4_param_specs[] = { 1765 fsparam_flag ("bsddf", Opt_bsd_df), 1766 fsparam_flag ("minixdf", Opt_minix_df), 1767 fsparam_flag ("grpid", Opt_grpid), 1768 fsparam_flag ("bsdgroups", Opt_grpid), 1769 fsparam_flag ("nogrpid", Opt_nogrpid), 1770 fsparam_flag ("sysvgroups", Opt_nogrpid), 1771 fsparam_u32 ("resgid", Opt_resgid), 1772 fsparam_u32 ("resuid", Opt_resuid), 1773 fsparam_u32 ("sb", Opt_sb), 1774 fsparam_enum ("errors", Opt_errors, ext4_param_errors), 1775 fsparam_flag ("nouid32", Opt_nouid32), 1776 fsparam_flag ("debug", Opt_debug), 1777 fsparam_flag ("oldalloc", Opt_removed), 1778 fsparam_flag ("orlov", Opt_removed), 1779 fsparam_flag ("user_xattr", Opt_user_xattr), 1780 fsparam_flag ("nouser_xattr", Opt_nouser_xattr), 1781 fsparam_flag ("acl", Opt_acl), 1782 fsparam_flag ("noacl", Opt_noacl), 1783 fsparam_flag ("norecovery", Opt_noload), 1784 fsparam_flag ("noload", Opt_noload), 1785 fsparam_flag ("bh", Opt_removed), 1786 fsparam_flag ("nobh", Opt_removed), 1787 fsparam_u32 ("commit", Opt_commit), 1788 fsparam_u32 ("min_batch_time", Opt_min_batch_time), 1789 fsparam_u32 ("max_batch_time", Opt_max_batch_time), 1790 fsparam_u32 ("journal_dev", Opt_journal_dev), 1791 fsparam_bdev ("journal_path", Opt_journal_path), 1792 fsparam_flag ("journal_checksum", Opt_journal_checksum), 1793 fsparam_flag ("nojournal_checksum", Opt_nojournal_checksum), 1794 fsparam_flag ("journal_async_commit",Opt_journal_async_commit), 1795 fsparam_flag ("abort", Opt_abort), 1796 fsparam_enum ("data", Opt_data, ext4_param_data), 1797 fsparam_enum ("data_err", Opt_data_err, 1798 ext4_param_data_err), 1799 fsparam_string_empty 1800 ("usrjquota", Opt_usrjquota), 1801 fsparam_string_empty 1802 ("grpjquota", Opt_grpjquota), 1803 fsparam_enum ("jqfmt", Opt_jqfmt, ext4_param_jqfmt), 1804 fsparam_flag ("grpquota", Opt_grpquota), 1805 fsparam_flag ("quota", Opt_quota), 1806 fsparam_flag ("noquota", Opt_noquota), 1807 fsparam_flag ("usrquota", Opt_usrquota), 1808 fsparam_flag ("prjquota", Opt_prjquota), 1809 fsparam_flag ("barrier", Opt_barrier), 1810 fsparam_u32 ("barrier", Opt_barrier), 1811 fsparam_flag ("nobarrier", Opt_nobarrier), 1812 fsparam_flag ("i_version", Opt_i_version), 1813 fsparam_flag ("dax", Opt_dax), 1814 fsparam_enum ("dax", Opt_dax_type, ext4_param_dax), 1815 fsparam_u32 ("stripe", Opt_stripe), 1816 fsparam_flag ("delalloc", Opt_delalloc), 1817 fsparam_flag ("nodelalloc", Opt_nodelalloc), 1818 fsparam_flag ("warn_on_error", Opt_warn_on_error), 1819 fsparam_flag ("nowarn_on_error", Opt_nowarn_on_error), 1820 fsparam_u32 ("debug_want_extra_isize", 1821 Opt_debug_want_extra_isize), 1822 fsparam_flag ("mblk_io_submit", Opt_removed), 1823 fsparam_flag ("nomblk_io_submit", Opt_removed), 1824 fsparam_flag ("block_validity", Opt_block_validity), 1825 fsparam_flag ("noblock_validity", Opt_noblock_validity), 1826 fsparam_u32 ("inode_readahead_blks", 1827 Opt_inode_readahead_blks), 1828 fsparam_u32 ("journal_ioprio", Opt_journal_ioprio), 1829 fsparam_u32 ("auto_da_alloc", Opt_auto_da_alloc), 1830 fsparam_flag ("auto_da_alloc", Opt_auto_da_alloc), 1831 fsparam_flag ("noauto_da_alloc", Opt_noauto_da_alloc), 1832 fsparam_flag ("dioread_nolock", Opt_dioread_nolock), 1833 fsparam_flag ("nodioread_nolock", Opt_dioread_lock), 1834 fsparam_flag ("dioread_lock", Opt_dioread_lock), 1835 fsparam_flag ("discard", Opt_discard), 1836 fsparam_flag ("nodiscard", Opt_nodiscard), 1837 fsparam_u32 ("init_itable", Opt_init_itable), 1838 fsparam_flag ("init_itable", Opt_init_itable), 1839 fsparam_flag ("noinit_itable", Opt_noinit_itable), 1840#ifdef CONFIG_EXT4_DEBUG 1841 fsparam_flag ("fc_debug_force", Opt_fc_debug_force), 1842 fsparam_u32 ("fc_debug_max_replay", Opt_fc_debug_max_replay), 1843#endif 1844 fsparam_u32 ("max_dir_size_kb", Opt_max_dir_size_kb), 1845 fsparam_flag ("test_dummy_encryption", 1846 Opt_test_dummy_encryption), 1847 fsparam_string ("test_dummy_encryption", 1848 Opt_test_dummy_encryption), 1849 fsparam_flag ("inlinecrypt", Opt_inlinecrypt), 1850 fsparam_flag ("nombcache", Opt_nombcache), 1851 fsparam_flag ("no_mbcache", Opt_nombcache), /* for backward compatibility */ 1852 fsparam_flag ("prefetch_block_bitmaps", 1853 Opt_removed), 1854 fsparam_flag ("no_prefetch_block_bitmaps", 1855 Opt_no_prefetch_block_bitmaps), 1856 fsparam_s32 ("mb_optimize_scan", Opt_mb_optimize_scan), 1857 fsparam_string ("check", Opt_removed), /* mount option from ext2/3 */ 1858 fsparam_flag ("nocheck", Opt_removed), /* mount option from ext2/3 */ 1859 fsparam_flag ("reservation", Opt_removed), /* mount option from ext2/3 */ 1860 fsparam_flag ("noreservation", Opt_removed), /* mount option from ext2/3 */ 1861 fsparam_u32 ("journal", Opt_removed), /* mount option from ext2/3 */ 1862 {} 1863}; 1864 |
|
1824#define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3)) 1825#define DEFAULT_MB_OPTIMIZE_SCAN (-1) 1826 1827static const char deprecated_msg[] = 1828 "Mount option \"%s\" will be removed by %s\n" 1829 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n"; 1830 | 1865#define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3)) 1866#define DEFAULT_MB_OPTIMIZE_SCAN (-1) 1867 1868static const char deprecated_msg[] = 1869 "Mount option \"%s\" will be removed by %s\n" 1870 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n"; 1871 |
1831#ifdef CONFIG_QUOTA 1832static int set_qf_name(struct super_block *sb, int qtype, substring_t *args) 1833{ 1834 struct ext4_sb_info *sbi = EXT4_SB(sb); 1835 char *qname, *old_qname = get_qf_name(sb, sbi, qtype); 1836 int ret = -1; 1837 1838 if (sb_any_quota_loaded(sb) && !old_qname) { 1839 ext4_msg(sb, KERN_ERR, 1840 "Cannot change journaled " 1841 "quota options when quota turned on"); 1842 return -1; 1843 } 1844 if (ext4_has_feature_quota(sb)) { 1845 ext4_msg(sb, KERN_INFO, "Journaled quota options " 1846 "ignored when QUOTA feature is enabled"); 1847 return 1; 1848 } 1849 qname = match_strdup(args); 1850 if (!qname) { 1851 ext4_msg(sb, KERN_ERR, 1852 "Not enough memory for storing quotafile name"); 1853 return -1; 1854 } 1855 if (old_qname) { 1856 if (strcmp(old_qname, qname) == 0) 1857 ret = 1; 1858 else 1859 ext4_msg(sb, KERN_ERR, 1860 "%s quota file already specified", 1861 QTYPE2NAME(qtype)); 1862 goto errout; 1863 } 1864 if (strchr(qname, '/')) { 1865 ext4_msg(sb, KERN_ERR, 1866 "quotafile must be on filesystem root"); 1867 goto errout; 1868 } 1869 rcu_assign_pointer(sbi->s_qf_names[qtype], qname); 1870 set_opt(sb, QUOTA); 1871 return 1; 1872errout: 1873 kfree(qname); 1874 return ret; 1875} 1876 1877static int clear_qf_name(struct super_block *sb, int qtype) 1878{ 1879 1880 struct ext4_sb_info *sbi = EXT4_SB(sb); 1881 char *old_qname = get_qf_name(sb, sbi, qtype); 1882 1883 if (sb_any_quota_loaded(sb) && old_qname) { 1884 ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options" 1885 " when quota turned on"); 1886 return -1; 1887 } 1888 rcu_assign_pointer(sbi->s_qf_names[qtype], NULL); 1889 synchronize_rcu(); 1890 kfree(old_qname); 1891 return 1; 1892} 1893#endif 1894 | |
1895#define MOPT_SET 0x0001 1896#define MOPT_CLEAR 0x0002 1897#define MOPT_NOSUPPORT 0x0004 1898#define MOPT_EXPLICIT 0x0008 | 1872#define MOPT_SET 0x0001 1873#define MOPT_CLEAR 0x0002 1874#define MOPT_NOSUPPORT 0x0004 1875#define MOPT_EXPLICIT 0x0008 |
1899#define MOPT_CLEAR_ERR 0x0010 1900#define MOPT_GTE0 0x0020 | |
1901#ifdef CONFIG_QUOTA 1902#define MOPT_Q 0 | 1876#ifdef CONFIG_QUOTA 1877#define MOPT_Q 0 |
1903#define MOPT_QFMT 0x0040 | 1878#define MOPT_QFMT 0x0010 |
1904#else 1905#define MOPT_Q MOPT_NOSUPPORT 1906#define MOPT_QFMT MOPT_NOSUPPORT 1907#endif | 1879#else 1880#define MOPT_Q MOPT_NOSUPPORT 1881#define MOPT_QFMT MOPT_NOSUPPORT 1882#endif |
1908#define MOPT_DATAJ 0x0080 1909#define MOPT_NO_EXT2 0x0100 1910#define MOPT_NO_EXT3 0x0200 | 1883#define MOPT_NO_EXT2 0x0020 1884#define MOPT_NO_EXT3 0x0040 |
1911#define MOPT_EXT4_ONLY (MOPT_NO_EXT2 | MOPT_NO_EXT3) | 1885#define MOPT_EXT4_ONLY (MOPT_NO_EXT2 | MOPT_NO_EXT3) |
1912#define MOPT_STRING 0x0400 1913#define MOPT_SKIP 0x0800 1914#define MOPT_2 0x1000 | 1886#define MOPT_SKIP 0x0080 1887#define MOPT_2 0x0100 |
1915 1916static const struct mount_opts { 1917 int token; 1918 int mount_opt; 1919 int flags; 1920} ext4_mount_opts[] = { 1921 {Opt_minix_df, EXT4_MOUNT_MINIX_DF, MOPT_SET}, 1922 {Opt_bsd_df, EXT4_MOUNT_MINIX_DF, MOPT_CLEAR}, --- 16 unchanged lines hidden (view full) --- 1939 {Opt_nojournal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM, 1940 MOPT_EXT4_ONLY | MOPT_CLEAR}, 1941 {Opt_journal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM, 1942 MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT}, 1943 {Opt_journal_async_commit, (EXT4_MOUNT_JOURNAL_ASYNC_COMMIT | 1944 EXT4_MOUNT_JOURNAL_CHECKSUM), 1945 MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT}, 1946 {Opt_noload, EXT4_MOUNT_NOLOAD, MOPT_NO_EXT2 | MOPT_SET}, | 1888 1889static const struct mount_opts { 1890 int token; 1891 int mount_opt; 1892 int flags; 1893} ext4_mount_opts[] = { 1894 {Opt_minix_df, EXT4_MOUNT_MINIX_DF, MOPT_SET}, 1895 {Opt_bsd_df, EXT4_MOUNT_MINIX_DF, MOPT_CLEAR}, --- 16 unchanged lines hidden (view full) --- 1912 {Opt_nojournal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM, 1913 MOPT_EXT4_ONLY | MOPT_CLEAR}, 1914 {Opt_journal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM, 1915 MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT}, 1916 {Opt_journal_async_commit, (EXT4_MOUNT_JOURNAL_ASYNC_COMMIT | 1917 EXT4_MOUNT_JOURNAL_CHECKSUM), 1918 MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT}, 1919 {Opt_noload, EXT4_MOUNT_NOLOAD, MOPT_NO_EXT2 | MOPT_SET}, |
1947 {Opt_err_panic, EXT4_MOUNT_ERRORS_PANIC, MOPT_SET | MOPT_CLEAR_ERR}, 1948 {Opt_err_ro, EXT4_MOUNT_ERRORS_RO, MOPT_SET | MOPT_CLEAR_ERR}, 1949 {Opt_err_cont, EXT4_MOUNT_ERRORS_CONT, MOPT_SET | MOPT_CLEAR_ERR}, 1950 {Opt_data_err_abort, EXT4_MOUNT_DATA_ERR_ABORT, 1951 MOPT_NO_EXT2}, 1952 {Opt_data_err_ignore, EXT4_MOUNT_DATA_ERR_ABORT, 1953 MOPT_NO_EXT2}, | 1920 {Opt_data_err, EXT4_MOUNT_DATA_ERR_ABORT, MOPT_NO_EXT2}, |
1954 {Opt_barrier, EXT4_MOUNT_BARRIER, MOPT_SET}, 1955 {Opt_nobarrier, EXT4_MOUNT_BARRIER, MOPT_CLEAR}, 1956 {Opt_noauto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_SET}, 1957 {Opt_auto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_CLEAR}, 1958 {Opt_noinit_itable, EXT4_MOUNT_INIT_INODE_TABLE, MOPT_CLEAR}, | 1921 {Opt_barrier, EXT4_MOUNT_BARRIER, MOPT_SET}, 1922 {Opt_nobarrier, EXT4_MOUNT_BARRIER, MOPT_CLEAR}, 1923 {Opt_noauto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_SET}, 1924 {Opt_auto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_CLEAR}, 1925 {Opt_noinit_itable, EXT4_MOUNT_INIT_INODE_TABLE, MOPT_CLEAR}, |
1959 {Opt_commit, 0, MOPT_GTE0}, 1960 {Opt_max_batch_time, 0, MOPT_GTE0}, 1961 {Opt_min_batch_time, 0, MOPT_GTE0}, 1962 {Opt_inode_readahead_blks, 0, MOPT_GTE0}, 1963 {Opt_init_itable, 0, MOPT_GTE0}, 1964 {Opt_dax, EXT4_MOUNT_DAX_ALWAYS, MOPT_SET | MOPT_SKIP}, 1965 {Opt_dax_always, EXT4_MOUNT_DAX_ALWAYS, 1966 MOPT_EXT4_ONLY | MOPT_SET | MOPT_SKIP}, 1967 {Opt_dax_inode, EXT4_MOUNT2_DAX_INODE, 1968 MOPT_EXT4_ONLY | MOPT_SET | MOPT_SKIP}, 1969 {Opt_dax_never, EXT4_MOUNT2_DAX_NEVER, 1970 MOPT_EXT4_ONLY | MOPT_SET | MOPT_SKIP}, 1971 {Opt_stripe, 0, MOPT_GTE0}, 1972 {Opt_resuid, 0, MOPT_GTE0}, 1973 {Opt_resgid, 0, MOPT_GTE0}, 1974 {Opt_journal_dev, 0, MOPT_NO_EXT2 | MOPT_GTE0}, 1975 {Opt_journal_path, 0, MOPT_NO_EXT2 | MOPT_STRING}, 1976 {Opt_journal_ioprio, 0, MOPT_NO_EXT2 | MOPT_GTE0}, 1977 {Opt_data_journal, EXT4_MOUNT_JOURNAL_DATA, MOPT_NO_EXT2 | MOPT_DATAJ}, 1978 {Opt_data_ordered, EXT4_MOUNT_ORDERED_DATA, MOPT_NO_EXT2 | MOPT_DATAJ}, 1979 {Opt_data_writeback, EXT4_MOUNT_WRITEBACK_DATA, 1980 MOPT_NO_EXT2 | MOPT_DATAJ}, | 1926 {Opt_dax_type, 0, MOPT_EXT4_ONLY}, 1927 {Opt_journal_dev, 0, MOPT_NO_EXT2}, 1928 {Opt_journal_path, 0, MOPT_NO_EXT2}, 1929 {Opt_journal_ioprio, 0, MOPT_NO_EXT2}, 1930 {Opt_data, 0, MOPT_NO_EXT2}, |
1981 {Opt_user_xattr, EXT4_MOUNT_XATTR_USER, MOPT_SET}, 1982 {Opt_nouser_xattr, EXT4_MOUNT_XATTR_USER, MOPT_CLEAR}, 1983#ifdef CONFIG_EXT4_FS_POSIX_ACL 1984 {Opt_acl, EXT4_MOUNT_POSIX_ACL, MOPT_SET}, 1985 {Opt_noacl, EXT4_MOUNT_POSIX_ACL, MOPT_CLEAR}, 1986#else 1987 {Opt_acl, 0, MOPT_NOSUPPORT}, 1988 {Opt_noacl, 0, MOPT_NOSUPPORT}, 1989#endif 1990 {Opt_nouid32, EXT4_MOUNT_NO_UID32, MOPT_SET}, 1991 {Opt_debug, EXT4_MOUNT_DEBUG, MOPT_SET}, | 1931 {Opt_user_xattr, EXT4_MOUNT_XATTR_USER, MOPT_SET}, 1932 {Opt_nouser_xattr, EXT4_MOUNT_XATTR_USER, MOPT_CLEAR}, 1933#ifdef CONFIG_EXT4_FS_POSIX_ACL 1934 {Opt_acl, EXT4_MOUNT_POSIX_ACL, MOPT_SET}, 1935 {Opt_noacl, EXT4_MOUNT_POSIX_ACL, MOPT_CLEAR}, 1936#else 1937 {Opt_acl, 0, MOPT_NOSUPPORT}, 1938 {Opt_noacl, 0, MOPT_NOSUPPORT}, 1939#endif 1940 {Opt_nouid32, EXT4_MOUNT_NO_UID32, MOPT_SET}, 1941 {Opt_debug, EXT4_MOUNT_DEBUG, MOPT_SET}, |
1992 {Opt_debug_want_extra_isize, 0, MOPT_GTE0}, | |
1993 {Opt_quota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA, MOPT_SET | MOPT_Q}, 1994 {Opt_usrquota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA, 1995 MOPT_SET | MOPT_Q}, 1996 {Opt_grpquota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_GRPQUOTA, 1997 MOPT_SET | MOPT_Q}, 1998 {Opt_prjquota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_PRJQUOTA, 1999 MOPT_SET | MOPT_Q}, 2000 {Opt_noquota, (EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA | 2001 EXT4_MOUNT_GRPQUOTA | EXT4_MOUNT_PRJQUOTA), 2002 MOPT_CLEAR | MOPT_Q}, | 1942 {Opt_quota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA, MOPT_SET | MOPT_Q}, 1943 {Opt_usrquota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA, 1944 MOPT_SET | MOPT_Q}, 1945 {Opt_grpquota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_GRPQUOTA, 1946 MOPT_SET | MOPT_Q}, 1947 {Opt_prjquota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_PRJQUOTA, 1948 MOPT_SET | MOPT_Q}, 1949 {Opt_noquota, (EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA | 1950 EXT4_MOUNT_GRPQUOTA | EXT4_MOUNT_PRJQUOTA), 1951 MOPT_CLEAR | MOPT_Q}, |
2003 {Opt_usrjquota, 0, MOPT_Q | MOPT_STRING}, 2004 {Opt_grpjquota, 0, MOPT_Q | MOPT_STRING}, 2005 {Opt_offusrjquota, 0, MOPT_Q}, 2006 {Opt_offgrpjquota, 0, MOPT_Q}, 2007 {Opt_jqfmt_vfsold, QFMT_VFS_OLD, MOPT_QFMT}, 2008 {Opt_jqfmt_vfsv0, QFMT_VFS_V0, MOPT_QFMT}, 2009 {Opt_jqfmt_vfsv1, QFMT_VFS_V1, MOPT_QFMT}, 2010 {Opt_max_dir_size_kb, 0, MOPT_GTE0}, 2011 {Opt_test_dummy_encryption, 0, MOPT_STRING}, | 1952 {Opt_usrjquota, 0, MOPT_Q}, 1953 {Opt_grpjquota, 0, MOPT_Q}, 1954 {Opt_jqfmt, 0, MOPT_QFMT}, |
2012 {Opt_nombcache, EXT4_MOUNT_NO_MBCACHE, MOPT_SET}, 2013 {Opt_no_prefetch_block_bitmaps, EXT4_MOUNT_NO_PREFETCH_BLOCK_BITMAPS, 2014 MOPT_SET}, | 1955 {Opt_nombcache, EXT4_MOUNT_NO_MBCACHE, MOPT_SET}, 1956 {Opt_no_prefetch_block_bitmaps, EXT4_MOUNT_NO_PREFETCH_BLOCK_BITMAPS, 1957 MOPT_SET}, |
2015 {Opt_mb_optimize_scan, EXT4_MOUNT2_MB_OPTIMIZE_SCAN, MOPT_GTE0}, | |
2016#ifdef CONFIG_EXT4_DEBUG 2017 {Opt_fc_debug_force, EXT4_MOUNT2_JOURNAL_FAST_COMMIT, 2018 MOPT_SET | MOPT_2 | MOPT_EXT4_ONLY}, | 1958#ifdef CONFIG_EXT4_DEBUG 1959 {Opt_fc_debug_force, EXT4_MOUNT2_JOURNAL_FAST_COMMIT, 1960 MOPT_SET | MOPT_2 | MOPT_EXT4_ONLY}, |
2019 {Opt_fc_debug_max_replay, 0, MOPT_GTE0}, | |
2020#endif 2021 {Opt_err, 0, 0} 2022}; 2023 | 1961#endif 1962 {Opt_err, 0, 0} 1963}; 1964 |
2024#ifdef CONFIG_UNICODE | 1965#if IS_ENABLED(CONFIG_UNICODE) |
2025static const struct ext4_sb_encodings { 2026 __u16 magic; 2027 char *name; | 1966static const struct ext4_sb_encodings { 1967 __u16 magic; 1968 char *name; |
2028 char *version; | 1969 unsigned int version; |
2029} ext4_sb_encoding_map[] = { | 1970} ext4_sb_encoding_map[] = { |
2030 {EXT4_ENC_UTF8_12_1, "utf8", "12.1.0"}, | 1971 {EXT4_ENC_UTF8_12_1, "utf8", UNICODE_AGE(12, 1, 0)}, |
2031}; 2032 | 1972}; 1973 |
2033static int ext4_sb_read_encoding(const struct ext4_super_block *es, 2034 const struct ext4_sb_encodings **encoding, 2035 __u16 *flags) | 1974static const struct ext4_sb_encodings * 1975ext4_sb_read_encoding(const struct ext4_super_block *es) |
2036{ 2037 __u16 magic = le16_to_cpu(es->s_encoding); 2038 int i; 2039 2040 for (i = 0; i < ARRAY_SIZE(ext4_sb_encoding_map); i++) 2041 if (magic == ext4_sb_encoding_map[i].magic) | 1976{ 1977 __u16 magic = le16_to_cpu(es->s_encoding); 1978 int i; 1979 1980 for (i = 0; i < ARRAY_SIZE(ext4_sb_encoding_map); i++) 1981 if (magic == ext4_sb_encoding_map[i].magic) |
2042 break; | 1982 return &ext4_sb_encoding_map[i]; |
2043 | 1983 |
2044 if (i >= ARRAY_SIZE(ext4_sb_encoding_map)) 2045 return -EINVAL; 2046 2047 *encoding = &ext4_sb_encoding_map[i]; 2048 *flags = le16_to_cpu(es->s_encoding_flags); 2049 2050 return 0; | 1984 return NULL; |
2051} 2052#endif 2053 | 1985} 1986#endif 1987 |
2054static int ext4_set_test_dummy_encryption(struct super_block *sb, 2055 const char *opt, 2056 const substring_t *arg, 2057 bool is_remount) | 1988static int ext4_set_test_dummy_encryption(struct super_block *sb, char *arg) |
2058{ 2059#ifdef CONFIG_FS_ENCRYPTION 2060 struct ext4_sb_info *sbi = EXT4_SB(sb); 2061 int err; 2062 | 1989{ 1990#ifdef CONFIG_FS_ENCRYPTION 1991 struct ext4_sb_info *sbi = EXT4_SB(sb); 1992 int err; 1993 |
2063 /* 2064 * This mount option is just for testing, and it's not worthwhile to 2065 * implement the extra complexity (e.g. RCU protection) that would be 2066 * needed to allow it to be set or changed during remount. We do allow 2067 * it to be specified during remount, but only if there is no change. 2068 */ 2069 if (is_remount && !sbi->s_dummy_enc_policy.policy) { 2070 ext4_msg(sb, KERN_WARNING, 2071 "Can't set test_dummy_encryption on remount"); 2072 return -1; 2073 } 2074 err = fscrypt_set_test_dummy_encryption(sb, arg->from, | 1994 err = fscrypt_set_test_dummy_encryption(sb, arg, |
2075 &sbi->s_dummy_enc_policy); 2076 if (err) { | 1995 &sbi->s_dummy_enc_policy); 1996 if (err) { |
2077 if (err == -EEXIST) 2078 ext4_msg(sb, KERN_WARNING, 2079 "Can't change test_dummy_encryption on remount"); 2080 else if (err == -EINVAL) 2081 ext4_msg(sb, KERN_WARNING, 2082 "Value of option \"%s\" is unrecognized", opt); 2083 else 2084 ext4_msg(sb, KERN_WARNING, 2085 "Error processing option \"%s\" [%d]", 2086 opt, err); 2087 return -1; | 1997 ext4_msg(sb, KERN_WARNING, 1998 "Error while setting test dummy encryption [%d]", err); 1999 return err; |
2088 } 2089 ext4_msg(sb, KERN_WARNING, "Test dummy encryption mode enabled"); | 2000 } 2001 ext4_msg(sb, KERN_WARNING, "Test dummy encryption mode enabled"); |
2090#else 2091 ext4_msg(sb, KERN_WARNING, 2092 "Test dummy encryption mount option ignored"); | |
2093#endif | 2002#endif |
2094 return 1; | 2003 return 0; |
2095} 2096 | 2004} 2005 |
2097struct ext4_parsed_options { 2098 unsigned long journal_devnum; 2099 unsigned int journal_ioprio; 2100 int mb_optimize_scan; | 2006#define EXT4_SPEC_JQUOTA (1 << 0) 2007#define EXT4_SPEC_JQFMT (1 << 1) 2008#define EXT4_SPEC_DATAJ (1 << 2) 2009#define EXT4_SPEC_SB_BLOCK (1 << 3) 2010#define EXT4_SPEC_JOURNAL_DEV (1 << 4) 2011#define EXT4_SPEC_JOURNAL_IOPRIO (1 << 5) 2012#define EXT4_SPEC_DUMMY_ENCRYPTION (1 << 6) 2013#define EXT4_SPEC_s_want_extra_isize (1 << 7) 2014#define EXT4_SPEC_s_max_batch_time (1 << 8) 2015#define EXT4_SPEC_s_min_batch_time (1 << 9) 2016#define EXT4_SPEC_s_inode_readahead_blks (1 << 10) 2017#define EXT4_SPEC_s_li_wait_mult (1 << 11) 2018#define EXT4_SPEC_s_max_dir_size_kb (1 << 12) 2019#define EXT4_SPEC_s_stripe (1 << 13) 2020#define EXT4_SPEC_s_resuid (1 << 14) 2021#define EXT4_SPEC_s_resgid (1 << 15) 2022#define EXT4_SPEC_s_commit_interval (1 << 16) 2023#define EXT4_SPEC_s_fc_debug_max_replay (1 << 17) 2024#define EXT4_SPEC_s_sb_block (1 << 18) 2025 2026struct ext4_fs_context { 2027 char *s_qf_names[EXT4_MAXQUOTAS]; 2028 char *test_dummy_enc_arg; 2029 int s_jquota_fmt; /* Format of quota to use */ 2030 int mb_optimize_scan; 2031#ifdef CONFIG_EXT4_DEBUG 2032 int s_fc_debug_max_replay; 2033#endif 2034 unsigned short qname_spec; 2035 unsigned long vals_s_flags; /* Bits to set in s_flags */ 2036 unsigned long mask_s_flags; /* Bits changed in s_flags */ 2037 unsigned long journal_devnum; 2038 unsigned long s_commit_interval; 2039 unsigned long s_stripe; 2040 unsigned int s_inode_readahead_blks; 2041 unsigned int s_want_extra_isize; 2042 unsigned int s_li_wait_mult; 2043 unsigned int s_max_dir_size_kb; 2044 unsigned int journal_ioprio; 2045 unsigned int vals_s_mount_opt; 2046 unsigned int mask_s_mount_opt; 2047 unsigned int vals_s_mount_opt2; 2048 unsigned int mask_s_mount_opt2; 2049 unsigned int vals_s_mount_flags; 2050 unsigned int mask_s_mount_flags; 2051 unsigned int opt_flags; /* MOPT flags */ 2052 unsigned int spec; 2053 u32 s_max_batch_time; 2054 u32 s_min_batch_time; 2055 kuid_t s_resuid; 2056 kgid_t s_resgid; 2057 ext4_fsblk_t s_sb_block; |
2101}; 2102 | 2058}; 2059 |
2103static int handle_mount_opt(struct super_block *sb, char *opt, int token, 2104 substring_t *args, struct ext4_parsed_options *parsed_opts, 2105 int is_remount) | 2060static void ext4_fc_free(struct fs_context *fc) |
2106{ | 2061{ |
2107 struct ext4_sb_info *sbi = EXT4_SB(sb); | 2062 struct ext4_fs_context *ctx = fc->fs_private; 2063 int i; 2064 2065 if (!ctx) 2066 return; 2067 2068 for (i = 0; i < EXT4_MAXQUOTAS; i++) 2069 kfree(ctx->s_qf_names[i]); 2070 2071 kfree(ctx->test_dummy_enc_arg); 2072 kfree(ctx); 2073} 2074 2075int ext4_init_fs_context(struct fs_context *fc) 2076{ 2077 struct ext4_fs_context *ctx; 2078 2079 ctx = kzalloc(sizeof(struct ext4_fs_context), GFP_KERNEL); 2080 if (!ctx) 2081 return -ENOMEM; 2082 2083 fc->fs_private = ctx; 2084 fc->ops = &ext4_context_ops; 2085 2086 return 0; 2087} 2088 2089#ifdef CONFIG_QUOTA 2090/* 2091 * Note the name of the specified quota file. 2092 */ 2093static int note_qf_name(struct fs_context *fc, int qtype, 2094 struct fs_parameter *param) 2095{ 2096 struct ext4_fs_context *ctx = fc->fs_private; 2097 char *qname; 2098 2099 if (param->size < 1) { 2100 ext4_msg(NULL, KERN_ERR, "Missing quota name"); 2101 return -EINVAL; 2102 } 2103 if (strchr(param->string, '/')) { 2104 ext4_msg(NULL, KERN_ERR, 2105 "quotafile must be on filesystem root"); 2106 return -EINVAL; 2107 } 2108 if (ctx->s_qf_names[qtype]) { 2109 if (strcmp(ctx->s_qf_names[qtype], param->string) != 0) { 2110 ext4_msg(NULL, KERN_ERR, 2111 "%s quota file already specified", 2112 QTYPE2NAME(qtype)); 2113 return -EINVAL; 2114 } 2115 return 0; 2116 } 2117 2118 qname = kmemdup_nul(param->string, param->size, GFP_KERNEL); 2119 if (!qname) { 2120 ext4_msg(NULL, KERN_ERR, 2121 "Not enough memory for storing quotafile name"); 2122 return -ENOMEM; 2123 } 2124 ctx->s_qf_names[qtype] = qname; 2125 ctx->qname_spec |= 1 << qtype; 2126 ctx->spec |= EXT4_SPEC_JQUOTA; 2127 return 0; 2128} 2129 2130/* 2131 * Clear the name of the specified quota file. 2132 */ 2133static int unnote_qf_name(struct fs_context *fc, int qtype) 2134{ 2135 struct ext4_fs_context *ctx = fc->fs_private; 2136 2137 if (ctx->s_qf_names[qtype]) 2138 kfree(ctx->s_qf_names[qtype]); 2139 2140 ctx->s_qf_names[qtype] = NULL; 2141 ctx->qname_spec |= 1 << qtype; 2142 ctx->spec |= EXT4_SPEC_JQUOTA; 2143 return 0; 2144} 2145#endif 2146 2147#define EXT4_SET_CTX(name) \ 2148static inline void ctx_set_##name(struct ext4_fs_context *ctx, \ 2149 unsigned long flag) \ 2150{ \ 2151 ctx->mask_s_##name |= flag; \ 2152 ctx->vals_s_##name |= flag; \ 2153} \ 2154static inline void ctx_clear_##name(struct ext4_fs_context *ctx, \ 2155 unsigned long flag) \ 2156{ \ 2157 ctx->mask_s_##name |= flag; \ 2158 ctx->vals_s_##name &= ~flag; \ 2159} \ 2160static inline unsigned long \ 2161ctx_test_##name(struct ext4_fs_context *ctx, unsigned long flag) \ 2162{ \ 2163 return (ctx->vals_s_##name & flag); \ 2164} \ 2165 2166EXT4_SET_CTX(flags); 2167EXT4_SET_CTX(mount_opt); 2168EXT4_SET_CTX(mount_opt2); 2169EXT4_SET_CTX(mount_flags); 2170 2171static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param) 2172{ 2173 struct ext4_fs_context *ctx = fc->fs_private; 2174 struct fs_parse_result result; |
2108 const struct mount_opts *m; | 2175 const struct mount_opts *m; |
2176 int is_remount; |
|
2109 kuid_t uid; 2110 kgid_t gid; | 2177 kuid_t uid; 2178 kgid_t gid; |
2111 int arg = 0; | 2179 int token; |
2112 | 2180 |
2113#ifdef CONFIG_QUOTA 2114 if (token == Opt_usrjquota) 2115 return set_qf_name(sb, USRQUOTA, &args[0]); 2116 else if (token == Opt_grpjquota) 2117 return set_qf_name(sb, GRPQUOTA, &args[0]); 2118 else if (token == Opt_offusrjquota) 2119 return clear_qf_name(sb, USRQUOTA); 2120 else if (token == Opt_offgrpjquota) 2121 return clear_qf_name(sb, GRPQUOTA); 2122#endif 2123 switch (token) { 2124 case Opt_noacl: 2125 case Opt_nouser_xattr: 2126 ext4_msg(sb, KERN_WARNING, deprecated_msg, opt, "3.5"); 2127 break; 2128 case Opt_sb: 2129 return 1; /* handled by get_sb_block() */ 2130 case Opt_removed: 2131 ext4_msg(sb, KERN_WARNING, "Ignoring removed %s option", opt); 2132 return 1; 2133 case Opt_abort: 2134 ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED); 2135 return 1; 2136 case Opt_i_version: 2137 sb->s_flags |= SB_I_VERSION; 2138 return 1; 2139 case Opt_lazytime: 2140 sb->s_flags |= SB_LAZYTIME; 2141 return 1; 2142 case Opt_nolazytime: 2143 sb->s_flags &= ~SB_LAZYTIME; 2144 return 1; 2145 case Opt_inlinecrypt: 2146#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT 2147 sb->s_flags |= SB_INLINECRYPT; 2148#else 2149 ext4_msg(sb, KERN_ERR, "inline encryption not supported"); 2150#endif 2151 return 1; 2152 } | 2181 token = fs_parse(fc, ext4_param_specs, param, &result); 2182 if (token < 0) 2183 return token; 2184 is_remount = fc->purpose == FS_CONTEXT_FOR_RECONFIGURE; |
2153 2154 for (m = ext4_mount_opts; m->token != Opt_err; m++) 2155 if (token == m->token) 2156 break; 2157 | 2185 2186 for (m = ext4_mount_opts; m->token != Opt_err; m++) 2187 if (token == m->token) 2188 break; 2189 |
2158 if (m->token == Opt_err) { 2159 ext4_msg(sb, KERN_ERR, "Unrecognized mount option \"%s\" " 2160 "or missing value", opt); 2161 return -1; 2162 } | 2190 ctx->opt_flags |= m->flags; |
2163 | 2191 |
2164 if ((m->flags & MOPT_NO_EXT2) && IS_EXT2_SB(sb)) { 2165 ext4_msg(sb, KERN_ERR, 2166 "Mount option \"%s\" incompatible with ext2", opt); 2167 return -1; 2168 } 2169 if ((m->flags & MOPT_NO_EXT3) && IS_EXT3_SB(sb)) { 2170 ext4_msg(sb, KERN_ERR, 2171 "Mount option \"%s\" incompatible with ext3", opt); 2172 return -1; 2173 } 2174 2175 if (args->from && !(m->flags & MOPT_STRING) && match_int(args, &arg)) 2176 return -1; 2177 if (args->from && (m->flags & MOPT_GTE0) && (arg < 0)) 2178 return -1; | |
2179 if (m->flags & MOPT_EXPLICIT) { 2180 if (m->mount_opt & EXT4_MOUNT_DELALLOC) { | 2192 if (m->flags & MOPT_EXPLICIT) { 2193 if (m->mount_opt & EXT4_MOUNT_DELALLOC) { |
2181 set_opt2(sb, EXPLICIT_DELALLOC); | 2194 ctx_set_mount_opt2(ctx, EXT4_MOUNT2_EXPLICIT_DELALLOC); |
2182 } else if (m->mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) { | 2195 } else if (m->mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) { |
2183 set_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM); | 2196 ctx_set_mount_opt2(ctx, 2197 EXT4_MOUNT2_EXPLICIT_JOURNAL_CHECKSUM); |
2184 } else | 2198 } else |
2185 return -1; | 2199 return -EINVAL; |
2186 } | 2200 } |
2187 if (m->flags & MOPT_CLEAR_ERR) 2188 clear_opt(sb, ERRORS_MASK); 2189 if (token == Opt_noquota && sb_any_quota_loaded(sb)) { 2190 ext4_msg(sb, KERN_ERR, "Cannot change quota " 2191 "options when quota turned on"); 2192 return -1; 2193 } | |
2194 2195 if (m->flags & MOPT_NOSUPPORT) { | 2201 2202 if (m->flags & MOPT_NOSUPPORT) { |
2196 ext4_msg(sb, KERN_ERR, "%s option not supported", opt); 2197 } else if (token == Opt_commit) { 2198 if (arg == 0) 2199 arg = JBD2_DEFAULT_MAX_COMMIT_AGE; 2200 else if (arg > INT_MAX / HZ) { 2201 ext4_msg(sb, KERN_ERR, | 2203 ext4_msg(NULL, KERN_ERR, "%s option not supported", 2204 param->key); 2205 return 0; 2206 } 2207 2208 switch (token) { 2209#ifdef CONFIG_QUOTA 2210 case Opt_usrjquota: 2211 if (!*param->string) 2212 return unnote_qf_name(fc, USRQUOTA); 2213 else 2214 return note_qf_name(fc, USRQUOTA, param); 2215 case Opt_grpjquota: 2216 if (!*param->string) 2217 return unnote_qf_name(fc, GRPQUOTA); 2218 else 2219 return note_qf_name(fc, GRPQUOTA, param); 2220#endif 2221 case Opt_noacl: 2222 case Opt_nouser_xattr: 2223 ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "3.5"); 2224 break; 2225 case Opt_sb: 2226 if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) { 2227 ext4_msg(NULL, KERN_WARNING, 2228 "Ignoring %s option on remount", param->key); 2229 } else { 2230 ctx->s_sb_block = result.uint_32; 2231 ctx->spec |= EXT4_SPEC_s_sb_block; 2232 } 2233 return 0; 2234 case Opt_removed: 2235 ext4_msg(NULL, KERN_WARNING, "Ignoring removed %s option", 2236 param->key); 2237 return 0; 2238 case Opt_abort: 2239 ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED); 2240 return 0; 2241 case Opt_i_version: 2242 ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "5.20"); 2243 ext4_msg(NULL, KERN_WARNING, "Use iversion instead\n"); 2244 ctx_set_flags(ctx, SB_I_VERSION); 2245 return 0; 2246 case Opt_inlinecrypt: 2247#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT 2248 ctx_set_flags(ctx, SB_INLINECRYPT); 2249#else 2250 ext4_msg(NULL, KERN_ERR, "inline encryption not supported"); 2251#endif 2252 return 0; 2253 case Opt_errors: 2254 ctx_clear_mount_opt(ctx, EXT4_MOUNT_ERRORS_MASK); 2255 ctx_set_mount_opt(ctx, result.uint_32); 2256 return 0; 2257#ifdef CONFIG_QUOTA 2258 case Opt_jqfmt: 2259 ctx->s_jquota_fmt = result.uint_32; 2260 ctx->spec |= EXT4_SPEC_JQFMT; 2261 return 0; 2262#endif 2263 case Opt_data: 2264 ctx_clear_mount_opt(ctx, EXT4_MOUNT_DATA_FLAGS); 2265 ctx_set_mount_opt(ctx, result.uint_32); 2266 ctx->spec |= EXT4_SPEC_DATAJ; 2267 return 0; 2268 case Opt_commit: 2269 if (result.uint_32 == 0) 2270 ctx->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE; 2271 else if (result.uint_32 > INT_MAX / HZ) { 2272 ext4_msg(NULL, KERN_ERR, |
2202 "Invalid commit interval %d, " 2203 "must be smaller than %d", | 2273 "Invalid commit interval %d, " 2274 "must be smaller than %d", |
2204 arg, INT_MAX / HZ); 2205 return -1; | 2275 result.uint_32, INT_MAX / HZ); 2276 return -EINVAL; |
2206 } | 2277 } |
2207 sbi->s_commit_interval = HZ * arg; 2208 } else if (token == Opt_debug_want_extra_isize) { 2209 if ((arg & 1) || 2210 (arg < 4) || 2211 (arg > (sbi->s_inode_size - EXT4_GOOD_OLD_INODE_SIZE))) { 2212 ext4_msg(sb, KERN_ERR, 2213 "Invalid want_extra_isize %d", arg); 2214 return -1; | 2278 ctx->s_commit_interval = HZ * result.uint_32; 2279 ctx->spec |= EXT4_SPEC_s_commit_interval; 2280 return 0; 2281 case Opt_debug_want_extra_isize: 2282 if ((result.uint_32 & 1) || (result.uint_32 < 4)) { 2283 ext4_msg(NULL, KERN_ERR, 2284 "Invalid want_extra_isize %d", result.uint_32); 2285 return -EINVAL; |
2215 } | 2286 } |
2216 sbi->s_want_extra_isize = arg; 2217 } else if (token == Opt_max_batch_time) { 2218 sbi->s_max_batch_time = arg; 2219 } else if (token == Opt_min_batch_time) { 2220 sbi->s_min_batch_time = arg; 2221 } else if (token == Opt_inode_readahead_blks) { 2222 if (arg && (arg > (1 << 30) || !is_power_of_2(arg))) { 2223 ext4_msg(sb, KERN_ERR, | 2287 ctx->s_want_extra_isize = result.uint_32; 2288 ctx->spec |= EXT4_SPEC_s_want_extra_isize; 2289 return 0; 2290 case Opt_max_batch_time: 2291 ctx->s_max_batch_time = result.uint_32; 2292 ctx->spec |= EXT4_SPEC_s_max_batch_time; 2293 return 0; 2294 case Opt_min_batch_time: 2295 ctx->s_min_batch_time = result.uint_32; 2296 ctx->spec |= EXT4_SPEC_s_min_batch_time; 2297 return 0; 2298 case Opt_inode_readahead_blks: 2299 if (result.uint_32 && 2300 (result.uint_32 > (1 << 30) || 2301 !is_power_of_2(result.uint_32))) { 2302 ext4_msg(NULL, KERN_ERR, |
2224 "EXT4-fs: inode_readahead_blks must be " 2225 "0 or a power of 2 smaller than 2^31"); | 2303 "EXT4-fs: inode_readahead_blks must be " 2304 "0 or a power of 2 smaller than 2^31"); |
2226 return -1; | 2305 return -EINVAL; |
2227 } | 2306 } |
2228 sbi->s_inode_readahead_blks = arg; 2229 } else if (token == Opt_init_itable) { 2230 set_opt(sb, INIT_INODE_TABLE); 2231 if (!args->from) 2232 arg = EXT4_DEF_LI_WAIT_MULT; 2233 sbi->s_li_wait_mult = arg; 2234 } else if (token == Opt_max_dir_size_kb) { 2235 sbi->s_max_dir_size_kb = arg; | 2307 ctx->s_inode_readahead_blks = result.uint_32; 2308 ctx->spec |= EXT4_SPEC_s_inode_readahead_blks; 2309 return 0; 2310 case Opt_init_itable: 2311 ctx_set_mount_opt(ctx, EXT4_MOUNT_INIT_INODE_TABLE); 2312 ctx->s_li_wait_mult = EXT4_DEF_LI_WAIT_MULT; 2313 if (param->type == fs_value_is_string) 2314 ctx->s_li_wait_mult = result.uint_32; 2315 ctx->spec |= EXT4_SPEC_s_li_wait_mult; 2316 return 0; 2317 case Opt_max_dir_size_kb: 2318 ctx->s_max_dir_size_kb = result.uint_32; 2319 ctx->spec |= EXT4_SPEC_s_max_dir_size_kb; 2320 return 0; |
2236#ifdef CONFIG_EXT4_DEBUG | 2321#ifdef CONFIG_EXT4_DEBUG |
2237 } else if (token == Opt_fc_debug_max_replay) { 2238 sbi->s_fc_debug_max_replay = arg; | 2322 case Opt_fc_debug_max_replay: 2323 ctx->s_fc_debug_max_replay = result.uint_32; 2324 ctx->spec |= EXT4_SPEC_s_fc_debug_max_replay; 2325 return 0; |
2239#endif | 2326#endif |
2240 } else if (token == Opt_stripe) { 2241 sbi->s_stripe = arg; 2242 } else if (token == Opt_resuid) { 2243 uid = make_kuid(current_user_ns(), arg); | 2327 case Opt_stripe: 2328 ctx->s_stripe = result.uint_32; 2329 ctx->spec |= EXT4_SPEC_s_stripe; 2330 return 0; 2331 case Opt_resuid: 2332 uid = make_kuid(current_user_ns(), result.uint_32); |
2244 if (!uid_valid(uid)) { | 2333 if (!uid_valid(uid)) { |
2245 ext4_msg(sb, KERN_ERR, "Invalid uid value %d", arg); 2246 return -1; | 2334 ext4_msg(NULL, KERN_ERR, "Invalid uid value %d", 2335 result.uint_32); 2336 return -EINVAL; |
2247 } | 2337 } |
2248 sbi->s_resuid = uid; 2249 } else if (token == Opt_resgid) { 2250 gid = make_kgid(current_user_ns(), arg); | 2338 ctx->s_resuid = uid; 2339 ctx->spec |= EXT4_SPEC_s_resuid; 2340 return 0; 2341 case Opt_resgid: 2342 gid = make_kgid(current_user_ns(), result.uint_32); |
2251 if (!gid_valid(gid)) { | 2343 if (!gid_valid(gid)) { |
2252 ext4_msg(sb, KERN_ERR, "Invalid gid value %d", arg); 2253 return -1; | 2344 ext4_msg(NULL, KERN_ERR, "Invalid gid value %d", 2345 result.uint_32); 2346 return -EINVAL; |
2254 } | 2347 } |
2255 sbi->s_resgid = gid; 2256 } else if (token == Opt_journal_dev) { | 2348 ctx->s_resgid = gid; 2349 ctx->spec |= EXT4_SPEC_s_resgid; 2350 return 0; 2351 case Opt_journal_dev: |
2257 if (is_remount) { | 2352 if (is_remount) { |
2258 ext4_msg(sb, KERN_ERR, | 2353 ext4_msg(NULL, KERN_ERR, |
2259 "Cannot specify journal on remount"); | 2354 "Cannot specify journal on remount"); |
2260 return -1; | 2355 return -EINVAL; |
2261 } | 2356 } |
2262 parsed_opts->journal_devnum = arg; 2263 } else if (token == Opt_journal_path) { 2264 char *journal_path; | 2357 ctx->journal_devnum = result.uint_32; 2358 ctx->spec |= EXT4_SPEC_JOURNAL_DEV; 2359 return 0; 2360 case Opt_journal_path: 2361 { |
2265 struct inode *journal_inode; 2266 struct path path; 2267 int error; 2268 2269 if (is_remount) { | 2362 struct inode *journal_inode; 2363 struct path path; 2364 int error; 2365 2366 if (is_remount) { |
2270 ext4_msg(sb, KERN_ERR, | 2367 ext4_msg(NULL, KERN_ERR, |
2271 "Cannot specify journal on remount"); | 2368 "Cannot specify journal on remount"); |
2272 return -1; | 2369 return -EINVAL; |
2273 } | 2370 } |
2274 journal_path = match_strdup(&args[0]); 2275 if (!journal_path) { 2276 ext4_msg(sb, KERN_ERR, "error: could not dup " 2277 "journal device string"); 2278 return -1; 2279 } | |
2280 | 2371 |
2281 error = kern_path(journal_path, LOOKUP_FOLLOW, &path); | 2372 error = fs_lookup_param(fc, param, 1, &path); |
2282 if (error) { | 2373 if (error) { |
2283 ext4_msg(sb, KERN_ERR, "error: could not find " 2284 "journal device path: error %d", error); 2285 kfree(journal_path); 2286 return -1; | 2374 ext4_msg(NULL, KERN_ERR, "error: could not find " 2375 "journal device path"); 2376 return -EINVAL; |
2287 } 2288 2289 journal_inode = d_inode(path.dentry); | 2377 } 2378 2379 journal_inode = d_inode(path.dentry); |
2290 if (!S_ISBLK(journal_inode->i_mode)) { 2291 ext4_msg(sb, KERN_ERR, "error: journal path %s " 2292 "is not a block device", journal_path); 2293 path_put(&path); 2294 kfree(journal_path); 2295 return -1; 2296 } 2297 2298 parsed_opts->journal_devnum = new_encode_dev(journal_inode->i_rdev); | 2380 ctx->journal_devnum = new_encode_dev(journal_inode->i_rdev); 2381 ctx->spec |= EXT4_SPEC_JOURNAL_DEV; |
2299 path_put(&path); | 2382 path_put(&path); |
2300 kfree(journal_path); 2301 } else if (token == Opt_journal_ioprio) { 2302 if (arg > 7) { 2303 ext4_msg(sb, KERN_ERR, "Invalid journal IO priority" | 2383 return 0; 2384 } 2385 case Opt_journal_ioprio: 2386 if (result.uint_32 > 7) { 2387 ext4_msg(NULL, KERN_ERR, "Invalid journal IO priority" |
2304 " (must be 0-7)"); | 2388 " (must be 0-7)"); |
2305 return -1; | 2389 return -EINVAL; |
2306 } | 2390 } |
2307 parsed_opts->journal_ioprio = 2308 IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, arg); 2309 } else if (token == Opt_test_dummy_encryption) { 2310 return ext4_set_test_dummy_encryption(sb, opt, &args[0], 2311 is_remount); 2312 } else if (m->flags & MOPT_DATAJ) { 2313 if (is_remount) { 2314 if (!sbi->s_journal) 2315 ext4_msg(sb, KERN_WARNING, "Remounting file system with no journal so ignoring journalled data option"); 2316 else if (test_opt(sb, DATA_FLAGS) != m->mount_opt) { 2317 ext4_msg(sb, KERN_ERR, 2318 "Cannot change data mode on remount"); 2319 return -1; 2320 } 2321 } else { 2322 clear_opt(sb, DATA_FLAGS); 2323 sbi->s_mount_opt |= m->mount_opt; | 2391 ctx->journal_ioprio = 2392 IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, result.uint_32); 2393 ctx->spec |= EXT4_SPEC_JOURNAL_IOPRIO; 2394 return 0; 2395 case Opt_test_dummy_encryption: 2396#ifdef CONFIG_FS_ENCRYPTION 2397 if (param->type == fs_value_is_flag) { 2398 ctx->spec |= EXT4_SPEC_DUMMY_ENCRYPTION; 2399 ctx->test_dummy_enc_arg = NULL; 2400 return 0; |
2324 } | 2401 } |
2325#ifdef CONFIG_QUOTA 2326 } else if (m->flags & MOPT_QFMT) { 2327 if (sb_any_quota_loaded(sb) && 2328 sbi->s_jquota_fmt != m->mount_opt) { 2329 ext4_msg(sb, KERN_ERR, "Cannot change journaled " 2330 "quota options when quota turned on"); 2331 return -1; | 2402 if (*param->string && 2403 !(!strcmp(param->string, "v1") || 2404 !strcmp(param->string, "v2"))) { 2405 ext4_msg(NULL, KERN_WARNING, 2406 "Value of option \"%s\" is unrecognized", 2407 param->key); 2408 return -EINVAL; |
2332 } | 2409 } |
2333 if (ext4_has_feature_quota(sb)) { 2334 ext4_msg(sb, KERN_INFO, 2335 "Quota format mount options ignored " 2336 "when QUOTA feature is enabled"); 2337 return 1; 2338 } 2339 sbi->s_jquota_fmt = m->mount_opt; | 2410 ctx->spec |= EXT4_SPEC_DUMMY_ENCRYPTION; 2411 ctx->test_dummy_enc_arg = kmemdup_nul(param->string, param->size, 2412 GFP_KERNEL); 2413#else 2414 ext4_msg(NULL, KERN_WARNING, 2415 "Test dummy encryption mount option ignored"); |
2340#endif | 2416#endif |
2341 } else if (token == Opt_dax || token == Opt_dax_always || 2342 token == Opt_dax_inode || token == Opt_dax_never) { | 2417 return 0; 2418 case Opt_dax: 2419 case Opt_dax_type: |
2343#ifdef CONFIG_FS_DAX | 2420#ifdef CONFIG_FS_DAX |
2344 switch (token) { | 2421 { 2422 int type = (token == Opt_dax) ? 2423 Opt_dax : result.uint_32; 2424 2425 switch (type) { |
2345 case Opt_dax: 2346 case Opt_dax_always: | 2426 case Opt_dax: 2427 case Opt_dax_always: |
2347 if (is_remount && 2348 (!(sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) || 2349 (sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_NEVER))) { 2350 fail_dax_change_remount: 2351 ext4_msg(sb, KERN_ERR, "can't change " 2352 "dax mount option while remounting"); 2353 return -1; 2354 } 2355 if (is_remount && 2356 (test_opt(sb, DATA_FLAGS) == 2357 EXT4_MOUNT_JOURNAL_DATA)) { 2358 ext4_msg(sb, KERN_ERR, "can't mount with " 2359 "both data=journal and dax"); 2360 return -1; 2361 } 2362 ext4_msg(sb, KERN_WARNING, 2363 "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); 2364 sbi->s_mount_opt |= EXT4_MOUNT_DAX_ALWAYS; 2365 sbi->s_mount_opt2 &= ~EXT4_MOUNT2_DAX_NEVER; | 2428 ctx_set_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS); 2429 ctx_clear_mount_opt2(ctx, EXT4_MOUNT2_DAX_NEVER); |
2366 break; 2367 case Opt_dax_never: | 2430 break; 2431 case Opt_dax_never: |
2368 if (is_remount && 2369 (!(sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_NEVER) || 2370 (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS))) 2371 goto fail_dax_change_remount; 2372 sbi->s_mount_opt2 |= EXT4_MOUNT2_DAX_NEVER; 2373 sbi->s_mount_opt &= ~EXT4_MOUNT_DAX_ALWAYS; | 2432 ctx_set_mount_opt2(ctx, EXT4_MOUNT2_DAX_NEVER); 2433 ctx_clear_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS); |
2374 break; 2375 case Opt_dax_inode: | 2434 break; 2435 case Opt_dax_inode: |
2376 if (is_remount && 2377 ((sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) || 2378 (sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_NEVER) || 2379 !(sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_INODE))) 2380 goto fail_dax_change_remount; 2381 sbi->s_mount_opt &= ~EXT4_MOUNT_DAX_ALWAYS; 2382 sbi->s_mount_opt2 &= ~EXT4_MOUNT2_DAX_NEVER; | 2436 ctx_clear_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS); 2437 ctx_clear_mount_opt2(ctx, EXT4_MOUNT2_DAX_NEVER); |
2383 /* Strictly for printing options */ | 2438 /* Strictly for printing options */ |
2384 sbi->s_mount_opt2 |= EXT4_MOUNT2_DAX_INODE; | 2439 ctx_set_mount_opt2(ctx, EXT4_MOUNT2_DAX_INODE); |
2385 break; 2386 } | 2440 break; 2441 } |
2442 return 0; 2443 } |
|
2387#else | 2444#else |
2388 ext4_msg(sb, KERN_INFO, "dax option not supported"); 2389 sbi->s_mount_opt2 |= EXT4_MOUNT2_DAX_NEVER; 2390 sbi->s_mount_opt &= ~EXT4_MOUNT_DAX_ALWAYS; 2391 return -1; | 2445 ext4_msg(NULL, KERN_INFO, "dax option not supported"); 2446 return -EINVAL; |
2392#endif | 2447#endif |
2393 } else if (token == Opt_data_err_abort) { 2394 sbi->s_mount_opt |= m->mount_opt; 2395 } else if (token == Opt_data_err_ignore) { 2396 sbi->s_mount_opt &= ~m->mount_opt; 2397 } else if (token == Opt_mb_optimize_scan) { 2398 if (arg != 0 && arg != 1) { 2399 ext4_msg(sb, KERN_WARNING, | 2448 case Opt_data_err: 2449 if (result.uint_32 == Opt_data_err_abort) 2450 ctx_set_mount_opt(ctx, m->mount_opt); 2451 else if (result.uint_32 == Opt_data_err_ignore) 2452 ctx_clear_mount_opt(ctx, m->mount_opt); 2453 return 0; 2454 case Opt_mb_optimize_scan: 2455 if (result.int_32 != 0 && result.int_32 != 1) { 2456 ext4_msg(NULL, KERN_WARNING, |
2400 "mb_optimize_scan should be set to 0 or 1."); | 2457 "mb_optimize_scan should be set to 0 or 1."); |
2401 return -1; | 2458 return -EINVAL; |
2402 } | 2459 } |
2403 parsed_opts->mb_optimize_scan = arg; 2404 } else { 2405 if (!args->from) 2406 arg = 1; | 2460 ctx->mb_optimize_scan = result.int_32; 2461 return 0; 2462 } 2463 2464 /* 2465 * At this point we should only be getting options requiring MOPT_SET, 2466 * or MOPT_CLEAR. Anything else is a bug 2467 */ 2468 if (m->token == Opt_err) { 2469 ext4_msg(NULL, KERN_WARNING, "buggy handling of option %s", 2470 param->key); 2471 WARN_ON(1); 2472 return -EINVAL; 2473 } 2474 2475 else { 2476 unsigned int set = 0; 2477 2478 if ((param->type == fs_value_is_flag) || 2479 result.uint_32 > 0) 2480 set = 1; 2481 |
2407 if (m->flags & MOPT_CLEAR) | 2482 if (m->flags & MOPT_CLEAR) |
2408 arg = !arg; | 2483 set = !set; |
2409 else if (unlikely(!(m->flags & MOPT_SET))) { | 2484 else if (unlikely(!(m->flags & MOPT_SET))) { |
2410 ext4_msg(sb, KERN_WARNING, 2411 "buggy handling of option %s", opt); | 2485 ext4_msg(NULL, KERN_WARNING, 2486 "buggy handling of option %s", 2487 param->key); |
2412 WARN_ON(1); | 2488 WARN_ON(1); |
2413 return -1; | 2489 return -EINVAL; |
2414 } 2415 if (m->flags & MOPT_2) { | 2490 } 2491 if (m->flags & MOPT_2) { |
2416 if (arg != 0) 2417 sbi->s_mount_opt2 |= m->mount_opt; | 2492 if (set != 0) 2493 ctx_set_mount_opt2(ctx, m->mount_opt); |
2418 else | 2494 else |
2419 sbi->s_mount_opt2 &= ~m->mount_opt; | 2495 ctx_clear_mount_opt2(ctx, m->mount_opt); |
2420 } else { | 2496 } else { |
2421 if (arg != 0) 2422 sbi->s_mount_opt |= m->mount_opt; | 2497 if (set != 0) 2498 ctx_set_mount_opt(ctx, m->mount_opt); |
2423 else | 2499 else |
2424 sbi->s_mount_opt &= ~m->mount_opt; | 2500 ctx_clear_mount_opt(ctx, m->mount_opt); |
2425 } 2426 } | 2501 } 2502 } |
2427 return 1; | 2503 2504 return 0; |
2428} 2429 | 2505} 2506 |
2430static int parse_options(char *options, struct super_block *sb, 2431 struct ext4_parsed_options *ret_opts, 2432 int is_remount) | 2507static int parse_options(struct fs_context *fc, char *options) |
2433{ | 2508{ |
2434 struct ext4_sb_info __maybe_unused *sbi = EXT4_SB(sb); 2435 char *p, __maybe_unused *usr_qf_name, __maybe_unused *grp_qf_name; 2436 substring_t args[MAX_OPT_ARGS]; 2437 int token; | 2509 struct fs_parameter param; 2510 int ret; 2511 char *key; |
2438 2439 if (!options) | 2512 2513 if (!options) |
2440 return 1; | 2514 return 0; |
2441 | 2515 |
2442 while ((p = strsep(&options, ",")) != NULL) { 2443 if (!*p) 2444 continue; 2445 /* 2446 * Initialize args struct so we know whether arg was 2447 * found; some options take optional arguments. 2448 */ 2449 args[0].to = args[0].from = NULL; 2450 token = match_token(p, tokens, args); 2451 if (handle_mount_opt(sb, p, token, args, ret_opts, 2452 is_remount) < 0) 2453 return 0; | 2516 while ((key = strsep(&options, ",")) != NULL) { 2517 if (*key) { 2518 size_t v_len = 0; 2519 char *value = strchr(key, '='); 2520 2521 param.type = fs_value_is_flag; 2522 param.string = NULL; 2523 2524 if (value) { 2525 if (value == key) 2526 continue; 2527 2528 *value++ = 0; 2529 v_len = strlen(value); 2530 param.string = kmemdup_nul(value, v_len, 2531 GFP_KERNEL); 2532 if (!param.string) 2533 return -ENOMEM; 2534 param.type = fs_value_is_string; 2535 } 2536 2537 param.key = key; 2538 param.size = v_len; 2539 2540 ret = ext4_parse_param(fc, ¶m); 2541 if (param.string) 2542 kfree(param.string); 2543 if (ret < 0) 2544 return ret; 2545 } |
2454 } | 2546 } |
2547 2548 ret = ext4_validate_options(fc); 2549 if (ret < 0) 2550 return ret; 2551 2552 return 0; 2553} 2554 2555static int parse_apply_sb_mount_options(struct super_block *sb, 2556 struct ext4_fs_context *m_ctx) 2557{ 2558 struct ext4_sb_info *sbi = EXT4_SB(sb); 2559 char *s_mount_opts = NULL; 2560 struct ext4_fs_context *s_ctx = NULL; 2561 struct fs_context *fc = NULL; 2562 int ret = -ENOMEM; 2563 2564 if (!sbi->s_es->s_mount_opts[0]) 2565 return 0; 2566 2567 s_mount_opts = kstrndup(sbi->s_es->s_mount_opts, 2568 sizeof(sbi->s_es->s_mount_opts), 2569 GFP_KERNEL); 2570 if (!s_mount_opts) 2571 return ret; 2572 2573 fc = kzalloc(sizeof(struct fs_context), GFP_KERNEL); 2574 if (!fc) 2575 goto out_free; 2576 2577 s_ctx = kzalloc(sizeof(struct ext4_fs_context), GFP_KERNEL); 2578 if (!s_ctx) 2579 goto out_free; 2580 2581 fc->fs_private = s_ctx; 2582 fc->s_fs_info = sbi; 2583 2584 ret = parse_options(fc, s_mount_opts); 2585 if (ret < 0) 2586 goto parse_failed; 2587 2588 ret = ext4_check_opt_consistency(fc, sb); 2589 if (ret < 0) { 2590parse_failed: 2591 ext4_msg(sb, KERN_WARNING, 2592 "failed to parse options in superblock: %s", 2593 s_mount_opts); 2594 ret = 0; 2595 goto out_free; 2596 } 2597 2598 if (s_ctx->spec & EXT4_SPEC_JOURNAL_DEV) 2599 m_ctx->journal_devnum = s_ctx->journal_devnum; 2600 if (s_ctx->spec & EXT4_SPEC_JOURNAL_IOPRIO) 2601 m_ctx->journal_ioprio = s_ctx->journal_ioprio; 2602 2603 ret = ext4_apply_options(fc, sb); 2604 2605out_free: 2606 kfree(s_ctx); 2607 kfree(fc); 2608 kfree(s_mount_opts); 2609 return ret; 2610} 2611 2612static void ext4_apply_quota_options(struct fs_context *fc, 2613 struct super_block *sb) 2614{ |
|
2455#ifdef CONFIG_QUOTA | 2615#ifdef CONFIG_QUOTA |
2616 bool quota_feature = ext4_has_feature_quota(sb); 2617 struct ext4_fs_context *ctx = fc->fs_private; 2618 struct ext4_sb_info *sbi = EXT4_SB(sb); 2619 char *qname; 2620 int i; 2621 2622 if (quota_feature) 2623 return; 2624 2625 if (ctx->spec & EXT4_SPEC_JQUOTA) { 2626 for (i = 0; i < EXT4_MAXQUOTAS; i++) { 2627 if (!(ctx->qname_spec & (1 << i))) 2628 continue; 2629 2630 qname = ctx->s_qf_names[i]; /* May be NULL */ 2631 if (qname) 2632 set_opt(sb, QUOTA); 2633 ctx->s_qf_names[i] = NULL; 2634 qname = rcu_replace_pointer(sbi->s_qf_names[i], qname, 2635 lockdep_is_held(&sb->s_umount)); 2636 if (qname) 2637 kfree_rcu(qname); 2638 } 2639 } 2640 2641 if (ctx->spec & EXT4_SPEC_JQFMT) 2642 sbi->s_jquota_fmt = ctx->s_jquota_fmt; 2643#endif 2644} 2645 2646/* 2647 * Check quota settings consistency. 2648 */ 2649static int ext4_check_quota_consistency(struct fs_context *fc, 2650 struct super_block *sb) 2651{ 2652#ifdef CONFIG_QUOTA 2653 struct ext4_fs_context *ctx = fc->fs_private; 2654 struct ext4_sb_info *sbi = EXT4_SB(sb); 2655 bool quota_feature = ext4_has_feature_quota(sb); 2656 bool quota_loaded = sb_any_quota_loaded(sb); 2657 bool usr_qf_name, grp_qf_name, usrquota, grpquota; 2658 int quota_flags, i; 2659 |
|
2456 /* 2457 * We do the test below only for project quotas. 'usrquota' and 2458 * 'grpquota' mount options are allowed even without quota feature 2459 * to support legacy quotas in quota files. 2460 */ | 2660 /* 2661 * We do the test below only for project quotas. 'usrquota' and 2662 * 'grpquota' mount options are allowed even without quota feature 2663 * to support legacy quotas in quota files. 2664 */ |
2461 if (test_opt(sb, PRJQUOTA) && !ext4_has_feature_project(sb)) { 2462 ext4_msg(sb, KERN_ERR, "Project quota feature not enabled. " | 2665 if (ctx_test_mount_opt(ctx, EXT4_MOUNT_PRJQUOTA) && 2666 !ext4_has_feature_project(sb)) { 2667 ext4_msg(NULL, KERN_ERR, "Project quota feature not enabled. " |
2463 "Cannot enable project quota enforcement."); | 2668 "Cannot enable project quota enforcement."); |
2464 return 0; | 2669 return -EINVAL; |
2465 } | 2670 } |
2466 usr_qf_name = get_qf_name(sb, sbi, USRQUOTA); 2467 grp_qf_name = get_qf_name(sb, sbi, GRPQUOTA); 2468 if (usr_qf_name || grp_qf_name) { 2469 if (test_opt(sb, USRQUOTA) && usr_qf_name) 2470 clear_opt(sb, USRQUOTA); | |
2471 | 2671 |
2472 if (test_opt(sb, GRPQUOTA) && grp_qf_name) 2473 clear_opt(sb, GRPQUOTA); | 2672 quota_flags = EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA | 2673 EXT4_MOUNT_GRPQUOTA | EXT4_MOUNT_PRJQUOTA; 2674 if (quota_loaded && 2675 ctx->mask_s_mount_opt & quota_flags && 2676 !ctx_test_mount_opt(ctx, quota_flags)) 2677 goto err_quota_change; |
2474 | 2678 |
2475 if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { 2476 ext4_msg(sb, KERN_ERR, "old and new quota " 2477 "format mixing"); | 2679 if (ctx->spec & EXT4_SPEC_JQUOTA) { 2680 2681 for (i = 0; i < EXT4_MAXQUOTAS; i++) { 2682 if (!(ctx->qname_spec & (1 << i))) 2683 continue; 2684 2685 if (quota_loaded && 2686 !!sbi->s_qf_names[i] != !!ctx->s_qf_names[i]) 2687 goto err_jquota_change; 2688 2689 if (sbi->s_qf_names[i] && ctx->s_qf_names[i] && 2690 strcmp(get_qf_name(sb, sbi, i), 2691 ctx->s_qf_names[i]) != 0) 2692 goto err_jquota_specified; 2693 } 2694 2695 if (quota_feature) { 2696 ext4_msg(NULL, KERN_INFO, 2697 "Journaled quota options ignored when " 2698 "QUOTA feature is enabled"); |
2478 return 0; 2479 } | 2699 return 0; 2700 } |
2701 } |
|
2480 | 2702 |
2481 if (!sbi->s_jquota_fmt) { 2482 ext4_msg(sb, KERN_ERR, "journaled quota format " 2483 "not specified"); | 2703 if (ctx->spec & EXT4_SPEC_JQFMT) { 2704 if (sbi->s_jquota_fmt != ctx->s_jquota_fmt && quota_loaded) 2705 goto err_jquota_change; 2706 if (quota_feature) { 2707 ext4_msg(NULL, KERN_INFO, "Quota format mount options " 2708 "ignored when QUOTA feature is enabled"); |
2484 return 0; 2485 } 2486 } | 2709 return 0; 2710 } 2711 } |
2712 2713 /* Make sure we don't mix old and new quota format */ 2714 usr_qf_name = (get_qf_name(sb, sbi, USRQUOTA) || 2715 ctx->s_qf_names[USRQUOTA]); 2716 grp_qf_name = (get_qf_name(sb, sbi, GRPQUOTA) || 2717 ctx->s_qf_names[GRPQUOTA]); 2718 2719 usrquota = (ctx_test_mount_opt(ctx, EXT4_MOUNT_USRQUOTA) || 2720 test_opt(sb, USRQUOTA)); 2721 2722 grpquota = (ctx_test_mount_opt(ctx, EXT4_MOUNT_GRPQUOTA) || 2723 test_opt(sb, GRPQUOTA)); 2724 2725 if (usr_qf_name) { 2726 ctx_clear_mount_opt(ctx, EXT4_MOUNT_USRQUOTA); 2727 usrquota = false; 2728 } 2729 if (grp_qf_name) { 2730 ctx_clear_mount_opt(ctx, EXT4_MOUNT_GRPQUOTA); 2731 grpquota = false; 2732 } 2733 2734 if (usr_qf_name || grp_qf_name) { 2735 if (usrquota || grpquota) { 2736 ext4_msg(NULL, KERN_ERR, "old and new quota " 2737 "format mixing"); 2738 return -EINVAL; 2739 } 2740 2741 if (!(ctx->spec & EXT4_SPEC_JQFMT || sbi->s_jquota_fmt)) { 2742 ext4_msg(NULL, KERN_ERR, "journaled quota format " 2743 "not specified"); 2744 return -EINVAL; 2745 } 2746 } 2747 2748 return 0; 2749 2750err_quota_change: 2751 ext4_msg(NULL, KERN_ERR, 2752 "Cannot change quota options when quota turned on"); 2753 return -EINVAL; 2754err_jquota_change: 2755 ext4_msg(NULL, KERN_ERR, "Cannot change journaled quota " 2756 "options when quota turned on"); 2757 return -EINVAL; 2758err_jquota_specified: 2759 ext4_msg(NULL, KERN_ERR, "%s quota file already specified", 2760 QTYPE2NAME(i)); 2761 return -EINVAL; 2762#else 2763 return 0; |
|
2487#endif | 2764#endif |
2488 if (test_opt(sb, DIOREAD_NOLOCK)) { | 2765} 2766 2767static int ext4_check_opt_consistency(struct fs_context *fc, 2768 struct super_block *sb) 2769{ 2770 struct ext4_fs_context *ctx = fc->fs_private; 2771 struct ext4_sb_info *sbi = fc->s_fs_info; 2772 int is_remount = fc->purpose == FS_CONTEXT_FOR_RECONFIGURE; 2773 2774 if ((ctx->opt_flags & MOPT_NO_EXT2) && IS_EXT2_SB(sb)) { 2775 ext4_msg(NULL, KERN_ERR, 2776 "Mount option(s) incompatible with ext2"); 2777 return -EINVAL; 2778 } 2779 if ((ctx->opt_flags & MOPT_NO_EXT3) && IS_EXT3_SB(sb)) { 2780 ext4_msg(NULL, KERN_ERR, 2781 "Mount option(s) incompatible with ext3"); 2782 return -EINVAL; 2783 } 2784 2785 if (ctx->s_want_extra_isize > 2786 (sbi->s_inode_size - EXT4_GOOD_OLD_INODE_SIZE)) { 2787 ext4_msg(NULL, KERN_ERR, 2788 "Invalid want_extra_isize %d", 2789 ctx->s_want_extra_isize); 2790 return -EINVAL; 2791 } 2792 2793 if (ctx_test_mount_opt(ctx, EXT4_MOUNT_DIOREAD_NOLOCK)) { |
2489 int blocksize = 2490 BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); 2491 if (blocksize < PAGE_SIZE) | 2794 int blocksize = 2795 BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); 2796 if (blocksize < PAGE_SIZE) |
2492 ext4_msg(sb, KERN_WARNING, "Warning: mounting with an " | 2797 ext4_msg(NULL, KERN_WARNING, "Warning: mounting with an " |
2493 "experimental mount option 'dioread_nolock' " 2494 "for blocksize < PAGE_SIZE"); 2495 } | 2798 "experimental mount option 'dioread_nolock' " 2799 "for blocksize < PAGE_SIZE"); 2800 } |
2801 2802#ifdef CONFIG_FS_ENCRYPTION 2803 /* 2804 * This mount option is just for testing, and it's not worthwhile to 2805 * implement the extra complexity (e.g. RCU protection) that would be 2806 * needed to allow it to be set or changed during remount. We do allow 2807 * it to be specified during remount, but only if there is no change. 2808 */ 2809 if ((ctx->spec & EXT4_SPEC_DUMMY_ENCRYPTION) && 2810 is_remount && !sbi->s_dummy_enc_policy.policy) { 2811 ext4_msg(NULL, KERN_WARNING, 2812 "Can't set test_dummy_encryption on remount"); 2813 return -1; 2814 } 2815#endif 2816 2817 if ((ctx->spec & EXT4_SPEC_DATAJ) && is_remount) { 2818 if (!sbi->s_journal) { 2819 ext4_msg(NULL, KERN_WARNING, 2820 "Remounting file system with no journal " 2821 "so ignoring journalled data option"); 2822 ctx_clear_mount_opt(ctx, EXT4_MOUNT_DATA_FLAGS); 2823 } else if (ctx_test_mount_opt(ctx, EXT4_MOUNT_DATA_FLAGS) != 2824 test_opt(sb, DATA_FLAGS)) { 2825 ext4_msg(NULL, KERN_ERR, "Cannot change data mode " 2826 "on remount"); 2827 return -EINVAL; 2828 } 2829 } 2830 2831 if (is_remount) { 2832 if (ctx_test_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS) && 2833 (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)) { 2834 ext4_msg(NULL, KERN_ERR, "can't mount with " 2835 "both data=journal and dax"); 2836 return -EINVAL; 2837 } 2838 2839 if (ctx_test_mount_opt(ctx, EXT4_MOUNT_DAX_ALWAYS) && 2840 (!(sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) || 2841 (sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_NEVER))) { 2842fail_dax_change_remount: 2843 ext4_msg(NULL, KERN_ERR, "can't change " 2844 "dax mount option while remounting"); 2845 return -EINVAL; 2846 } else if (ctx_test_mount_opt2(ctx, EXT4_MOUNT2_DAX_NEVER) && 2847 (!(sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_NEVER) || 2848 (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS))) { 2849 goto fail_dax_change_remount; 2850 } else if (ctx_test_mount_opt2(ctx, EXT4_MOUNT2_DAX_INODE) && 2851 ((sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) || 2852 (sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_NEVER) || 2853 !(sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_INODE))) { 2854 goto fail_dax_change_remount; 2855 } 2856 } 2857 2858 return ext4_check_quota_consistency(fc, sb); 2859} 2860 2861static int ext4_apply_options(struct fs_context *fc, struct super_block *sb) 2862{ 2863 struct ext4_fs_context *ctx = fc->fs_private; 2864 struct ext4_sb_info *sbi = fc->s_fs_info; 2865 int ret = 0; 2866 2867 sbi->s_mount_opt &= ~ctx->mask_s_mount_opt; 2868 sbi->s_mount_opt |= ctx->vals_s_mount_opt; 2869 sbi->s_mount_opt2 &= ~ctx->mask_s_mount_opt2; 2870 sbi->s_mount_opt2 |= ctx->vals_s_mount_opt2; 2871 sbi->s_mount_flags &= ~ctx->mask_s_mount_flags; 2872 sbi->s_mount_flags |= ctx->vals_s_mount_flags; 2873 sb->s_flags &= ~ctx->mask_s_flags; 2874 sb->s_flags |= ctx->vals_s_flags; 2875 2876 /* 2877 * i_version differs from common mount option iversion so we have 2878 * to let vfs know that it was set, otherwise it would get cleared 2879 * on remount 2880 */ 2881 if (ctx->mask_s_flags & SB_I_VERSION) 2882 fc->sb_flags |= SB_I_VERSION; 2883 2884#define APPLY(X) ({ if (ctx->spec & EXT4_SPEC_##X) sbi->X = ctx->X; }) 2885 APPLY(s_commit_interval); 2886 APPLY(s_stripe); 2887 APPLY(s_max_batch_time); 2888 APPLY(s_min_batch_time); 2889 APPLY(s_want_extra_isize); 2890 APPLY(s_inode_readahead_blks); 2891 APPLY(s_max_dir_size_kb); 2892 APPLY(s_li_wait_mult); 2893 APPLY(s_resgid); 2894 APPLY(s_resuid); 2895 2896#ifdef CONFIG_EXT4_DEBUG 2897 APPLY(s_fc_debug_max_replay); 2898#endif 2899 2900 ext4_apply_quota_options(fc, sb); 2901 2902 if (ctx->spec & EXT4_SPEC_DUMMY_ENCRYPTION) 2903 ret = ext4_set_test_dummy_encryption(sb, ctx->test_dummy_enc_arg); 2904 2905 return ret; 2906} 2907 2908 2909static int ext4_validate_options(struct fs_context *fc) 2910{ 2911#ifdef CONFIG_QUOTA 2912 struct ext4_fs_context *ctx = fc->fs_private; 2913 char *usr_qf_name, *grp_qf_name; 2914 2915 usr_qf_name = ctx->s_qf_names[USRQUOTA]; 2916 grp_qf_name = ctx->s_qf_names[GRPQUOTA]; 2917 2918 if (usr_qf_name || grp_qf_name) { 2919 if (ctx_test_mount_opt(ctx, EXT4_MOUNT_USRQUOTA) && usr_qf_name) 2920 ctx_clear_mount_opt(ctx, EXT4_MOUNT_USRQUOTA); 2921 2922 if (ctx_test_mount_opt(ctx, EXT4_MOUNT_GRPQUOTA) && grp_qf_name) 2923 ctx_clear_mount_opt(ctx, EXT4_MOUNT_GRPQUOTA); 2924 2925 if (ctx_test_mount_opt(ctx, EXT4_MOUNT_USRQUOTA) || 2926 ctx_test_mount_opt(ctx, EXT4_MOUNT_GRPQUOTA)) { 2927 ext4_msg(NULL, KERN_ERR, "old and new quota " 2928 "format mixing"); 2929 return -EINVAL; 2930 } 2931 } 2932#endif |
|
2496 return 1; 2497} 2498 2499static inline void ext4_show_quota_options(struct seq_file *seq, 2500 struct super_block *sb) 2501{ 2502#if defined(CONFIG_QUOTA) 2503 struct ext4_sb_info *sbi = EXT4_SB(sb); --- 24 unchanged lines hidden (view full) --- 2528 if (grp_qf_name) 2529 seq_show_option(seq, "grpjquota", grp_qf_name); 2530 rcu_read_unlock(); 2531#endif 2532} 2533 2534static const char *token2str(int token) 2535{ | 2933 return 1; 2934} 2935 2936static inline void ext4_show_quota_options(struct seq_file *seq, 2937 struct super_block *sb) 2938{ 2939#if defined(CONFIG_QUOTA) 2940 struct ext4_sb_info *sbi = EXT4_SB(sb); --- 24 unchanged lines hidden (view full) --- 2965 if (grp_qf_name) 2966 seq_show_option(seq, "grpjquota", grp_qf_name); 2967 rcu_read_unlock(); 2968#endif 2969} 2970 2971static const char *token2str(int token) 2972{ |
2536 const struct match_token *t; | 2973 const struct fs_parameter_spec *spec; |
2537 | 2974 |
2538 for (t = tokens; t->token != Opt_err; t++) 2539 if (t->token == token && !strchr(t->pattern, '=')) | 2975 for (spec = ext4_param_specs; spec->name != NULL; spec++) 2976 if (spec->opt == token && !spec->type) |
2540 break; | 2977 break; |
2541 return t->pattern; | 2978 return spec->name; |
2542} 2543 2544/* 2545 * Show an option if 2546 * - it's set to a non-default value OR 2547 * - if the per-sb default is different from the global default 2548 */ 2549static int _ext4_show_options(struct seq_file *seq, struct super_block *sb, --- 9 unchanged lines hidden (view full) --- 2559#define SEQ_OPTS_PRINT(str, arg) seq_printf(seq, "%c" str, sep, arg) 2560 2561 if (sbi->s_sb_block != 1) 2562 SEQ_OPTS_PRINT("sb=%llu", sbi->s_sb_block); 2563 2564 for (m = ext4_mount_opts; m->token != Opt_err; m++) { 2565 int want_set = m->flags & MOPT_SET; 2566 if (((m->flags & (MOPT_SET|MOPT_CLEAR)) == 0) || | 2979} 2980 2981/* 2982 * Show an option if 2983 * - it's set to a non-default value OR 2984 * - if the per-sb default is different from the global default 2985 */ 2986static int _ext4_show_options(struct seq_file *seq, struct super_block *sb, --- 9 unchanged lines hidden (view full) --- 2996#define SEQ_OPTS_PRINT(str, arg) seq_printf(seq, "%c" str, sep, arg) 2997 2998 if (sbi->s_sb_block != 1) 2999 SEQ_OPTS_PRINT("sb=%llu", sbi->s_sb_block); 3000 3001 for (m = ext4_mount_opts; m->token != Opt_err; m++) { 3002 int want_set = m->flags & MOPT_SET; 3003 if (((m->flags & (MOPT_SET|MOPT_CLEAR)) == 0) || |
2567 (m->flags & MOPT_CLEAR_ERR) || m->flags & MOPT_SKIP) | 3004 m->flags & MOPT_SKIP) |
2568 continue; 2569 if (!nodefs && !(m->mount_opt & (sbi->s_mount_opt ^ def_mount_opt))) 2570 continue; /* skip if same as the default */ 2571 if ((want_set && 2572 (sbi->s_mount_opt & m->mount_opt) != m->mount_opt) || 2573 (!want_set && (sbi->s_mount_opt & m->mount_opt))) 2574 continue; /* select Opt_noFoo vs Opt_Foo */ 2575 SEQ_OPTS_PRINT("%s", token2str(m->token)); --- 591 unchanged lines hidden (view full) --- 3167 ext4_msg(sb, KERN_ERR, 3168 "Couldn't mount because of " 3169 "unsupported optional features (%x)", 3170 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) & 3171 ~EXT4_FEATURE_INCOMPAT_SUPP)); 3172 return 0; 3173 } 3174 | 3005 continue; 3006 if (!nodefs && !(m->mount_opt & (sbi->s_mount_opt ^ def_mount_opt))) 3007 continue; /* skip if same as the default */ 3008 if ((want_set && 3009 (sbi->s_mount_opt & m->mount_opt) != m->mount_opt) || 3010 (!want_set && (sbi->s_mount_opt & m->mount_opt))) 3011 continue; /* select Opt_noFoo vs Opt_Foo */ 3012 SEQ_OPTS_PRINT("%s", token2str(m->token)); --- 591 unchanged lines hidden (view full) --- 3604 ext4_msg(sb, KERN_ERR, 3605 "Couldn't mount because of " 3606 "unsupported optional features (%x)", 3607 (le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) & 3608 ~EXT4_FEATURE_INCOMPAT_SUPP)); 3609 return 0; 3610 } 3611 |
3175#ifndef CONFIG_UNICODE | 3612#if !IS_ENABLED(CONFIG_UNICODE) |
3176 if (ext4_has_feature_casefold(sb)) { 3177 ext4_msg(sb, KERN_ERR, 3178 "Filesystem with casefold feature cannot be " 3179 "mounted without CONFIG_UNICODE"); 3180 return 0; 3181 } 3182#endif 3183 --- 687 unchanged lines hidden (view full) --- 3871 size_t size)) 3872{ 3873 struct ext4_sb_info *sbi = EXT4_SB(sb); 3874 3875 sbi->s_journal_triggers[type].sb = sb; 3876 sbi->s_journal_triggers[type].tr_triggers.t_frozen = trigger; 3877} 3878 | 3613 if (ext4_has_feature_casefold(sb)) { 3614 ext4_msg(sb, KERN_ERR, 3615 "Filesystem with casefold feature cannot be " 3616 "mounted without CONFIG_UNICODE"); 3617 return 0; 3618 } 3619#endif 3620 --- 687 unchanged lines hidden (view full) --- 4308 size_t size)) 4309{ 4310 struct ext4_sb_info *sbi = EXT4_SB(sb); 4311 4312 sbi->s_journal_triggers[type].sb = sb; 4313 sbi->s_journal_triggers[type].tr_triggers.t_frozen = trigger; 4314} 4315 |
3879static int ext4_fill_super(struct super_block *sb, void *data, int silent) | 4316static void ext4_free_sbi(struct ext4_sb_info *sbi) |
3880{ | 4317{ |
3881 struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev); 3882 char *orig_data = kstrdup(data, GFP_KERNEL); | 4318 if (!sbi) 4319 return; 4320 4321 kfree(sbi->s_blockgroup_lock); 4322 fs_put_dax(sbi->s_daxdev); 4323 kfree(sbi); 4324} 4325 4326static struct ext4_sb_info *ext4_alloc_sbi(struct super_block *sb) 4327{ 4328 struct ext4_sb_info *sbi; 4329 4330 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 4331 if (!sbi) 4332 return NULL; 4333 4334 sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->s_dax_part_off); 4335 4336 sbi->s_blockgroup_lock = 4337 kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); 4338 4339 if (!sbi->s_blockgroup_lock) 4340 goto err_out; 4341 4342 sb->s_fs_info = sbi; 4343 sbi->s_sb = sb; 4344 return sbi; 4345err_out: 4346 fs_put_dax(sbi->s_daxdev); 4347 kfree(sbi); 4348 return NULL; 4349} 4350 4351static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) 4352{ |
3883 struct buffer_head *bh, **group_desc; 3884 struct ext4_super_block *es = NULL; | 4353 struct buffer_head *bh, **group_desc; 4354 struct ext4_super_block *es = NULL; |
3885 struct ext4_sb_info *sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 4355 struct ext4_sb_info *sbi = EXT4_SB(sb); |
3886 struct flex_groups **flex_groups; 3887 ext4_fsblk_t block; | 4356 struct flex_groups **flex_groups; 4357 ext4_fsblk_t block; |
3888 ext4_fsblk_t sb_block = get_sb_block(&data); | |
3889 ext4_fsblk_t logical_sb_block; 3890 unsigned long offset = 0; 3891 unsigned long def_mount_opts; 3892 struct inode *root; | 4358 ext4_fsblk_t logical_sb_block; 4359 unsigned long offset = 0; 4360 unsigned long def_mount_opts; 4361 struct inode *root; |
3893 const char *descr; | |
3894 int ret = -ENOMEM; 3895 int blocksize, clustersize; 3896 unsigned int db_count; 3897 unsigned int i; 3898 int needs_recovery, has_huge_files; 3899 __u64 blocks_count; 3900 int err = 0; 3901 ext4_group_t first_not_zeroed; | 4362 int ret = -ENOMEM; 4363 int blocksize, clustersize; 4364 unsigned int db_count; 4365 unsigned int i; 4366 int needs_recovery, has_huge_files; 4367 __u64 blocks_count; 4368 int err = 0; 4369 ext4_group_t first_not_zeroed; |
3902 struct ext4_parsed_options parsed_opts; | 4370 struct ext4_fs_context *ctx = fc->fs_private; 4371 int silent = fc->sb_flags & SB_SILENT; |
3903 3904 /* Set defaults for the variables that will be set during parsing */ | 4372 4373 /* Set defaults for the variables that will be set during parsing */ |
3905 parsed_opts.journal_ioprio = DEFAULT_JOURNAL_IOPRIO; 3906 parsed_opts.journal_devnum = 0; 3907 parsed_opts.mb_optimize_scan = DEFAULT_MB_OPTIMIZE_SCAN; | 4374 ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO; 4375 ctx->mb_optimize_scan = DEFAULT_MB_OPTIMIZE_SCAN; |
3908 | 4376 |
3909 if ((data && !orig_data) || !sbi) 3910 goto out_free_base; 3911 3912 sbi->s_daxdev = dax_dev; 3913 sbi->s_blockgroup_lock = 3914 kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); 3915 if (!sbi->s_blockgroup_lock) 3916 goto out_free_base; 3917 3918 sb->s_fs_info = sbi; 3919 sbi->s_sb = sb; | |
3920 sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; | 4377 sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; |
3921 sbi->s_sb_block = sb_block; | |
3922 sbi->s_sectors_written_start = 3923 part_stat_read(sb->s_bdev, sectors[STAT_WRITE]); 3924 | 4378 sbi->s_sectors_written_start = 4379 part_stat_read(sb->s_bdev, sectors[STAT_WRITE]); 4380 |
3925 /* Cleanup superblock name */ 3926 strreplace(sb->s_id, '/', '!'); 3927 | |
3928 /* -EINVAL is default */ 3929 ret = -EINVAL; 3930 blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); 3931 if (!blocksize) { 3932 ext4_msg(sb, KERN_ERR, "unable to set blocksize"); 3933 goto out_fail; 3934 } 3935 3936 /* 3937 * The ext4 superblock will not be buffer aligned for other than 1kB 3938 * block sizes. We need to calculate the offset from buffer start. 3939 */ 3940 if (blocksize != EXT4_MIN_BLOCK_SIZE) { | 4381 /* -EINVAL is default */ 4382 ret = -EINVAL; 4383 blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); 4384 if (!blocksize) { 4385 ext4_msg(sb, KERN_ERR, "unable to set blocksize"); 4386 goto out_fail; 4387 } 4388 4389 /* 4390 * The ext4 superblock will not be buffer aligned for other than 1kB 4391 * block sizes. We need to calculate the offset from buffer start. 4392 */ 4393 if (blocksize != EXT4_MIN_BLOCK_SIZE) { |
3941 logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE; | 4394 logical_sb_block = sbi->s_sb_block * EXT4_MIN_BLOCK_SIZE; |
3942 offset = do_div(logical_sb_block, blocksize); 3943 } else { | 4395 offset = do_div(logical_sb_block, blocksize); 4396 } else { |
3944 logical_sb_block = sb_block; | 4397 logical_sb_block = sbi->s_sb_block; |
3945 } 3946 3947 bh = ext4_sb_bread_unmovable(sb, logical_sb_block); 3948 if (IS_ERR(bh)) { 3949 ext4_msg(sb, KERN_ERR, "unable to read superblock"); 3950 ret = PTR_ERR(bh); 3951 goto out_fail; 3952 } --- 188 unchanged lines hidden (view full) --- 4141 "bad s_min_extra_isize: %d", v); 4142 goto failed_mount; 4143 } 4144 if (sbi->s_want_extra_isize < v) 4145 sbi->s_want_extra_isize = v; 4146 } 4147 } 4148 | 4398 } 4399 4400 bh = ext4_sb_bread_unmovable(sb, logical_sb_block); 4401 if (IS_ERR(bh)) { 4402 ext4_msg(sb, KERN_ERR, "unable to read superblock"); 4403 ret = PTR_ERR(bh); 4404 goto out_fail; 4405 } --- 188 unchanged lines hidden (view full) --- 4594 "bad s_min_extra_isize: %d", v); 4595 goto failed_mount; 4596 } 4597 if (sbi->s_want_extra_isize < v) 4598 sbi->s_want_extra_isize = v; 4599 } 4600 } 4601 |
4149 if (sbi->s_es->s_mount_opts[0]) { 4150 char *s_mount_opts = kstrndup(sbi->s_es->s_mount_opts, 4151 sizeof(sbi->s_es->s_mount_opts), 4152 GFP_KERNEL); 4153 if (!s_mount_opts) 4154 goto failed_mount; 4155 if (!parse_options(s_mount_opts, sb, &parsed_opts, 0)) { 4156 ext4_msg(sb, KERN_WARNING, 4157 "failed to parse options in superblock: %s", 4158 s_mount_opts); 4159 } 4160 kfree(s_mount_opts); 4161 } | 4602 err = parse_apply_sb_mount_options(sb, ctx); 4603 if (err < 0) 4604 goto failed_mount; 4605 |
4162 sbi->s_def_mount_opt = sbi->s_mount_opt; | 4606 sbi->s_def_mount_opt = sbi->s_mount_opt; |
4163 if (!parse_options((char *) data, sb, &parsed_opts, 0)) | 4607 4608 err = ext4_check_opt_consistency(fc, sb); 4609 if (err < 0) |
4164 goto failed_mount; 4165 | 4610 goto failed_mount; 4611 |
4166#ifdef CONFIG_UNICODE | 4612 err = ext4_apply_options(fc, sb); 4613 if (err < 0) 4614 goto failed_mount; 4615 4616#if IS_ENABLED(CONFIG_UNICODE) |
4167 if (ext4_has_feature_casefold(sb) && !sb->s_encoding) { 4168 const struct ext4_sb_encodings *encoding_info; 4169 struct unicode_map *encoding; | 4617 if (ext4_has_feature_casefold(sb) && !sb->s_encoding) { 4618 const struct ext4_sb_encodings *encoding_info; 4619 struct unicode_map *encoding; |
4170 __u16 encoding_flags; | 4620 __u16 encoding_flags = le16_to_cpu(es->s_encoding_flags); |
4171 | 4621 |
4172 if (ext4_sb_read_encoding(es, &encoding_info, 4173 &encoding_flags)) { | 4622 encoding_info = ext4_sb_read_encoding(es); 4623 if (!encoding_info) { |
4174 ext4_msg(sb, KERN_ERR, 4175 "Encoding requested by superblock is unknown"); 4176 goto failed_mount; 4177 } 4178 4179 encoding = utf8_load(encoding_info->version); 4180 if (IS_ERR(encoding)) { 4181 ext4_msg(sb, KERN_ERR, | 4624 ext4_msg(sb, KERN_ERR, 4625 "Encoding requested by superblock is unknown"); 4626 goto failed_mount; 4627 } 4628 4629 encoding = utf8_load(encoding_info->version); 4630 if (IS_ERR(encoding)) { 4631 ext4_msg(sb, KERN_ERR, |
4182 "can't mount with superblock charset: %s-%s " | 4632 "can't mount with superblock charset: %s-%u.%u.%u " |
4183 "not supported by the kernel. flags: 0x%x.", | 4633 "not supported by the kernel. flags: 0x%x.", |
4184 encoding_info->name, encoding_info->version, | 4634 encoding_info->name, 4635 unicode_major(encoding_info->version), 4636 unicode_minor(encoding_info->version), 4637 unicode_rev(encoding_info->version), |
4185 encoding_flags); 4186 goto failed_mount; 4187 } 4188 ext4_msg(sb, KERN_INFO,"Using encoding defined by superblock: " | 4638 encoding_flags); 4639 goto failed_mount; 4640 } 4641 ext4_msg(sb, KERN_INFO,"Using encoding defined by superblock: " |
4189 "%s-%s with flags 0x%hx", encoding_info->name, 4190 encoding_info->version?:"\b", encoding_flags); | 4642 "%s-%u.%u.%u with flags 0x%hx", encoding_info->name, 4643 unicode_major(encoding_info->version), 4644 unicode_minor(encoding_info->version), 4645 unicode_rev(encoding_info->version), 4646 encoding_flags); |
4191 4192 sb->s_encoding = encoding; 4193 sb->s_encoding_flags = encoding_flags; 4194 } 4195#endif 4196 4197 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { 4198 printk_once(KERN_WARNING "EXT4-fs: Warning: mounting with data=journal disables delayed allocation, dioread_nolock, O_DIRECT and fast_commit support!\n"); --- 95 unchanged lines hidden (view full) --- 4294 4295 if (le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) > (blocksize / 4)) { 4296 ext4_msg(sb, KERN_ERR, 4297 "Number of reserved GDT blocks insanely large: %d", 4298 le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks)); 4299 goto failed_mount; 4300 } 4301 | 4647 4648 sb->s_encoding = encoding; 4649 sb->s_encoding_flags = encoding_flags; 4650 } 4651#endif 4652 4653 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { 4654 printk_once(KERN_WARNING "EXT4-fs: Warning: mounting with data=journal disables delayed allocation, dioread_nolock, O_DIRECT and fast_commit support!\n"); --- 95 unchanged lines hidden (view full) --- 4750 4751 if (le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) > (blocksize / 4)) { 4752 ext4_msg(sb, KERN_ERR, 4753 "Number of reserved GDT blocks insanely large: %d", 4754 le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks)); 4755 goto failed_mount; 4756 } 4757 |
4302 if (dax_supported(dax_dev, sb->s_bdev, blocksize, 0, 4303 bdev_nr_sectors(sb->s_bdev))) 4304 set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags); | 4758 if (sbi->s_daxdev) { 4759 if (blocksize == PAGE_SIZE) 4760 set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags); 4761 else 4762 ext4_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n"); 4763 } |
4305 4306 if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) { 4307 if (ext4_has_feature_inline_data(sb)) { 4308 ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem" 4309 " that may contain inline data"); 4310 goto failed_mount; 4311 } 4312 if (!test_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags)) { --- 19 unchanged lines hidden (view full) --- 4332 /* Validate the filesystem blocksize */ 4333 if (!sb_set_blocksize(sb, blocksize)) { 4334 ext4_msg(sb, KERN_ERR, "bad block size %d", 4335 blocksize); 4336 bh = NULL; 4337 goto failed_mount; 4338 } 4339 | 4764 4765 if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) { 4766 if (ext4_has_feature_inline_data(sb)) { 4767 ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem" 4768 " that may contain inline data"); 4769 goto failed_mount; 4770 } 4771 if (!test_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags)) { --- 19 unchanged lines hidden (view full) --- 4791 /* Validate the filesystem blocksize */ 4792 if (!sb_set_blocksize(sb, blocksize)) { 4793 ext4_msg(sb, KERN_ERR, "bad block size %d", 4794 blocksize); 4795 bh = NULL; 4796 goto failed_mount; 4797 } 4798 |
4340 logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE; | 4799 logical_sb_block = sbi->s_sb_block * EXT4_MIN_BLOCK_SIZE; |
4341 offset = do_div(logical_sb_block, blocksize); 4342 bh = ext4_sb_bread_unmovable(sb, logical_sb_block); 4343 if (IS_ERR(bh)) { 4344 ext4_msg(sb, KERN_ERR, 4345 "Can't read superblock on 2nd try"); 4346 ret = PTR_ERR(bh); 4347 bh = NULL; 4348 goto failed_mount; --- 266 unchanged lines hidden (view full) --- 4615#endif 4616 memcpy(&sb->s_uuid, es->s_uuid, sizeof(es->s_uuid)); 4617 4618 INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ 4619 mutex_init(&sbi->s_orphan_lock); 4620 4621 /* Initialize fast commit stuff */ 4622 atomic_set(&sbi->s_fc_subtid, 0); | 4800 offset = do_div(logical_sb_block, blocksize); 4801 bh = ext4_sb_bread_unmovable(sb, logical_sb_block); 4802 if (IS_ERR(bh)) { 4803 ext4_msg(sb, KERN_ERR, 4804 "Can't read superblock on 2nd try"); 4805 ret = PTR_ERR(bh); 4806 bh = NULL; 4807 goto failed_mount; --- 266 unchanged lines hidden (view full) --- 5074#endif 5075 memcpy(&sb->s_uuid, es->s_uuid, sizeof(es->s_uuid)); 5076 5077 INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ 5078 mutex_init(&sbi->s_orphan_lock); 5079 5080 /* Initialize fast commit stuff */ 5081 atomic_set(&sbi->s_fc_subtid, 0); |
4623 atomic_set(&sbi->s_fc_ineligible_updates, 0); | |
4624 INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_MAIN]); 4625 INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_STAGING]); 4626 INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]); 4627 INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]); 4628 sbi->s_fc_bytes = 0; 4629 ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); 4630 ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING); 4631 spin_lock_init(&sbi->s_fc_lock); --- 16 unchanged lines hidden (view full) --- 4648 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block))) 4649 goto failed_mount3a; 4650 4651 /* 4652 * The first inode we look at is the journal inode. Don't try 4653 * root first: it may be modified in the journal! 4654 */ 4655 if (!test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) { | 5082 INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_MAIN]); 5083 INIT_LIST_HEAD(&sbi->s_fc_q[FC_Q_STAGING]); 5084 INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]); 5085 INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]); 5086 sbi->s_fc_bytes = 0; 5087 ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); 5088 ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING); 5089 spin_lock_init(&sbi->s_fc_lock); --- 16 unchanged lines hidden (view full) --- 5106 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block))) 5107 goto failed_mount3a; 5108 5109 /* 5110 * The first inode we look at is the journal inode. Don't try 5111 * root first: it may be modified in the journal! 5112 */ 5113 if (!test_opt(sb, NOLOAD) && ext4_has_feature_journal(sb)) { |
4656 err = ext4_load_journal(sb, es, parsed_opts.journal_devnum); | 5114 err = ext4_load_journal(sb, es, ctx->journal_devnum); |
4657 if (err) 4658 goto failed_mount3a; 4659 } else if (test_opt(sb, NOLOAD) && !sb_rdonly(sb) && 4660 ext4_has_feature_journal_needs_recovery(sb)) { 4661 ext4_msg(sb, KERN_ERR, "required journal recovery " 4662 "suppressed and not mounted read-only"); 4663 goto failed_mount_wq; 4664 } else { --- 83 unchanged lines hidden (view full) --- 4748 4749 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA && 4750 test_opt(sb, JOURNAL_ASYNC_COMMIT)) { 4751 ext4_msg(sb, KERN_ERR, "can't mount with " 4752 "journal_async_commit in data=ordered mode"); 4753 goto failed_mount_wq; 4754 } 4755 | 5115 if (err) 5116 goto failed_mount3a; 5117 } else if (test_opt(sb, NOLOAD) && !sb_rdonly(sb) && 5118 ext4_has_feature_journal_needs_recovery(sb)) { 5119 ext4_msg(sb, KERN_ERR, "required journal recovery " 5120 "suppressed and not mounted read-only"); 5121 goto failed_mount_wq; 5122 } else { --- 83 unchanged lines hidden (view full) --- 5206 5207 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA && 5208 test_opt(sb, JOURNAL_ASYNC_COMMIT)) { 5209 ext4_msg(sb, KERN_ERR, "can't mount with " 5210 "journal_async_commit in data=ordered mode"); 5211 goto failed_mount_wq; 5212 } 5213 |
4756 set_task_ioprio(sbi->s_journal->j_task, parsed_opts.journal_ioprio); | 5214 set_task_ioprio(sbi->s_journal->j_task, ctx->journal_ioprio); |
4757 4758 sbi->s_journal->j_submit_inode_data_buffers = 4759 ext4_journal_submit_inode_data_buffers; 4760 sbi->s_journal->j_finish_inode_data_buffers = 4761 ext4_journal_finish_inode_data_buffers; 4762 4763no_journal: 4764 if (!test_opt(sb, NO_MBCACHE)) { --- 95 unchanged lines hidden (view full) --- 4860 4861 ext4_ext_init(sb); 4862 4863 /* 4864 * Enable optimize_scan if number of groups is > threshold. This can be 4865 * turned off by passing "mb_optimize_scan=0". This can also be 4866 * turned on forcefully by passing "mb_optimize_scan=1". 4867 */ | 5215 5216 sbi->s_journal->j_submit_inode_data_buffers = 5217 ext4_journal_submit_inode_data_buffers; 5218 sbi->s_journal->j_finish_inode_data_buffers = 5219 ext4_journal_finish_inode_data_buffers; 5220 5221no_journal: 5222 if (!test_opt(sb, NO_MBCACHE)) { --- 95 unchanged lines hidden (view full) --- 5318 5319 ext4_ext_init(sb); 5320 5321 /* 5322 * Enable optimize_scan if number of groups is > threshold. This can be 5323 * turned off by passing "mb_optimize_scan=0". This can also be 5324 * turned on forcefully by passing "mb_optimize_scan=1". 5325 */ |
4868 if (parsed_opts.mb_optimize_scan == 1) | 5326 if (ctx->mb_optimize_scan == 1) |
4869 set_opt2(sb, MB_OPTIMIZE_SCAN); | 5327 set_opt2(sb, MB_OPTIMIZE_SCAN); |
4870 else if (parsed_opts.mb_optimize_scan == 0) | 5328 else if (ctx->mb_optimize_scan == 0) |
4871 clear_opt2(sb, MB_OPTIMIZE_SCAN); 4872 else if (sbi->s_groups_count >= MB_DEFAULT_LINEAR_SCAN_THRESHOLD) 4873 set_opt2(sb, MB_OPTIMIZE_SCAN); 4874 4875 err = ext4_mb_init(sb); 4876 if (err) { 4877 ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", 4878 err); --- 85 unchanged lines hidden (view full) --- 4964 ext4_orphan_cleanup(sb, es); 4965 EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; 4966 if (needs_recovery) { 4967 ext4_msg(sb, KERN_INFO, "recovery complete"); 4968 err = ext4_mark_recovery_complete(sb, es); 4969 if (err) 4970 goto failed_mount9; 4971 } | 5329 clear_opt2(sb, MB_OPTIMIZE_SCAN); 5330 else if (sbi->s_groups_count >= MB_DEFAULT_LINEAR_SCAN_THRESHOLD) 5331 set_opt2(sb, MB_OPTIMIZE_SCAN); 5332 5333 err = ext4_mb_init(sb); 5334 if (err) { 5335 ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", 5336 err); --- 85 unchanged lines hidden (view full) --- 5422 ext4_orphan_cleanup(sb, es); 5423 EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS; 5424 if (needs_recovery) { 5425 ext4_msg(sb, KERN_INFO, "recovery complete"); 5426 err = ext4_mark_recovery_complete(sb, es); 5427 if (err) 5428 goto failed_mount9; 5429 } |
4972 if (EXT4_SB(sb)->s_journal) { 4973 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) 4974 descr = " journalled data mode"; 4975 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) 4976 descr = " ordered data mode"; 4977 else 4978 descr = " writeback data mode"; 4979 } else 4980 descr = "out journal"; | |
4981 4982 if (test_opt(sb, DISCARD)) { 4983 struct request_queue *q = bdev_get_queue(sb->s_bdev); 4984 if (!blk_queue_discard(q)) 4985 ext4_msg(sb, KERN_WARNING, 4986 "mounting with \"discard\" option, but " 4987 "the device does not support discard"); 4988 } 4989 | 5430 5431 if (test_opt(sb, DISCARD)) { 5432 struct request_queue *q = bdev_get_queue(sb->s_bdev); 5433 if (!blk_queue_discard(q)) 5434 ext4_msg(sb, KERN_WARNING, 5435 "mounting with \"discard\" option, but " 5436 "the device does not support discard"); 5437 } 5438 |
4990 if (___ratelimit(&ext4_mount_msg_ratelimit, "EXT4-fs mount")) 4991 ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " 4992 "Opts: %.*s%s%s. Quota mode: %s.", descr, 4993 (int) sizeof(sbi->s_es->s_mount_opts), 4994 sbi->s_es->s_mount_opts, 4995 *sbi->s_es->s_mount_opts ? "; " : "", orig_data, 4996 ext4_quota_mode(sb)); 4997 | |
4998 if (es->s_error_count) 4999 mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */ 5000 5001 /* Enable message ratelimiting. Default is 10 messages per 5 secs. */ 5002 ratelimit_state_init(&sbi->s_err_ratelimit_state, 5 * HZ, 10); 5003 ratelimit_state_init(&sbi->s_warning_ratelimit_state, 5 * HZ, 10); 5004 ratelimit_state_init(&sbi->s_msg_ratelimit_state, 5 * HZ, 10); 5005 atomic_set(&sbi->s_warning_count, 0); 5006 atomic_set(&sbi->s_msg_count, 0); 5007 | 5439 if (es->s_error_count) 5440 mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */ 5441 5442 /* Enable message ratelimiting. Default is 10 messages per 5 secs. */ 5443 ratelimit_state_init(&sbi->s_err_ratelimit_state, 5 * HZ, 10); 5444 ratelimit_state_init(&sbi->s_warning_ratelimit_state, 5 * HZ, 10); 5445 ratelimit_state_init(&sbi->s_msg_ratelimit_state, 5 * HZ, 10); 5446 atomic_set(&sbi->s_warning_count, 0); 5447 atomic_set(&sbi->s_msg_count, 0); 5448 |
5008 kfree(orig_data); | |
5009 return 0; 5010 5011cantfind_ext4: 5012 if (!silent) 5013 ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem"); 5014 goto failed_mount; 5015 5016failed_mount9: --- 55 unchanged lines hidden (view full) --- 5072 for (i = 0; i < db_count; i++) 5073 brelse(group_desc[i]); 5074 kvfree(group_desc); 5075 rcu_read_unlock(); 5076failed_mount: 5077 if (sbi->s_chksum_driver) 5078 crypto_free_shash(sbi->s_chksum_driver); 5079 | 5449 return 0; 5450 5451cantfind_ext4: 5452 if (!silent) 5453 ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem"); 5454 goto failed_mount; 5455 5456failed_mount9: --- 55 unchanged lines hidden (view full) --- 5512 for (i = 0; i < db_count; i++) 5513 brelse(group_desc[i]); 5514 kvfree(group_desc); 5515 rcu_read_unlock(); 5516failed_mount: 5517 if (sbi->s_chksum_driver) 5518 crypto_free_shash(sbi->s_chksum_driver); 5519 |
5080#ifdef CONFIG_UNICODE | 5520#if IS_ENABLED(CONFIG_UNICODE) |
5081 utf8_unload(sb->s_encoding); 5082#endif 5083 5084#ifdef CONFIG_QUOTA 5085 for (i = 0; i < EXT4_MAXQUOTAS; i++) 5086 kfree(get_qf_name(sb, sbi, i)); 5087#endif 5088 fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy); 5089 /* ext4_blkdev_remove() calls kill_bdev(), release bh before it. */ 5090 brelse(bh); 5091 ext4_blkdev_remove(sbi); 5092out_fail: 5093 sb->s_fs_info = NULL; | 5521 utf8_unload(sb->s_encoding); 5522#endif 5523 5524#ifdef CONFIG_QUOTA 5525 for (i = 0; i < EXT4_MAXQUOTAS; i++) 5526 kfree(get_qf_name(sb, sbi, i)); 5527#endif 5528 fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy); 5529 /* ext4_blkdev_remove() calls kill_bdev(), release bh before it. */ 5530 brelse(bh); 5531 ext4_blkdev_remove(sbi); 5532out_fail: 5533 sb->s_fs_info = NULL; |
5094 kfree(sbi->s_blockgroup_lock); 5095out_free_base: 5096 kfree(sbi); 5097 kfree(orig_data); 5098 fs_put_dax(dax_dev); | |
5099 return err ? err : ret; 5100} 5101 | 5534 return err ? err : ret; 5535} 5536 |
5537static int ext4_fill_super(struct super_block *sb, struct fs_context *fc) 5538{ 5539 struct ext4_fs_context *ctx = fc->fs_private; 5540 struct ext4_sb_info *sbi; 5541 const char *descr; 5542 int ret; 5543 5544 sbi = ext4_alloc_sbi(sb); 5545 if (!sbi) 5546 ret = -ENOMEM; 5547 5548 fc->s_fs_info = sbi; 5549 5550 /* Cleanup superblock name */ 5551 strreplace(sb->s_id, '/', '!'); 5552 5553 sbi->s_sb_block = 1; /* Default super block location */ 5554 if (ctx->spec & EXT4_SPEC_s_sb_block) 5555 sbi->s_sb_block = ctx->s_sb_block; 5556 5557 ret = __ext4_fill_super(fc, sb); 5558 if (ret < 0) 5559 goto free_sbi; 5560 5561 if (sbi->s_journal) { 5562 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) 5563 descr = " journalled data mode"; 5564 else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) 5565 descr = " ordered data mode"; 5566 else 5567 descr = " writeback data mode"; 5568 } else 5569 descr = "out journal"; 5570 5571 if (___ratelimit(&ext4_mount_msg_ratelimit, "EXT4-fs mount")) 5572 ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " 5573 "Quota mode: %s.", descr, ext4_quota_mode(sb)); 5574 5575 return 0; 5576 5577free_sbi: 5578 ext4_free_sbi(sbi); 5579 fc->s_fs_info = NULL; 5580 return ret; 5581} 5582 5583static int ext4_get_tree(struct fs_context *fc) 5584{ 5585 return get_tree_bdev(fc, ext4_fill_super); 5586} 5587 |
|
5102/* 5103 * Setup any per-fs journal parameters now. We'll do this both on 5104 * initial mount, once the journal has been initialised but before we've 5105 * done any recovery; and again on any subsequent remount. 5106 */ 5107static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) 5108{ 5109 struct ext4_sb_info *sbi = EXT4_SB(sb); --- 612 unchanged lines hidden (view full) --- 5722 unsigned long s_commit_interval; 5723 u32 s_min_batch_time, s_max_batch_time; 5724#ifdef CONFIG_QUOTA 5725 int s_jquota_fmt; 5726 char *s_qf_names[EXT4_MAXQUOTAS]; 5727#endif 5728}; 5729 | 5588/* 5589 * Setup any per-fs journal parameters now. We'll do this both on 5590 * initial mount, once the journal has been initialised but before we've 5591 * done any recovery; and again on any subsequent remount. 5592 */ 5593static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) 5594{ 5595 struct ext4_sb_info *sbi = EXT4_SB(sb); --- 612 unchanged lines hidden (view full) --- 6208 unsigned long s_commit_interval; 6209 u32 s_min_batch_time, s_max_batch_time; 6210#ifdef CONFIG_QUOTA 6211 int s_jquota_fmt; 6212 char *s_qf_names[EXT4_MAXQUOTAS]; 6213#endif 6214}; 6215 |
5730static int ext4_remount(struct super_block *sb, int *flags, char *data) | 6216static int __ext4_remount(struct fs_context *fc, struct super_block *sb) |
5731{ | 6217{ |
6218 struct ext4_fs_context *ctx = fc->fs_private; |
|
5732 struct ext4_super_block *es; 5733 struct ext4_sb_info *sbi = EXT4_SB(sb); | 6219 struct ext4_super_block *es; 6220 struct ext4_sb_info *sbi = EXT4_SB(sb); |
5734 unsigned long old_sb_flags, vfs_flags; | 6221 unsigned long old_sb_flags; |
5735 struct ext4_mount_options old_opts; 5736 ext4_group_t g; 5737 int err = 0; 5738#ifdef CONFIG_QUOTA 5739 int enable_quota = 0; 5740 int i, j; 5741 char *to_free[EXT4_MAXQUOTAS]; 5742#endif | 6222 struct ext4_mount_options old_opts; 6223 ext4_group_t g; 6224 int err = 0; 6225#ifdef CONFIG_QUOTA 6226 int enable_quota = 0; 6227 int i, j; 6228 char *to_free[EXT4_MAXQUOTAS]; 6229#endif |
5743 char *orig_data = kstrdup(data, GFP_KERNEL); 5744 struct ext4_parsed_options parsed_opts; | |
5745 | 6230 |
5746 parsed_opts.journal_ioprio = DEFAULT_JOURNAL_IOPRIO; 5747 parsed_opts.journal_devnum = 0; | 6231 ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO; |
5748 | 6232 |
5749 if (data && !orig_data) 5750 return -ENOMEM; 5751 | |
5752 /* Store the original options */ 5753 old_sb_flags = sb->s_flags; 5754 old_opts.s_mount_opt = sbi->s_mount_opt; 5755 old_opts.s_mount_opt2 = sbi->s_mount_opt2; 5756 old_opts.s_resuid = sbi->s_resuid; 5757 old_opts.s_resgid = sbi->s_resgid; 5758 old_opts.s_commit_interval = sbi->s_commit_interval; 5759 old_opts.s_min_batch_time = sbi->s_min_batch_time; 5760 old_opts.s_max_batch_time = sbi->s_max_batch_time; 5761#ifdef CONFIG_QUOTA 5762 old_opts.s_jquota_fmt = sbi->s_jquota_fmt; 5763 for (i = 0; i < EXT4_MAXQUOTAS; i++) 5764 if (sbi->s_qf_names[i]) { 5765 char *qf_name = get_qf_name(sb, sbi, i); 5766 5767 old_opts.s_qf_names[i] = kstrdup(qf_name, GFP_KERNEL); 5768 if (!old_opts.s_qf_names[i]) { 5769 for (j = 0; j < i; j++) 5770 kfree(old_opts.s_qf_names[j]); | 6233 /* Store the original options */ 6234 old_sb_flags = sb->s_flags; 6235 old_opts.s_mount_opt = sbi->s_mount_opt; 6236 old_opts.s_mount_opt2 = sbi->s_mount_opt2; 6237 old_opts.s_resuid = sbi->s_resuid; 6238 old_opts.s_resgid = sbi->s_resgid; 6239 old_opts.s_commit_interval = sbi->s_commit_interval; 6240 old_opts.s_min_batch_time = sbi->s_min_batch_time; 6241 old_opts.s_max_batch_time = sbi->s_max_batch_time; 6242#ifdef CONFIG_QUOTA 6243 old_opts.s_jquota_fmt = sbi->s_jquota_fmt; 6244 for (i = 0; i < EXT4_MAXQUOTAS; i++) 6245 if (sbi->s_qf_names[i]) { 6246 char *qf_name = get_qf_name(sb, sbi, i); 6247 6248 old_opts.s_qf_names[i] = kstrdup(qf_name, GFP_KERNEL); 6249 if (!old_opts.s_qf_names[i]) { 6250 for (j = 0; j < i; j++) 6251 kfree(old_opts.s_qf_names[j]); |
5771 kfree(orig_data); | |
5772 return -ENOMEM; 5773 } 5774 } else 5775 old_opts.s_qf_names[i] = NULL; 5776#endif 5777 if (sbi->s_journal && sbi->s_journal->j_task->io_context) | 6252 return -ENOMEM; 6253 } 6254 } else 6255 old_opts.s_qf_names[i] = NULL; 6256#endif 6257 if (sbi->s_journal && sbi->s_journal->j_task->io_context) |
5778 parsed_opts.journal_ioprio = | 6258 ctx->journal_ioprio = |
5779 sbi->s_journal->j_task->io_context->ioprio; 5780 | 6259 sbi->s_journal->j_task->io_context->ioprio; 6260 |
5781 /* 5782 * Some options can be enabled by ext4 and/or by VFS mount flag 5783 * either way we need to make sure it matches in both *flags and 5784 * s_flags. Copy those selected flags from *flags to s_flags 5785 */ 5786 vfs_flags = SB_LAZYTIME | SB_I_VERSION; 5787 sb->s_flags = (sb->s_flags & ~vfs_flags) | (*flags & vfs_flags); | 6261 ext4_apply_options(fc, sb); |
5788 | 6262 |
5789 if (!parse_options(data, sb, &parsed_opts, 1)) { 5790 err = -EINVAL; 5791 goto restore_opts; 5792 } 5793 | |
5794 if ((old_opts.s_mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) ^ 5795 test_opt(sb, JOURNAL_CHECKSUM)) { 5796 ext4_msg(sb, KERN_ERR, "changing journal_checksum " 5797 "during remount not supported; ignoring"); 5798 sbi->s_mount_opt ^= EXT4_MOUNT_JOURNAL_CHECKSUM; 5799 } 5800 5801 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { --- 29 unchanged lines hidden (view full) --- 5831 5832 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | 5833 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); 5834 5835 es = sbi->s_es; 5836 5837 if (sbi->s_journal) { 5838 ext4_init_journal_params(sb, sbi->s_journal); | 6263 if ((old_opts.s_mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) ^ 6264 test_opt(sb, JOURNAL_CHECKSUM)) { 6265 ext4_msg(sb, KERN_ERR, "changing journal_checksum " 6266 "during remount not supported; ignoring"); 6267 sbi->s_mount_opt ^= EXT4_MOUNT_JOURNAL_CHECKSUM; 6268 } 6269 6270 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { --- 29 unchanged lines hidden (view full) --- 6300 6301 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | 6302 (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); 6303 6304 es = sbi->s_es; 6305 6306 if (sbi->s_journal) { 6307 ext4_init_journal_params(sb, sbi->s_journal); |
5839 set_task_ioprio(sbi->s_journal->j_task, parsed_opts.journal_ioprio); | 6308 set_task_ioprio(sbi->s_journal->j_task, ctx->journal_ioprio); |
5840 } 5841 5842 /* Flush outstanding errors before changing fs state */ 5843 flush_work(&sbi->s_error_work); 5844 | 6309 } 6310 6311 /* Flush outstanding errors before changing fs state */ 6312 flush_work(&sbi->s_error_work); 6313 |
5845 if ((bool)(*flags & SB_RDONLY) != sb_rdonly(sb)) { | 6314 if ((bool)(fc->sb_flags & SB_RDONLY) != sb_rdonly(sb)) { |
5846 if (ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED)) { 5847 err = -EROFS; 5848 goto restore_opts; 5849 } 5850 | 6315 if (ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED)) { 6316 err = -EROFS; 6317 goto restore_opts; 6318 } 6319 |
5851 if (*flags & SB_RDONLY) { | 6320 if (fc->sb_flags & SB_RDONLY) { |
5852 err = sync_filesystem(sb); 5853 if (err < 0) 5854 goto restore_opts; 5855 err = dquot_suspend(sb, -1); 5856 if (err < 0) 5857 goto restore_opts; 5858 5859 /* --- 131 unchanged lines hidden (view full) --- 5991 } 5992#endif 5993 if (!test_opt(sb, BLOCK_VALIDITY) && sbi->s_system_blks) 5994 ext4_release_system_zone(sb); 5995 5996 if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb)) 5997 ext4_stop_mmpd(sbi); 5998 | 6321 err = sync_filesystem(sb); 6322 if (err < 0) 6323 goto restore_opts; 6324 err = dquot_suspend(sb, -1); 6325 if (err < 0) 6326 goto restore_opts; 6327 6328 /* --- 131 unchanged lines hidden (view full) --- 6460 } 6461#endif 6462 if (!test_opt(sb, BLOCK_VALIDITY) && sbi->s_system_blks) 6463 ext4_release_system_zone(sb); 6464 6465 if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb)) 6466 ext4_stop_mmpd(sbi); 6467 |
5999 /* 6000 * Some options can be enabled by ext4 and/or by VFS mount flag 6001 * either way we need to make sure it matches in both *flags and 6002 * s_flags. Copy those selected flags from s_flags to *flags 6003 */ 6004 *flags = (*flags & ~vfs_flags) | (sb->s_flags & vfs_flags); 6005 6006 ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s. Quota mode: %s.", 6007 orig_data, ext4_quota_mode(sb)); 6008 kfree(orig_data); | |
6009 return 0; 6010 6011restore_opts: 6012 sb->s_flags = old_sb_flags; 6013 sbi->s_mount_opt = old_opts.s_mount_opt; 6014 sbi->s_mount_opt2 = old_opts.s_mount_opt2; 6015 sbi->s_resuid = old_opts.s_resuid; 6016 sbi->s_resgid = old_opts.s_resgid; --- 9 unchanged lines hidden (view full) --- 6026 rcu_assign_pointer(sbi->s_qf_names[i], old_opts.s_qf_names[i]); 6027 } 6028 synchronize_rcu(); 6029 for (i = 0; i < EXT4_MAXQUOTAS; i++) 6030 kfree(to_free[i]); 6031#endif 6032 if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb)) 6033 ext4_stop_mmpd(sbi); | 6468 return 0; 6469 6470restore_opts: 6471 sb->s_flags = old_sb_flags; 6472 sbi->s_mount_opt = old_opts.s_mount_opt; 6473 sbi->s_mount_opt2 = old_opts.s_mount_opt2; 6474 sbi->s_resuid = old_opts.s_resuid; 6475 sbi->s_resgid = old_opts.s_resgid; --- 9 unchanged lines hidden (view full) --- 6485 rcu_assign_pointer(sbi->s_qf_names[i], old_opts.s_qf_names[i]); 6486 } 6487 synchronize_rcu(); 6488 for (i = 0; i < EXT4_MAXQUOTAS; i++) 6489 kfree(to_free[i]); 6490#endif 6491 if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb)) 6492 ext4_stop_mmpd(sbi); |
6034 kfree(orig_data); | |
6035 return err; 6036} 6037 | 6493 return err; 6494} 6495 |
6496static int ext4_reconfigure(struct fs_context *fc) 6497{ 6498 struct super_block *sb = fc->root->d_sb; 6499 int ret; 6500 6501 fc->s_fs_info = EXT4_SB(sb); 6502 6503 ret = ext4_check_opt_consistency(fc, sb); 6504 if (ret < 0) 6505 return ret; 6506 6507 ret = __ext4_remount(fc, sb); 6508 if (ret < 0) 6509 return ret; 6510 6511 ext4_msg(sb, KERN_INFO, "re-mounted. Quota mode: %s.", 6512 ext4_quota_mode(sb)); 6513 6514 return 0; 6515} 6516 |
|
6038#ifdef CONFIG_QUOTA 6039static int ext4_statfs_project(struct super_block *sb, 6040 kprojid_t projid, struct kstatfs *buf) 6041{ 6042 struct kqid qid; 6043 struct dquot *dquot; 6044 u64 limit; 6045 u64 curblock; --- 224 unchanged lines hidden (view full) --- 6270 err = jbd2_journal_flush(EXT4_SB(sb)->s_journal, 0); 6271 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); 6272 if (err) 6273 return err; 6274 } 6275 6276 lockdep_set_quota_inode(path->dentry->d_inode, I_DATA_SEM_QUOTA); 6277 err = dquot_quota_on(sb, type, format_id, path); | 6517#ifdef CONFIG_QUOTA 6518static int ext4_statfs_project(struct super_block *sb, 6519 kprojid_t projid, struct kstatfs *buf) 6520{ 6521 struct kqid qid; 6522 struct dquot *dquot; 6523 u64 limit; 6524 u64 curblock; --- 224 unchanged lines hidden (view full) --- 6749 err = jbd2_journal_flush(EXT4_SB(sb)->s_journal, 0); 6750 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); 6751 if (err) 6752 return err; 6753 } 6754 6755 lockdep_set_quota_inode(path->dentry->d_inode, I_DATA_SEM_QUOTA); 6756 err = dquot_quota_on(sb, type, format_id, path); |
6278 if (err) { 6279 lockdep_set_quota_inode(path->dentry->d_inode, 6280 I_DATA_SEM_NORMAL); 6281 } else { | 6757 if (!err) { |
6282 struct inode *inode = d_inode(path->dentry); 6283 handle_t *handle; 6284 6285 /* 6286 * Set inode flags to prevent userspace from messing with quota 6287 * files. If this fails, we return success anyway since quotas 6288 * are already enabled and this is not a hard failure. 6289 */ 6290 inode_lock(inode); 6291 handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1); 6292 if (IS_ERR(handle)) 6293 goto unlock_inode; 6294 EXT4_I(inode)->i_flags |= EXT4_NOATIME_FL | EXT4_IMMUTABLE_FL; 6295 inode_set_flags(inode, S_NOATIME | S_IMMUTABLE, 6296 S_NOATIME | S_IMMUTABLE); 6297 err = ext4_mark_inode_dirty(handle, inode); 6298 ext4_journal_stop(handle); 6299 unlock_inode: 6300 inode_unlock(inode); | 6758 struct inode *inode = d_inode(path->dentry); 6759 handle_t *handle; 6760 6761 /* 6762 * Set inode flags to prevent userspace from messing with quota 6763 * files. If this fails, we return success anyway since quotas 6764 * are already enabled and this is not a hard failure. 6765 */ 6766 inode_lock(inode); 6767 handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1); 6768 if (IS_ERR(handle)) 6769 goto unlock_inode; 6770 EXT4_I(inode)->i_flags |= EXT4_NOATIME_FL | EXT4_IMMUTABLE_FL; 6771 inode_set_flags(inode, S_NOATIME | S_IMMUTABLE, 6772 S_NOATIME | S_IMMUTABLE); 6773 err = ext4_mark_inode_dirty(handle, inode); 6774 ext4_journal_stop(handle); 6775 unlock_inode: 6776 inode_unlock(inode); |
6777 if (err) 6778 dquot_quota_off(sb, type); |
|
6301 } | 6779 } |
6780 if (err) 6781 lockdep_set_quota_inode(path->dentry->d_inode, 6782 I_DATA_SEM_NORMAL); |
|
6302 return err; 6303} 6304 6305static int ext4_quota_enable(struct super_block *sb, int type, int format_id, 6306 unsigned int flags) 6307{ 6308 int err; 6309 struct inode *qf_inode; --- 46 unchanged lines hidden (view full) --- 6356 err = ext4_quota_enable(sb, type, QFMT_VFS_V1, 6357 DQUOT_USAGE_ENABLED | 6358 (quota_mopt[type] ? DQUOT_LIMITS_ENABLED : 0)); 6359 if (err) { 6360 ext4_warning(sb, 6361 "Failed to enable quota tracking " 6362 "(type=%d, err=%d). Please run " 6363 "e2fsck to fix.", type, err); | 6783 return err; 6784} 6785 6786static int ext4_quota_enable(struct super_block *sb, int type, int format_id, 6787 unsigned int flags) 6788{ 6789 int err; 6790 struct inode *qf_inode; --- 46 unchanged lines hidden (view full) --- 6837 err = ext4_quota_enable(sb, type, QFMT_VFS_V1, 6838 DQUOT_USAGE_ENABLED | 6839 (quota_mopt[type] ? DQUOT_LIMITS_ENABLED : 0)); 6840 if (err) { 6841 ext4_warning(sb, 6842 "Failed to enable quota tracking " 6843 "(type=%d, err=%d). Please run " 6844 "e2fsck to fix.", type, err); |
6364 for (type--; type >= 0; type--) | 6845 for (type--; type >= 0; type--) { 6846 struct inode *inode; 6847 6848 inode = sb_dqopt(sb)->files[type]; 6849 if (inode) 6850 inode = igrab(inode); |
6365 dquot_quota_off(sb, type); | 6851 dquot_quota_off(sb, type); |
6852 if (inode) { 6853 lockdep_set_quota_inode(inode, 6854 I_DATA_SEM_NORMAL); 6855 iput(inode); 6856 } 6857 } |
|
6366 6367 return err; 6368 } 6369 } 6370 } 6371 return 0; 6372} 6373 --- 87 unchanged lines hidden (view full) --- 6461{ 6462 struct inode *inode = sb_dqopt(sb)->files[type]; 6463 ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); 6464 int err = 0, err2 = 0, offset = off & (sb->s_blocksize - 1); 6465 int retries = 0; 6466 struct buffer_head *bh; 6467 handle_t *handle = journal_current_handle(); 6468 | 6858 6859 return err; 6860 } 6861 } 6862 } 6863 return 0; 6864} 6865 --- 87 unchanged lines hidden (view full) --- 6953{ 6954 struct inode *inode = sb_dqopt(sb)->files[type]; 6955 ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); 6956 int err = 0, err2 = 0, offset = off & (sb->s_blocksize - 1); 6957 int retries = 0; 6958 struct buffer_head *bh; 6959 handle_t *handle = journal_current_handle(); 6960 |
6469 if (EXT4_SB(sb)->s_journal && !handle) { | 6961 if (!handle) { |
6470 ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" 6471 " cancelled because transaction is not started", 6472 (unsigned long long)off, (unsigned long long)len); 6473 return -EIO; 6474 } 6475 /* 6476 * Since we account only one data block in transaction credits, 6477 * then it is impossible to cross a block boundary. --- 34 unchanged lines hidden (view full) --- 6512 err2 = ext4_mark_inode_dirty(handle, inode); 6513 if (unlikely(err2 && !err)) 6514 err = err2; 6515 } 6516 return err ? err : len; 6517} 6518#endif 6519 | 6962 ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" 6963 " cancelled because transaction is not started", 6964 (unsigned long long)off, (unsigned long long)len); 6965 return -EIO; 6966 } 6967 /* 6968 * Since we account only one data block in transaction credits, 6969 * then it is impossible to cross a block boundary. --- 34 unchanged lines hidden (view full) --- 7004 err2 = ext4_mark_inode_dirty(handle, inode); 7005 if (unlikely(err2 && !err)) 7006 err = err2; 7007 } 7008 return err ? err : len; 7009} 7010#endif 7011 |
6520static struct dentry *ext4_mount(struct file_system_type *fs_type, int flags, 6521 const char *dev_name, void *data) 6522{ 6523 return mount_bdev(fs_type, flags, dev_name, data, ext4_fill_super); 6524} 6525 | |
6526#if !defined(CONFIG_EXT2_FS) && !defined(CONFIG_EXT2_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT2) 6527static inline void register_as_ext2(void) 6528{ 6529 int err = register_filesystem(&ext2_fs_type); 6530 if (err) 6531 printk(KERN_WARNING 6532 "EXT4-fs: Unable to register as ext2 (%d)\n", err); 6533} --- 41 unchanged lines hidden (view full) --- 6575 if (sb_rdonly(sb)) 6576 return 1; 6577 if (ext4_has_unknown_ext3_ro_compat_features(sb)) 6578 return 0; 6579 return 1; 6580} 6581 6582static struct file_system_type ext4_fs_type = { | 7012#if !defined(CONFIG_EXT2_FS) && !defined(CONFIG_EXT2_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT2) 7013static inline void register_as_ext2(void) 7014{ 7015 int err = register_filesystem(&ext2_fs_type); 7016 if (err) 7017 printk(KERN_WARNING 7018 "EXT4-fs: Unable to register as ext2 (%d)\n", err); 7019} --- 41 unchanged lines hidden (view full) --- 7061 if (sb_rdonly(sb)) 7062 return 1; 7063 if (ext4_has_unknown_ext3_ro_compat_features(sb)) 7064 return 0; 7065 return 1; 7066} 7067 7068static struct file_system_type ext4_fs_type = { |
6583 .owner = THIS_MODULE, 6584 .name = "ext4", 6585 .mount = ext4_mount, 6586 .kill_sb = kill_block_super, 6587 .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, | 7069 .owner = THIS_MODULE, 7070 .name = "ext4", 7071 .init_fs_context = ext4_init_fs_context, 7072 .parameters = ext4_param_specs, 7073 .kill_sb = kill_block_super, 7074 .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, |
6588}; 6589MODULE_ALIAS_FS("ext4"); 6590 6591/* Shared across all ext4 file systems */ 6592wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ]; 6593 6594static int __init ext4_init_fs(void) 6595{ --- 48 unchanged lines hidden (view full) --- 6644 err = register_filesystem(&ext4_fs_type); 6645 if (err) 6646 goto out; 6647 6648 return 0; 6649out: 6650 unregister_as_ext2(); 6651 unregister_as_ext3(); | 7075}; 7076MODULE_ALIAS_FS("ext4"); 7077 7078/* Shared across all ext4 file systems */ 7079wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ]; 7080 7081static int __init ext4_init_fs(void) 7082{ --- 48 unchanged lines hidden (view full) --- 7131 err = register_filesystem(&ext4_fs_type); 7132 if (err) 7133 goto out; 7134 7135 return 0; 7136out: 7137 unregister_as_ext2(); 7138 unregister_as_ext3(); |
7139 ext4_fc_destroy_dentry_cache(); |
|
6652out05: 6653 destroy_inodecache(); 6654out1: 6655 ext4_exit_mballoc(); 6656out2: 6657 ext4_exit_sysfs(); 6658out3: 6659 ext4_exit_system_zone(); --- 10 unchanged lines hidden (view full) --- 6670} 6671 6672static void __exit ext4_exit_fs(void) 6673{ 6674 ext4_destroy_lazyinit_thread(); 6675 unregister_as_ext2(); 6676 unregister_as_ext3(); 6677 unregister_filesystem(&ext4_fs_type); | 7140out05: 7141 destroy_inodecache(); 7142out1: 7143 ext4_exit_mballoc(); 7144out2: 7145 ext4_exit_sysfs(); 7146out3: 7147 ext4_exit_system_zone(); --- 10 unchanged lines hidden (view full) --- 7158} 7159 7160static void __exit ext4_exit_fs(void) 7161{ 7162 ext4_destroy_lazyinit_thread(); 7163 unregister_as_ext2(); 7164 unregister_as_ext3(); 7165 unregister_filesystem(&ext4_fs_type); |
7166 ext4_fc_destroy_dentry_cache(); |
|
6678 destroy_inodecache(); 6679 ext4_exit_mballoc(); 6680 ext4_exit_sysfs(); 6681 ext4_exit_system_zone(); 6682 ext4_exit_pageio(); 6683 ext4_exit_post_read_processing(); 6684 ext4_exit_es(); 6685 ext4_exit_pending(); 6686} 6687 6688MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); 6689MODULE_DESCRIPTION("Fourth Extended Filesystem"); 6690MODULE_LICENSE("GPL"); 6691MODULE_SOFTDEP("pre: crc32c"); 6692module_init(ext4_init_fs) 6693module_exit(ext4_exit_fs) | 7167 destroy_inodecache(); 7168 ext4_exit_mballoc(); 7169 ext4_exit_sysfs(); 7170 ext4_exit_system_zone(); 7171 ext4_exit_pageio(); 7172 ext4_exit_post_read_processing(); 7173 ext4_exit_es(); 7174 ext4_exit_pending(); 7175} 7176 7177MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); 7178MODULE_DESCRIPTION("Fourth Extended Filesystem"); 7179MODULE_LICENSE("GPL"); 7180MODULE_SOFTDEP("pre: crc32c"); 7181module_init(ext4_init_fs) 7182module_exit(ext4_exit_fs) |