Re: [PATCH] btrfs: add missing check for nocow and compression inode flags

David Sterba
2020-07-10T13:34:37Z

On Fri, Jul 10, 2020 at 01:10:25PM +0300, Nikolay Borisov wrote:
> > +static int check_fsflags(unsigned int old_flags, unsigned int flags)
> > {
> > if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
> > FS_NOATIME_FL | FS_NODUMP_FL | \
> > @@ -174,9 +177,19 @@ static int check_fsflags(unsigned int flags)
> > FS_NOCOW_FL))
> > return -EOPNOTSUPP;
> >
> > + /* COMPR and NOCOMP on new/old are valid */
> > if ((flags & FS_NOCOMP_FL) && (flags & FS_COMPR_FL))
> > return -EINVAL;
> >
> > + if ((flags & FS_COMPR_FL) && (flags & FS_NOCOW_FL))
> > + return -EINVAL;
> > +
> > + /* NOCOW and compression options are mutually exclusive */
> > + if ((old_flags & FS_NOCOW_FL) && (flags & (FS_COMPR_FL | FS_NOCOMP_FL)))
>
> Why is NOCOW and setting NOCOMP (which would really be a NOOP) an
> invalid combination?

The options are not conflicting directly, like for the compression and
nodatacow, but it still is related to compression so it does not feel
right to allow that even if it's a noop.