Re: [PATCH v9 08/41] btrfs: disallow NODATACOW in ZONED mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 30, 2020 at 10:51:15PM +0900, Naohiro Aota wrote:
>  
> +static int check_fsflags_compatible(struct btrfs_fs_info *fs_info,
> +				    unsigned int flags)
> +{
> +	bool zoned = btrfs_is_zoned(fs_info);

No need for variable when it's one time use.

> +
> +	if (zoned && (flags & FS_NOCOW_FL))
> +		return -EPERM;
> +
> +	return 0;
> +}
> +
> +
>  static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
>  {
>  	struct inode *inode = file_inode(file);
> @@ -230,6 +242,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
>  	if (ret)
>  		goto out_unlock;
>  
> +	ret = check_fsflags_compatible(fs_info, fsflags);
> +	if (ret)
> +		goto out_unlock;

This is called under inode lock although it technically does not need
to but I don't see a problem it logically fits to the sequence and
rarely fails.

> +
>  	binode_flags = binode->flags;
>  	if (fsflags & FS_SYNC_FL)
>  		binode_flags |= BTRFS_INODE_SYNC;
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index 3885fa327049..1939b3ee6c10 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -281,5 +281,11 @@ int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info)
>  		return -EOPNOTSUPP;
>  	}
>  
> +	if (btrfs_test_opt(info, NODATACOW)) {
> +		btrfs_err(info,
> +		  "cannot enable nodatacow with ZONED mode");

		"zoned: NODATACOW not supported"

Eventually all incompatible features will use same message style, there
may be more in the patchset

> +		return -EOPNOTSUPP;

Also EINVAL

> +	}
> +
>  	return 0;
>  }
> -- 
> 2.27.0



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux