Commit d206e9c9 authored by Naohiro Aota's avatar Naohiro Aota Committed by David Sterba

btrfs: disallow NODATACOW in ZONED mode

NODATACOW implies overwriting the file data on a device, which is
impossible in sequential required zones. Disable NODATACOW globally with
mount option and per-file NODATACOW attribute by masking FS_NOCOW_FL.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 5d1ab66c
...@@ -193,6 +193,15 @@ static int check_fsflags(unsigned int old_flags, unsigned int flags) ...@@ -193,6 +193,15 @@ static int check_fsflags(unsigned int old_flags, unsigned int flags)
return 0; 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;
}
static int btrfs_ioctl_setflags(struct file *file, void __user *arg) static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
{ {
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
...@@ -230,6 +239,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) ...@@ -230,6 +239,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
if (ret) if (ret)
goto out_unlock; goto out_unlock;
ret = check_fsflags_compatible(fs_info, fsflags);
if (ret)
goto out_unlock;
binode_flags = binode->flags; binode_flags = binode->flags;
if (fsflags & FS_SYNC_FL) if (fsflags & FS_SYNC_FL)
binode_flags |= BTRFS_INODE_SYNC; binode_flags |= BTRFS_INODE_SYNC;
......
...@@ -274,5 +274,10 @@ int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info) ...@@ -274,5 +274,10 @@ int btrfs_check_mountopts_zoned(struct btrfs_fs_info *info)
return -EINVAL; return -EINVAL;
} }
if (btrfs_test_opt(info, NODATACOW)) {
btrfs_err(info, "zoned: NODATACOW not supported");
return -EINVAL;
}
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment