honor AT_STATX_DONT_SYNC in netfs
Subsystems (12)
cover honor AT_STATX_DONT_SYNC in netfs
This is pretty simple to do: all netfs getattr implementations consist of two phases:
1) refresh attributes
2) fill in kstat
We just need to omit the first phase if this flag is given.
---
Miklos Szeredi (10):
ceph: honor AT_STATX_DONT_SYNC
cifs: honor AT_STATX_DONT_SYNC
coda: honor AT_STATX_DONT_SYNC
fuse: honor AT_STATX_DONT_SYNC
gfs2: honor AT_STATX_DONT_SYNC
lustre: honor AT_STATX_DONT_SYNC
nfs: honor AT_STATX_DONT_SYNC
ocfs2: honor AT_STATX_DONT_SYNC
orangefs: honor AT_STATX_DONT_SYNC
9p: honor AT_STATX_DONT_SYNC
drivers/staging/lustre/lustre/llite/file.c | 12 +++++++----- fs/9p/vfs_inode.c | 4 +++- fs/9p/vfs_inode_dotl.c | 3 ++- fs/ceph/inode.c | 6 ++++-- fs/cifs/inode.c | 30 ++++++++++++++++-------------- fs/coda/inode.c | 5 ++++- fs/fuse/dir.c | 9 +++++---- fs/gfs2/inode.c | 3 ++- fs/nfs/inode.c | 6 +++++- fs/ocfs2/file.c | 12 +++++++----- fs/orangefs/inode.c | 6 ++++-- 11 files changed, 59 insertions(+), 37 deletions(-)
Signature · 1 line
2.5.5
PATCH 1/10 ceph: honor AT_STATX_DONT_SYNC
The description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
--- fs/ceph/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ceph/inode.c +4 -2
@@ -2201,9 +2201,11 @@ int ceph_getattr(const struct path *path, struct kstat *stat, {struct inode *inode =d_inode (path->dentry);struct ceph_inode_info *ci =ceph_inode (inode); -int err; +int err =0 ; + +if (!(flags &AT_STATX_DONT_SYNC )) + err =ceph_do_getattr (inode,CEPH_STAT_CAP_INODE_ALL , false); - err =ceph_do_getattr (inode,CEPH_STAT_CAP_INODE_ALL , false);if (!err) {generic_fillattr (inode, stat); stat->ino =ceph_translate_ino (inode->i_sb, inode->i_ino);
Signature · 1 line
2.5.5
PATCH 2/10 cifs: honor AT_STATX_DONT_SYNC
In reply to Miklos SzerediThe description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
--- fs/cifs/inode.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
fs/cifs/inode.c +16 -14
@@ -2003,22 +2003,24 @@ int cifs_getattr(const struct path *path, struct kstat *stat,struct inode *inode =d_inode (dentry);int rc; -/* -* We need to be sure that all dirty pages are written and the server -* has actual ctime, mtime and file length. -*/ -if (!CIFS_CACHE_READ (CIFS_I (inode)) && inode->i_mapping && - inode->i_mapping->nrpages !=0 ) { - rc =filemap_fdatawait (inode->i_mapping); -if (rc) { -mapping_set_error (inode->i_mapping, rc); -return rc; +if (!(flags &AT_STATX_DONT_SYNC )) { +/* +* We need to be sure that all dirty pages are written and the +* server has actual ctime, mtime and file length. +*/ +if (!CIFS_CACHE_READ (CIFS_I (inode)) && inode->i_mapping && + inode->i_mapping->nrpages !=0 ) { + rc =filemap_fdatawait (inode->i_mapping); +if (rc) { +mapping_set_error (inode->i_mapping, rc); +return rc; + } } - } - rc =cifs_revalidate_dentry_attr (dentry); -if (rc) -return rc; + rc =cifs_revalidate_dentry_attr (dentry); +if (rc) +return rc; + }generic_fillattr (inode, stat); stat->blksize =CIFS_MAX_MSGSIZE ;
Signature · 1 line
2.5.5
Re: [PATCH 02/10] cifs: honor AT_STATX_DONT_SYNC
Do you have any sample program/code to query with this flag?
Quoted 56 lines · Miklos Szeredi
The description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
Signed-off-by Miklos Szeredi <[email protected]>Cc Steve French <[email protected]>--- fs/cifs/inode.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)fs/cifs/inode.c +16
-15@@ -2003,22 +2003,24 @@ int cifs_getattr(const struct path *path, struct kstat *stat,struct inode *inode =d_inode (dentry);int rc; -/* -* We need to be sure that all dirty pages are written and the server -* has actual ctime, mtime and file length. -*/ -if (!CIFS_CACHE_READ (CIFS_I (inode)) && inode->i_mapping && - inode->i_mapping->nrpages !=0 ) { - rc =filemap_fdatawait (inode->i_mapping); -if (rc) { -mapping_set_error (inode->i_mapping, rc); -return rc; +if (!(flags &AT_STATX_DONT_SYNC )) { +/* +* We need to be sure that all dirty pages are written and the +* server has actual ctime, mtime and file length. +*/ +if (!CIFS_CACHE_READ (CIFS_I (inode)) && inode->i_mapping && + inode->i_mapping->nrpages !=0 ) { + rc =filemap_fdatawait (inode->i_mapping); +if (rc) { +mapping_set_error (inode->i_mapping, rc); +return rc; + } } - } - rc =cifs_revalidate_dentry_attr (dentry); -if (rc) -return rc; + rc =cifs_revalidate_dentry_attr (dentry); +if (rc) +return rc; + }generic_fillattr (inode, stat); stat->blksize =CIFS_MAX_MSGSIZE ; --2.5.5
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): CAH2r5mtNGzVsoKw49zxButMNfwTtx1H4CFe9o9=mCxhCHZVFuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
PATCH 2/10 cifs: honor AT_STATX_DONT_SYNC
Adding linux-cifs to cc
---------- Forwarded message ----------
From: Steve French <[email protected]>
Date: Thu, Sep 21, 2017 at 1:14 PM
Subject: Re: [PATCH 02/10] cifs: honor AT_STATX_DONT_SYNC
To: Miklos Szeredi <[email protected]>
Cc: linux-fsdevel <[email protected]>, LKML <[email protected]>, Al Viro <viro-RmSDqhL/[email protected]>, David Howells <[email protected]>, Steve French <[email protected]>
Do you have any sample program/code to query with this flag?
Quoted 54 lines · Miklos Szeredi
The description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
Signed-off-by Miklos Szeredi <[email protected]>Cc Steve French <[email protected]>--- fs/cifs/inode.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)fs/cifs/inode.c +16
-15@@ -2003,22 +2003,24 @@ int cifs_getattr(const struct path *path, struct kstat *stat,struct inode *inode =d_inode (dentry);int rc; -/* -* We need to be sure that all dirty pages are written and the server -* has actual ctime, mtime and file length. -*/ -if (!CIFS_CACHE_READ (CIFS_I (inode)) && inode->i_mapping && - inode->i_mapping->nrpages !=0 ) { - rc =filemap_fdatawait (inode->i_mapping); -if (rc) { -mapping_set_error (inode->i_mapping, rc); -return rc; +if (!(flags &AT_STATX_DONT_SYNC )) { +/* +* We need to be sure that all dirty pages are written and the +* server has actual ctime, mtime and file length. +*/ +if (!CIFS_CACHE_READ (CIFS_I (inode)) && inode->i_mapping && + inode->i_mapping->nrpages !=0 ) { + rc =filemap_fdatawait (inode->i_mapping); +if (rc) { +mapping_set_error (inode->i_mapping, rc); +return rc; + } } - } - rc =cifs_revalidate_dentry_attr (dentry); -if (rc) -return rc; + rc =cifs_revalidate_dentry_attr (dentry); +if (rc) +return rc; + }generic_fillattr (inode, stat); stat->blksize =CIFS_MAX_MSGSIZE ; --
Quoted 2 lines
2.5.5
--
Thanks,
Steve
Signature · 3 lines
Thanks, Steve
PATCH 3/10 coda: honor AT_STATX_DONT_SYNC
In reply to Miklos SzerediThe description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
--- fs/coda/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/coda/inode.c +4 -1
@@ -255,7 +255,10 @@ static void coda_evict_inode(struct inode *inode)int coda_getattr (const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags) { -int err =coda_revalidate_inode (d_inode (path->dentry)); +int err =0 ; + +if (!(flags &AT_STATX_DONT_SYNC )) + err =coda_revalidate_inode (d_inode (path->dentry));if (!err)generic_fillattr (d_inode (path->dentry), stat);return err;
Signature · 1 line
2.5.5
Jan Harkes
maintainerRe: [PATCH 03/10] coda: honor AT_STATX_DONT_SYNC
Quoted 3 lines · Miklos Szeredi
The description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
What is the use case for this AT_STATX_DONT_SYNC flag?
I'm asking because the Coda userspace client potentially has attributes that are not cached in the kernel but can be (re-)validated without network communication. So if we just care about avoiding network traffic we could propagate the flag up to userspace. If we want to avoid context switches, disk I/O and only check on what happens to be cached in the kernel the current approach works fine.
Jan
Quoted 26 lines
Signed-off-by Miklos Szeredi <[email protected]>Cc Jan Harkes <[email protected]>--- fs/coda/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fs/coda/inode.c +4
-1@@ -255,7 +255,10 @@ static void coda_evict_inode(struct inode *inode)int coda_getattr (const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags) { -int err =coda_revalidate_inode (d_inode (path->dentry)); +int err =0 ; + +if (!(flags &AT_STATX_DONT_SYNC )) + err =coda_revalidate_inode (d_inode (path->dentry));if (!err)generic_fillattr (d_inode (path->dentry), stat);return err;Signature · 1 line
2.5.5
Re: [PATCH 03/10] coda: honor AT_STATX_DONT_SYNC
Quoted 5 lines · Jan Harkes
Quoted 3 lines · Miklos Szeredi
The description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
Quoted 8 lines
What is the use case for this
AT_STATX_DONT_SYNCflag?I'm asking because the Coda userspace client potentially has attributes that are not cached in the kernel but can be (re-)validated without network communication. So if we just care about avoiding network traffic we could propagate the flag up to userspace. If we want to avoid context switches, disk I/O and only check on what happens to be cached in the kernel the current approach works fine.
It's an interesting question, "server" could mean several different things depending on the context. I interpreted it as "any entity outside the kernel the filesystem resides in", mainly because it's the simplest interpretation.
Thanks,
Miklos
Quoted 26 lines
Quoted 26 lines
Signed-off-by Miklos Szeredi <[email protected]>Cc Jan Harkes <[email protected]>--- fs/coda/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fs/coda/inode.c +4
-2@@ -255,7 +255,10 @@ static void coda_evict_inode(struct inode *inode)int coda_getattr (const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags) { -int err =coda_revalidate_inode (d_inode (path->dentry)); +int err =0 ; + +if (!(flags &AT_STATX_DONT_SYNC )) + err =coda_revalidate_inode (d_inode (path->dentry));if (!err)generic_fillattr (d_inode (path->dentry), stat);return err; --2.5.5
PATCH 4/10 fuse: honor AT_STATX_DONT_SYNC
In reply to Miklos SzerediThe description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
--- fs/fuse/dir.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/fuse/dir.c +5 -4
@@ -924,12 +924,13 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat, }static int fuse_update_get_attr (struct inode *inode,struct file *file, -struct kstat *stat) +struct kstat *stat,unsigned int flags) {struct fuse_inode *fi =get_fuse_inode (inode);int err =0 ; -if (time_before64 (fi->i_time,get_jiffies_64 ())) { +if (!(flags &AT_STATX_DONT_SYNC ) && +time_before64 (fi->i_time,get_jiffies_64 ())) {forget_all_cached_acls (inode); err =fuse_do_getattr (inode, stat, file); }else if (stat) {
@@ -943,7 +944,7 @@ static int fuse_update_get_attr(struct inode *inode, struct file *file,int fuse_update_attributes (struct inode *inode,struct file *file) { -return fuse_update_get_attr (inode, file,NULL ); +return fuse_update_get_attr (inode, file,NULL ,0 ); } int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
@@ -1782,7 +1783,7 @@ static int fuse_getattr(const struct path *path, struct kstat *stat,if (!fuse_allow_current_process (fc))return -EACCES ; -return fuse_update_get_attr (inode,NULL , stat); +return fuse_update_get_attr (inode,NULL , stat, flags); }static const struct inode_operations fuse_dir_inode_operations = {
Signature · 1 line
2.5.5
PATCH 5/10 gfs2: honor AT_STATX_DONT_SYNC
In reply to Miklos SzerediThe description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
--- fs/gfs2/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/gfs2/inode.c +2 -1
@@ -1989,7 +1989,8 @@ static int gfs2_getattr(const struct path *path, struct kstat *stat,int error;gfs2_holder_mark_uninitialized (&gh); -if (gfs2_glock_is_locked_by_me (ip->i_gl) ==NULL ) { +if (!(flags &AT_STATX_DONT_SYNC ) && +gfs2_glock_is_locked_by_me (ip->i_gl) ==NULL ) { error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , &gh);if (error)return error;
Signature · 1 line
2.5.5
PATCH 6/10 lustre: honor AT_STATX_DONT_SYNC
In reply to Miklos SzerediThe description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
--- drivers/staging/lustre/lustre/llite/file.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/llite/file.c +7 -5
@@ -2955,14 +2955,16 @@ int ll_getattr(const struct path *path, struct kstat *stat,struct ll_inode_info *lli =ll_i2info (inode);int res; - res =ll_inode_revalidate (path->dentry, +if (!(flags &AT_STATX_DONT_SYNC )) { + res =ll_inode_revalidate (path->dentry,MDS_INODELOCK_UPDATE |MDS_INODELOCK_LOOKUP ); -ll_stats_ops_tally (sbi,LPROC_LL_GETATTR ,1 ); +ll_stats_ops_tally (sbi,LPROC_LL_GETATTR ,1 ); -if (res) -return res; +if (res) +return res; -OBD_FAIL_TIMEOUT (OBD_FAIL_GETATTR_DELAY ,30 ); +OBD_FAIL_TIMEOUT (OBD_FAIL_GETATTR_DELAY ,30 ); + } stat->dev = inode->i_sb->s_dev;if (ll_need_32bit_api (sbi))
Signature · 1 line
2.5.5
PATCH 7/10 nfs: honor AT_STATX_DONT_SYNC
In reply to Miklos SzerediThe description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
--- fs/nfs/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/nfs/inode.c +5 -1
@@ -739,6 +739,10 @@ int nfs_getattr(const struct path *path, struct kstat *stat,int err =0 ;trace_nfs_getattr_enter (inode); + +if (query_flags &AT_STATX_DONT_SYNC ) + goto out; +/* Flush out writes to the server in order to update c/mtime. */ if (S_ISREG (inode->i_mode)) { err =filemap_write_and_wait (inode->i_mapping);
@@ -769,13 +773,13 @@ int nfs_getattr(const struct path *path, struct kstat *stat, err =__nfs_revalidate_inode (server, inode); }else nfs_readdirplus_parent_cache_hit (path->dentry); +out:if (!err) {generic_fillattr (inode, stat); stat->ino =nfs_compat_user_ino64 (NFS_FILEID (inode));if (S_ISDIR (inode->i_mode)) stat->blksize =NFS_SERVER (inode)->dtsize; } -out:trace_nfs_getattr_exit (inode, err);return err; }
Signature · 1 line
2.5.5
PATCH 8/10 ocfs2: honor AT_STATX_DONT_SYNC
In reply to Miklos SzerediThe description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
--- fs/ocfs2/file.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/ocfs2/file.c +7 -5
@@ -1307,11 +1307,13 @@ int ocfs2_getattr(const struct path *path, struct kstat *stat,struct ocfs2_super *osb = sb->s_fs_info;int err; - err =ocfs2_inode_revalidate (path->dentry); -if (err) { -if (err != -ENOENT ) -mlog_errno (err); - goto bail; +if (!(flags &AT_STATX_DONT_SYNC )) { + err =ocfs2_inode_revalidate (path->dentry); +if (err) { +if (err != -ENOENT ) +mlog_errno (err); + goto bail; + } }generic_fillattr (inode, stat);
Signature · 1 line
2.5.5
PATCH 9/10 orangefs: honor AT_STATX_DONT_SYNC
In reply to Miklos SzerediThe description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
--- fs/orangefs/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/orangefs/inode.c +4 -2
@@ -247,7 +247,7 @@ int orangefs_setattr(struct dentry *dentry, struct iattr *iattr)int orangefs_getattr (const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags) { -int ret = -ENOENT ; +int ret =0 ;struct inode *inode = path->dentry->d_inode;struct orangefs_inode_s *orangefs_inode =NULL ;
@@ -255,7 +255,9 @@ int orangefs_getattr(const struct path *path, struct kstat *stat,"orangefs_getattr: called on %pd\n" , path->dentry); - ret =orangefs_inode_getattr (inode,0 ,0 , request_mask); +if (!(flags &AT_STATX_DONT_SYNC )) + ret =orangefs_inode_getattr (inode,0 ,0 , request_mask); +if (ret ==0 ) {generic_fillattr (inode, stat);
Signature · 1 line
2.5.5
PATCH 10/10 9p: honor AT_STATX_DONT_SYNC
In reply to Miklos SzerediThe description of this flag says "Don't sync attributes with the server". In other words: always use the attributes cached in the kernel and don't send network or local messages to refresh the attributes.
--- fs/9p/vfs_inode.c | 4 +++- fs/9p/vfs_inode_dotl.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-)
fs/9p/vfs_inode.c +3 -1
@@ -1065,7 +1065,9 @@ v9fs_vfs_getattr(const struct path *path, struct kstat *stat,p9_debug (P9_DEBUG_VFS ,"dentry: %p\n" , dentry); v9ses =v9fs_dentry2v9ses (dentry); -if (v9ses->cache ==CACHE_LOOSE || v9ses->cache ==CACHE_FSCACHE ) { + +if (v9ses->cache ==CACHE_LOOSE || v9ses->cache ==CACHE_FSCACHE || + (flags &AT_STATX_DONT_SYNC )) {generic_fillattr (d_inode (dentry), stat);return 0 ; }
fs/9p/vfs_inode_dotl.c +2 -1
@@ -478,7 +478,8 @@ v9fs_vfs_getattr_dotl(const struct path *path, struct kstat *stat,p9_debug (P9_DEBUG_VFS ,"dentry: %p\n" , dentry); v9ses =v9fs_dentry2v9ses (dentry); -if (v9ses->cache ==CACHE_LOOSE || v9ses->cache ==CACHE_FSCACHE ) { +if (v9ses->cache ==CACHE_LOOSE || v9ses->cache ==CACHE_FSCACHE || + (flags &AT_STATX_DONT_SYNC )) {generic_fillattr (d_inode (dentry), stat);return 0 ; }
Signature · 1 line
2.5.5