btrfs: refactor btrfs_set_props to validate externally

In preparation to merge multiple transactions when setting the
compression flags, split btrfs_set_props() validation part outside of
it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Anand Jain
2019-04-20 19:48:51 +08:00
committed by David Sterba
parent 7c15d41016
commit f22125e5d8
4 changed files with 26 additions and 6 deletions

View File

@@ -284,6 +284,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
binode->flags &= ~BTRFS_INODE_COMPRESS;
binode->flags |= BTRFS_INODE_NOCOMPRESS;
/* set no-compression no need to validate prop here */
ret = btrfs_set_prop_trans(inode, "btrfs.compression", NULL,
0, 0);
if (ret && ret != -ENODATA)
@@ -299,6 +300,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
binode->flags |= BTRFS_INODE_COMPRESS;
binode->flags &= ~BTRFS_INODE_NOCOMPRESS;
/* compress_type is already validated during mount options */
comp = btrfs_compress_type2str(fs_info->compress_type);
if (!comp || comp[0] == 0)
comp = btrfs_compress_type2str(BTRFS_COMPRESS_ZLIB);
@@ -309,6 +311,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
goto out_drop;
} else {
/* reset prop, no need of validate prop here */
ret = btrfs_set_prop_trans(inode, "btrfs.compression", NULL,
0, 0);
if (ret && ret != -ENODATA)