Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1525496 > unrolled thread
| Started by | David Howells <dhowells@redhat.com> |
|---|---|
| First post | 2016-11-18 17:30 +0100 |
| Last post | 2016-11-18 18:00 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[RFC][PATCH 0/4] Enhanced file stat system call [ver #2] David Howells <dhowells@redhat.com> - 2016-11-18 17:30 +0100
[PATCH 3/4] statx: NFS: Return enhanced file attributes [ver #2] David Howells <dhowells@redhat.com> - 2016-11-18 17:30 +0100
Re: [PATCH 1/4] statx: Add a system call to make enhanced file info available [ver #2] Arnd Bergmann <arnd@arndb.de> - 2016-11-18 18:00 +0100
| From | David Howells <dhowells@redhat.com> |
|---|---|
| Date | 2016-11-18 17:30 +0100 |
| Subject | [RFC][PATCH 0/4] Enhanced file stat system call [ver #2] |
| Message-ID | <sEUd3-14p-3@gated-at.bofh.it> |
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 and attributes.
A subset of these is available through a number of filesystems (such
as CIFS, NFS, AFS, Ext4 and BTRFS).
(2) Lightweight stat (AT_STATX_DONT_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_STATX_FORCE_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.
(7) Takes dfd, filename and flags in a similar way to fstatat().
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.
=======
CHANGES
=======
Ver #2:
- Turn the AT_STATX_*_SYNC flags into a 2-bit field with three options and
give EINVAL if the undefined option in that field is specified.
- Removed various STATX_ATTR_* flags for lack of definition - can be
reinstated later.
- Removed stx_version and STATX_VERSION for lack of a way to make it
consistent - can be reinstated later.
David
---
David Howells (4):
statx: Add a system call to make enhanced file info available
statx: Ext4: Return enhanced file attributes
statx: NFS: Return enhanced file attributes
statx: AFS: Return enhanced file attributes
arch/x86/entry/syscalls/syscall_32.tbl | 1
arch/x86/entry/syscalls/syscall_64.tbl | 1
fs/afs/inode.c | 11 +
fs/exportfs/expfs.c | 4
fs/ext4/ext4.h | 2
fs/ext4/file.c | 2
fs/ext4/inode.c | 36 ++++
fs/ext4/namei.c | 2
fs/ext4/symlink.c | 2
fs/nfs/inode.c | 32 +++
fs/stat.c | 296 +++++++++++++++++++++++++++++---
include/linux/fs.h | 5 -
include/linux/stat.h | 19 +-
include/linux/syscalls.h | 3
include/uapi/linux/fcntl.h | 5 +
include/uapi/linux/stat.h | 116 +++++++++++++
samples/Kconfig | 5 +
samples/Makefile | 3
samples/statx/Makefile | 10 +
samples/statx/test-statx.c | 248 +++++++++++++++++++++++++++
20 files changed, 746 insertions(+), 57 deletions(-)
create mode 100644 samples/statx/Makefile
create mode 100644 samples/statx/test-statx.c
[toc] | [next] | [standalone]
| From | David Howells <dhowells@redhat.com> |
|---|---|
| Date | 2016-11-18 17:30 +0100 |
| Subject | [PATCH 3/4] statx: NFS: Return enhanced file attributes [ver #2] |
| Message-ID | <sEUd5-14p-53@gated-at.bofh.it> |
| In reply to | #1525496 |
Return enhanced file atrributes from the NFS filesystem. This includes the
following:
(1) STATX_ATTR_AUTOMOUNT is set on referral or submount directories that
are automounted upon. NFS shows one directory with a different FSID,
but the local VFS has two: the mountpoint directory (fabricated) and
the root of the filesystem mounted upon it.
Furthermore, what nfs_getattr() does can be controlled as follows:
(1) If AT_STATX_DONT_SYNC is indicated then this will suppress the
flushing of outstanding writes and the rereading of the inode's
attributes with the server as detailed below.
(2) Otherwise:
(a) If AT_STATX_FORCE_SYNC is indicated, or mtime or ctime are
requested then the outstanding writes will be written to the
server first.
(b) The inode's attributes will be reread from the server:
(i) if AT_STATX_FORCE_SYNC is indicated;
(ii) if atime is requested (and atime updating is not suppressed by
a mount flag); or
(iii) if the cached attributes have expired;
If the inode isn't synchronised, then the cached attributes will be used -
even if expired - without reference to the server.
Example output:
[root@andromeda ~]# ./samples/statx/test-statx /warthog/
statx(/warthog/) = 0
results=17ff
Size: 4096 Blocks: 8 IO Block: 1048576 directory
Device: 00:26 Inode: 2 Links: 21
Access: (0555/dr-xr-xr-x) Uid: 0 Gid: 0
Access: 2016-11-14 11:49:14.582749262+0000
Modify: 2016-09-08 20:39:46.785788707+0100
Change: 2016-09-08 20:39:46.785788707+0100
IO-blocksize: blksize=1048576
Note that the NFS4 protocol potentially provides a creation time that could
be passed through this interface and system, hidden and archive values that
could be passed as attributes. There is also a backup time that could be
exposed.
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/nfs/inode.c | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index bf4ec5ecc97e..3002350d4a84 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -656,12 +656,20 @@ static bool nfs_need_revalidate_inode(struct inode *inode)
int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
{
struct inode *inode = d_inode(dentry);
- int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME;
+ unsigned int sync_type = stat->query_flags & AT_STATX_SYNC_TYPE;
+ bool need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME;
int err = 0;
trace_nfs_getattr_enter(inode);
- /* Flush out writes to the server in order to update c/mtime. */
- if (S_ISREG(inode->i_mode)) {
+
+ /* Flush out writes to the server in order to update c/mtime if the
+ * user wants them.
+ */
+ if (sync_type != AT_STATX_DONT_SYNC &&
+ S_ISREG(inode->i_mode) &&
+ (sync_type == AT_STATX_FORCE_SYNC ||
+ (stat->request_mask & (STATX_MTIME | STATX_CTIME)))
+ ) {
err = filemap_write_and_wait(inode->i_mapping);
if (err)
goto out;
@@ -676,11 +684,15 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
* - NFS never sets MS_NOATIME or MS_NODIRATIME so there is
* no point in checking those.
*/
- if ((mnt->mnt_flags & MNT_NOATIME) ||
- ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)))
- need_atime = 0;
-
- if (need_atime || nfs_need_revalidate_inode(inode)) {
+ if (!(stat->request_mask & STATX_ATIME) ||
+ (mnt->mnt_flags & MNT_NOATIME) ||
+ ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)))
+ need_atime = false;
+
+ if (sync_type != AT_STATX_DONT_SYNC &&
+ (sync_type == AT_STATX_FORCE_SYNC ||
+ need_atime ||
+ nfs_need_revalidate_inode(inode))) {
struct nfs_server *server = NFS_SERVER(inode);
if (server->caps & NFS_CAP_READDIRPLUS)
@@ -693,6 +705,10 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
if (S_ISDIR(inode->i_mode))
stat->blksize = NFS_SERVER(inode)->dtsize;
}
+
+ generic_fillattr(inode, stat);
+ stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode));
+
out:
trace_nfs_getattr_exit(inode, err);
return err;
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2016-11-18 18:00 +0100 |
| Subject | Re: [PATCH 1/4] statx: Add a system call to make enhanced file info available [ver #2] |
| Message-ID | <sEUG5-1ff-13@gated-at.bofh.it> |
| In reply to | #1525496 |
On Friday, November 18, 2016 4:20:38 PM CET David Howells wrote: > Add a system call to make extended file information available, including > file creation and some attribute flags where available through the > underlying filesystem. Looks great! Is there still hope of scheduling this for v4.10, or are you planning it for v4.11 at this point? > ======== > OVERVIEW > ======== > > The idea was initially proposed as a set of xattrs that could be retrieved > with getxattr(), but the general preferance proved to be for a new syscall > with an extended stat structure. > > This has a number of uses: ... > > Note that not all of the above are implemented here. It's good to have the whole list of possible features here, but the list of features that are actually implemented is probably more important for the changelog. You seem to have that list in the introductory mail but not in the actual patch. > - stat->atime = inode->i_atime; > > stat->mtime = inode->i_mtime; > stat->ctime = inode->i_ctime; > > - stat->blksize = (1 << inode->i_blkbits); > + stat->size = i_size_read(inode); > > stat->blocks = inode->i_blocks; > > -} > + stat->blksize = 1 << inode->i_blkbits; > > + stat->result_mask |= STATX_BASIC_STATS; > + if (IS_NOATIME(inode)) > + stat->result_mask &= ~STATX_ATIME; > + else > + stat->atime = inode->i_atime; This looks like you are changing the behavior of the existing stat call to no longer return the atime from the on-disk inode if NOATIME is set. Is my interpretation correct, and is this an intentional change? Arnd
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web