Commit ffdec8d6 authored by Steve French's avatar Steve French

cifs: do not ignore the SYNC flags in getattr

Check the AT_STATX_FORCE_SYNC flag and force an attribute
revalidation if requested by the caller, and if the caller
specificies AT_STATX_DONT_SYNC only revalidate cached attributes
if required.  In addition do not flush writes in getattr (which
can be expensive) if size or timestamps not requested by the
caller.
Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 16fbf79b
...@@ -2148,8 +2148,9 @@ int cifs_getattr(const struct path *path, struct kstat *stat, ...@@ -2148,8 +2148,9 @@ int cifs_getattr(const struct path *path, struct kstat *stat,
* We need to be sure that all dirty pages are written and the server * We need to be sure that all dirty pages are written and the server
* has actual ctime, mtime and file length. * has actual ctime, mtime and file length.
*/ */
if (!CIFS_CACHE_READ(CIFS_I(inode)) && inode->i_mapping && if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_SIZE)) &&
inode->i_mapping->nrpages != 0) { !CIFS_CACHE_READ(CIFS_I(inode)) &&
inode->i_mapping && inode->i_mapping->nrpages != 0) {
rc = filemap_fdatawait(inode->i_mapping); rc = filemap_fdatawait(inode->i_mapping);
if (rc) { if (rc) {
mapping_set_error(inode->i_mapping, rc); mapping_set_error(inode->i_mapping, rc);
...@@ -2157,9 +2158,20 @@ int cifs_getattr(const struct path *path, struct kstat *stat, ...@@ -2157,9 +2158,20 @@ int cifs_getattr(const struct path *path, struct kstat *stat,
} }
} }
rc = cifs_revalidate_dentry_attr(dentry); if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_FORCE_SYNC)
if (rc) CIFS_I(inode)->time = 0; /* force revalidate */
return rc;
/*
* If the caller doesn't require syncing, only sync if
* necessary (e.g. due to earlier truncate or setattr
* invalidating the cached metadata)
*/
if (((flags & AT_STATX_SYNC_TYPE) != AT_STATX_DONT_SYNC) ||
(CIFS_I(inode)->time == 0)) {
rc = cifs_revalidate_dentry_attr(dentry);
if (rc)
return rc;
}
generic_fillattr(inode, stat); generic_fillattr(inode, stat);
stat->blksize = cifs_sb->bsize; stat->blksize = cifs_sb->bsize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment