Message ID | dd096a7fac48e8314eb43b3f4a17fa5e4ca56c53.1637745470.git.johannes.thumshirn@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: first batch of zoned cleanups | expand |
On Wed, Nov 24, 2021 at 01:30:31AM -0800, Johannes Thumshirn wrote: > check_fsflags_compatible() is only used in zoned filesystems, so move it > to zoned code. The function logically belongs to the ioctl, it is supposed to verify that the flags requested by user are compatible with current filesystem state. > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> > --- > fs/btrfs/ioctl.c | 12 ++---------- > fs/btrfs/zoned.h | 9 +++++++++ > 2 files changed, 11 insertions(+), 10 deletions(-) > > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c > index 05c77a1979a9f..d7f710e57890e 100644 > --- a/fs/btrfs/ioctl.c > +++ b/fs/btrfs/ioctl.c > @@ -49,6 +49,7 @@ > #include "delalloc-space.h" > #include "block-group.h" > #include "subpage.h" > +#include "zoned.h" > > #ifdef CONFIG_64BIT > /* If we have a 32-bit userspace and 64-bit kernel, then the UAPI > @@ -192,15 +193,6 @@ static int check_fsflags(unsigned int old_flags, unsigned int flags) > return 0; > } > > -static int check_fsflags_compatible(struct btrfs_fs_info *fs_info, > - unsigned int flags) > -{ > - if (btrfs_is_zoned(fs_info) && (flags & FS_NOCOW_FL)) > - return -EPERM; The intention of the function is "verify anything that's relevant", so checking the zoned condition here is IMHO appropriate and expected as there can be more such checks in the future. Although we don't have any yet moving the helper to zoned.c disconnects it from the ioctl.
On 24/11/2021 18:37, David Sterba wrote: > The intention of the function is "verify anything that's relevant", so > checking the zoned condition here is IMHO appropriate and expected as > there can be more such checks in the future. Although we don't have any > yet moving the helper to zoned.c disconnects it from the ioctl. > OK, dropped the patch for v2.
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 05c77a1979a9f..d7f710e57890e 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -49,6 +49,7 @@ #include "delalloc-space.h" #include "block-group.h" #include "subpage.h" +#include "zoned.h" #ifdef CONFIG_64BIT /* If we have a 32-bit userspace and 64-bit kernel, then the UAPI @@ -192,15 +193,6 @@ static int check_fsflags(unsigned int old_flags, unsigned int flags) return 0; } -static int check_fsflags_compatible(struct btrfs_fs_info *fs_info, - unsigned int flags) -{ - if (btrfs_is_zoned(fs_info) && (flags & FS_NOCOW_FL)) - return -EPERM; - - return 0; -} - /* * Set flags/xflags from the internal inode flags. The remaining items of * fsxattr are zeroed. @@ -238,7 +230,7 @@ int btrfs_fileattr_set(struct user_namespace *mnt_userns, if (ret) return ret; - ret = check_fsflags_compatible(fs_info, fsflags); + ret = btrfs_zoned_check_fsflags_compatible(fs_info, fsflags); if (ret) return ret; diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h index e3eaf03a34222..8e8f36c1d28a4 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -371,4 +371,13 @@ static inline void btrfs_zoned_data_reloc_unlock(struct inode *inode) btrfs_inode_unlock(inode, 0); } +static inline int btrfs_zoned_check_fsflags_compatible( + struct btrfs_fs_info *fs_info, + unsigned int flags) +{ + if (btrfs_is_zoned(fs_info) && (flags & FS_NOCOW_FL)) + return -EPERM; + + return 0; +} #endif
check_fsflags_compatible() is only used in zoned filesystems, so move it to zoned code. Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- fs/btrfs/ioctl.c | 12 ++---------- fs/btrfs/zoned.h | 9 +++++++++ 2 files changed, 11 insertions(+), 10 deletions(-)