Re: [PATCH v2 5/8] btrfs: add helpers for FS_XFLAG_* conversion

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

 



On Thu, May 10, 2018 at 09:44:23AM +0300, Nikolay Borisov wrote:
> 
> 
> On  9.05.2018 16:54, David Sterba wrote:
> > Preparatory work for the FS_IOC_FSGETXATTR ioctl, basic conversions and
> > checking helpers.
> > 
> > Signed-off-by: David Sterba <dsterba@xxxxxxxx>
> > ---
> >  fs/btrfs/ioctl.c | 32 ++++++++++++++++++++++++++++++++
> >  1 file changed, 32 insertions(+)
> > 
> > diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> > index 40eeb99310d5..54dfcb851ec2 100644
> > --- a/fs/btrfs/ioctl.c
> > +++ b/fs/btrfs/ioctl.c
> > @@ -338,6 +338,38 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
> >  	return ret;
> >  }
> >  
> > +/*
> > + * Translate btrfs internal inode flags to xflags as expected by the
> > + * FS_IOC_FSGETXATT ioctl. Filter only the supported ones, unknown flags are
> > + * silently dropped.
> > + */
> > +static unsigned int btrfs_inode_flags_to_xflags(unsigned int flags)
> > +{
> > +	unsigned int xflags = 0;
> > +
> > +	if (flags & BTRFS_INODE_APPEND)
> > +		xflags |= FS_XFLAG_APPEND;
> > +	if (flags & BTRFS_INODE_IMMUTABLE)
> > +		xflags |= FS_XFLAG_IMMUTABLE;
> > +	if (flags & BTRFS_INODE_NOATIME)
> > +		xflags |= FS_XFLAG_NOATIME;
> > +	if (flags & BTRFS_INODE_NODUMP)
> > +		xflags |= FS_XFLAG_NODUMP;
> > +	if (flags & BTRFS_INODE_SYNC)
> > +		xflags |= FS_XFLAG_SYNC;
> > +
> > +	return xflags;
> > +}
> 
> same suggestion as previous patch:
> 
> BTRFS_XFLAGS(ip)/btrfs_xflags(ip) (macro/function variants). Imho it
> makes sense for such function to actually take an inode. Otherwise we
> are exposing an implementation detail how we derive the iflags/xflags
> from an inode - i.e query the ->flags field. Let's keep this
> encapsulated behind whatever interface we decide.

So the inode as argument does not sound bad, I'd rather do it as a
separate patch as I don't see how to squash the prototype change into
any of the patches. The helper btrfs_inode_flags_to_xflags now follows
the style of the other helpers.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux