linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/11] NFSv4: Don't request size+change attribute if they are delegated to us
@ 2018-06-04 22:31 Trond Myklebust
  2018-06-04 22:31 ` [PATCH 02/11] NFS: Pass the inode down to the getattr() callback Trond Myklebust
  0 siblings, 1 reply; 11+ messages in thread
From: Trond Myklebust @ 2018-06-04 22:31 UTC (permalink / raw)
  To: linux-nfs

From: Trond Myklebust <trond.myklebust@primarydata.com>

When we hold a delegation, we should not need to request attributes such
as the file size or the change attribute. For some servers, avoiding
asking for these unneeded attributes can improve the overall system
performance.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/nfs4proc.c | 40 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index bb1141c48281..c44cfa6be8ff 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -71,6 +71,8 @@
 
 #define NFSDBG_FACILITY		NFSDBG_PROC
 
+#define NFS4_BITMASK_SZ		3
+
 #define NFS4_POLL_RETRY_MIN	(HZ/10)
 #define NFS4_POLL_RETRY_MAX	(15*HZ)
 
@@ -274,6 +276,33 @@ const u32 nfs4_fs_locations_bitmap[3] = {
 	| FATTR4_WORD1_MOUNTED_ON_FILEID,
 };
 
+static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,
+		struct inode *inode)
+{
+	unsigned long cache_validity;
+
+	memcpy(dst, src, NFS4_BITMASK_SZ*sizeof(*dst));
+	if (!inode || !nfs4_have_delegation(inode, FMODE_READ))
+		return;
+
+	cache_validity = READ_ONCE(NFS_I(inode)->cache_validity);
+	if (!(cache_validity & NFS_INO_REVAL_FORCED))
+		cache_validity &= ~(NFS_INO_INVALID_CHANGE
+				| NFS_INO_INVALID_SIZE);
+
+	if (!(cache_validity & NFS_INO_INVALID_SIZE))
+		dst[0] &= ~FATTR4_WORD0_SIZE;
+
+	if (!(cache_validity & NFS_INO_INVALID_CHANGE))
+		dst[0] &= ~FATTR4_WORD0_CHANGE;
+}
+
+static void nfs4_bitmap_copy_adjust_setattr(__u32 *dst,
+		const __u32 *src, struct inode *inode)
+{
+	nfs4_bitmap_copy_adjust(dst, src, inode);
+}
+
 static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry,
 		struct nfs4_readdir_arg *readdir)
 {
@@ -3074,12 +3103,13 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
 			   struct nfs4_label *olabel)
 {
 	struct nfs_server *server = NFS_SERVER(inode);
+	__u32 bitmask[NFS4_BITMASK_SZ];
 	struct nfs4_state *state = ctx ? ctx->state : NULL;
 	struct nfs_setattrargs	arg = {
 		.fh		= NFS_FH(inode),
 		.iap		= sattr,
 		.server		= server,
-		.bitmask = server->attr_bitmask,
+		.bitmask = bitmask,
 		.label		= ilabel,
 	};
 	struct nfs_setattrres  res = {
@@ -3094,11 +3124,11 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
 	};
 	int err;
 
-	arg.bitmask = nfs4_bitmask(server, ilabel);
-	if (ilabel)
-		arg.bitmask = nfs4_bitmask(server, olabel);
-
 	do {
+		nfs4_bitmap_copy_adjust_setattr(bitmask,
+				nfs4_bitmask(server, olabel),
+				inode);
+
 		err = _nfs4_do_setattr(inode, &arg, &res, cred, ctx);
 		switch (err) {
 		case -NFS4ERR_OPENMODE:
-- 
2.17.1


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

end of thread, other threads:[~2018-06-04 22:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-04 22:31 [PATCH 01/11] NFSv4: Don't request size+change attribute if they are delegated to us Trond Myklebust
2018-06-04 22:31 ` [PATCH 02/11] NFS: Pass the inode down to the getattr() callback Trond Myklebust
2018-06-04 22:31   ` [PATCH 03/11] NFSv4: Don't ask for delegated attributes when revalidating the inode Trond Myklebust
2018-06-04 22:31     ` [PATCH 04/11] NFSv4: Don't ask for delegated attributes when adding a hard link Trond Myklebust
2018-06-04 22:31       ` [PATCH 05/11] NFSv4: Ignore NFS_INO_REVAL_FORCED in nfs4_proc_access Trond Myklebust
2018-06-04 22:31         ` [PATCH 06/11] NFSv4: Ensure the inode is clean when we set a delegation Trond Myklebust
2018-06-04 22:31           ` [PATCH 07/11] NFS: fix up nfs_setattr_update_inode Trond Myklebust
2018-06-04 22:31             ` [PATCH 08/11] NFS: Fix attribute revalidation Trond Myklebust
2018-06-04 22:31               ` [PATCH 09/11] NFS: Improve caching while holding a delegation Trond Myklebust
2018-06-04 22:31                 ` [PATCH 10/11] NFS: Ignore NFS_INO_REVAL_FORCED in nfs_check_inode_attributes() Trond Myklebust
2018-06-04 22:31                   ` [PATCH 11/11] NFS: Filter cache invalidation when holding a delegation Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).