Re: [PATCH v5 06/28] btrfs: disallow NODATACOW in HMZONED mode

David Sterba
2019-12-05T15:31:51Z

On Wed, Dec 04, 2019 at 05:17:13PM +0900, Naohiro Aota wrote:
> 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.
>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> ---
> fs/btrfs/hmzoned.c | 6 ++++++
> fs/btrfs/ioctl.c | 3 +++
> 2 files changed, 9 insertions(+)
>
> diff --git a/fs/btrfs/hmzoned.c b/fs/btrfs/hmzoned.c
> index 1c015ed050fc..e890d2ab8cd9 100644
> --- a/fs/btrfs/hmzoned.c
> +++ b/fs/btrfs/hmzoned.c
> @@ -269,5 +269,11 @@ int btrfs_check_mountopts_hmzoned(struct btrfs_fs_info *info)
> return -EINVAL;
> }
>
> + if (btrfs_test_opt(info, NODATACOW)) {
> + btrfs_err(info,
> + "cannot enable nodatacow with HMZONED mode");
> + return -EINVAL;

That's maybe -EOPNOTSUPP, the error message explains what's wrong and we
can leave EINVAL for the really invalid arguments. I'll need to look if
this is consistent with the rest of error code returned from mount
though.