Linux-CIFS Archive on lore.kernel.org
 help / color / Atom feed
* [CIFS][PATCH] Honor the AT_SYNC_TYPE flags
@ 2020-02-19  5:04 Steve French
  2020-02-20 16:15 ` Aurélien Aptel
  0 siblings, 1 reply; 2+ messages in thread
From: Steve French @ 2020-02-19  5:04 UTC (permalink / raw)
  To: CIFS; +Cc: linux-fsdevel

[-- Attachment #1: Type: text/plain, Size: 417 bytes --]

     cifs.ko should 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.

-- 
Thanks,

Steve

[-- Attachment #2: 0001-cifs-do-not-ignore-the-SYNC-flags-in-getattr.patch --]
[-- Type: text/x-patch, Size: 2090 bytes --]

From 29361590ed10fe5db2b02574b19d3ed8afec5bf4 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Tue, 18 Feb 2020 18:07:57 -0600
Subject: [PATCH] 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.

Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/inode.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 1212ace05258..4fed7a9117c6 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -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
 	 * has actual ctime, mtime and file length.
 	 */
-	if (!CIFS_CACHE_READ(CIFS_I(inode)) && inode->i_mapping &&
-	    inode->i_mapping->nrpages != 0) {
+	if ((request_mask & (STATX_CTIME | STATX_MTIME | STATX_SIZE)) &&
+	    !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);
@@ -2157,9 +2158,20 @@ int cifs_getattr(const struct path *path, struct kstat *stat,
 		}
 	}
 
-	rc = cifs_revalidate_dentry_attr(dentry);
-	if (rc)
-		return rc;
+	if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_FORCE_SYNC)
+		CIFS_I(inode)->time = 0; /* force revalidate */
+
+	/*
+	 * 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);
 	stat->blksize = cifs_sb->bsize;
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [CIFS][PATCH] Honor the AT_SYNC_TYPE flags
  2020-02-19  5:04 [CIFS][PATCH] Honor the AT_SYNC_TYPE flags Steve French
@ 2020-02-20 16:15 ` Aurélien Aptel
  0 siblings, 0 replies; 2+ messages in thread
From: Aurélien Aptel @ 2020-02-20 16:15 UTC (permalink / raw)
  To: Steve French, CIFS; +Cc: linux-fsdevel


Reviewed-by: Aurelien Aptel <aaptel@suse.com>

-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19  5:04 [CIFS][PATCH] Honor the AT_SYNC_TYPE flags Steve French
2020-02-20 16:15 ` Aurélien Aptel

Linux-CIFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-cifs/0 linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ https://lore.kernel.org/linux-cifs \
		linux-cifs@vger.kernel.org
	public-inbox-index linux-cifs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-cifs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git