fs: generic filesystem shutdown handling
Subsystems (32)
Jan Kara
maintainercover fs: generic filesystem shutdown handling
Hello,
this patch series implements generic handling of filesystem shutdown. The idea is very simple: Have a superblock flag, which when set, will make VFS refuse modifications to the filesystem. The patch series consists of several parts. Patches 1-6 cleanup handling of SB_I_ flags which is currently messy (different flags seem to have different locks protecting them although they are modified by plain stores). Patches 7-12 gradually convert code to be able to handle errors from sb_start_write() / sb_start_pagefault(). Patch 13 then shows how filesystems can use this generic flag. Additionally, we could remove some shutdown checks from within ext4 code and rely on checks in VFS but I didn't want to complicate the series with ext4 specific things.
Also, as Dave suggested, we can lift *_IOC_{SHUTDOWN|GOINGDOWN} ioctl handling to VFS (currently in 5 filesystems) and just call new ->shutdown op for the filesystem abort handling itself. But that is kind of independent thing and this series is long enough as is.
So what do people think?
Honza
Jan Kara
maintainerPATCH 1/13 fs: Define bit numbers for SB_I_ flags
sb->s_iflags has unclear locking rules. Some users modify it under sb_lock, some under sb->s_umount rwsem, some without any lock. Readers are generally not holding any locks either. The flags are rarely modified so this does not lead to any practical problems but it is a mess. To reconcile the situation, handle sb->i_flags without any locks by using atomic bit operations. Since the flags are rarely modified, this does not introduce any noticeable performance overhead and resolves all possible issues when different users of sb->s_iflags could possibly stomp on each other's toes. Define new constants using bit numbers and functions to tests, set and clear the flags.
--- include/linux/fs.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
include/linux/fs.h +34 -0
@@ -1190,6 +1190,25 @@ extern int send_sigurg(struct fown_struct *fown);#define SB_I_RETIRED 0x00000800/* superblock shouldn't be reused */ #define SB_I_NOUMASK 0x00001000/* VFS does not apply umask */ +enum { + _SB_I_CGROUPWB,/* cgroup-aware writeback enabled */ + _SB_I_NOEXEC,/* Ignore executables on this fs */ + _SB_I_NODEV,/* Ignore devices on this fs */ + _SB_I_STABLE_WRITES,/* don't modify blks until WB is done */ + +/* sb->s_iflags to limit user namespace mounts */ + _SB_I_USERNS_VISIBLE,/* fstype already mounted */ + _SB_I_IMA_UNVERIFIABLE_SIGNATURE, + _SB_I_UNTRUSTED_MOUNTER, + _SB_I_EVM_HMAC_UNSUPPORTED, + + _SB_I_SKIP_SYNC,/* Skip superblock at global sync */ + _SB_I_PERSB_BDI,/* has a per-sb bdi */ + _SB_I_TS_EXPIRY_WARNED,/* warned about timestamp range expiry */ + _SB_I_RETIRED,/* superblock shouldn't be reused */ + _SB_I_NOUMASK,/* VFS does not apply umask */ +}; +/* Possible states of 'frozen' field */ enum {SB_UNFROZEN =0 ,/* FS is unfrozen */
@@ -1351,6 +1370,21 @@ struct super_block {struct list_head s_inodes_wb;/* writeback inodes */ } __randomize_layout; +static inline bool sb_test_iflag (const struct super_block *sb,int flag) +{ +return test_bit (flag, &sb->s_iflags); +} + +static inline void sb_set_iflag (struct super_block *sb,int flag) +{ +set_bit (flag, &sb->s_iflags); +} + +static inline void sb_clear_iflag (struct super_block *sb,int flag) +{ +clear_bit (flag, &sb->s_iflags); +} +static inline struct user_namespace *i_user_ns (const struct inode *inode) {return inode->i_sb->s_user_ns;
Signature · 1 line
2.35.3
Jan Kara
maintainerPATCH 2/13 fs: Convert fs_context use of SB_I_ flags to new constants
In reply to Jan KaraConvert uses of SB_I_ constants in fc->s_iflags to the new bit constants. No functional changes.
--- block/bdev.c | 2 +- fs/aio.c | 2 +- fs/nfs/fs_context.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
block/bdev.c +1 -1
@@ -373,7 +373,7 @@ static int bd_init_fs_context(struct fs_context *fc)struct pseudo_fs_context *ctx =init_pseudo (fc,BDEVFS_MAGIC );if (!ctx)return -ENOMEM ; - fc->s_iflags |=SB_I_CGROUPWB ; + fc->s_iflags |=1 << _SB_I_CGROUPWB; ctx->ops = &bdev_sops;return 0 ; }
fs/aio.c +1 -1
@@ -279,7 +279,7 @@ static int aio_init_fs_context(struct fs_context *fc) {if (!init_pseudo (fc,AIO_RING_MAGIC ))return -ENOMEM ; - fc->s_iflags |=SB_I_NOEXEC ; + fc->s_iflags |=1 << _SB_I_NOEXEC;return 0 ; }
fs/nfs/fs_context.c +1 -1
@@ -1643,7 +1643,7 @@ static int nfs_init_fs_context(struct fs_context *fc) ctx->xprtsec.cert_serial =TLS_NO_CERT ; ctx->xprtsec.privkey_serial =TLS_NO_PRIVKEY ; - fc->s_iflags |=SB_I_STABLE_WRITES ; + fc->s_iflags |=1 << _SB_I_STABLE_WRITES; } fc->fs_private = ctx; fc->ops = &nfs_fs_context_ops;
Signature · 1 line
2.35.3
Jan Kara
maintainerPATCH 3/13 fs: Convert mount_too_revealing() to new s_iflags handling functions
In reply to Jan KaraConvert mount_too_revealing() to use the new functions for handling sb->s_iflags and new bit constants.
--- fs/namespace.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
fs/namespace.c +4 -7
@@ -5623,21 +5623,18 @@ static bool mnt_already_visible(struct mnt_namespace *ns,static bool mount_too_revealing (const struct super_block *sb,int *new_mnt_flags) { -const unsigned long required_iflags =SB_I_NOEXEC |SB_I_NODEV ;struct mnt_namespace *ns = current->nsproxy->mnt_ns; -unsigned long s_iflags;if (ns->user_ns == &init_user_ns)return false;/* Can this filesystem be too revealing? */ - s_iflags = sb->s_iflags; -if (!(s_iflags &SB_I_USERNS_VISIBLE )) +if (!sb_test_iflag (sb, _SB_I_USERNS_VISIBLE))return false; -if ((s_iflags & required_iflags) != required_iflags) { -WARN_ONCE (1 ,"Expected s_iflags to contain 0x%lx\n" , - required_iflags); +if (!sb_test_iflag (sb, _SB_I_NOEXEC) || !sb_test_iflag (sb, _SB_I_NODEV)) { +WARN_ONCE (1 ,"Expected s_iflags to contain SB_I_NOEXEC and " +"SB_I_NODEV\n" );return true; }
Signature · 1 line
2.35.3
Jan Kara
maintainerPATCH 4/13 fs: Convert remaining usage of SB_I_ flags
In reply to Jan KaraConvert remaining handling of sb->s_iflags to use the new helper functions and new bit constants. The patch was generated using coccinelle with a few manual fixups to improve code style.
--- drivers/android/binderfs.c | 4 ++-- fs/btrfs/super.c | 2 +- fs/devpts/inode.c | 2 +- fs/exec.c | 2 +- fs/ext2/super.c | 2 +- fs/ext4/super.c | 2 +- fs/f2fs/super.c | 2 +- fs/fuse/inode.c | 4 ++-- fs/inode.c | 2 +- fs/kernfs/mount.c | 3 ++- fs/namei.c | 2 +- fs/namespace.c | 4 ++-- fs/nfs/super.c | 2 +- fs/overlayfs/super.c | 6 +++--- fs/proc/root.c | 4 +++- fs/super.c | 18 +++++++++--------- fs/sync.c | 2 +- fs/sysfs/mount.c | 2 +- fs/xfs/xfs_super.c | 2 +- include/linux/backing-dev.h | 2 +- include/linux/namei.h | 2 +- ipc/mqueue.c | 3 ++- security/integrity/evm/evm_main.c | 2 +- security/integrity/ima/ima_appraise.c | 4 ++-- security/integrity/ima/ima_main.c | 4 ++-- 25 files changed, 44 insertions(+), 40 deletions(-)
drivers/android/binderfs.c +2 -2
@@ -672,8 +672,8 @@ static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc)* allowed to do. So removing the SB_I_NODEV flag from s_iflags is both * necessary and safe. */ - sb->s_iflags &= ~SB_I_NODEV ; - sb->s_iflags |=SB_I_NOEXEC ; +sb_clear_iflag (sb, _SB_I_NODEV); +sb_set_iflag (sb, _SB_I_NOEXEC); sb->s_magic =BINDERFS_SUPER_MAGIC ; sb->s_op = &binderfs_super_ops; sb->s_time_gran =1 ;
fs/btrfs/super.c +1 -1
@@ -950,7 +950,7 @@ static int btrfs_fill_super(struct super_block *sb,#endif sb->s_xattr = btrfs_xattr_handlers; sb->s_time_gran =1 ; - sb->s_iflags |=SB_I_CGROUPWB ; +sb_set_iflag (sb, _SB_I_CGROUPWB); err =super_setup_bdi (sb);if (err) {
fs/devpts/inode.c +1 -1
@@ -428,7 +428,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent)struct inode *inode;int error; - s->s_iflags &= ~SB_I_NODEV ; +sb_clear_iflag (s, _SB_I_NODEV); s->s_blocksize =1024 ; s->s_blocksize_bits =10 ; s->s_magic =DEVPTS_SUPER_MAGIC ;
fs/exec.c +1 -1
@@ -112,7 +112,7 @@ static inline void put_binfmt(struct linux_binfmt * fmt)bool path_noexec (const struct path *path) {return (path->mnt->mnt_flags &MNT_NOEXEC ) || - (path->mnt->mnt_sb->s_iflags &SB_I_NOEXEC ); +sb_test_iflag (path->mnt->mnt_sb, _SB_I_NOEXEC); }#ifdef CONFIG_USELIB
fs/ext2/super.c +1 -1
@@ -916,7 +916,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) sb->s_flags = (sb->s_flags & ~SB_POSIXACL ) | (test_opt (sb,POSIX_ACL ) ?SB_POSIXACL :0 ); - sb->s_iflags |=SB_I_CGROUPWB ; +sb_set_iflag (sb, _SB_I_CGROUPWB); if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV && (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
fs/ext4/super.c +1 -1
@@ -4972,7 +4972,7 @@ static int ext4_check_journal_data_mode(struct super_block *sb)if (test_opt (sb,DELALLOC ))clear_opt (sb,DELALLOC ); }else { - sb->s_iflags |=SB_I_CGROUPWB ; +sb_set_iflag (sb, _SB_I_CGROUPWB); }return 0 ;
fs/f2fs/super.c +1 -1
@@ -4472,7 +4472,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) (test_opt (sbi,POSIX_ACL ) ?SB_POSIXACL :0 );super_set_uuid (sb, (void *) raw_super->uuid,sizeof (raw_super->uuid));super_set_sysfs_name_bdev (sb); - sb->s_iflags |=SB_I_CGROUPWB ; +sb_set_iflag (sb, _SB_I_CGROUPWB);/* init f2fs-specific super block info */ sbi->valid_super_block = valid_super_block;
fs/fuse/inode.c +2 -2
@@ -1566,9 +1566,9 @@ static void fuse_sb_defaults(struct super_block *sb) sb->s_maxbytes =MAX_LFS_FILESIZE ; sb->s_time_gran =1 ; sb->s_export_op = &fuse_export_operations; - sb->s_iflags |=SB_I_IMA_UNVERIFIABLE_SIGNATURE ; +sb_set_iflag (sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE);if (sb->s_user_ns != &init_user_ns) - sb->s_iflags |=SB_I_UNTRUSTED_MOUNTER ; +sb_set_iflag (sb, _SB_I_UNTRUSTED_MOUNTER); sb->s_flags &= ~(SB_NOSEC |SB_I_VERSION ); }
fs/inode.c +1 -1
@@ -216,7 +216,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)lockdep_set_class_and_name (&mapping->invalidate_lock, &sb->s_type->invalidate_lock_key,"mapping.invalidate_lock" ); -if (sb->s_iflags &SB_I_STABLE_WRITES ) +if (sb_test_iflag (sb, _SB_I_STABLE_WRITES))mapping_set_stable_writes (mapping); inode->i_private =NULL ; inode->i_mapping = mapping;
fs/kernfs/mount.c +2 -1
@@ -252,7 +252,8 @@ static int kernfs_fill_super(struct super_block *sb, struct kernfs_fs_context *k info->sb = sb;/* Userspace would break if executables or devices appear on sysfs */ - sb->s_iflags |=SB_I_NOEXEC |SB_I_NODEV ; +sb_set_iflag (sb, _SB_I_NOEXEC); +sb_set_iflag (sb, _SB_I_NODEV); sb->s_blocksize =PAGE_SIZE ; sb->s_blocksize_bits =PAGE_SHIFT ; sb->s_magic = kfc->magic;
fs/namei.c +1 -1
@@ -3308,7 +3308,7 @@ EXPORT_SYMBOL(vfs_mkobj);bool may_open_dev (const struct path *path) {return !(path->mnt->mnt_flags &MNT_NODEV ) && - !(path->mnt->mnt_sb->s_iflags &SB_I_NODEV ); + !sb_test_iflag (path->mnt->mnt_sb, _SB_I_NODEV); } static int may_open(struct mnt_idmap *idmap, const struct path *path,
fs/namespace.c +2 -2
@@ -2919,7 +2919,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount *struct super_block *sb = mnt->mnt_sb;if (!__mnt_is_readonly (mnt) && - (!(sb->s_iflags &SB_I_TS_EXPIRY_WARNED )) && + !sb_test_iflag (sb, _SB_I_TS_EXPIRY_WARNED) && (ktime_get_real_seconds () +TIME_UPTIME_SEC_MAX > sb->s_time_max)) {char *buf = (char *)__get_free_page (GFP_KERNEL );char *mntpath = buf ?d_path (mountpoint, buf,PAGE_SIZE ) :ERR_PTR (-ENOMEM );
@@ -2931,7 +2931,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount * (unsigned long long)sb->s_time_max);free_page ((unsigned long )buf); - sb->s_iflags |=SB_I_TS_EXPIRY_WARNED ; +sb_set_iflag (sb, _SB_I_TS_EXPIRY_WARNED); } }
fs/nfs/super.c +1 -1
@@ -1094,7 +1094,7 @@ static void nfs_fill_super(struct super_block *sb, struct nfs_fs_context *ctx) sb->s_export_op = &nfs_export_ops;break ;case 4 : - sb->s_iflags |=SB_I_NOUMASK ; +sb_set_iflag (sb, _SB_I_NOUMASK); sb->s_time_gran =1 ; sb->s_time_min =S64_MIN ; sb->s_time_max =S64_MAX ;
fs/overlayfs/super.c +3 -3
@@ -1453,14 +1453,14 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc)#ifdef CONFIG_FS_POSIX_ACL sb->s_flags |=SB_POSIXACL ;#endif - sb->s_iflags |=SB_I_SKIP_SYNC ; +sb_set_iflag (sb, _SB_I_SKIP_SYNC);/* * Ensure that umask handling is done by the filesystems used * for the the upper layer instead of overlayfs as that would * lead to unexpected results. */ - sb->s_iflags |=SB_I_NOUMASK ; - sb->s_iflags |=SB_I_EVM_HMAC_UNSUPPORTED ; +sb_set_iflag (sb, _SB_I_NOUMASK); +sb_set_iflag (sb, _SB_I_EVM_HMAC_UNSUPPORTED); err = -ENOMEM ; root_dentry =ovl_get_root (sb, ctx->upper.dentry, oe);
fs/proc/root.c +3 -1
@@ -171,7 +171,9 @@ static int proc_fill_super(struct super_block *s, struct fs_context *fc)proc_apply_options (fs_info, fc,current_user_ns ());/* User space would break if executables or devices appear on proc */ - s->s_iflags |=SB_I_USERNS_VISIBLE |SB_I_NOEXEC |SB_I_NODEV ; +sb_set_iflag (s, _SB_I_USERNS_VISIBLE); +sb_set_iflag (s, _SB_I_NOEXEC); +sb_set_iflag (s, _SB_I_NODEV); s->s_flags |=SB_NODIRATIME |SB_NOSUID |SB_NOEXEC ; s->s_blocksize =1024 ; s->s_blocksize_bits =10 ;
fs/super.c +9 -9
@@ -355,7 +355,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_bdi = &noop_backing_dev_info; s->s_flags = flags;if (s->s_user_ns != &init_user_ns) - s->s_iflags |=SB_I_NODEV ; +sb_set_iflag (s, _SB_I_NODEV);INIT_HLIST_NODE (&s->s_instances);INIT_HLIST_BL_HEAD (&s->s_roots);mutex_init (&s->s_sync_lock);
@@ -589,11 +589,11 @@ void retire_super(struct super_block *sb) {WARN_ON (!sb->s_bdev);__super_lock_excl (sb); -if (sb->s_iflags &SB_I_PERSB_BDI ) { +if (sb_test_iflag (sb, _SB_I_PERSB_BDI)) {bdi_unregister (sb->s_bdi); - sb->s_iflags &= ~SB_I_PERSB_BDI ; +sb_clear_iflag (sb, _SB_I_PERSB_BDI); } - sb->s_iflags |=SB_I_RETIRED ; +sb_set_iflag (sb, _SB_I_RETIRED);super_unlock_excl (sb); }EXPORT_SYMBOL (retire_super);
@@ -678,7 +678,7 @@ void generic_shutdown_super(struct super_block *sb)super_wake (sb,SB_DYING );super_unlock_excl (sb);if (sb->s_bdi != &noop_backing_dev_info) { -if (sb->s_iflags &SB_I_PERSB_BDI ) +if (sb_test_iflag (sb, _SB_I_PERSB_BDI))bdi_unregister (sb->s_bdi);bdi_put (sb->s_bdi); sb->s_bdi = &noop_backing_dev_info;
@@ -1331,7 +1331,7 @@ static int super_s_dev_set(struct super_block *s, struct fs_context *fc)static int super_s_dev_test (struct super_block *s,struct fs_context *fc) { -return !(s->s_iflags &SB_I_RETIRED ) && +return !sb_test_iflag (s, _SB_I_RETIRED) && s->s_dev == *(dev_t *)fc->sget_key; }
@@ -1584,7 +1584,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, sb->s_bdev = bdev; sb->s_bdi =bdi_get (bdev->bd_disk->bdi);if (bdev_stable_writes (bdev)) - sb->s_iflags |=SB_I_STABLE_WRITES ; +sb_set_iflag (sb, _SB_I_STABLE_WRITES);spin_unlock (&sb_lock);snprintf (sb->s_id,sizeof (sb->s_id),"%pg" , bdev);
@@ -1648,7 +1648,7 @@ EXPORT_SYMBOL(get_tree_bdev);static int test_bdev_super (struct super_block *s,void *data) { -return !(s->s_iflags &SB_I_RETIRED ) && s->s_dev == *(dev_t *)data; +return !sb_test_iflag (s, _SB_I_RETIRED) && s->s_dev == *(dev_t *)data; } struct dentry *mount_bdev(struct file_system_type *fs_type,
@@ -1864,7 +1864,7 @@ int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) }WARN_ON (sb->s_bdi != &noop_backing_dev_info); sb->s_bdi = bdi; - sb->s_iflags |=SB_I_PERSB_BDI ; +sb_set_iflag (sb, _SB_I_PERSB_BDI);return 0 ; }
fs/sync.c +1 -1
@@ -79,7 +79,7 @@ static void sync_inodes_one_sb(struct super_block *sb, void *arg)static void sync_fs_one_sb (struct super_block *sb,void *arg) { -if (!sb_rdonly (sb) && !(sb->s_iflags &SB_I_SKIP_SYNC ) && +if (!sb_rdonly (sb) && !sb_test_iflag (sb, _SB_I_SKIP_SYNC) && sb->s_op->sync_fs) sb->s_op->sync_fs (sb, *(int *)arg); }
fs/sysfs/mount.c +1 -1
@@ -33,7 +33,7 @@ static int sysfs_get_tree(struct fs_context *fc)return ret;if (kfc->new_sb_created) - fc->root->d_sb->s_iflags |=SB_I_USERNS_VISIBLE ; +sb_set_iflag (fc->root->d_sb, _SB_I_USERNS_VISIBLE);return 0 ; }
fs/xfs/xfs_super.c +1 -1
@@ -1701,7 +1701,7 @@ xfs_fs_fill_super( sb->s_time_max =XFS_LEGACY_TIME_MAX ; }trace_xfs_inode_timestamp_range (mp, sb->s_time_min, sb->s_time_max); - sb->s_iflags |=SB_I_CGROUPWB ; +sb_set_iflag (sb, _SB_I_CGROUPWB);set_posix_acl_flag (sb);
include/linux/backing-dev.h +1 -1
@@ -176,7 +176,7 @@ static inline bool inode_cgwb_enabled(struct inode *inode)return cgroup_subsys_on_dfl (memory_cgrp_subsys) &&cgroup_subsys_on_dfl (io_cgrp_subsys) && (bdi->capabilities &BDI_CAP_WRITEBACK ) && - (inode->i_sb->s_iflags &SB_I_CGROUPWB ); +sb_test_iflag (inode->i_sb, _SB_I_CGROUPWB); }/**
include/linux/namei.h +1 -1
@@ -107,7 +107,7 @@ extern void unlock_rename(struct dentry *, struct dentry *);*/ static inline umode_t __must_check mode_strip_umask (const struct inode *dir,umode_t mode) { -if (!IS_POSIXACL (dir) && !(dir->i_sb->s_iflags &SB_I_NOUMASK )) +if (!IS_POSIXACL (dir) && !sb_test_iflag (dir->i_sb, _SB_I_NOUMASK)) mode &= ~current_umask ();return mode; }
ipc/mqueue.c +2 -1
@@ -406,7 +406,8 @@ static int mqueue_fill_super(struct super_block *sb, struct fs_context *fc)struct inode *inode;struct ipc_namespace *ns = sb->s_fs_info; - sb->s_iflags |=SB_I_NOEXEC |SB_I_NODEV ; +sb_set_iflag (sb, _SB_I_NOEXEC); +sb_set_iflag (sb, _SB_I_NODEV); sb->s_blocksize =PAGE_SIZE ; sb->s_blocksize_bits =PAGE_SHIFT ; sb->s_magic =MQUEUE_MAGIC ;
security/integrity/evm/evm_main.c +1 -1
@@ -155,7 +155,7 @@ static int is_unsupported_hmac_fs(struct dentry *dentry) {struct inode *inode =d_backing_inode (dentry); -if (inode->i_sb->s_iflags &SB_I_EVM_HMAC_UNSUPPORTED ) { +if (sb_test_iflag (inode->i_sb, _SB_I_EVM_HMAC_UNSUPPORTED)) {pr_info_once ("%s not supported\n" , inode->i_sb->s_type->name);return 1 ; }
security/integrity/ima/ima_appraise.c +2 -2
@@ -564,8 +564,8 @@ int ima_appraise_measurement(enum ima_hooks func, struct ima_iint_cache *iint,* system not willing to accept such a risk, fail the file signature * verification. */ -if ((inode->i_sb->s_iflags &SB_I_IMA_UNVERIFIABLE_SIGNATURE ) && - ((inode->i_sb->s_iflags &SB_I_UNTRUSTED_MOUNTER ) || +if (sb_test_iflag (inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && + (sb_test_iflag (inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) || (iint->flags &IMA_FAIL_UNVERIFIABLE_SIGS ))) { status =INTEGRITY_FAIL ; cause ="unverifiable-signature" ;
security/integrity/ima/ima_main.c +2 -2
@@ -280,8 +280,8 @@ static int process_measurement(struct file *file, const struct cred *cred,* (Limited to privileged mounted filesystems.) */ if (test_and_clear_bit (IMA_CHANGE_XATTR , &iint->atomic_flags) || - ((inode->i_sb->s_iflags &SB_I_IMA_UNVERIFIABLE_SIGNATURE ) && - !(inode->i_sb->s_iflags &SB_I_UNTRUSTED_MOUNTER ) && + (sb_test_iflag (inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && + !sb_test_iflag (inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) && !(action &IMA_FAIL_UNVERIFIABLE_SIGS ))) { iint->flags &= ~IMA_DONE_MASK ; iint->measured_pcrs =0 ;
Signature · 1 line
2.35.3
Jan Kara
maintainerPATCH 5/13 fs: Drop old SB_I_ constants
In reply to Jan KaraNothing is using the old SB_I_ constants anymore. Remove them.
--- include/linux/fs.h | 17 ----------------- 1 file changed, 17 deletions(-)
include/linux/fs.h +0 -17
@@ -1173,23 +1173,6 @@ extern int send_sigurg(struct fown_struct *fown);#define UMOUNT_UNUSED 0x80000000/* Flag guaranteed to be unused */ /* sb->s_iflags */ -#define SB_I_CGROUPWB 0x00000001/* cgroup-aware writeback enabled */ -#define SB_I_NOEXEC 0x00000002/* Ignore executables on this fs */ -#define SB_I_NODEV 0x00000004/* Ignore devices on this fs */ -#define SB_I_STABLE_WRITES 0x00000008/* don't modify blks until WB is done */ - -/* sb->s_iflags to limit user namespace mounts */ -#define SB_I_USERNS_VISIBLE 0x00000010/* fstype already mounted */ -#define SB_I_IMA_UNVERIFIABLE_SIGNATURE 0x00000020 -#define SB_I_UNTRUSTED_MOUNTER 0x00000040 -#define SB_I_EVM_HMAC_UNSUPPORTED 0x00000080 - -#define SB_I_SKIP_SYNC 0x00000100/* Skip superblock at global sync */ -#define SB_I_PERSB_BDI 0x00000200/* has a per-sb bdi */ -#define SB_I_TS_EXPIRY_WARNED 0x00000400/* warned about timestamp range expiry */ -#define SB_I_RETIRED 0x00000800/* superblock shouldn't be reused */ -#define SB_I_NOUMASK 0x00001000/* VFS does not apply umask */ -enum { _SB_I_CGROUPWB,/* cgroup-aware writeback enabled */ _SB_I_NOEXEC,/* Ignore executables on this fs */
Signature · 1 line
2.35.3
Jan Kara
maintainerPATCH 6/13 fs: Drop unnecessary underscore from _SB_I_ constants
In reply to Jan KaraNow that old constants are gone, remove the unnecessary underscore from the new _SB_I_ constants. Pure mechanical replacement, no functional changes.
--- block/bdev.c | 2 +- drivers/android/binderfs.c | 4 ++-- fs/aio.c | 2 +- fs/btrfs/super.c | 2 +- fs/devpts/inode.c | 2 +- fs/exec.c | 2 +- fs/ext2/super.c | 2 +- fs/ext4/super.c | 2 +- fs/f2fs/super.c | 2 +- fs/fuse/inode.c | 4 ++-- fs/inode.c | 2 +- fs/kernfs/mount.c | 4 ++-- fs/namei.c | 2 +- fs/namespace.c | 8 ++++---- fs/nfs/fs_context.c | 2 +- fs/nfs/super.c | 2 +- fs/overlayfs/super.c | 6 +++--- fs/proc/root.c | 6 +++--- fs/super.c | 18 ++++++++--------- fs/sync.c | 2 +- fs/sysfs/mount.c | 2 +- fs/xfs/xfs_super.c | 2 +- include/linux/backing-dev.h | 2 +- include/linux/fs.h | 28 +++++++++++++-------------- include/linux/namei.h | 2 +- ipc/mqueue.c | 4 ++-- security/integrity/evm/evm_main.c | 2 +- security/integrity/ima/ima_appraise.c | 4 ++-- security/integrity/ima/ima_main.c | 4 ++-- 29 files changed, 63 insertions(+), 63 deletions(-)
block/bdev.c +1 -1
@@ -373,7 +373,7 @@ static int bd_init_fs_context(struct fs_context *fc)struct pseudo_fs_context *ctx =init_pseudo (fc,BDEVFS_MAGIC );if (!ctx)return -ENOMEM ; - fc->s_iflags |=1 << _SB_I_CGROUPWB; + fc->s_iflags |=1 <<SB_I_CGROUPWB ; ctx->ops = &bdev_sops;return 0 ; }
drivers/android/binderfs.c +2 -2
@@ -672,8 +672,8 @@ static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc)* allowed to do. So removing the SB_I_NODEV flag from s_iflags is both * necessary and safe. */ -sb_clear_iflag (sb, _SB_I_NODEV); -sb_set_iflag (sb, _SB_I_NOEXEC); +sb_clear_iflag (sb,SB_I_NODEV ); +sb_set_iflag (sb,SB_I_NOEXEC ); sb->s_magic =BINDERFS_SUPER_MAGIC ; sb->s_op = &binderfs_super_ops; sb->s_time_gran =1 ;
fs/aio.c +1 -1
@@ -279,7 +279,7 @@ static int aio_init_fs_context(struct fs_context *fc) {if (!init_pseudo (fc,AIO_RING_MAGIC ))return -ENOMEM ; - fc->s_iflags |=1 << _SB_I_NOEXEC; + fc->s_iflags |=1 <<SB_I_NOEXEC ;return 0 ; }
fs/btrfs/super.c +1 -1
@@ -950,7 +950,7 @@ static int btrfs_fill_super(struct super_block *sb,#endif sb->s_xattr = btrfs_xattr_handlers; sb->s_time_gran =1 ; -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB ); err =super_setup_bdi (sb);if (err) {
fs/devpts/inode.c +1 -1
@@ -428,7 +428,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent)struct inode *inode;int error; -sb_clear_iflag (s, _SB_I_NODEV); +sb_clear_iflag (s,SB_I_NODEV ); s->s_blocksize =1024 ; s->s_blocksize_bits =10 ; s->s_magic =DEVPTS_SUPER_MAGIC ;
fs/exec.c +1 -1
@@ -112,7 +112,7 @@ static inline void put_binfmt(struct linux_binfmt * fmt)bool path_noexec (const struct path *path) {return (path->mnt->mnt_flags &MNT_NOEXEC ) || -sb_test_iflag (path->mnt->mnt_sb, _SB_I_NOEXEC); +sb_test_iflag (path->mnt->mnt_sb,SB_I_NOEXEC ); }#ifdef CONFIG_USELIB
fs/ext2/super.c +1 -1
@@ -916,7 +916,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) sb->s_flags = (sb->s_flags & ~SB_POSIXACL ) | (test_opt (sb,POSIX_ACL ) ?SB_POSIXACL :0 ); -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB ); if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV && (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
fs/ext4/super.c +1 -1
@@ -4972,7 +4972,7 @@ static int ext4_check_journal_data_mode(struct super_block *sb)if (test_opt (sb,DELALLOC ))clear_opt (sb,DELALLOC ); }else { -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB ); }return 0 ;
fs/f2fs/super.c +1 -1
@@ -4472,7 +4472,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) (test_opt (sbi,POSIX_ACL ) ?SB_POSIXACL :0 );super_set_uuid (sb, (void *) raw_super->uuid,sizeof (raw_super->uuid));super_set_sysfs_name_bdev (sb); -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB );/* init f2fs-specific super block info */ sbi->valid_super_block = valid_super_block;
fs/fuse/inode.c +2 -2
@@ -1566,9 +1566,9 @@ static void fuse_sb_defaults(struct super_block *sb) sb->s_maxbytes =MAX_LFS_FILESIZE ; sb->s_time_gran =1 ; sb->s_export_op = &fuse_export_operations; -sb_set_iflag (sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE); +sb_set_iflag (sb,SB_I_IMA_UNVERIFIABLE_SIGNATURE );if (sb->s_user_ns != &init_user_ns) -sb_set_iflag (sb, _SB_I_UNTRUSTED_MOUNTER); +sb_set_iflag (sb,SB_I_UNTRUSTED_MOUNTER ); sb->s_flags &= ~(SB_NOSEC |SB_I_VERSION ); }
fs/inode.c +1 -1
@@ -216,7 +216,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)lockdep_set_class_and_name (&mapping->invalidate_lock, &sb->s_type->invalidate_lock_key,"mapping.invalidate_lock" ); -if (sb_test_iflag (sb, _SB_I_STABLE_WRITES)) +if (sb_test_iflag (sb,SB_I_STABLE_WRITES ))mapping_set_stable_writes (mapping); inode->i_private =NULL ; inode->i_mapping = mapping;
fs/kernfs/mount.c +2 -2
@@ -252,8 +252,8 @@ static int kernfs_fill_super(struct super_block *sb, struct kernfs_fs_context *k info->sb = sb;/* Userspace would break if executables or devices appear on sysfs */ -sb_set_iflag (sb, _SB_I_NOEXEC); -sb_set_iflag (sb, _SB_I_NODEV); +sb_set_iflag (sb,SB_I_NOEXEC ); +sb_set_iflag (sb,SB_I_NODEV ); sb->s_blocksize =PAGE_SIZE ; sb->s_blocksize_bits =PAGE_SHIFT ; sb->s_magic = kfc->magic;
fs/namei.c +1 -1
@@ -3308,7 +3308,7 @@ EXPORT_SYMBOL(vfs_mkobj);bool may_open_dev (const struct path *path) {return !(path->mnt->mnt_flags &MNT_NODEV ) && - !sb_test_iflag (path->mnt->mnt_sb, _SB_I_NODEV); + !sb_test_iflag (path->mnt->mnt_sb,SB_I_NODEV ); } static int may_open(struct mnt_idmap *idmap, const struct path *path,
fs/namespace.c +4 -4
@@ -2919,7 +2919,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount *struct super_block *sb = mnt->mnt_sb;if (!__mnt_is_readonly (mnt) && - !sb_test_iflag (sb, _SB_I_TS_EXPIRY_WARNED) && + !sb_test_iflag (sb,SB_I_TS_EXPIRY_WARNED ) && (ktime_get_real_seconds () +TIME_UPTIME_SEC_MAX > sb->s_time_max)) {char *buf = (char *)__get_free_page (GFP_KERNEL );char *mntpath = buf ?d_path (mountpoint, buf,PAGE_SIZE ) :ERR_PTR (-ENOMEM );
@@ -2931,7 +2931,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount * (unsigned long long)sb->s_time_max);free_page ((unsigned long )buf); -sb_set_iflag (sb, _SB_I_TS_EXPIRY_WARNED); +sb_set_iflag (sb,SB_I_TS_EXPIRY_WARNED ); } }
@@ -5629,10 +5629,10 @@ static bool mount_too_revealing(const struct super_block *sb, int *new_mnt_flagsreturn false;/* Can this filesystem be too revealing? */ -if (!sb_test_iflag (sb, _SB_I_USERNS_VISIBLE)) +if (!sb_test_iflag (sb,SB_I_USERNS_VISIBLE ))return false; -if (!sb_test_iflag (sb, _SB_I_NOEXEC) || !sb_test_iflag (sb, _SB_I_NODEV)) { +if (!sb_test_iflag (sb,SB_I_NOEXEC ) || !sb_test_iflag (sb,SB_I_NODEV )) {WARN_ONCE (1 ,"Expected s_iflags to contain SB_I_NOEXEC and " "SB_I_NODEV\n" );return true;
fs/nfs/fs_context.c +1 -1
@@ -1643,7 +1643,7 @@ static int nfs_init_fs_context(struct fs_context *fc) ctx->xprtsec.cert_serial =TLS_NO_CERT ; ctx->xprtsec.privkey_serial =TLS_NO_PRIVKEY ; - fc->s_iflags |=1 << _SB_I_STABLE_WRITES; + fc->s_iflags |=1 <<SB_I_STABLE_WRITES ; } fc->fs_private = ctx; fc->ops = &nfs_fs_context_ops;
fs/nfs/super.c +1 -1
@@ -1094,7 +1094,7 @@ static void nfs_fill_super(struct super_block *sb, struct nfs_fs_context *ctx) sb->s_export_op = &nfs_export_ops;break ;case 4 : -sb_set_iflag (sb, _SB_I_NOUMASK); +sb_set_iflag (sb,SB_I_NOUMASK ); sb->s_time_gran =1 ; sb->s_time_min =S64_MIN ; sb->s_time_max =S64_MAX ;
fs/overlayfs/super.c +3 -3
@@ -1453,14 +1453,14 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc)#ifdef CONFIG_FS_POSIX_ACL sb->s_flags |=SB_POSIXACL ;#endif -sb_set_iflag (sb, _SB_I_SKIP_SYNC); +sb_set_iflag (sb,SB_I_SKIP_SYNC );/* * Ensure that umask handling is done by the filesystems used * for the the upper layer instead of overlayfs as that would * lead to unexpected results. */ -sb_set_iflag (sb, _SB_I_NOUMASK); -sb_set_iflag (sb, _SB_I_EVM_HMAC_UNSUPPORTED); +sb_set_iflag (sb,SB_I_NOUMASK ); +sb_set_iflag (sb,SB_I_EVM_HMAC_UNSUPPORTED ); err = -ENOMEM ; root_dentry =ovl_get_root (sb, ctx->upper.dentry, oe);
fs/proc/root.c +3 -3
@@ -171,9 +171,9 @@ static int proc_fill_super(struct super_block *s, struct fs_context *fc)proc_apply_options (fs_info, fc,current_user_ns ());/* User space would break if executables or devices appear on proc */ -sb_set_iflag (s, _SB_I_USERNS_VISIBLE); -sb_set_iflag (s, _SB_I_NOEXEC); -sb_set_iflag (s, _SB_I_NODEV); +sb_set_iflag (s,SB_I_USERNS_VISIBLE ); +sb_set_iflag (s,SB_I_NOEXEC ); +sb_set_iflag (s,SB_I_NODEV ); s->s_flags |=SB_NODIRATIME |SB_NOSUID |SB_NOEXEC ; s->s_blocksize =1024 ; s->s_blocksize_bits =10 ;
fs/super.c +9 -9
@@ -355,7 +355,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_bdi = &noop_backing_dev_info; s->s_flags = flags;if (s->s_user_ns != &init_user_ns) -sb_set_iflag (s, _SB_I_NODEV); +sb_set_iflag (s,SB_I_NODEV );INIT_HLIST_NODE (&s->s_instances);INIT_HLIST_BL_HEAD (&s->s_roots);mutex_init (&s->s_sync_lock);
@@ -589,11 +589,11 @@ void retire_super(struct super_block *sb) {WARN_ON (!sb->s_bdev);__super_lock_excl (sb); -if (sb_test_iflag (sb, _SB_I_PERSB_BDI)) { +if (sb_test_iflag (sb,SB_I_PERSB_BDI )) {bdi_unregister (sb->s_bdi); -sb_clear_iflag (sb, _SB_I_PERSB_BDI); +sb_clear_iflag (sb,SB_I_PERSB_BDI ); } -sb_set_iflag (sb, _SB_I_RETIRED); +sb_set_iflag (sb,SB_I_RETIRED );super_unlock_excl (sb); }EXPORT_SYMBOL (retire_super);
@@ -678,7 +678,7 @@ void generic_shutdown_super(struct super_block *sb)super_wake (sb,SB_DYING );super_unlock_excl (sb);if (sb->s_bdi != &noop_backing_dev_info) { -if (sb_test_iflag (sb, _SB_I_PERSB_BDI)) +if (sb_test_iflag (sb,SB_I_PERSB_BDI ))bdi_unregister (sb->s_bdi);bdi_put (sb->s_bdi); sb->s_bdi = &noop_backing_dev_info;
@@ -1331,7 +1331,7 @@ static int super_s_dev_set(struct super_block *s, struct fs_context *fc)static int super_s_dev_test (struct super_block *s,struct fs_context *fc) { -return !sb_test_iflag (s, _SB_I_RETIRED) && +return !sb_test_iflag (s,SB_I_RETIRED ) && s->s_dev == *(dev_t *)fc->sget_key; }
@@ -1584,7 +1584,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, sb->s_bdev = bdev; sb->s_bdi =bdi_get (bdev->bd_disk->bdi);if (bdev_stable_writes (bdev)) -sb_set_iflag (sb, _SB_I_STABLE_WRITES); +sb_set_iflag (sb,SB_I_STABLE_WRITES );spin_unlock (&sb_lock);snprintf (sb->s_id,sizeof (sb->s_id),"%pg" , bdev);
@@ -1648,7 +1648,7 @@ EXPORT_SYMBOL(get_tree_bdev);static int test_bdev_super (struct super_block *s,void *data) { -return !sb_test_iflag (s, _SB_I_RETIRED) && s->s_dev == *(dev_t *)data; +return !sb_test_iflag (s,SB_I_RETIRED ) && s->s_dev == *(dev_t *)data; } struct dentry *mount_bdev(struct file_system_type *fs_type,
@@ -1864,7 +1864,7 @@ int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) }WARN_ON (sb->s_bdi != &noop_backing_dev_info); sb->s_bdi = bdi; -sb_set_iflag (sb, _SB_I_PERSB_BDI); +sb_set_iflag (sb,SB_I_PERSB_BDI );return 0 ; }
fs/sync.c +1 -1
@@ -79,7 +79,7 @@ static void sync_inodes_one_sb(struct super_block *sb, void *arg)static void sync_fs_one_sb (struct super_block *sb,void *arg) { -if (!sb_rdonly (sb) && !sb_test_iflag (sb, _SB_I_SKIP_SYNC) && +if (!sb_rdonly (sb) && !sb_test_iflag (sb,SB_I_SKIP_SYNC ) && sb->s_op->sync_fs) sb->s_op->sync_fs (sb, *(int *)arg); }
fs/sysfs/mount.c +1 -1
@@ -33,7 +33,7 @@ static int sysfs_get_tree(struct fs_context *fc)return ret;if (kfc->new_sb_created) -sb_set_iflag (fc->root->d_sb, _SB_I_USERNS_VISIBLE); +sb_set_iflag (fc->root->d_sb,SB_I_USERNS_VISIBLE );return 0 ; }
fs/xfs/xfs_super.c +1 -1
@@ -1701,7 +1701,7 @@ xfs_fs_fill_super( sb->s_time_max =XFS_LEGACY_TIME_MAX ; }trace_xfs_inode_timestamp_range (mp, sb->s_time_min, sb->s_time_max); -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB );set_posix_acl_flag (sb);
include/linux/backing-dev.h +1 -1
@@ -176,7 +176,7 @@ static inline bool inode_cgwb_enabled(struct inode *inode)return cgroup_subsys_on_dfl (memory_cgrp_subsys) &&cgroup_subsys_on_dfl (io_cgrp_subsys) && (bdi->capabilities &BDI_CAP_WRITEBACK ) && -sb_test_iflag (inode->i_sb, _SB_I_CGROUPWB); +sb_test_iflag (inode->i_sb,SB_I_CGROUPWB ); }/**
include/linux/fs.h +14 -14
@@ -1174,22 +1174,22 @@ extern int send_sigurg(struct fown_struct *fown);/* sb->s_iflags */ enum { - _SB_I_CGROUPWB,/* cgroup-aware writeback enabled */ - _SB_I_NOEXEC,/* Ignore executables on this fs */ - _SB_I_NODEV,/* Ignore devices on this fs */ - _SB_I_STABLE_WRITES,/* don't modify blks until WB is done */ +SB_I_CGROUPWB ,/* cgroup-aware writeback enabled */ +SB_I_NOEXEC ,/* Ignore executables on this fs */ +SB_I_NODEV ,/* Ignore devices on this fs */ +SB_I_STABLE_WRITES ,/* don't modify blks until WB is done */ /* sb->s_iflags to limit user namespace mounts */ - _SB_I_USERNS_VISIBLE,/* fstype already mounted */ - _SB_I_IMA_UNVERIFIABLE_SIGNATURE, - _SB_I_UNTRUSTED_MOUNTER, - _SB_I_EVM_HMAC_UNSUPPORTED, - - _SB_I_SKIP_SYNC,/* Skip superblock at global sync */ - _SB_I_PERSB_BDI,/* has a per-sb bdi */ - _SB_I_TS_EXPIRY_WARNED,/* warned about timestamp range expiry */ - _SB_I_RETIRED,/* superblock shouldn't be reused */ - _SB_I_NOUMASK,/* VFS does not apply umask */ +SB_I_USERNS_VISIBLE ,/* fstype already mounted */ +SB_I_IMA_UNVERIFIABLE_SIGNATURE , +SB_I_UNTRUSTED_MOUNTER , +SB_I_EVM_HMAC_UNSUPPORTED , + +SB_I_SKIP_SYNC ,/* Skip superblock at global sync */ +SB_I_PERSB_BDI ,/* has a per-sb bdi */ +SB_I_TS_EXPIRY_WARNED ,/* warned about timestamp range expiry */ +SB_I_RETIRED ,/* superblock shouldn't be reused */ +SB_I_NOUMASK ,/* VFS does not apply umask */ };/* Possible states of 'frozen' field */
include/linux/namei.h +1 -1
@@ -107,7 +107,7 @@ extern void unlock_rename(struct dentry *, struct dentry *);*/ static inline umode_t __must_check mode_strip_umask (const struct inode *dir,umode_t mode) { -if (!IS_POSIXACL (dir) && !sb_test_iflag (dir->i_sb, _SB_I_NOUMASK)) +if (!IS_POSIXACL (dir) && !sb_test_iflag (dir->i_sb,SB_I_NOUMASK )) mode &= ~current_umask ();return mode; }
ipc/mqueue.c +2 -2
@@ -406,8 +406,8 @@ static int mqueue_fill_super(struct super_block *sb, struct fs_context *fc)struct inode *inode;struct ipc_namespace *ns = sb->s_fs_info; -sb_set_iflag (sb, _SB_I_NOEXEC); -sb_set_iflag (sb, _SB_I_NODEV); +sb_set_iflag (sb,SB_I_NOEXEC ); +sb_set_iflag (sb,SB_I_NODEV ); sb->s_blocksize =PAGE_SIZE ; sb->s_blocksize_bits =PAGE_SHIFT ; sb->s_magic =MQUEUE_MAGIC ;
security/integrity/evm/evm_main.c +1 -1
@@ -155,7 +155,7 @@ static int is_unsupported_hmac_fs(struct dentry *dentry) {struct inode *inode =d_backing_inode (dentry); -if (sb_test_iflag (inode->i_sb, _SB_I_EVM_HMAC_UNSUPPORTED)) { +if (sb_test_iflag (inode->i_sb,SB_I_EVM_HMAC_UNSUPPORTED )) {pr_info_once ("%s not supported\n" , inode->i_sb->s_type->name);return 1 ; }
security/integrity/ima/ima_appraise.c +2 -2
@@ -564,8 +564,8 @@ int ima_appraise_measurement(enum ima_hooks func, struct ima_iint_cache *iint,* system not willing to accept such a risk, fail the file signature * verification. */ -if (sb_test_iflag (inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && - (sb_test_iflag (inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) || +if (sb_test_iflag (inode->i_sb,SB_I_IMA_UNVERIFIABLE_SIGNATURE ) && + (sb_test_iflag (inode->i_sb,SB_I_UNTRUSTED_MOUNTER ) || (iint->flags &IMA_FAIL_UNVERIFIABLE_SIGS ))) { status =INTEGRITY_FAIL ; cause ="unverifiable-signature" ;
security/integrity/ima/ima_main.c +2 -2
@@ -280,8 +280,8 @@ static int process_measurement(struct file *file, const struct cred *cred,* (Limited to privileged mounted filesystems.) */ if (test_and_clear_bit (IMA_CHANGE_XATTR , &iint->atomic_flags) || - (sb_test_iflag (inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && - !sb_test_iflag (inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) && + (sb_test_iflag (inode->i_sb,SB_I_IMA_UNVERIFIABLE_SIGNATURE ) && + !sb_test_iflag (inode->i_sb,SB_I_UNTRUSTED_MOUNTER ) && !(action &IMA_FAIL_UNVERIFIABLE_SIGS ))) { iint->flags &= ~IMA_DONE_MASK ; iint->measured_pcrs =0 ;
Signature · 1 line
2.35.3
Amir Goldstein
maintainerRe: [PATCH 06/13] fs: Drop unnecessary underscore from _SB_I_ constants
Quoted 5 lines · Jan Kara
Now that old constants are gone, remove the unnecessary underscore from the new _SB_I_ constants. Pure mechanical replacement, no functional changes.
This is a potential backporting bomb.
It is true that code using the old constant names with new macros will not build on stable kernels, but I think this is still asking for trouble.
Also, it is a bit strange that SB_* flags are bit masks and SB_I_* flags are bit numbers.
How about leaving the underscore and using sb_*_iflag() macros to add the underscore?
Thanks,
Amir.
Quoted 550 lines
Signed-off-by Jan Kara <[email protected]>--- block/bdev.c | 2 +- drivers/android/binderfs.c | 4 ++-- fs/aio.c | 2 +- fs/btrfs/super.c | 2 +- fs/devpts/inode.c | 2 +- fs/exec.c | 2 +- fs/ext2/super.c | 2 +- fs/ext4/super.c | 2 +- fs/f2fs/super.c | 2 +- fs/fuse/inode.c | 4 ++-- fs/inode.c | 2 +- fs/kernfs/mount.c | 4 ++-- fs/namei.c | 2 +- fs/namespace.c | 8 ++++---- fs/nfs/fs_context.c | 2 +- fs/nfs/super.c | 2 +- fs/overlayfs/super.c | 6 +++--- fs/proc/root.c | 6 +++--- fs/super.c | 18 ++++++++--------- fs/sync.c | 2 +- fs/sysfs/mount.c | 2 +- fs/xfs/xfs_super.c | 2 +- include/linux/backing-dev.h | 2 +- include/linux/fs.h | 28 +++++++++++++-------------- include/linux/namei.h | 2 +- ipc/mqueue.c | 4 ++-- security/integrity/evm/evm_main.c | 2 +- security/integrity/ima/ima_appraise.c | 4 ++-- security/integrity/ima/ima_main.c | 4 ++-- 29 files changed, 63 insertions(+), 63 deletions(-)block/bdev.c +1
-1@@ -373,7 +373,7 @@ static int bd_init_fs_context(struct fs_context *fc)struct pseudo_fs_context *ctx =init_pseudo (fc,BDEVFS_MAGIC );if (!ctx)return -ENOMEM ; - fc->s_iflags |=1 << _SB_I_CGROUPWB; + fc->s_iflags |=1 <<SB_I_CGROUPWB ; ctx->ops = &bdev_sops;return 0 ; }drivers/android/binderfs.c +2
-2@@ -672,8 +672,8 @@ static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc)* allowed to do. So removing the SB_I_NODEV flag from s_iflags is both * necessary and safe. */ -sb_clear_iflag (sb, _SB_I_NODEV); -sb_set_iflag (sb, _SB_I_NOEXEC); +sb_clear_iflag (sb,SB_I_NODEV ); +sb_set_iflag (sb,SB_I_NOEXEC ); sb->s_magic =BINDERFS_SUPER_MAGIC ; sb->s_op = &binderfs_super_ops; sb->s_time_gran =1 ;fs/aio.c +1
-1@@ -279,7 +279,7 @@ static int aio_init_fs_context(struct fs_context *fc) {if (!init_pseudo (fc,AIO_RING_MAGIC ))return -ENOMEM ; - fc->s_iflags |=1 << _SB_I_NOEXEC; + fc->s_iflags |=1 <<SB_I_NOEXEC ;return 0 ; }fs/btrfs/super.c +1
-1@@ -950,7 +950,7 @@ static int btrfs_fill_super(struct super_block *sb,#endif sb->s_xattr = btrfs_xattr_handlers; sb->s_time_gran =1 ; -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB ); err =super_setup_bdi (sb);if (err) {fs/devpts/inode.c +1
-1@@ -428,7 +428,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent)struct inode *inode;int error; -sb_clear_iflag (s, _SB_I_NODEV); +sb_clear_iflag (s,SB_I_NODEV ); s->s_blocksize =1024 ; s->s_blocksize_bits =10 ; s->s_magic =DEVPTS_SUPER_MAGIC ;fs/exec.c +1
-1@@ -112,7 +112,7 @@ static inline void put_binfmt(struct linux_binfmt * fmt)bool path_noexec (const struct path *path) {return (path->mnt->mnt_flags &MNT_NOEXEC ) || -sb_test_iflag (path->mnt->mnt_sb, _SB_I_NOEXEC); +sb_test_iflag (path->mnt->mnt_sb,SB_I_NOEXEC ); }#ifdef CONFIG_USELIB fs/ext2/super.c +1
-1@@ -916,7 +916,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) sb->s_flags = (sb->s_flags & ~SB_POSIXACL ) | (test_opt (sb,POSIX_ACL ) ?SB_POSIXACL :0 ); -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB ); if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV && (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||fs/ext4/super.c +1
-1@@ -4972,7 +4972,7 @@ static int ext4_check_journal_data_mode(struct super_block *sb)if (test_opt (sb,DELALLOC ))clear_opt (sb,DELALLOC ); }else { -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB ); }return 0 ;fs/f2fs/super.c +1
-1@@ -4472,7 +4472,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) (test_opt (sbi,POSIX_ACL ) ?SB_POSIXACL :0 );super_set_uuid (sb, (void *) raw_super->uuid,sizeof (raw_super->uuid));super_set_sysfs_name_bdev (sb); -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB );/* init f2fs-specific super block info */ sbi->valid_super_block = valid_super_block;fs/fuse/inode.c +2
-2@@ -1566,9 +1566,9 @@ static void fuse_sb_defaults(struct super_block *sb) sb->s_maxbytes =MAX_LFS_FILESIZE ; sb->s_time_gran =1 ; sb->s_export_op = &fuse_export_operations; -sb_set_iflag (sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE); +sb_set_iflag (sb,SB_I_IMA_UNVERIFIABLE_SIGNATURE );if (sb->s_user_ns != &init_user_ns) -sb_set_iflag (sb, _SB_I_UNTRUSTED_MOUNTER); +sb_set_iflag (sb,SB_I_UNTRUSTED_MOUNTER ); sb->s_flags &= ~(SB_NOSEC |SB_I_VERSION ); }fs/inode.c +1
-1@@ -216,7 +216,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)lockdep_set_class_and_name (&mapping->invalidate_lock, &sb->s_type->invalidate_lock_key,"mapping.invalidate_lock" ); -if (sb_test_iflag (sb, _SB_I_STABLE_WRITES)) +if (sb_test_iflag (sb,SB_I_STABLE_WRITES ))mapping_set_stable_writes (mapping); inode->i_private =NULL ; inode->i_mapping = mapping;fs/kernfs/mount.c +2
-2@@ -252,8 +252,8 @@ static int kernfs_fill_super(struct super_block *sb, struct kernfs_fs_context *k info->sb = sb;/* Userspace would break if executables or devices appear on sysfs */ -sb_set_iflag (sb, _SB_I_NOEXEC); -sb_set_iflag (sb, _SB_I_NODEV); +sb_set_iflag (sb,SB_I_NOEXEC ); +sb_set_iflag (sb,SB_I_NODEV ); sb->s_blocksize =PAGE_SIZE ; sb->s_blocksize_bits =PAGE_SHIFT ; sb->s_magic = kfc->magic;fs/namei.c +1
-1@@ -3308,7 +3308,7 @@ EXPORT_SYMBOL(vfs_mkobj);bool may_open_dev (const struct path *path) {return !(path->mnt->mnt_flags &MNT_NODEV ) && - !sb_test_iflag (path->mnt->mnt_sb, _SB_I_NODEV); + !sb_test_iflag (path->mnt->mnt_sb,SB_I_NODEV ); } static int may_open(struct mnt_idmap *idmap, const struct path *path,fs/namespace.c +4
-4@@ -2919,7 +2919,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount *struct super_block *sb = mnt->mnt_sb;if (!__mnt_is_readonly (mnt) && - !sb_test_iflag (sb, _SB_I_TS_EXPIRY_WARNED) && + !sb_test_iflag (sb,SB_I_TS_EXPIRY_WARNED ) && (ktime_get_real_seconds () +TIME_UPTIME_SEC_MAX > sb->s_time_max)) {char *buf = (char *)__get_free_page (GFP_KERNEL );char *mntpath = buf ?d_path (mountpoint, buf,PAGE_SIZE ) :ERR_PTR (-ENOMEM );@@ -2931,7 +2931,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount * (unsigned long long)sb->s_time_max);free_page ((unsigned long )buf); -sb_set_iflag (sb, _SB_I_TS_EXPIRY_WARNED); +sb_set_iflag (sb,SB_I_TS_EXPIRY_WARNED ); } }@@ -5629,10 +5629,10 @@ static bool mount_too_revealing(const struct super_block *sb, int *new_mnt_flagsreturn false;/* Can this filesystem be too revealing? */ -if (!sb_test_iflag (sb, _SB_I_USERNS_VISIBLE)) +if (!sb_test_iflag (sb,SB_I_USERNS_VISIBLE ))return false; -if (!sb_test_iflag (sb, _SB_I_NOEXEC) || !sb_test_iflag (sb, _SB_I_NODEV)) { +if (!sb_test_iflag (sb,SB_I_NOEXEC ) || !sb_test_iflag (sb,SB_I_NODEV )) {WARN_ONCE (1 ,"Expected s_iflags to contain SB_I_NOEXEC and " "SB_I_NODEV\n" );return true;fs/nfs/fs_context.c +1
-1@@ -1643,7 +1643,7 @@ static int nfs_init_fs_context(struct fs_context *fc) ctx->xprtsec.cert_serial =TLS_NO_CERT ; ctx->xprtsec.privkey_serial =TLS_NO_PRIVKEY ; - fc->s_iflags |=1 << _SB_I_STABLE_WRITES; + fc->s_iflags |=1 <<SB_I_STABLE_WRITES ; } fc->fs_private = ctx; fc->ops = &nfs_fs_context_ops;fs/nfs/super.c +1
-1@@ -1094,7 +1094,7 @@ static void nfs_fill_super(struct super_block *sb, struct nfs_fs_context *ctx) sb->s_export_op = &nfs_export_ops;break ;case 4 : -sb_set_iflag (sb, _SB_I_NOUMASK); +sb_set_iflag (sb,SB_I_NOUMASK ); sb->s_time_gran =1 ; sb->s_time_min =S64_MIN ; sb->s_time_max =S64_MAX ;fs/overlayfs/super.c +3
-3@@ -1453,14 +1453,14 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc)#ifdef CONFIG_FS_POSIX_ACL sb->s_flags |=SB_POSIXACL ;#endif -sb_set_iflag (sb, _SB_I_SKIP_SYNC); +sb_set_iflag (sb,SB_I_SKIP_SYNC );/* * Ensure that umask handling is done by the filesystems used * for the the upper layer instead of overlayfs as that would * lead to unexpected results. */ -sb_set_iflag (sb, _SB_I_NOUMASK); -sb_set_iflag (sb, _SB_I_EVM_HMAC_UNSUPPORTED); +sb_set_iflag (sb,SB_I_NOUMASK ); +sb_set_iflag (sb,SB_I_EVM_HMAC_UNSUPPORTED ); err = -ENOMEM ; root_dentry =ovl_get_root (sb, ctx->upper.dentry, oe);fs/proc/root.c +3
-3@@ -171,9 +171,9 @@ static int proc_fill_super(struct super_block *s, struct fs_context *fc)proc_apply_options (fs_info, fc,current_user_ns ());/* User space would break if executables or devices appear on proc */ -sb_set_iflag (s, _SB_I_USERNS_VISIBLE); -sb_set_iflag (s, _SB_I_NOEXEC); -sb_set_iflag (s, _SB_I_NODEV); +sb_set_iflag (s,SB_I_USERNS_VISIBLE ); +sb_set_iflag (s,SB_I_NOEXEC ); +sb_set_iflag (s,SB_I_NODEV ); s->s_flags |=SB_NODIRATIME |SB_NOSUID |SB_NOEXEC ; s->s_blocksize =1024 ; s->s_blocksize_bits =10 ;fs/super.c +9
-9@@ -355,7 +355,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_bdi = &noop_backing_dev_info; s->s_flags = flags;if (s->s_user_ns != &init_user_ns) -sb_set_iflag (s, _SB_I_NODEV); +sb_set_iflag (s,SB_I_NODEV );INIT_HLIST_NODE (&s->s_instances);INIT_HLIST_BL_HEAD (&s->s_roots);mutex_init (&s->s_sync_lock);@@ -589,11 +589,11 @@ void retire_super(struct super_block *sb) {WARN_ON (!sb->s_bdev);__super_lock_excl (sb); -if (sb_test_iflag (sb, _SB_I_PERSB_BDI)) { +if (sb_test_iflag (sb,SB_I_PERSB_BDI )) {bdi_unregister (sb->s_bdi); -sb_clear_iflag (sb, _SB_I_PERSB_BDI); +sb_clear_iflag (sb,SB_I_PERSB_BDI ); } -sb_set_iflag (sb, _SB_I_RETIRED); +sb_set_iflag (sb,SB_I_RETIRED );super_unlock_excl (sb); }EXPORT_SYMBOL (retire_super);@@ -678,7 +678,7 @@ void generic_shutdown_super(struct super_block *sb)super_wake (sb,SB_DYING );super_unlock_excl (sb);if (sb->s_bdi != &noop_backing_dev_info) { -if (sb_test_iflag (sb, _SB_I_PERSB_BDI)) +if (sb_test_iflag (sb,SB_I_PERSB_BDI ))bdi_unregister (sb->s_bdi);bdi_put (sb->s_bdi); sb->s_bdi = &noop_backing_dev_info;@@ -1331,7 +1331,7 @@ static int super_s_dev_set(struct super_block *s, struct fs_context *fc)static int super_s_dev_test (struct super_block *s,struct fs_context *fc) { -return !sb_test_iflag (s, _SB_I_RETIRED) && +return !sb_test_iflag (s,SB_I_RETIRED ) && s->s_dev == *(dev_t *)fc->sget_key; }@@ -1584,7 +1584,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, sb->s_bdev = bdev; sb->s_bdi =bdi_get (bdev->bd_disk->bdi);if (bdev_stable_writes (bdev)) -sb_set_iflag (sb, _SB_I_STABLE_WRITES); +sb_set_iflag (sb,SB_I_STABLE_WRITES );spin_unlock (&sb_lock);snprintf (sb->s_id,sizeof (sb->s_id),"%pg" , bdev);@@ -1648,7 +1648,7 @@ EXPORT_SYMBOL(get_tree_bdev);static int test_bdev_super (struct super_block *s,void *data) { -return !sb_test_iflag (s, _SB_I_RETIRED) && s->s_dev == *(dev_t *)data; +return !sb_test_iflag (s,SB_I_RETIRED ) && s->s_dev == *(dev_t *)data; } struct dentry *mount_bdev(struct file_system_type *fs_type,@@ -1864,7 +1864,7 @@ int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) }WARN_ON (sb->s_bdi != &noop_backing_dev_info); sb->s_bdi = bdi; -sb_set_iflag (sb, _SB_I_PERSB_BDI); +sb_set_iflag (sb,SB_I_PERSB_BDI );return 0 ; }fs/sync.c +1
-1@@ -79,7 +79,7 @@ static void sync_inodes_one_sb(struct super_block *sb, void *arg)static void sync_fs_one_sb (struct super_block *sb,void *arg) { -if (!sb_rdonly (sb) && !sb_test_iflag (sb, _SB_I_SKIP_SYNC) && +if (!sb_rdonly (sb) && !sb_test_iflag (sb,SB_I_SKIP_SYNC ) && sb->s_op->sync_fs) sb->s_op->sync_fs (sb, *(int *)arg); }fs/sysfs/mount.c +1
-1@@ -33,7 +33,7 @@ static int sysfs_get_tree(struct fs_context *fc)return ret;if (kfc->new_sb_created) -sb_set_iflag (fc->root->d_sb, _SB_I_USERNS_VISIBLE); +sb_set_iflag (fc->root->d_sb,SB_I_USERNS_VISIBLE );return 0 ; }fs/xfs/xfs_super.c +1
-1@@ -1701,7 +1701,7 @@ xfs_fs_fill_super( sb->s_time_max =XFS_LEGACY_TIME_MAX ; }trace_xfs_inode_timestamp_range (mp, sb->s_time_min, sb->s_time_max); -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB );set_posix_acl_flag (sb);include/linux/backing-dev.h +1
-1@@ -176,7 +176,7 @@ static inline bool inode_cgwb_enabled(struct inode *inode)return cgroup_subsys_on_dfl (memory_cgrp_subsys) &&cgroup_subsys_on_dfl (io_cgrp_subsys) && (bdi->capabilities &BDI_CAP_WRITEBACK ) && -sb_test_iflag (inode->i_sb, _SB_I_CGROUPWB); +sb_test_iflag (inode->i_sb,SB_I_CGROUPWB ); }/** include/linux/fs.h +14
-14@@ -1174,22 +1174,22 @@ extern int send_sigurg(struct fown_struct *fown);/* sb->s_iflags */ enum { - _SB_I_CGROUPWB,/* cgroup-aware writeback enabled */ - _SB_I_NOEXEC,/* Ignore executables on this fs */ - _SB_I_NODEV,/* Ignore devices on this fs */ - _SB_I_STABLE_WRITES,/* don't modify blks until WB is done */ +SB_I_CGROUPWB ,/* cgroup-aware writeback enabled */ +SB_I_NOEXEC ,/* Ignore executables on this fs */ +SB_I_NODEV ,/* Ignore devices on this fs */ +SB_I_STABLE_WRITES ,/* don't modify blks until WB is done */ /* sb->s_iflags to limit user namespace mounts */ - _SB_I_USERNS_VISIBLE,/* fstype already mounted */ - _SB_I_IMA_UNVERIFIABLE_SIGNATURE, - _SB_I_UNTRUSTED_MOUNTER, - _SB_I_EVM_HMAC_UNSUPPORTED, - - _SB_I_SKIP_SYNC,/* Skip superblock at global sync */ - _SB_I_PERSB_BDI,/* has a per-sb bdi */ - _SB_I_TS_EXPIRY_WARNED,/* warned about timestamp range expiry */ - _SB_I_RETIRED,/* superblock shouldn't be reused */ - _SB_I_NOUMASK,/* VFS does not apply umask */ +SB_I_USERNS_VISIBLE ,/* fstype already mounted */ +SB_I_IMA_UNVERIFIABLE_SIGNATURE , +SB_I_UNTRUSTED_MOUNTER , +SB_I_EVM_HMAC_UNSUPPORTED , + +SB_I_SKIP_SYNC ,/* Skip superblock at global sync */ +SB_I_PERSB_BDI ,/* has a per-sb bdi */ +SB_I_TS_EXPIRY_WARNED ,/* warned about timestamp range expiry */ +SB_I_RETIRED ,/* superblock shouldn't be reused */ +SB_I_NOUMASK ,/* VFS does not apply umask */ };/* Possible states of 'frozen' field */ include/linux/namei.h +1
-1@@ -107,7 +107,7 @@ extern void unlock_rename(struct dentry *, struct dentry *);*/ static inline umode_t __must_check mode_strip_umask (const struct inode *dir,umode_t mode) { -if (!IS_POSIXACL (dir) && !sb_test_iflag (dir->i_sb, _SB_I_NOUMASK)) +if (!IS_POSIXACL (dir) && !sb_test_iflag (dir->i_sb,SB_I_NOUMASK )) mode &= ~current_umask ();return mode; }ipc/mqueue.c +2
-2@@ -406,8 +406,8 @@ static int mqueue_fill_super(struct super_block *sb, struct fs_context *fc)struct inode *inode;struct ipc_namespace *ns = sb->s_fs_info; -sb_set_iflag (sb, _SB_I_NOEXEC); -sb_set_iflag (sb, _SB_I_NODEV); +sb_set_iflag (sb,SB_I_NOEXEC ); +sb_set_iflag (sb,SB_I_NODEV ); sb->s_blocksize =PAGE_SIZE ; sb->s_blocksize_bits =PAGE_SHIFT ; sb->s_magic =MQUEUE_MAGIC ;security/integrity/evm/evm_main.c +1
-1@@ -155,7 +155,7 @@ static int is_unsupported_hmac_fs(struct dentry *dentry) {struct inode *inode =d_backing_inode (dentry); -if (sb_test_iflag (inode->i_sb, _SB_I_EVM_HMAC_UNSUPPORTED)) { +if (sb_test_iflag (inode->i_sb,SB_I_EVM_HMAC_UNSUPPORTED )) {pr_info_once ("%s not supported\n" , inode->i_sb->s_type->name);return 1 ; }security/integrity/ima/ima_appraise.c +2
-2@@ -564,8 +564,8 @@ int ima_appraise_measurement(enum ima_hooks func, struct ima_iint_cache *iint,* system not willing to accept such a risk, fail the file signature * verification. */ -if (sb_test_iflag (inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && - (sb_test_iflag (inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) || +if (sb_test_iflag (inode->i_sb,SB_I_IMA_UNVERIFIABLE_SIGNATURE ) && + (sb_test_iflag (inode->i_sb,SB_I_UNTRUSTED_MOUNTER ) || (iint->flags &IMA_FAIL_UNVERIFIABLE_SIGS ))) { status =INTEGRITY_FAIL ; cause ="unverifiable-signature" ;security/integrity/ima/ima_main.c +2
-3@@ -280,8 +280,8 @@ static int process_measurement(struct file *file, const struct cred *cred,* (Limited to privileged mounted filesystems.) */ if (test_and_clear_bit (IMA_CHANGE_XATTR , &iint->atomic_flags) || - (sb_test_iflag (inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && - !sb_test_iflag (inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) && + (sb_test_iflag (inode->i_sb,SB_I_IMA_UNVERIFIABLE_SIGNATURE ) && + !sb_test_iflag (inode->i_sb,SB_I_UNTRUSTED_MOUNTER ) && !(action &IMA_FAIL_UNVERIFIABLE_SIGS ))) { iint->flags &= ~IMA_DONE_MASK ; iint->measured_pcrs =0 ; --2.35.3
Re: [PATCH 06/13] fs: Drop unnecessary underscore from _SB_I_ constants
Quoted 7 lines · Amir Goldstein
Quoted 5 lines · Jan Kara
Now that old constants are gone, remove the unnecessary underscore from the new _SB_I_ constants. Pure mechanical replacement, no functional changes.
Quoted 8 lines
This is a potential backporting bomb.
It is true that code using the old constant names with new macros will not build on stable kernels, but I think this is still asking for trouble.Also, it is a bit strange that SB_* flags are bit masks and SB_I_* flags are bit numbers.
How about leaving the underscore and using sb_*_iflag() macros to add the underscore?
Or append _BIT to the new names, as is sometimes done elsewhere in the kernel?
#define SB_I_VERSION_BIT 23
etc.
--D
Quoted 554 lines
Thanks,
Amir.Quoted 550 lines
Signed-off-by Jan Kara <[email protected]>--- block/bdev.c | 2 +- drivers/android/binderfs.c | 4 ++-- fs/aio.c | 2 +- fs/btrfs/super.c | 2 +- fs/devpts/inode.c | 2 +- fs/exec.c | 2 +- fs/ext2/super.c | 2 +- fs/ext4/super.c | 2 +- fs/f2fs/super.c | 2 +- fs/fuse/inode.c | 4 ++-- fs/inode.c | 2 +- fs/kernfs/mount.c | 4 ++-- fs/namei.c | 2 +- fs/namespace.c | 8 ++++---- fs/nfs/fs_context.c | 2 +- fs/nfs/super.c | 2 +- fs/overlayfs/super.c | 6 +++--- fs/proc/root.c | 6 +++--- fs/super.c | 18 ++++++++--------- fs/sync.c | 2 +- fs/sysfs/mount.c | 2 +- fs/xfs/xfs_super.c | 2 +- include/linux/backing-dev.h | 2 +- include/linux/fs.h | 28 +++++++++++++-------------- include/linux/namei.h | 2 +- ipc/mqueue.c | 4 ++-- security/integrity/evm/evm_main.c | 2 +- security/integrity/ima/ima_appraise.c | 4 ++-- security/integrity/ima/ima_main.c | 4 ++-- 29 files changed, 63 insertions(+), 63 deletions(-)block/bdev.c +1
-1@@ -373,7 +373,7 @@ static int bd_init_fs_context(struct fs_context *fc)struct pseudo_fs_context *ctx =init_pseudo (fc,BDEVFS_MAGIC );if (!ctx)return -ENOMEM ; - fc->s_iflags |=1 << _SB_I_CGROUPWB; + fc->s_iflags |=1 <<SB_I_CGROUPWB ; ctx->ops = &bdev_sops;return 0 ; }drivers/android/binderfs.c +2
-2@@ -672,8 +672,8 @@ static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc)* allowed to do. So removing the SB_I_NODEV flag from s_iflags is both * necessary and safe. */ -sb_clear_iflag (sb, _SB_I_NODEV); -sb_set_iflag (sb, _SB_I_NOEXEC); +sb_clear_iflag (sb,SB_I_NODEV ); +sb_set_iflag (sb,SB_I_NOEXEC ); sb->s_magic =BINDERFS_SUPER_MAGIC ; sb->s_op = &binderfs_super_ops; sb->s_time_gran =1 ;fs/aio.c +1
-1@@ -279,7 +279,7 @@ static int aio_init_fs_context(struct fs_context *fc) {if (!init_pseudo (fc,AIO_RING_MAGIC ))return -ENOMEM ; - fc->s_iflags |=1 << _SB_I_NOEXEC; + fc->s_iflags |=1 <<SB_I_NOEXEC ;return 0 ; }fs/btrfs/super.c +1
-1@@ -950,7 +950,7 @@ static int btrfs_fill_super(struct super_block *sb,#endif sb->s_xattr = btrfs_xattr_handlers; sb->s_time_gran =1 ; -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB ); err =super_setup_bdi (sb);if (err) {fs/devpts/inode.c +1
-1@@ -428,7 +428,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent)struct inode *inode;int error; -sb_clear_iflag (s, _SB_I_NODEV); +sb_clear_iflag (s,SB_I_NODEV ); s->s_blocksize =1024 ; s->s_blocksize_bits =10 ; s->s_magic =DEVPTS_SUPER_MAGIC ;fs/exec.c +1
-1@@ -112,7 +112,7 @@ static inline void put_binfmt(struct linux_binfmt * fmt)bool path_noexec (const struct path *path) {return (path->mnt->mnt_flags &MNT_NOEXEC ) || -sb_test_iflag (path->mnt->mnt_sb, _SB_I_NOEXEC); +sb_test_iflag (path->mnt->mnt_sb,SB_I_NOEXEC ); }#ifdef CONFIG_USELIB fs/ext2/super.c +1
-1@@ -916,7 +916,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) sb->s_flags = (sb->s_flags & ~SB_POSIXACL ) | (test_opt (sb,POSIX_ACL ) ?SB_POSIXACL :0 ); -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB ); if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV && (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||fs/ext4/super.c +1
-1@@ -4972,7 +4972,7 @@ static int ext4_check_journal_data_mode(struct super_block *sb)if (test_opt (sb,DELALLOC ))clear_opt (sb,DELALLOC ); }else { -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB ); }return 0 ;fs/f2fs/super.c +1
-1@@ -4472,7 +4472,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) (test_opt (sbi,POSIX_ACL ) ?SB_POSIXACL :0 );super_set_uuid (sb, (void *) raw_super->uuid,sizeof (raw_super->uuid));super_set_sysfs_name_bdev (sb); -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB );/* init f2fs-specific super block info */ sbi->valid_super_block = valid_super_block;fs/fuse/inode.c +2
-2@@ -1566,9 +1566,9 @@ static void fuse_sb_defaults(struct super_block *sb) sb->s_maxbytes =MAX_LFS_FILESIZE ; sb->s_time_gran =1 ; sb->s_export_op = &fuse_export_operations; -sb_set_iflag (sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE); +sb_set_iflag (sb,SB_I_IMA_UNVERIFIABLE_SIGNATURE );if (sb->s_user_ns != &init_user_ns) -sb_set_iflag (sb, _SB_I_UNTRUSTED_MOUNTER); +sb_set_iflag (sb,SB_I_UNTRUSTED_MOUNTER ); sb->s_flags &= ~(SB_NOSEC |SB_I_VERSION ); }fs/inode.c +1
-1@@ -216,7 +216,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)lockdep_set_class_and_name (&mapping->invalidate_lock, &sb->s_type->invalidate_lock_key,"mapping.invalidate_lock" ); -if (sb_test_iflag (sb, _SB_I_STABLE_WRITES)) +if (sb_test_iflag (sb,SB_I_STABLE_WRITES ))mapping_set_stable_writes (mapping); inode->i_private =NULL ; inode->i_mapping = mapping;fs/kernfs/mount.c +2
-2@@ -252,8 +252,8 @@ static int kernfs_fill_super(struct super_block *sb, struct kernfs_fs_context *k info->sb = sb;/* Userspace would break if executables or devices appear on sysfs */ -sb_set_iflag (sb, _SB_I_NOEXEC); -sb_set_iflag (sb, _SB_I_NODEV); +sb_set_iflag (sb,SB_I_NOEXEC ); +sb_set_iflag (sb,SB_I_NODEV ); sb->s_blocksize =PAGE_SIZE ; sb->s_blocksize_bits =PAGE_SHIFT ; sb->s_magic = kfc->magic;fs/namei.c +1
-1@@ -3308,7 +3308,7 @@ EXPORT_SYMBOL(vfs_mkobj);bool may_open_dev (const struct path *path) {return !(path->mnt->mnt_flags &MNT_NODEV ) && - !sb_test_iflag (path->mnt->mnt_sb, _SB_I_NODEV); + !sb_test_iflag (path->mnt->mnt_sb,SB_I_NODEV ); } static int may_open(struct mnt_idmap *idmap, const struct path *path,fs/namespace.c +4
-4@@ -2919,7 +2919,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount *struct super_block *sb = mnt->mnt_sb;if (!__mnt_is_readonly (mnt) && - !sb_test_iflag (sb, _SB_I_TS_EXPIRY_WARNED) && + !sb_test_iflag (sb,SB_I_TS_EXPIRY_WARNED ) && (ktime_get_real_seconds () +TIME_UPTIME_SEC_MAX > sb->s_time_max)) {char *buf = (char *)__get_free_page (GFP_KERNEL );char *mntpath = buf ?d_path (mountpoint, buf,PAGE_SIZE ) :ERR_PTR (-ENOMEM );@@ -2931,7 +2931,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount * (unsigned long long)sb->s_time_max);free_page ((unsigned long )buf); -sb_set_iflag (sb, _SB_I_TS_EXPIRY_WARNED); +sb_set_iflag (sb,SB_I_TS_EXPIRY_WARNED ); } }@@ -5629,10 +5629,10 @@ static bool mount_too_revealing(const struct super_block *sb, int *new_mnt_flagsreturn false;/* Can this filesystem be too revealing? */ -if (!sb_test_iflag (sb, _SB_I_USERNS_VISIBLE)) +if (!sb_test_iflag (sb,SB_I_USERNS_VISIBLE ))return false; -if (!sb_test_iflag (sb, _SB_I_NOEXEC) || !sb_test_iflag (sb, _SB_I_NODEV)) { +if (!sb_test_iflag (sb,SB_I_NOEXEC ) || !sb_test_iflag (sb,SB_I_NODEV )) {WARN_ONCE (1 ,"Expected s_iflags to contain SB_I_NOEXEC and " "SB_I_NODEV\n" );return true;fs/nfs/fs_context.c +1
-1@@ -1643,7 +1643,7 @@ static int nfs_init_fs_context(struct fs_context *fc) ctx->xprtsec.cert_serial =TLS_NO_CERT ; ctx->xprtsec.privkey_serial =TLS_NO_PRIVKEY ; - fc->s_iflags |=1 << _SB_I_STABLE_WRITES; + fc->s_iflags |=1 <<SB_I_STABLE_WRITES ; } fc->fs_private = ctx; fc->ops = &nfs_fs_context_ops;fs/nfs/super.c +1
-1@@ -1094,7 +1094,7 @@ static void nfs_fill_super(struct super_block *sb, struct nfs_fs_context *ctx) sb->s_export_op = &nfs_export_ops;break ;case 4 : -sb_set_iflag (sb, _SB_I_NOUMASK); +sb_set_iflag (sb,SB_I_NOUMASK ); sb->s_time_gran =1 ; sb->s_time_min =S64_MIN ; sb->s_time_max =S64_MAX ;fs/overlayfs/super.c +3
-3@@ -1453,14 +1453,14 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc)#ifdef CONFIG_FS_POSIX_ACL sb->s_flags |=SB_POSIXACL ;#endif -sb_set_iflag (sb, _SB_I_SKIP_SYNC); +sb_set_iflag (sb,SB_I_SKIP_SYNC );/* * Ensure that umask handling is done by the filesystems used * for the the upper layer instead of overlayfs as that would * lead to unexpected results. */ -sb_set_iflag (sb, _SB_I_NOUMASK); -sb_set_iflag (sb, _SB_I_EVM_HMAC_UNSUPPORTED); +sb_set_iflag (sb,SB_I_NOUMASK ); +sb_set_iflag (sb,SB_I_EVM_HMAC_UNSUPPORTED ); err = -ENOMEM ; root_dentry =ovl_get_root (sb, ctx->upper.dentry, oe);fs/proc/root.c +3
-3@@ -171,9 +171,9 @@ static int proc_fill_super(struct super_block *s, struct fs_context *fc)proc_apply_options (fs_info, fc,current_user_ns ());/* User space would break if executables or devices appear on proc */ -sb_set_iflag (s, _SB_I_USERNS_VISIBLE); -sb_set_iflag (s, _SB_I_NOEXEC); -sb_set_iflag (s, _SB_I_NODEV); +sb_set_iflag (s,SB_I_USERNS_VISIBLE ); +sb_set_iflag (s,SB_I_NOEXEC ); +sb_set_iflag (s,SB_I_NODEV ); s->s_flags |=SB_NODIRATIME |SB_NOSUID |SB_NOEXEC ; s->s_blocksize =1024 ; s->s_blocksize_bits =10 ;fs/super.c +9
-9@@ -355,7 +355,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_bdi = &noop_backing_dev_info; s->s_flags = flags;if (s->s_user_ns != &init_user_ns) -sb_set_iflag (s, _SB_I_NODEV); +sb_set_iflag (s,SB_I_NODEV );INIT_HLIST_NODE (&s->s_instances);INIT_HLIST_BL_HEAD (&s->s_roots);mutex_init (&s->s_sync_lock);@@ -589,11 +589,11 @@ void retire_super(struct super_block *sb) {WARN_ON (!sb->s_bdev);__super_lock_excl (sb); -if (sb_test_iflag (sb, _SB_I_PERSB_BDI)) { +if (sb_test_iflag (sb,SB_I_PERSB_BDI )) {bdi_unregister (sb->s_bdi); -sb_clear_iflag (sb, _SB_I_PERSB_BDI); +sb_clear_iflag (sb,SB_I_PERSB_BDI ); } -sb_set_iflag (sb, _SB_I_RETIRED); +sb_set_iflag (sb,SB_I_RETIRED );super_unlock_excl (sb); }EXPORT_SYMBOL (retire_super);@@ -678,7 +678,7 @@ void generic_shutdown_super(struct super_block *sb)super_wake (sb,SB_DYING );super_unlock_excl (sb);if (sb->s_bdi != &noop_backing_dev_info) { -if (sb_test_iflag (sb, _SB_I_PERSB_BDI)) +if (sb_test_iflag (sb,SB_I_PERSB_BDI ))bdi_unregister (sb->s_bdi);bdi_put (sb->s_bdi); sb->s_bdi = &noop_backing_dev_info;@@ -1331,7 +1331,7 @@ static int super_s_dev_set(struct super_block *s, struct fs_context *fc)static int super_s_dev_test (struct super_block *s,struct fs_context *fc) { -return !sb_test_iflag (s, _SB_I_RETIRED) && +return !sb_test_iflag (s,SB_I_RETIRED ) && s->s_dev == *(dev_t *)fc->sget_key; }@@ -1584,7 +1584,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, sb->s_bdev = bdev; sb->s_bdi =bdi_get (bdev->bd_disk->bdi);if (bdev_stable_writes (bdev)) -sb_set_iflag (sb, _SB_I_STABLE_WRITES); +sb_set_iflag (sb,SB_I_STABLE_WRITES );spin_unlock (&sb_lock);snprintf (sb->s_id,sizeof (sb->s_id),"%pg" , bdev);@@ -1648,7 +1648,7 @@ EXPORT_SYMBOL(get_tree_bdev);static int test_bdev_super (struct super_block *s,void *data) { -return !sb_test_iflag (s, _SB_I_RETIRED) && s->s_dev == *(dev_t *)data; +return !sb_test_iflag (s,SB_I_RETIRED ) && s->s_dev == *(dev_t *)data; } struct dentry *mount_bdev(struct file_system_type *fs_type,@@ -1864,7 +1864,7 @@ int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) }WARN_ON (sb->s_bdi != &noop_backing_dev_info); sb->s_bdi = bdi; -sb_set_iflag (sb, _SB_I_PERSB_BDI); +sb_set_iflag (sb,SB_I_PERSB_BDI );return 0 ; }fs/sync.c +1
-1@@ -79,7 +79,7 @@ static void sync_inodes_one_sb(struct super_block *sb, void *arg)static void sync_fs_one_sb (struct super_block *sb,void *arg) { -if (!sb_rdonly (sb) && !sb_test_iflag (sb, _SB_I_SKIP_SYNC) && +if (!sb_rdonly (sb) && !sb_test_iflag (sb,SB_I_SKIP_SYNC ) && sb->s_op->sync_fs) sb->s_op->sync_fs (sb, *(int *)arg); }fs/sysfs/mount.c +1
-1@@ -33,7 +33,7 @@ static int sysfs_get_tree(struct fs_context *fc)return ret;if (kfc->new_sb_created) -sb_set_iflag (fc->root->d_sb, _SB_I_USERNS_VISIBLE); +sb_set_iflag (fc->root->d_sb,SB_I_USERNS_VISIBLE );return 0 ; }fs/xfs/xfs_super.c +1
-1@@ -1701,7 +1701,7 @@ xfs_fs_fill_super( sb->s_time_max =XFS_LEGACY_TIME_MAX ; }trace_xfs_inode_timestamp_range (mp, sb->s_time_min, sb->s_time_max); -sb_set_iflag (sb, _SB_I_CGROUPWB); +sb_set_iflag (sb,SB_I_CGROUPWB );set_posix_acl_flag (sb);include/linux/backing-dev.h +1
-1@@ -176,7 +176,7 @@ static inline bool inode_cgwb_enabled(struct inode *inode)return cgroup_subsys_on_dfl (memory_cgrp_subsys) &&cgroup_subsys_on_dfl (io_cgrp_subsys) && (bdi->capabilities &BDI_CAP_WRITEBACK ) && -sb_test_iflag (inode->i_sb, _SB_I_CGROUPWB); +sb_test_iflag (inode->i_sb,SB_I_CGROUPWB ); }/** include/linux/fs.h +14
-14@@ -1174,22 +1174,22 @@ extern int send_sigurg(struct fown_struct *fown);/* sb->s_iflags */ enum { - _SB_I_CGROUPWB,/* cgroup-aware writeback enabled */ - _SB_I_NOEXEC,/* Ignore executables on this fs */ - _SB_I_NODEV,/* Ignore devices on this fs */ - _SB_I_STABLE_WRITES,/* don't modify blks until WB is done */ +SB_I_CGROUPWB ,/* cgroup-aware writeback enabled */ +SB_I_NOEXEC ,/* Ignore executables on this fs */ +SB_I_NODEV ,/* Ignore devices on this fs */ +SB_I_STABLE_WRITES ,/* don't modify blks until WB is done */ /* sb->s_iflags to limit user namespace mounts */ - _SB_I_USERNS_VISIBLE,/* fstype already mounted */ - _SB_I_IMA_UNVERIFIABLE_SIGNATURE, - _SB_I_UNTRUSTED_MOUNTER, - _SB_I_EVM_HMAC_UNSUPPORTED, - - _SB_I_SKIP_SYNC,/* Skip superblock at global sync */ - _SB_I_PERSB_BDI,/* has a per-sb bdi */ - _SB_I_TS_EXPIRY_WARNED,/* warned about timestamp range expiry */ - _SB_I_RETIRED,/* superblock shouldn't be reused */ - _SB_I_NOUMASK,/* VFS does not apply umask */ +SB_I_USERNS_VISIBLE ,/* fstype already mounted */ +SB_I_IMA_UNVERIFIABLE_SIGNATURE , +SB_I_UNTRUSTED_MOUNTER , +SB_I_EVM_HMAC_UNSUPPORTED , + +SB_I_SKIP_SYNC ,/* Skip superblock at global sync */ +SB_I_PERSB_BDI ,/* has a per-sb bdi */ +SB_I_TS_EXPIRY_WARNED ,/* warned about timestamp range expiry */ +SB_I_RETIRED ,/* superblock shouldn't be reused */ +SB_I_NOUMASK ,/* VFS does not apply umask */ };/* Possible states of 'frozen' field */ include/linux/namei.h +1
-1@@ -107,7 +107,7 @@ extern void unlock_rename(struct dentry *, struct dentry *);*/ static inline umode_t __must_check mode_strip_umask (const struct inode *dir,umode_t mode) { -if (!IS_POSIXACL (dir) && !sb_test_iflag (dir->i_sb, _SB_I_NOUMASK)) +if (!IS_POSIXACL (dir) && !sb_test_iflag (dir->i_sb,SB_I_NOUMASK )) mode &= ~current_umask ();return mode; }ipc/mqueue.c +2
-2@@ -406,8 +406,8 @@ static int mqueue_fill_super(struct super_block *sb, struct fs_context *fc)struct inode *inode;struct ipc_namespace *ns = sb->s_fs_info; -sb_set_iflag (sb, _SB_I_NOEXEC); -sb_set_iflag (sb, _SB_I_NODEV); +sb_set_iflag (sb,SB_I_NOEXEC ); +sb_set_iflag (sb,SB_I_NODEV ); sb->s_blocksize =PAGE_SIZE ; sb->s_blocksize_bits =PAGE_SHIFT ; sb->s_magic =MQUEUE_MAGIC ;security/integrity/evm/evm_main.c +1
-1@@ -155,7 +155,7 @@ static int is_unsupported_hmac_fs(struct dentry *dentry) {struct inode *inode =d_backing_inode (dentry); -if (sb_test_iflag (inode->i_sb, _SB_I_EVM_HMAC_UNSUPPORTED)) { +if (sb_test_iflag (inode->i_sb,SB_I_EVM_HMAC_UNSUPPORTED )) {pr_info_once ("%s not supported\n" , inode->i_sb->s_type->name);return 1 ; }security/integrity/ima/ima_appraise.c +2
-2@@ -564,8 +564,8 @@ int ima_appraise_measurement(enum ima_hooks func, struct ima_iint_cache *iint,* system not willing to accept such a risk, fail the file signature * verification. */ -if (sb_test_iflag (inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && - (sb_test_iflag (inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) || +if (sb_test_iflag (inode->i_sb,SB_I_IMA_UNVERIFIABLE_SIGNATURE ) && + (sb_test_iflag (inode->i_sb,SB_I_UNTRUSTED_MOUNTER ) || (iint->flags &IMA_FAIL_UNVERIFIABLE_SIGS ))) { status =INTEGRITY_FAIL ; cause ="unverifiable-signature" ;security/integrity/ima/ima_main.c +2
-3@@ -280,8 +280,8 @@ static int process_measurement(struct file *file, const struct cred *cred,* (Limited to privileged mounted filesystems.) */ if (test_and_clear_bit (IMA_CHANGE_XATTR , &iint->atomic_flags) || - (sb_test_iflag (inode->i_sb, _SB_I_IMA_UNVERIFIABLE_SIGNATURE) && - !sb_test_iflag (inode->i_sb, _SB_I_UNTRUSTED_MOUNTER) && + (sb_test_iflag (inode->i_sb,SB_I_IMA_UNVERIFIABLE_SIGNATURE ) && + !sb_test_iflag (inode->i_sb,SB_I_UNTRUSTED_MOUNTER ) && !(action &IMA_FAIL_UNVERIFIABLE_SIGS ))) { iint->flags &= ~IMA_DONE_MASK ; iint->measured_pcrs =0 ; --2.35.3
Christian Brauner
maintainerRe: [PATCH 06/13] fs: Drop unnecessary underscore from _SB_I_ constants
Quoted 17 lines · Darrick J. Wong
Quoted 7 lines · Amir Goldstein
Quoted 5 lines · Jan Kara
Now that old constants are gone, remove the unnecessary underscore from the new _SB_I_ constants. Pure mechanical replacement, no functional changes.
Quoted 8 lines
This is a potential backporting bomb.
It is true that code using the old constant names with new macros will not build on stable kernels, but I think this is still asking for trouble.Also, it is a bit strange that SB_* flags are bit masks and SB_I_* flags are bit numbers.
How about leaving the underscore and using sb_*_iflag() macros to add the underscore?
Quoted 4 lines
Or append
_BITto the new names, as is sometimes done elsewhere in the kernel?#define
SB_I_VERSION_BIT23
Yeah, that's better (Fwiw, SB_I_VERSION is confusingly not an sb->i_flags. I complained about this when it was added.).
I don't want to end up with the same confusion that we have for __I_NEW/I_NEW and __I_SYNC/I_SYNC which trips me up every so often when I read that code.
So t probably wouldn't be the worst if we had:
#define SB_I_NODEV_BIT 3
#define SB_I_NODEV BIT(SB_I_NODEV_BIT)
so filesystems that raise that flag when they're initialized can do:
sb->i_flags |= SB_I_NODEV;
and not pointlessly make them do:
sb->i_flags |= 1 << SB_I_NODEV_BIT;
Jan Kara
maintainerRe: [PATCH 06/13] fs: Drop unnecessary underscore from _SB_I_ constants
Quoted 21 lines · Christian Brauner
Quoted 20 lines · Darrick J. Wong
Quoted 7 lines · Amir Goldstein
Quoted 5 lines · Jan Kara
Now that old constants are gone, remove the unnecessary underscore from the new _SB_I_ constants. Pure mechanical replacement, no functional changes.
Quoted 8 lines
This is a potential backporting bomb.
It is true that code using the old constant names with new macros will not build on stable kernels, but I think this is still asking for trouble.Also, it is a bit strange that SB_* flags are bit masks and SB_I_* flags are bit numbers.
How about leaving the underscore and using sb_*_iflag() macros to add the underscore?Or append
_BITto the new names, as is sometimes done elsewhere in the kernel?
Quoted 8 lines
Quoted 1 line
#define
SB_I_VERSION_BIT23Yeah, that's better (Fwiw,
SB_I_VERSIONis confusingly not ansb->i_flags. I complained about this when it was added.).I don't want to end up with the same confusion that we have for __I_NEW/I_NEW and __I_SYNC/I_SYNC which trips me up every so often when I read that code.
OK, _BIT suffix sounds nice.
Quoted 5 lines
So t probably wouldn't be the worst if we had:
#define
SB_I_NODEV_BIT3
#defineSB_I_NODEVBIT(SB_I_NODEV_BIT)
Quoted 7 lines
so filesystems that raise that flag when they're initialized can do:
sb->i_flags|=SB_I_NODEV;and not pointlessly make them do:
sb->i_flags|= 1 <<SB_I_NODEV_BIT;
Well, all sb->i_flags modifications should be using sb_set_iflag() / sb_clear_iflag(). I know it is unnecessarily more expensive in some cases but none of those paths is really that performance sensitive. The only (three) places where we have expression like 1 << SB_I_<foo>_BIT are there because the flags are also used for fc->s_iflags.
I think that keeping SB_I_NODEV around together with SB_I_NODEV_BIT makes it easier to write code like sb->i_flags |= val without thinking twice and the three callsites that would be simplified are not really worth it. But if someone feels strongly about this, I can live with it.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
maintainerPATCH 7/13 overlayfs: Make ovl_start_write() return error
In reply to Jan Karasb_start_write() will be returning error for a shutdown filesystem. Teach all ovl_start_write() to handle the error and bail out.
--- fs/overlayfs/copy_up.c | 42 +++++++++++++++++++++++++++++++--------- fs/overlayfs/overlayfs.h | 2 +- fs/overlayfs/util.c | 3 ++- 3 files changed, 36 insertions(+), 11 deletions(-)
fs/overlayfs/copy_up.c +33 -9
@@ -584,7 +584,9 @@ static int ovl_link_up(struct ovl_copy_up_ctx *c)struct ovl_fs *ofs =OVL_FS (c->dentry->d_sb);struct inode *udir =d_inode (upperdir); -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) +return err;/* Mark parent "impure" because it may now contain non-pure upper */ err =ovl_set_impure (c->parent, upperdir);
@@ -744,6 +746,7 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)struct path path = { .mnt =ovl_upper_mnt (ofs) };struct dentry *temp, *upper, *trap;struct ovl_cu_creds cc; +bool frozen = false;int err;struct ovl_cattr cattr = {/* Can't properly set mode on creation because of the umask */
@@ -756,7 +759,11 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)if (err)return err; -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) { +ovl_revert_cu_creds (&cc); +return err; + }inode_lock (wdir); temp =ovl_create_temp (ofs, c->workdir, &cattr);inode_unlock (wdir);
@@ -778,7 +785,10 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)* ovl_copy_up_data(), so lock workdir and destdir and make sure that * temp wasn't moved before copy up completion or cleanup. */ -ovl_start_write (c->dentry); +if (!err) { + err =ovl_start_write (c->dentry); + frozen = !err; + } trap =lock_rename (c->workdir, c->destdir);if (trap || temp->d_parent != c->workdir) {/* temp or workdir moved underneath us? abort without cleanup */
@@ -827,7 +837,8 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c) unlock:unlock_rename (c->workdir, c->destdir); out: -ovl_end_write (c->dentry); +if (frozen) +ovl_end_write (c->dentry);return err;
@@ -851,7 +862,11 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c)if (err)return err; -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) { +ovl_revert_cu_creds (&cc); +return err; + } tmpfile =ovl_do_tmpfile (ofs, c->workdir, c->stat.mode);ovl_end_write (c->dentry);ovl_revert_cu_creds (&cc);
@@ -865,7 +880,9 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c) goto out_fput; } -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) + goto out_fput; err =ovl_copy_up_metadata (c, temp);if (err)
@@ -964,7 +981,9 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)* Mark parent "impure" because it may now contain non-pure * upper */ -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) + goto out_free_fh; err =ovl_set_impure (c->parent, c->destdir);ovl_end_write (c->dentry);if (err)
@@ -982,7 +1001,9 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)if (c->indexed)ovl_set_flag (OVL_INDEX ,d_inode (c->dentry)); -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) + goto out;if (to_index) {/* Initialize nlink for copy up of disconnected dentry */ err =ovl_set_nlink_upper (c->dentry);
@@ -1088,7 +1109,10 @@ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c)* Writing to upper file will clear security.capability xattr. We * don't want that to happen for normal copy-up operation. */ -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) + goto out_free; +if (capability) { err =ovl_do_setxattr (ofs, upperpath.dentry,XATTR_NAME_CAPS , capability, cap_size,0 );
fs/overlayfs/overlayfs.h +1 -1
@@ -423,7 +423,7 @@ static inline int ovl_do_getattr(const struct path *path, struct kstat *stat,/* util.c */ int ovl_get_write_access (struct dentry *dentry);void ovl_put_write_access (struct dentry *dentry); -void ovl_start_write (struct dentry *dentry); +int __must_check ovl_start_write (struct dentry *dentry);void ovl_end_write (struct dentry *dentry);int ovl_want_write (struct dentry *dentry);void ovl_drop_write (struct dentry *dentry);
fs/overlayfs/util.c +2 -1
@@ -25,10 +25,11 @@ int ovl_get_write_access(struct dentry *dentry) }/* Get write access to upper sb - may block if upper sb is frozen */ -void ovl_start_write (struct dentry *dentry) +int __must_check ovl_start_write (struct dentry *dentry) {struct ovl_fs *ofs =OVL_FS (dentry->d_sb);sb_start_write (ovl_upper_mnt (ofs)->mnt_sb); +return 0 ; }int ovl_want_write (struct dentry *dentry)
Signature · 1 line
2.35.3
Amir Goldstein
maintainerRe: [PATCH 07/13] overlayfs: Make ovl_start_write() return error
Quoted 27 lines · Jan Kara
sb_start_write()will be returning error for a shutdown filesystem. Teach allovl_start_write()to handle the error and bail out.Signed-off-by Jan Kara <[email protected]>--- fs/overlayfs/copy_up.c | 42 +++++++++++++++++++++++++++++++--------- fs/overlayfs/overlayfs.h | 2 +- fs/overlayfs/util.c | 3 ++- 3 files changed, 36 insertions(+), 11 deletions(-)fs/overlayfs/copy_up.c +3
-1@@ -584,7 +584,9 @@ static int ovl_link_up(struct ovl_copy_up_ctx *c)struct ovl_fs *ofs =OVL_FS (c->dentry->d_sb);struct inode *udir =d_inode (upperdir); -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) +return err;/* Mark parent "impure" because it may now contain non-pure upper */ err =ovl_set_impure (c->parent, upperdir);
fs/overlayfs/copy_up.c static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c) · line 749
Quoted 4 lines
fs/overlayfs/copy_up.c +1
-0@@ -744,6 +746,7 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)struct path path = { .mnt =ovl_upper_mnt (ofs) };struct dentry *temp, *upper, *trap;struct ovl_cu_creds cc; +bool frozen = false;
frozen is not a descriptive name for taking sb_writers?
Quoted 17 lines
fs/overlayfs/copy_up.c +5
-1int err;struct ovl_cattr cattr = {/* Can't properly set mode on creation because of the umask */ @@ -756,7 +759,11 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)if (err)return err; -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) { +ovl_revert_cu_creds (&cc); +return err; + }inode_lock (wdir); temp =ovl_create_temp (ofs, c->workdir, &cattr);inode_unlock (wdir);
fs/overlayfs/copy_up.c static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c) · line 788
Quoted 5 lines
fs/overlayfs/copy_up.c +1
-1@@ -778,7 +785,10 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)* ovl_copy_up_data(), so lock workdir and destdir and make sure that * temp wasn't moved before copy up completion or cleanup. */ -ovl_start_write (c->dentry); +if (!err) {
This is confusing, I admit, but !err is not checked because ovl_cleanup() needs sb_writers held.
Suggest something like:
err2 = ovl_start_write(c->dentry);
if (err2) {
dput(temp);
return err ?: err2;
}Quoted 92 lines
fs/overlayfs/copy_up.c +23
-6+ err =ovl_start_write (c->dentry); + frozen = !err; + } trap =lock_rename (c->workdir, c->destdir);if (trap || temp->d_parent != c->workdir) {/* temp or workdir moved underneath us? abort without cleanup */ @@ -827,7 +837,8 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c) unlock:unlock_rename (c->workdir, c->destdir); out: -ovl_end_write (c->dentry); +if (frozen) +ovl_end_write (c->dentry);return err;@@ -851,7 +862,11 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c)if (err)return err; -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) { +ovl_revert_cu_creds (&cc); +return err; + } tmpfile =ovl_do_tmpfile (ofs, c->workdir, c->stat.mode);ovl_end_write (c->dentry);ovl_revert_cu_creds (&cc);@@ -865,7 +880,9 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c) goto out_fput; } -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) + goto out_fput; err =ovl_copy_up_metadata (c, temp);if (err)@@ -964,7 +981,9 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)* Mark parent "impure" because it may now contain non-pure * upper */ -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) + goto out_free_fh; err =ovl_set_impure (c->parent, c->destdir);ovl_end_write (c->dentry);if (err)@@ -982,7 +1001,9 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)if (c->indexed)ovl_set_flag (OVL_INDEX ,d_inode (c->dentry)); -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) + goto out;if (to_index) {/* Initialize nlink for copy up of disconnected dentry */ err =ovl_set_nlink_upper (c->dentry);@@ -1088,7 +1109,10 @@ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c)* Writing to upper file will clear security.capability xattr. We * don't want that to happen for normal copy-up operation. */ -ovl_start_write (c->dentry); + err =ovl_start_write (c->dentry); +if (err) + goto out_free; +if (capability) { err =ovl_do_setxattr (ofs, upperpath.dentry,XATTR_NAME_CAPS , capability, cap_size,0 );fs/overlayfs/overlayfs.h +1
-1@@ -423,7 +423,7 @@ static inline int ovl_do_getattr(const struct path *path, struct kstat *stat,/* util.c */ int ovl_get_write_access (struct dentry *dentry);void ovl_put_write_access (struct dentry *dentry); -void ovl_start_write (struct dentry *dentry); +int __must_check ovl_start_write (struct dentry *dentry);void ovl_end_write (struct dentry *dentry);int ovl_want_write (struct dentry *dentry);void ovl_drop_write (struct dentry *dentry);fs/overlayfs/util.c +0
-0
fs/overlayfs/util.c int ovl_get_write_access(struct dentry *dentry) · line 33
Quoted 10 lines
fs/overlayfs/util.c +2
-1@@ -25,10 +25,11 @@ int ovl_get_write_access(struct dentry *dentry) }/* Get write access to upper sb - may block if upper sb is frozen */ -void ovl_start_write (struct dentry *dentry) +int __must_check ovl_start_write (struct dentry *dentry) {struct ovl_fs *ofs =OVL_FS (dentry->d_sb);sb_start_write (ovl_upper_mnt (ofs)->mnt_sb); +return 0 ; }
Is this an unintentional omission of sb_start_write() return value or fixed later on?
Thanks,
Amir.
Jan Kara
maintainerPATCH 8/13 fs: Teach callers of kiocb_start_write() to handle errors
In reply to Jan Karasb_start_write() will be returning error on shutdown filesystem. Teach callers of kiocb_start_write() to handle the error.
--- fs/aio.c | 14 +++++++++----- fs/read_write.c | 4 +++- include/linux/fs.h | 3 ++- io_uring/rw.c | 7 +++++-- 4 files changed, 19 insertions(+), 9 deletions(-)
fs/aio.c +9 -5
@@ -1626,12 +1626,16 @@ static int aio_write(struct kiocb *req, const struct iocb *iocb,if (ret <0 )return ret; ret =rw_verify_area (WRITE , file, &req->ki_pos,iov_iter_count (&iter)); -if (!ret) { -if (S_ISREG (file_inode (file)->i_mode)) -kiocb_start_write (req); - req->ki_flags |=IOCB_WRITE ; -aio_rw_done (req, file->f_op->write_iter (req, &iter)); +if (unlikely (ret)) + goto out; +if (S_ISREG (file_inode (file)->i_mode)) { + ret =kiocb_start_write (req); +if (unlikely (ret)) + goto out; } + req->ki_flags |=IOCB_WRITE ; +aio_rw_done (req, file->f_op->write_iter (req, &iter)); +out:kfree (iovec);return ret; }
fs/read_write.c +3 -1
@@ -859,7 +859,9 @@ ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb,if (ret <0 )return ret; -kiocb_start_write (iocb); + ret =kiocb_start_write (iocb); +if (ret <0 ) +return ret; ret = file->f_op->write_iter (iocb, iter);if (ret != -EIOCBQUEUED )kiocb_end_write (iocb);
include/linux/fs.h +2 -1
@@ -2920,7 +2920,7 @@ static inline void file_end_write(struct file *file)* This is a variant of sb_start_write() for async io submission. * Should be matched with a call to kiocb_end_write(). */ -static inline void kiocb_start_write (struct kiocb *iocb) +static inline int __must_check kiocb_start_write (struct kiocb *iocb) {struct inode *inode =file_inode (iocb->ki_filp);
@@ -2930,6 +2930,7 @@ static inline void kiocb_start_write(struct kiocb *iocb)* doesn't complain about the held lock when we return to userspace. */ __sb_writers_release (inode->i_sb,SB_FREEZE_WRITE ); +return 0 ; }/**
io_uring/rw.c +5 -2
@@ -1040,8 +1040,11 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)if (unlikely (ret))return ret; -if (req->flags &REQ_F_ISREG ) -kiocb_start_write (kiocb); +if (req->flags &REQ_F_ISREG ) { + ret =kiocb_start_write (kiocb); +if (unlikely (ret)) +return ret; + } kiocb->ki_flags |=IOCB_WRITE ;if (likely (req->file->f_op->write_iter))
Signature · 1 line
2.35.3
Jan Kara
maintainerPATCH 9/13 fs: Teach callers of file_start_write() to handle errors
In reply to Jan Karasb_start_write() will be returning error on shutdown filesystem. Teach callers of file_start_write() to handle the error.
--- fs/backing-file.c | 4 +++- fs/btrfs/ioctl.c | 4 +++- fs/coredump.c | 4 +++- fs/open.c | 4 +++- fs/read_write.c | 20 +++++++++++++++----- fs/remap_range.c | 4 +++- fs/splice.c | 8 ++++++-- fs/xfs/xfs_exchrange.c | 4 +++- include/linux/fs.h | 5 +++-- 9 files changed, 42 insertions(+), 15 deletions(-)
fs/backing-file.c +3 -1
@@ -308,7 +308,9 @@ ssize_t backing_file_splice_write(struct pipe_inode_info *pipe,return ret; old_cred =override_creds (ctx->cred); -file_start_write (out); + ret =file_start_write (out); +if (ret) +return ret; ret =iter_file_splice_write (pipe, out, ppos, len, flags);file_end_write (out);revert_creds (old_cred);
fs/btrfs/ioctl.c +3 -1
@@ -4676,7 +4676,9 @@ static int btrfs_ioctl_encoded_write(struct file *file, void __user *argp, bool goto out_iov; kiocb.ki_pos = pos; -file_start_write (file); + ret =file_start_write (file); +if (ret <0 ) + goto out_iov; ret =btrfs_do_write_iter (&kiocb, &iter, &args);if (ret >0 )
fs/coredump.c +3 -1
@@ -763,7 +763,9 @@ void do_coredump(const kernel_siginfo_t *siginfo)if (!dump_vma_snapshot (&cprm)) goto close_fail; -file_start_write (cprm.file); + retval =file_start_write (cprm.file); +if (retval) + goto close_fail; core_dumped = binfmt->core_dump (&cprm);/* * Ensures that file size is big enough to contain the current
fs/open.c +3 -1
@@ -330,7 +330,9 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)if (!file->f_op->fallocate)return -EOPNOTSUPP ; -file_start_write (file); + ret =file_start_write (file); +if (ret) +return ret; ret = file->f_op->fallocate (file, mode, offset, len);/*
fs/read_write.c +15 -5
@@ -560,7 +560,9 @@ ssize_t kernel_write(struct file *file, const void *buf, size_t count,if (ret)return ret; -file_start_write (file); + ret =file_start_write (file); +if (ret) +return ret; ret =__kernel_write (file, buf, count, pos);file_end_write (file);return ret;
@@ -583,7 +585,9 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_return ret;if (count >MAX_RW_COUNT ) count =MAX_RW_COUNT ; -file_start_write (file); + ret =file_start_write (file); +if (ret) +return ret;if (file->f_op->write) ret = file->f_op->write (file, buf, count, pos);else if (file->f_op->write_iter)
@@ -893,7 +897,9 @@ ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos,if (ret <0 )return ret; -file_start_write (file); + ret =file_start_write (file); +if (ret) +return ret; ret =do_iter_readv_writev (file, iter, ppos,WRITE , flags);if (ret >0 )fsnotify_modify (file);
@@ -968,7 +974,9 @@ static ssize_t vfs_writev(struct file *file, const struct iovec __user *vec,if (ret <0 ) goto out; -file_start_write (file); + ret =file_start_write (file); +if (ret <0 ) + goto out;if (file->f_op->write_iter) ret =do_iter_readv_writev (file, &iter, pos,WRITE , flags);else
@@ -1509,7 +1517,9 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in,if (len ==0 )return 0 ; -file_start_write (file_out); + ret =file_start_write (file_out); +if (unlikely (ret)) +return ret;/* * Cloning is supported by more file systems, so we implement copy on
fs/remap_range.c +3 -1
@@ -399,7 +399,9 @@ loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in,if (ret)return ret; -file_start_write (file_out); + ret =file_start_write (file_out); +if (ret) +return ret; ret = file_in->f_op->remap_file_range (file_in, pos_in, file_out, pos_out, len, remap_flags);file_end_write (file_out);
fs/splice.c +6 -2
@@ -1160,7 +1160,9 @@ static int direct_splice_actor(struct pipe_inode_info *pipe,struct file *file = sd->u.file;long ret; -file_start_write (file); + ret =file_start_write (file); +if (ret) +return ret; ret =do_splice_from (pipe, file, sd->opos, sd->total_len, sd->flags);file_end_write (file);return ret;
@@ -1350,7 +1352,9 @@ ssize_t do_splice(struct file *in, loff_t *off_in, struct file *out,if (in->f_flags &O_NONBLOCK ) flags |=SPLICE_F_NONBLOCK ; -file_start_write (out); + ret =file_start_write (out); +if (unlikely (ret)) +return ret; ret =do_splice_from (ipipe, out, &offset, len, flags);file_end_write (out);
fs/xfs/xfs_exchrange.c +3 -1
@@ -756,7 +756,9 @@ xfs_exchange_range(if (!(fxr->file2->f_mode &FMODE_NOCMTIME ) && !IS_NOCMTIME (inode2)) fxr->flags |= __XFS_EXCHANGE_RANGE_UPD_CMTIME2; -file_start_write (fxr->file2); + ret =file_start_write (fxr->file2); +if (ret) +return ret; ret =xfs_exchrange_contents (fxr);file_end_write (fxr->file2);if (ret)
include/linux/fs.h +3 -2
@@ -2886,11 +2886,12 @@ static inline bool inode_wrong_type(const struct inode *inode, umode_t mode)* This is a variant of sb_start_write() which is a noop on non-regualr file. * Should be matched with a call to file_end_write(). */ -static inline void file_start_write (struct file *file) +static inline int __must_check file_start_write (struct file *file) {if (!S_ISREG (file_inode (file)->i_mode)) -return ; +return 0 ;sb_start_write (file_inode (file)->i_sb); +return 0 ; }static inline bool file_start_write_trylock (struct file *file)
Signature · 1 line
2.35.3
Jan Kara
maintainerPATCH 10/13 fs: Add __must_check annotations to sb_start_write_trylock() and similar
In reply to Jan KaraThe callers of sb_start_write_trylock(), sb_start_intwrite_trylock(), file_start_write_trylock() must check the return value to figure out whether the protection has been acquired (and thus must be dropped) or not. Add __must_check annotation to these functions to catch forgotten checks early.
--- include/linux/fs.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
include/linux/fs.h +4 -3
@@ -1828,7 +1828,7 @@ static inline void sb_start_write(struct super_block *sb)__sb_start_write (sb,SB_FREEZE_WRITE ); } -static inline bool sb_start_write_trylock (struct super_block *sb) +static inline bool __must_check sb_start_write_trylock (struct super_block *sb) {return __sb_start_write_trylock (sb,SB_FREEZE_WRITE ); }
@@ -1875,7 +1875,8 @@ static inline void sb_start_intwrite(struct super_block *sb)__sb_start_write (sb,SB_FREEZE_FS ); } -static inline bool sb_start_intwrite_trylock (struct super_block *sb) +static inline bool __must_check sb_start_intwrite_trylock ( +struct super_block *sb) {return __sb_start_write_trylock (sb,SB_FREEZE_FS ); }
@@ -2894,7 +2895,7 @@ static inline int __must_check file_start_write(struct file *file)return 0 ; } -static inline bool file_start_write_trylock (struct file *file) +static inline bool __must_check file_start_write_trylock (struct file *file) {if (!S_ISREG (file_inode (file)->i_mode))return true;
Signature · 1 line
2.35.3
Jan Kara
maintainerPATCH 11/13 fs: Make sb_start_write() return error on shutdown filesystem
In reply to Jan KaraIntroduce new SB_I_SHUTDOWN flag that a filesystem can set when it is forcefully shutting down (usually due to errors). Make sb_start_write() return errors for such superblocks to avoid modifications to it which reduces noise in the error logs and generally makes life somewhat easier for filesystems. We teach all sb_start_write() callers to handle the error.
--- fs/btrfs/block-group.c | 3 ++- fs/btrfs/defrag.c | 6 +++++- fs/btrfs/volumes.c | 13 +++++++++---- fs/ext4/mmp.c | 4 +++- fs/namespace.c | 8 ++++++-- fs/open.c | 4 +++- fs/overlayfs/util.c | 3 +-- fs/quota/quota.c | 4 ++-- fs/xfs/xfs_ioctl.c | 4 +++- include/linux/fs.h | 16 ++++++++++++---- 10 files changed, 46 insertions(+), 19 deletions(-)
fs/btrfs/block-group.c +2 -1
@@ -1800,7 +1800,8 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)if (!btrfs_should_reclaim (fs_info))return ; -sb_start_write (fs_info->sb); +if (sb_start_write (fs_info->sb) <0 ) +return ;if (!btrfs_exclop_start (fs_info,BTRFS_EXCLOP_BALANCE )) {sb_end_write (fs_info->sb);
fs/btrfs/defrag.c +5 -1
@@ -274,7 +274,11 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info, range.start = cur; range.extent_thresh = defrag->extent_thresh; -sb_start_write (fs_info->sb); + ret =sb_start_write (fs_info->sb); +if (ret <0 ) { +iput (inode); + goto cleanup; + } ret =btrfs_defrag_file (inode,NULL , &range, defrag->transid,BTRFS_DEFRAG_BATCH );sb_end_write (fs_info->sb);
fs/btrfs/volumes.c +9 -4
@@ -4589,9 +4589,11 @@ int btrfs_balance(struct btrfs_fs_info *fs_info,static int balance_kthread (void *data) {struct btrfs_fs_info *fs_info = data; -int ret =0 ; +int ret; -sb_start_write (fs_info->sb); + ret =sb_start_write (fs_info->sb); +if (ret <0 ) +return ret;mutex_lock (&fs_info->balance_mutex);if (fs_info->balance_ctl) ret =btrfs_balance (fs_info, fs_info->balance_ctl,NULL );
@@ -8231,12 +8233,15 @@ static int relocating_repair_kthread(void *data)struct btrfs_block_group *cache = data;struct btrfs_fs_info *fs_info = cache->fs_info;u64 target; -int ret =0 ; +int ret; target = cache->start;btrfs_put_block_group (cache); -sb_start_write (fs_info->sb); + ret =sb_start_write (fs_info->sb); +if (ret <0 ) +return ret; +if (!btrfs_exclop_start (fs_info,BTRFS_EXCLOP_BALANCE )) { btrfs_info(fs_info, "zoned: skip relocating block group %llu to repair: EBUSY",
fs/ext4/mmp.c +3 -1
@@ -63,7 +63,9 @@ static int write_mmp_block(struct super_block *sb, struct buffer_head *bh)* We protect against freezing so that we don't create dirty buffers * on frozen filesystem. */ -sb_start_write (sb); + err =sb_start_write (sb); +if (err <0 ) +return err; err =write_mmp_block_thawed (sb, bh);sb_end_write (sb);return err;
fs/namespace.c +6 -2
@@ -512,7 +512,9 @@ int mnt_want_write(struct vfsmount *m) {int ret; -sb_start_write (m->mnt_sb); + ret =sb_start_write (m->mnt_sb); +if (ret) +return ret; ret =mnt_get_write_access (m);if (ret)sb_end_write (m->mnt_sb);
@@ -556,7 +558,9 @@ int mnt_want_write_file(struct file *file) {int ret; -sb_start_write (file_inode (file)->i_sb); + ret =sb_start_write (file_inode (file)->i_sb); +if (ret) +return ret; ret =mnt_get_write_access_file (file);if (ret)sb_end_write (file_inode (file)->i_sb);
fs/open.c +3 -1
@@ -175,7 +175,9 @@ long do_ftruncate(struct file *file, loff_t length, int small)/* Check IS_APPEND on real upper inode */ if (IS_APPEND (file_inode (file)))return -EPERM ; -sb_start_write (inode->i_sb); + error =sb_start_write (inode->i_sb); +if (error) +return error; error =security_file_truncate (file);if (!error) error = do_truncate(file_mnt_idmap(file), dentry, length,
fs/overlayfs/util.c +1 -2
@@ -28,8 +28,7 @@ int ovl_get_write_access(struct dentry *dentry)int __must_check ovl_start_write (struct dentry *dentry) {struct ovl_fs *ofs =OVL_FS (dentry->d_sb); -sb_start_write (ovl_upper_mnt (ofs)->mnt_sb); -return 0 ; +return sb_start_write (ovl_upper_mnt (ofs)->mnt_sb); }int ovl_want_write (struct dentry *dentry)
fs/quota/quota.c +2 -2
@@ -896,8 +896,8 @@ static struct super_block *quotactl_block(const char __user *special, int cmd)else up_read (&sb->s_umount);/* Wait for sb to unfreeze */ -sb_start_write (sb); -sb_end_write (sb); +if (sb_start_write (sb) ==0 ) +sb_end_write (sb);put_super (sb); goto retry; }
fs/xfs/xfs_ioctl.c +3 -1
@@ -1499,7 +1499,9 @@ xfs_file_ioctl(trace_xfs_ioc_free_eofblocks (mp, &icw, _RET_IP_); -sb_start_write (mp->m_super); + error =sb_start_write (mp->m_super); +if (error) +return error; error =xfs_blockgc_free_space (mp, &icw);sb_end_write (mp->m_super);return error;
include/linux/fs.h +12 -4
@@ -1190,6 +1190,9 @@ enum {SB_I_TS_EXPIRY_WARNED ,/* warned about timestamp range expiry */ SB_I_RETIRED ,/* superblock shouldn't be reused */ SB_I_NOUMASK ,/* VFS does not apply umask */ + SB_I_SHUTDOWN, /* The filesystem has shutdown. Refuse + * modification attempts with error as they are + * a futile exercise. */ };/* Possible states of 'frozen' field */
@@ -1823,9 +1826,12 @@ static inline void sb_end_intwrite(struct super_block *sb)* -> i_mutex (write path, truncate, directory ops, ...) * -> s_umount (freeze_super, thaw_super) */ -static inline void sb_start_write (struct super_block *sb) +static inline int __must_check sb_start_write (struct super_block *sb) { +if (sb_test_iflag (sb,SB_I_SHUTDOWN )) +return -EROFS ;__sb_start_write (sb,SB_FREEZE_WRITE ); +return 0 ; }static inline bool __must_check sb_start_write_trylock (struct super_block *sb)
@@ -2891,8 +2897,7 @@ static inline int __must_check file_start_write(struct file *file) {if (!S_ISREG (file_inode (file)->i_mode))return 0 ; -sb_start_write (file_inode (file)->i_sb); -return 0 ; +return sb_start_write (file_inode (file)->i_sb); }static inline bool __must_check file_start_write_trylock (struct file *file)
@@ -2925,8 +2930,11 @@ static inline void file_end_write(struct file *file)static inline int __must_check kiocb_start_write (struct kiocb *iocb) {struct inode *inode =file_inode (iocb->ki_filp); +int err; -sb_start_write (inode->i_sb); + err =sb_start_write (inode->i_sb); +if (err) +return err;/* * Fool lockdep by telling it the lock got released so that it * doesn't complain about the held lock when we return to userspace.
Signature · 1 line
2.35.3
Jan Kara
maintainerPATCH 12/13 fs: Make sb_start_pagefault() return error on shutdown filesystem
In reply to Jan KaraSimilarly to sb_start_write(), make sb_start_pagefault() return errors for superblocks which are marked as shutdown to avoid modifications to it which reduces noise in the error logs and generally makes life somewhat easier for filesystems. We teach all sb_start_pagefault() callers to handle the error.
--- fs/bcachefs/fs-io-pagecache.c | 3 ++- fs/btrfs/file.c | 3 ++- fs/ceph/addr.c | 9 ++++++--- fs/ext2/file.c | 3 ++- fs/ext4/file.c | 3 ++- fs/ext4/inode.c | 3 ++- fs/f2fs/file.c | 4 +++- fs/fuse/dax.c | 3 ++- fs/gfs2/file.c | 3 ++- fs/netfs/buffered_write.c | 3 ++- fs/nfs/file.c | 3 ++- fs/nilfs2/file.c | 3 ++- fs/ocfs2/mmap.c | 3 ++- fs/orangefs/inode.c | 3 ++- fs/udf/file.c | 3 ++- fs/xfs/xfs_file.c | 3 ++- fs/zonefs/file.c | 3 ++- include/linux/fs.h | 5 ++++- mm/filemap.c | 3 ++- 19 files changed, 45 insertions(+), 21 deletions(-)
fs/bcachefs/fs-io-pagecache.c +2 -1
@@ -611,7 +611,8 @@ vm_fault_t bch2_page_mkwrite(struct vm_fault *vmf)bch2_folio_reservation_init (c, inode, &res); -sb_start_pagefault (inode->v.i_sb); +if (sb_start_pagefault (inode->v.i_sb) <0 ) +return VM_FAULT_SIGBUS ;file_update_time (file);/*
fs/btrfs/file.c +2 -1
@@ -1900,7 +1900,8 @@ static vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) reserved_space =PAGE_SIZE ; -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ; page_start =page_offset (page); page_end = page_start +PAGE_SIZE -1 ; end = page_end;
fs/ceph/addr.c +6 -3
@@ -1686,7 +1686,9 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)if (!prealloc_cf)return VM_FAULT_OOM ; -sb_start_pagefault (inode->i_sb); + err =sb_start_pagefault (inode->i_sb); +if (err) + goto out_free;ceph_block_sigs (&oldset);if (off +thp_size (page) <= size)
@@ -1704,7 +1706,7 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf) got =0 ; err =ceph_get_caps (vma->vm_file,CEPH_CAP_FILE_WR , want, off + len, &got);if (err <0 ) - goto out_free; + goto out_sigs;doutc (cl,"%llx.%llx %llu~%zd got cap refs on %s\n" ,ceph_vinop (inode), off, len,ceph_cap_string (got));
@@ -1758,9 +1760,10 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)doutc (cl,"%llx.%llx %llu~%zd dropping cap refs on %s ret %x\n" ,ceph_vinop (inode), off, len,ceph_cap_string (got), ret);ceph_put_cap_refs_async (ci, got); -out_free: +out_sigs:ceph_restore_sigs (&oldset);sb_end_pagefault (inode->i_sb); +out_free:ceph_free_cap_flush (prealloc_cf);if (err <0 ) ret =vmf_error (err);
fs/ext2/file.c +2 -1
@@ -98,7 +98,8 @@ static vm_fault_t ext2_dax_fault(struct vm_fault *vmf) (vmf->vma->vm_flags &VM_SHARED );if (write) { -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ;file_update_time (vmf->vma->vm_file); }filemap_invalidate_lock_shared (inode->i_mapping);
fs/ext4/file.c +2 -1
@@ -725,7 +725,8 @@ static vm_fault_t ext4_dax_huge_fault(struct vm_fault *vmf, unsigned int order)pfn_t pfn;if (write) { -sb_start_pagefault (sb); +if (sb_start_pagefault (sb) <0 ) +return VM_FAULT_SIGBUS ;file_update_time (vmf->vma->vm_file);filemap_invalidate_lock_shared (mapping); retry:
fs/ext4/inode.c +2 -1
@@ -6128,7 +6128,8 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf)if (unlikely (IS_IMMUTABLE (inode)))return VM_FAULT_SIGBUS ; -sb_start_pagefault (inode->i_sb); +if (unlikely (sb_start_pagefault (inode->i_sb) <0 )) +return VM_FAULT_SIGBUS ;file_update_time (vma->vm_file);filemap_invalidate_lock_shared (mapping);
fs/f2fs/file.c +3 -1
@@ -100,7 +100,9 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)if (need_alloc)f2fs_balance_fs (sbi, true); -sb_start_pagefault (inode->i_sb); + err =sb_start_pagefault (inode->i_sb); +if (err) + goto out;f2fs_bug_on (sbi,f2fs_has_inline_data (inode));
fs/fuse/dax.c +2 -1
@@ -797,7 +797,8 @@ static vm_fault_t __fuse_dax_fault(struct vm_fault *vmf, unsigned int order,bool retry = false;if (write) -sb_start_pagefault (sb); +if (sb_start_pagefault (sb) <0 ) +return VM_FAULT_SIGBUS ; retry:if (retry && !(fcd->nr_free_ranges >0 ))wait_event (fcd->range_waitq, (fcd->nr_free_ranges >0 ));
fs/gfs2/file.c +2 -1
@@ -427,7 +427,8 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)loff_t size;int err; -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ;gfs2_holder_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &gh); err =gfs2_glock_nq (&gh);
fs/netfs/buffered_write.c +2 -1
@@ -531,7 +531,8 @@ vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf, struct netfs_group *netfs_gr_enter ("%lx" , folio->index); -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ;if (folio_lock_killable (folio) <0 ) goto out;
fs/nfs/file.c +2 -1
@@ -593,7 +593,8 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf) filp, filp->f_mapping->host->i_ino, (long long)folio_pos(folio)); -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ;/* make sure the cache has finished storing the page */ if (folio_test_private_2(folio) && /* [DEPRECATED] */
fs/nilfs2/file.c +2 -1
@@ -54,7 +54,8 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf)if (unlikely (nilfs_near_disk_full (inode->i_sb->s_fs_info)))return VM_FAULT_SIGBUS ;/* -ENOSPC */ -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ;folio_lock (folio); if (folio->mapping != inode->i_mapping || folio_pos(folio) >= i_size_read(inode) ||
fs/ocfs2/mmap.c +2 -1
@@ -119,7 +119,8 @@ static vm_fault_t ocfs2_page_mkwrite(struct vm_fault *vmf)int err;vm_fault_t ret; -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ;ocfs2_block_signals (&oldset);/*
fs/orangefs/inode.c +2 -1
@@ -632,7 +632,8 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf)vm_fault_t ret;struct orangefs_write_range *wr; -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ;if (wait_on_bit (bitlock,1 ,TASK_KILLABLE )) { ret =VM_FAULT_RETRY ;
fs/udf/file.c +2 -1
@@ -45,7 +45,8 @@ static vm_fault_t udf_page_mkwrite(struct vm_fault *vmf)vm_fault_t ret =VM_FAULT_LOCKED ;int err; -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ;file_update_time (vma->vm_file);filemap_invalidate_lock_shared (mapping);folio_lock (folio);
fs/xfs/xfs_file.c +2 -1
@@ -1283,7 +1283,8 @@ xfs_write_fault(unsigned int lock_mode =XFS_MMAPLOCK_SHARED ;vm_fault_t ret; -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ;file_update_time (vmf->vma->vm_file);/*
fs/zonefs/file.c +2 -1
@@ -294,7 +294,8 @@ static vm_fault_t zonefs_filemap_page_mkwrite(struct vm_fault *vmf)if (zonefs_inode_is_seq (inode))return VM_FAULT_NOPAGE ; -sb_start_pagefault (inode->i_sb); +if (sb_start_pagefault (inode->i_sb) <0 ) +return VM_FAULT_SIGBUS ;file_update_time (vmf->vma->vm_file);/* Serialize against truncates */
include/linux/fs.h +4 -1
@@ -1858,9 +1858,12 @@ static inline bool __must_check sb_start_write_trylock(struct super_block *sb)* mmap_lock * -> sb_start_pagefault */ -static inline void sb_start_pagefault (struct super_block *sb) +static inline int __must_check sb_start_pagefault (struct super_block *sb) { +if (sb_test_iflag (sb,SB_I_SHUTDOWN )) +return -EROFS ;__sb_start_write (sb,SB_FREEZE_PAGEFAULT ); +return 0 ; }/**
mm/filemap.c +2 -1
@@ -3672,7 +3672,8 @@ vm_fault_t filemap_page_mkwrite(struct vm_fault *vmf)struct folio *folio =page_folio (vmf->page);vm_fault_t ret =VM_FAULT_LOCKED ; -sb_start_pagefault (mapping->host->i_sb); +if (sb_start_pagefault (mapping->host->i_sb) <0 ) +return VM_FAULT_SIGBUS ;file_update_time (vmf->vma->vm_file);folio_lock (folio);if (folio->mapping != mapping) {
Signature · 1 line
2.35.3
Jan Kara
maintainerPATCH 13/13 ext4: Replace EXT4_FLAGS_SHUTDOWN flag with a generic SB_I_SHUTDOWN
In reply to Jan KaraInstead of using private ext4 EXT4_FLAGS_SHUTDOWN flag, use a generic variant SB_I_SHUTDOWN. As a bonus VFS will now refuse modification attempts for the filesystem when the flag is set.
--- fs/ext4/ext4.h | 3 +-- fs/ext4/ioctl.c | 6 +++--- fs/ext4/super.c | 11 +++++------ 3 files changed, 9 insertions(+), 11 deletions(-)
fs/ext4/ext4.h +1 -2
@@ -2240,12 +2240,11 @@ extern int ext4_feature_set_ok(struct super_block *sb, int readonly);* Superblock flags */ #define EXT4_FLAGS_RESIZING 0 -#define EXT4_FLAGS_SHUTDOWN 1#define EXT4_FLAGS_BDEV_IS_DAX 2static inline int ext4_forced_shutdown (struct super_block *sb) { -return test_bit (EXT4_FLAGS_SHUTDOWN , &EXT4_SB (sb)->s_ext4_flags); +return sb_test_iflag (sb,SB_I_SHUTDOWN ); }/*
fs/ext4/ioctl.c +3 -3
@@ -822,18 +822,18 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags) ret =bdev_freeze (sb->s_bdev);if (ret)return ret; -set_bit (EXT4_FLAGS_SHUTDOWN , &sbi->s_ext4_flags); +sb_set_iflag (sb,SB_I_SHUTDOWN );bdev_thaw (sb->s_bdev);break ;case EXT4_GOING_FLAGS_LOGFLUSH : -set_bit (EXT4_FLAGS_SHUTDOWN , &sbi->s_ext4_flags); +sb_set_iflag (sb,SB_I_SHUTDOWN );if (sbi->s_journal && !is_journal_aborted (sbi->s_journal)) { (void )ext4_force_commit (sb);jbd2_journal_abort (sbi->s_journal, -ESHUTDOWN ); }break ;case EXT4_GOING_FLAGS_NOLOGFLUSH : -set_bit (EXT4_FLAGS_SHUTDOWN , &sbi->s_ext4_flags); +sb_set_iflag (sb,SB_I_SHUTDOWN );if (sbi->s_journal && !is_journal_aborted (sbi->s_journal))jbd2_journal_abort (sbi->s_journal, -ESHUTDOWN );break ;
fs/ext4/super.c +5 -6
@@ -701,7 +701,7 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,WARN_ON_ONCE (1 );if (!continue_fs && !sb_rdonly (sb)) { -set_bit (EXT4_FLAGS_SHUTDOWN , &EXT4_SB (sb)->s_ext4_flags); +sb_set_iflag (sb,SB_I_SHUTDOWN );if (journal)jbd2_journal_abort (journal, -EIO ); }
@@ -735,11 +735,10 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,ext4_msg (sb,KERN_CRIT ,"Remounting filesystem read-only" );/* -* EXT4_FLAGS_SHUTDOWN was set which stops all filesystem -* modifications. We don't set SB_RDONLY because that requires -* sb->s_umount semaphore and setting it without proper remount -* procedure is confusing code such as freeze_super() leading to -* deadlocks and other problems. +* SB_I_SHUTDOWN was set which stops all filesystem modifications. We +* don't set SB_RDONLY because that requires sb->s_umount semaphore and +* setting it without proper remount procedure is confusing code such +* as freeze_super() leading to deadlocks and other problems. */ }
Signature · 1 line
2.35.3
Quoted 12 lines · Jan Kara
Hello,
this patch series implements generic handling of filesystem shutdown. The idea is very simple: Have a superblock flag, which when set, will make VFS refuse modifications to the filesystem. The patch series consists of several parts. Patches 1-6 cleanup handling of
SB_I_flags which is currently messy (different flags seem to have different locks protecting them although they are modified by plain stores). Patches 7-12 gradually convert code to be able to handle errors fromsb_start_write()/sb_start_pagefault(). Patch 13 then shows how filesystems can use this generic flag. Additionally, we could remove some shutdown checks from within ext4 code and rely on checks in VFS but I didn't want to complicate the series with ext4 specific things.
Overall this looks good. Two things that I noticed that we should nail down before anything else:
1. The original definition of a 'shutdown filesystem' (i.e. from the XFS origins) is that a shutdown filesystem must *never* do -physical IO- after the shutdown is initiated. This is a protection mechanism for the underlying storage to prevent potential propagation of problems in the storage media once a serious issue has been detected. (e.g. suspect physical media can be made worse by continually trying to read it.) It also allows the block device to go away and we won't try to access issue new IO to it once the ->shutdown call has been complete.
IOWs, XFS implements a "no new IO after shutdown" architecture, and this is also largely what ext4 implements as well.
However, this isn't what this generic shutdown infrastructure implements. It only prevents new user modifications from being started - it is effectively a "instant RO" mechanism rather than an "instant no more IO" architecture.
Hence we have an impedence mismatch between existing shutdown implementations that currently return -EIO on shutdown for all operations (both read and write) and this generic implementation which returns -EROFS only for write operations.
Hence the proposed generic shutdown model doesn't really solve the inconsistent shutdown behaviour problem across filesystems - it just adds a new inconsistency between existing filesystem shutdown implementations and the generic infrastructure.
2. On shutdown, this patchset returns -EROFS.
As per #1, returning -EROFS on shutdown will be a significant change of behaviour for some filesystems as they currently return -EIO when the filesystem is shut down.
I don't think -EROFS is right, because existing shutdown behaviour also impacts read-only operations and will return -EIO for them, too.
I think the error returned by a shutdown filesystem should always be consistent and that really means -EIO needs to be returned rather than -EROFS.
However, given this is new generic infrastructure, we can define a new error like -ESHUTDOWN (to reuse an existing errno) or even a new errno like -EFSSHUTDOWN for this, document it man pages and then convert all the existing filesystem shutdown checks to return this error instead of -EIO...
Quoted 4 lines
Also, as Dave suggested, we can lift *_IOC_{SHUTDOWN|GOINGDOWN} ioctl handling to VFS (currently in 5 filesystems) and just call new ->shutdown op for the filesystem abort handling itself. But that is kind of independent thing and this series is long enough as is.
Agreed - that can be done separately once we've sorted out the little details of what a shutdown filesystem actually means and how that gets reported consistently to userspace...
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 27 lines · Dave Chinner
Quoted 12 lines · Jan Kara
Hello,
this patch series implements generic handling of filesystem shutdown. The idea is very simple: Have a superblock flag, which when set, will make VFS refuse modifications to the filesystem. The patch series consists of several parts. Patches 1-6 cleanup handling of
SB_I_flags which is currently messy (different flags seem to have different locks protecting them although they are modified by plain stores). Patches 7-12 gradually convert code to be able to handle errors fromsb_start_write()/sb_start_pagefault(). Patch 13 then shows how filesystems can use this generic flag. Additionally, we could remove some shutdown checks from within ext4 code and rely on checks in VFS but I didn't want to complicate the series with ext4 specific things.Overall this looks good. Two things that I noticed that we should nail down before anything else:
1. The original definition of a 'shutdown filesystem' (i.e. from the XFS origins) is that a shutdown filesystem must *never* do -physical IO- after the shutdown is initiated. This is a protection mechanism for the underlying storage to prevent potential propagation of problems in the storage media once a serious issue has been detected. (e.g. suspect physical media can be made worse by continually trying to read it.) It also allows the block device to go away and we won't try to access issue new IO to it once the ->shutdown call has been complete.
Quoted 2 lines
IOWs, XFS implements a "no new IO after shutdown" architecture, and this is also largely what ext4 implements as well.
I don't think it quite does -- for EXT4_GOING_FLAGS_DEFAULT, it sets the shutdown flag, but it doesn't actually abort the journal. I think that's an implementation bug since XFS /does/ shut down the log.
But looking at XFS_FSOP_GOING_FLAGS_DEFAULT, I also notice that if the bdev_freeze fails, it returns 0 and the fs isn't shut down. ext4, otoh, actually does pass bdev_freeze's errno along. I think ext4's behavior is the correct one, right?
Quoted 4 lines
However, this isn't what this generic shutdown infrastructure implements. It only prevents new user modifications from being started - it is effectively a "instant RO" mechanism rather than an "instant no more IO" architecture.
I thought pagefaults are still allowed on a shutdown xfs? Curiously I don't see a prohibition on write faults, but iirc we still allowed read faults so that a shutdown on the rootfs doesn't immediately crash the whole machine?
Quoted 24 lines
Hence we have an impedence mismatch between existing shutdown implementations that currently return
-EIOon shutdown for all operations (both read and write) and this generic implementation which returns-EROFSonly for write operations.Hence the proposed generic shutdown model doesn't really solve the inconsistent shutdown behaviour problem across filesystems - it just adds a new inconsistency between existing filesystem shutdown implementations and the generic infrastructure.
2. On shutdown, this patchset returns
-EROFS.As per #1, returning
-EROFSon shutdown will be a significant change of behaviour for some filesystems as they currently return-EIOwhen the filesystem is shut down.I don't think
-EROFSis right, because existing shutdown behaviour also impacts read-only operations and will return-EIOfor them, too.I think the error returned by a shutdown filesystem should always be consistent and that really means
-EIOneeds to be returned rather than-EROFS.
Quoted 5 lines
However, given this is new generic infrastructure, we can define a new error like
-ESHUTDOWN(to reuse an existing errno) or even a new errno like-EFSSHUTDOWNfor this, document it man pages and then convert all the existing filesystem shutdown checks to return this error instead of-EIO...
Agree.
Quoted 8 lines
Quoted 4 lines
Also, as Dave suggested, we can lift *_IOC_{SHUTDOWN|GOINGDOWN} ioctl handling to VFS (currently in 5 filesystems) and just call new ->shutdown op for the filesystem abort handling itself. But that is kind of independent thing and this series is long enough as is.
Agreed - that can be done separately once we've sorted out the little details of what a shutdown filesystem actually means and how that gets reported consistently to userspace...
I would define it as:
No more writes to the filesystem or its underlying storage; file IO and stat* calls return ESHUTDOWN; read faults still allowed.
I like the idea of hoisting this to the vfs and defining how one figures out if the fs is shut down; thank you for working on this, Jan.
--D
Quoted 5 lines
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 31 lines · Darrick J. Wong
Quoted 27 lines · Dave Chinner
Quoted 12 lines · Jan Kara
Hello,
this patch series implements generic handling of filesystem shutdown. The idea is very simple: Have a superblock flag, which when set, will make VFS refuse modifications to the filesystem. The patch series consists of several parts. Patches 1-6 cleanup handling of
SB_I_flags which is currently messy (different flags seem to have different locks protecting them although they are modified by plain stores). Patches 7-12 gradually convert code to be able to handle errors fromsb_start_write()/sb_start_pagefault(). Patch 13 then shows how filesystems can use this generic flag. Additionally, we could remove some shutdown checks from within ext4 code and rely on checks in VFS but I didn't want to complicate the series with ext4 specific things.Overall this looks good. Two things that I noticed that we should nail down before anything else:
1. The original definition of a 'shutdown filesystem' (i.e. from the XFS origins) is that a shutdown filesystem must *never* do -physical IO- after the shutdown is initiated. This is a protection mechanism for the underlying storage to prevent potential propagation of problems in the storage media once a serious issue has been detected. (e.g. suspect physical media can be made worse by continually trying to read it.) It also allows the block device to go away and we won't try to access issue new IO to it once the ->shutdown call has been complete.
Quoted 2 lines
IOWs, XFS implements a "no new IO after shutdown" architecture, and this is also largely what ext4 implements as well.
Quoted 8 lines
I don't think it quite does -- for
EXT4_GOING_FLAGS_DEFAULT, it sets the shutdown flag, but it doesn't actually abort the journal. I think that's an implementation bug since XFS /does/ shut down the log.But looking at
XFS_FSOP_GOING_FLAGS_DEFAULT, I also notice that if thebdev_freezefails, it returns 0 and the fs isn't shut down. ext4, otoh, actually does pass bdev_freeze's errno along. I think ext4's behavior is the correct one, right?
Yes, there are inconsistencies in how different filesystems implement user-driven shutdown operations, but Jan has specifically left addressing those sorts of inconsistencies in ioctl/->shutdown implementations for a later patch set. I agree with that approach - let's first focus on defining a generic model for how shutdown filesystems should behave once they are shut down. Once we have the model defined, then we can worry about making filesystems shutdown mechanisms behave consistently within that model..
Quoted 9 lines
Quoted 4 lines
However, this isn't what this generic shutdown infrastructure implements. It only prevents new user modifications from being started - it is effectively a "instant RO" mechanism rather than an "instant no more IO" architecture.
I thought pagefaults are still allowed on a shutdown xfs? Curiously I don't see a prohibition on write faults, but iirc we still allowed read faults so that a shutdown on the rootfs doesn't immediately crash the whole machine?
Yes, page faults are allowed on a shutdown XFS filesystem right up to the point where they need to do IO on a page cache miss. Then the IO request hits the block mapping code (xfs_bmapi_read()), sees the shutdown state and the read IO fails. The result of this is SIGBUS for your executable.
IOWs, if the executable is cached, it will keep running after a shutdown. If it's not cached, then it's game over already.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Also, as Dave suggested, we can lift *_IOC_{SHUTDOWN|GOINGDOWN} ioctl handling to VFS (currently in 5 filesystems) and just call new ->shutdown op for the filesystem abort handling itself. But that is kind of independent thing and this series is long enough as is.
Quoted 8 lines
Quoted 3 lines
Agreed - that can be done separately once we've sorted out the little details of what a shutdown filesystem actually means and how that gets reported consistently to userspace...
I would define it as:
No more writes to the filesystem or its underlying storage; file IO and stat* calls return ESHUTDOWN; read faults still allowed.
We need to operations in terms of whether we allow physical IO or not. We currently don't allow physical IO from read faults on XFs, so...
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Jan Kara
maintainerQuoted 27 lines · Dave Chinner
Quoted 12 lines · Jan Kara
Hello,
this patch series implements generic handling of filesystem shutdown. The idea is very simple: Have a superblock flag, which when set, will make VFS refuse modifications to the filesystem. The patch series consists of several parts. Patches 1-6 cleanup handling of
SB_I_flags which is currently messy (different flags seem to have different locks protecting them although they are modified by plain stores). Patches 7-12 gradually convert code to be able to handle errors fromsb_start_write()/sb_start_pagefault(). Patch 13 then shows how filesystems can use this generic flag. Additionally, we could remove some shutdown checks from within ext4 code and rely on checks in VFS but I didn't want to complicate the series with ext4 specific things.Overall this looks good. Two things that I noticed that we should nail down before anything else:
1. The original definition of a 'shutdown filesystem' (i.e. from the XFS origins) is that a shutdown filesystem must *never* do -physical IO- after the shutdown is initiated. This is a protection mechanism for the underlying storage to prevent potential propagation of problems in the storage media once a serious issue has been detected. (e.g. suspect physical media can be made worse by continually trying to read it.) It also allows the block device to go away and we won't try to access issue new IO to it once the ->shutdown call has been complete.
Quoted 2 lines
IOWs, XFS implements a "no new IO after shutdown" architecture, and this is also largely what ext4 implements as well.
Thanks for sharing this. I wasn't aware that "no new IO after shutdown" is the goal. I knew this is required for modifications but I wasn't sure how strict this was for writes.
Quoted 10 lines
However, this isn't what this generic shutdown infrastructure implements. It only prevents new user modifications from being started - it is effectively a "instant RO" mechanism rather than an "instant no more IO" architecture.
Hence we have an impedence mismatch between existing shutdown implementations that currently return
-EIOon shutdown for all operations (both read and write) and this generic implementation which returns-EROFSonly for write operations.
Quoted 4 lines
Hence the proposed generic shutdown model doesn't really solve the inconsistent shutdown behaviour problem across filesystems - it just adds a new inconsistency between existing filesystem shutdown implementations and the generic infrastructure.
OK, understood. I also agree it would be good to keep this no-IO semantics when implementing the generic solution. I'm just pondering how to achieve that in a maintainable way. For the write path what I've done looks like the least painful way. For the read path the simplest is probably to still return whatever is in cache and just do the check + error return somewhere down in the call stack just before calling into filesystem. It is easy enough to stop things like ->read_folio, ->readahead, or ->lookup. But how about things like ->evict_inode or ->release? They can trigger IO but allowing inode reclaim on shutdown fs is desirable I'd say. Similarly for things like ->remount_fs or ->put_super. So avoiding IO from operations like these would rely on fs implementation anyway.
Quoted 14 lines
2. On shutdown, this patchset returns
-EROFS.As per #1, returning
-EROFSon shutdown will be a significant change of behaviour for some filesystems as they currently return-EIOwhen the filesystem is shut down.I don't think
-EROFSis right, because existing shutdown behaviour also impacts read-only operations and will return-EIOfor them, too.I think the error returned by a shutdown filesystem should always be consistent and that really means
-EIOneeds to be returned rather than-EROFS.
Quoted 5 lines
However, given this is new generic infrastructure, we can define a new error like
-ESHUTDOWN(to reuse an existing errno) or even a new errno like-EFSSHUTDOWNfor this, document it man pages and then convert all the existing filesystem shutdown checks to return this error instead of-EIO...
Right, -EROFS isn't really good return value when we refuse also reads. I think -EIO is fine. -ESHUTDOWN would be ok but the standard message ("Cannot send after transport endpoint shutdown") whould be IMO confusing to users. I was also thinking about -EFSCORRUPTED (alias -EUCLEAN) which already has some precedens in the filesystem space but -EIO is probably better.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Christian Brauner
maintainerQuoted 2 lines
things like ->remount_fs or ->put_super. So avoiding IO from operations like these would rely on fs implementation anyway.
I think that needs to remain filesystem specific and I don't think this needs to hold up the patchset.
Quoted 5 lines
Right,
-EROFSisn't really good return value when we refuse also reads. I think-EIOis fine.-ESHUTDOWNwould be ok but the standard message ("Cannot send after transport endpoint shutdown") whould be IMO confusing to users. I was also thinking about-EFSCORRUPTED(alias-EUCLEAN) which already has some precedens in the filesystem space but-EIOis probably better.
EIO isn't great but I agree that it's the best we probably have for now.
Quoted 50 lines · Jan Kara
Quoted 27 lines · Dave Chinner
Quoted 12 lines · Jan Kara
Hello,
this patch series implements generic handling of filesystem shutdown. The idea is very simple: Have a superblock flag, which when set, will make VFS refuse modifications to the filesystem. The patch series consists of several parts. Patches 1-6 cleanup handling of
SB_I_flags which is currently messy (different flags seem to have different locks protecting them although they are modified by plain stores). Patches 7-12 gradually convert code to be able to handle errors fromsb_start_write()/sb_start_pagefault(). Patch 13 then shows how filesystems can use this generic flag. Additionally, we could remove some shutdown checks from within ext4 code and rely on checks in VFS but I didn't want to complicate the series with ext4 specific things.Overall this looks good. Two things that I noticed that we should nail down before anything else:
1. The original definition of a 'shutdown filesystem' (i.e. from the XFS origins) is that a shutdown filesystem must *never* do -physical IO- after the shutdown is initiated. This is a protection mechanism for the underlying storage to prevent potential propagation of problems in the storage media once a serious issue has been detected. (e.g. suspect physical media can be made worse by continually trying to read it.) It also allows the block device to go away and we won't try to access issue new IO to it once the ->shutdown call has been complete.
Quoted 2 lines
IOWs, XFS implements a "no new IO after shutdown" architecture, and this is also largely what ext4 implements as well.
Thanks for sharing this. I wasn't aware that "no new IO after shutdown" is the goal. I knew this is required for modifications but I wasn't sure how strict this was for writes.
Quoted 10 lines
However, this isn't what this generic shutdown infrastructure implements. It only prevents new user modifications from being started - it is effectively a "instant RO" mechanism rather than an "instant no more IO" architecture.
Hence we have an impedence mismatch between existing shutdown implementations that currently return
-EIOon shutdown for all operations (both read and write) and this generic implementation which returns-EROFSonly for write operations.Quoted 4 lines
Hence the proposed generic shutdown model doesn't really solve the inconsistent shutdown behaviour problem across filesystems - it just adds a new inconsistency between existing filesystem shutdown implementations and the generic infrastructure.
Quoted 8 lines
OK, understood. I also agree it would be good to keep this no-IO semantics when implementing the generic solution. I'm just pondering how to achieve that in a maintainable way. For the write path what I've done looks like the least painful way. For the read path the simplest is probably to still return whatever is in cache and just do the check + error return somewhere down in the call stack just before calling into filesystem. It is easy enough to stop things like ->read_folio, ->readahead, or ->lookup. But how about things like ->evict_inode or ->release?
If the filesystem is shut down, inode eviction or releasing a FD should not be doing any IO at all - they should just be releasing in-memory resources and freeing the objects being released. e.g. we don't process unlinked inodes when the filesystem is shut down; they remain as unlinked on disk and recovery gets to clean up the mess. i.e. we process all inodes as if they were clean, linked inodes and just tear down the in-memory structures attached to the inode.
i.e. shutdown isn't concerned about keeping anything consistent either in memory or on disk - it's concerned only about releasing in-memory resources such that the filesystem can be unmounted without doing any IO at all. e.g. ext4_evict_inode() needs to treat all unlinked inodes as if they are bad when the filesystem is shut down. XFS does this (see the shutdown check in xfs_inode_needs_inactive()) and every filesystem that does unlinked inode processing in inode eviction will need similar modifications.
Yes, this means a "shutdown means no IO" model cannot be exclusively implemented at the VFS - it will need things like filesystems with customised inode eviction callouts to handle these cases themselves.
Quoted 4 lines
They can trigger IO but
allowing inode reclaim on shutdown fs is desirable I'd say. Similarly for things like ->remount_fs or ->put_super. So avoiding IO from operations like these would rely on fs implementation anyway.
remounts need to follow the fundamental rule of shutdowns: you can't change the state of a shutdown filesystem -at all- because any operation on a shutdown filesystem should be immediately failed. The only thing you can reliably do once a filesystem is shut down is unmount it. IOWs, the VFS should return -EIO when a remount is requested on a shutdown filesystem, and the filesystem code then doesn't have to care.
As for ->put_super(), this should act as if the filesystem is clean when the filesystem is shut down as everything that is dirty in memory will never get cleaned. IOWs, once shutdown has been set, dirty state should be completely ignored by everything and so object release/eviction should tear everything down regardless of it's state.
Supporting a "no-IO shutdown" model properly will require filesystem specific changes to handle, but that's really implementation details more than anything else. What we need to do first is define and document exactly what shutdown means and how the VFS and filesystems need to operate when that bit is set. Then we have a clear framework from which we can consistently answer "what should filesystem X do in this situation" issues that arise...
-Dave.
Signature · 2 lines
Dave Chinner [email protected]