Re: [RFC][PATCH 0/6] Enhanced file stat system call

From: Jeff Layton
Date: Sat Apr 30 2016 - 17:06:02 EST


On Fri, 2016-04-29 at 13:57 +0100, David Howells wrote:
> Implement a new system call to provide enhanced file stats.ÂÂThe patches can
> be found here:
>
> http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=xstat
>
>
> ===========
> DESCRIPTION
> ===========
>
> The first patch provides this new system call:
>
> long ret = statx(int dfd,
> Âconst char *filename,
> Âunsigned atflag,
> Âunsigned mask,
> Âstruct statx *buffer);
>
> This is an enhanced file stat function that provides a number of useful
> features, in summary:
>
> Â(1) More information: creation time, data version number, inode generation
> ÂÂÂÂÂnumber and flags.ÂÂA subset of these is available through a number of
> ÂÂÂÂÂfilesystems (such as CIFS, NFS, AFS, Ext4 and BTRFS).
>
> Â(2) Lightweight stat (AT_NO_ATTR_SYNC): Ask for just those details of
> ÂÂÂÂÂinterest, and allow a network fs to approximate anything not of
> ÂÂÂÂÂinterest, without going to the server.
>
> Â(3) Heavyweight stat (AT_FORCE_ATTR_SYNC): Force a network fs to flush
> ÂÂÂÂÂbuffers and go to the server, even if it thinks its cached attributes
> ÂÂÂÂÂare up to date.
>
> Â(4) Allow the filesystem to indicate what it can/cannot provide: A
> ÂÂÂÂÂfilesystem can now say it doesn't support a standard stat feature if
> ÂÂÂÂÂthat isn't available.
>
> Â(5) Make the fields a consistent size on all arches, and make them large.
>
> Â(6) Can be extended by using more request flags and using up the padding
> ÂÂÂÂÂspace in the statx struct.
>
> Note that no lstat() equivalent is required as that can be implemented
> through statx() with atflag == 0.ÂÂThere is also no fstat() equivalent as
> that can be implemented through statx() with filename == NULL and the
> relevant fd passed as dfd.
>
>
> =======
> TESTING
> =======
>
> A test program is added into samples/statx/ by the first patch.
>
> David
> ---
> David Howells (6):
> ÂÂÂÂÂÂstatx: Add a system call to make enhanced file info available
> ÂÂÂÂÂÂstatx: AFS: Return enhanced file attributes
> ÂÂÂÂÂÂstatx: Ext4: Return enhanced file attributes
> ÂÂÂÂÂÂstatx: NFS: Return enhanced file attributes
> ÂÂÂÂÂÂstatx: Make windows attributes available for CIFS, NTFS and FAT to use
> ÂÂÂÂÂÂstatx: CIFS: Return enhanced attributes
>
>
> Âarch/x86/entry/syscalls/syscall_32.tbl |ÂÂÂÂ1Â
> Âarch/x86/entry/syscalls/syscall_64.tbl |ÂÂÂÂ1Â
> Âfs/afs/inode.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ24 ++-
> Âfs/cifs/cifsfs.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ4Â
> Âfs/cifs/cifsglob.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ8 +
> Âfs/cifs/dir.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ2Â
> Âfs/cifs/inode.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ117 +++++++++---
> Âfs/exportfs/expfs.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ4Â
> Âfs/ext4/ext4.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ2Â
> Âfs/ext4/file.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ2Â
> Âfs/ext4/inode.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ30 +++
> Âfs/ext4/namei.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ2Â
> Âfs/ext4/symlink.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ2Â
> Âfs/nfs/inode.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ41 ++++
> Âfs/stat.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ306 +++++++++++++++++++++++++++++---
> Âinclude/linux/fs.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ5 -
> Âinclude/linux/stat.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ15 +-
> Âinclude/linux/syscalls.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ4Â
> Âinclude/uapi/linux/fcntl.hÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ2Â
> Âinclude/uapi/linux/stat.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ135 ++++++++++++++
> Âsamples/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂÂ2Â
> Âsamples/statx/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂÂ10 +
> Âsamples/statx/test-statx.cÂÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ274 +++++++++++++++++++++++++++++
> Â23 files changed, 910 insertions(+), 83 deletions(-)
> Âcreate mode 100644 samples/statx/Makefile
> Âcreate mode 100644 samples/statx/test-statx.c
>


I looked over the patchset and it looks fairly straightforward to me.

Are there things that I'd have probably done differently? Yes, but
nothing really sticks out to me as show-stopping and this has the
potential to be helpful in all sorts of ways.

I think we really ought to resist excessive bikeshedding this time
around. With the way the interface is designed, we should be able to
expand on it later if we want to add new attributes after the interface
itself is merged.

Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxxxxxxx>