All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nagendra Tomar <Nagendra.Tomar@microsoft.com>
To: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>,
	"anna.schumaker@netapp.com" <anna.schumaker@netapp.com>
Subject: [PATCH 4/5] nfs: Add mount option for forcing RPC requests to one file over one connection
Date: Tue, 23 Mar 2021 05:50:09 +0000	[thread overview]
Message-ID: <SG2P153MB036175692E2D6C18D06C3A1B9E649@SG2P153MB0361.APCP153.PROD.OUTLOOK.COM> (raw)

From: Nagendra S Tomar <natomar@microsoft.com>

Functions for computing target filehandles' hash for NFSv3.

Signed-off-by: Nagendra S Tomar <natomar@microsoft.com>
---
 fs/nfs/nfs3xdr.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 154 insertions(+)

diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index ed1c83738c30..3d90686cd77d 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -817,6 +817,13 @@ static void nfs3_xdr_enc_getattr3args(struct rpc_rqst *req,
 	encode_nfs_fh3(xdr, fh);
 }
 
+static u32 nfs3_fh_hash_getattr(const void *data)
+{
+	const struct nfs_fh *fh = data;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.2  SETATTR3args
  *
@@ -858,6 +865,14 @@ static void nfs3_xdr_enc_setattr3args(struct rpc_rqst *req,
 	encode_sattrguard3(xdr, args);
 }
 
+static u32 nfs3_fh_hash_setattr(const void *data)
+{
+	const struct nfs3_sattrargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.3  LOOKUP3args
  *
@@ -874,6 +889,14 @@ static void nfs3_xdr_enc_lookup3args(struct rpc_rqst *req,
 	encode_diropargs3(xdr, args->fh, args->name, args->len);
 }
 
+static u32 nfs3_fh_hash_lookup(const void *data)
+{
+	const struct nfs3_diropargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.4  ACCESS3args
  *
@@ -898,6 +921,14 @@ static void nfs3_xdr_enc_access3args(struct rpc_rqst *req,
 	encode_access3args(xdr, args);
 }
 
+static u32 nfs3_fh_hash_access(const void *data)
+{
+	const struct nfs3_accessargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.5  READLINK3args
  *
@@ -916,6 +947,14 @@ static void nfs3_xdr_enc_readlink3args(struct rpc_rqst *req,
 				NFS3_readlinkres_sz - NFS3_pagepad_sz);
 }
 
+static u32 nfs3_fh_hash_readlink(const void *data)
+{
+	const struct nfs3_readlinkargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.6  READ3args
  *
@@ -951,6 +990,14 @@ static void nfs3_xdr_enc_read3args(struct rpc_rqst *req,
 	req->rq_rcv_buf.flags |= XDRBUF_READ;
 }
 
+static u32 nfs3_fh_hash_read(const void *data)
+{
+	const struct nfs_pgio_args *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.7  WRITE3args
  *
@@ -993,6 +1040,14 @@ static void nfs3_xdr_enc_write3args(struct rpc_rqst *req,
 	xdr->buf->flags |= XDRBUF_WRITE;
 }
 
+static u32 nfs3_fh_hash_write(const void *data)
+{
+	const struct nfs_pgio_args *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.8  CREATE3args
  *
@@ -1043,6 +1098,14 @@ static void nfs3_xdr_enc_create3args(struct rpc_rqst *req,
 	encode_createhow3(xdr, args, rpc_rqst_userns(req));
 }
 
+static u32 nfs3_fh_hash_create(const void *data)
+{
+	const struct nfs3_createargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.9  MKDIR3args
  *
@@ -1061,6 +1124,14 @@ static void nfs3_xdr_enc_mkdir3args(struct rpc_rqst *req,
 	encode_sattr3(xdr, args->sattr, rpc_rqst_userns(req));
 }
 
+static u32 nfs3_fh_hash_mkdir(const void *data)
+{
+	const struct nfs3_mkdirargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.10  SYMLINK3args
  *
@@ -1095,6 +1166,14 @@ static void nfs3_xdr_enc_symlink3args(struct rpc_rqst *req,
 	xdr->buf->flags |= XDRBUF_WRITE;
 }
 
+static u32 nfs3_fh_hash_symlink(const void *data)
+{
+	const struct nfs3_symlinkargs *args = data;
+	const struct nfs_fh *fh = args->fromfh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.11  MKNOD3args
  *
@@ -1159,6 +1238,14 @@ static void nfs3_xdr_enc_mknod3args(struct rpc_rqst *req,
 	encode_mknoddata3(xdr, args, rpc_rqst_userns(req));
 }
 
+static u32 nfs3_fh_hash_mknod(const void *data)
+{
+	const struct nfs3_mknodargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.12  REMOVE3args
  *
@@ -1175,6 +1262,14 @@ static void nfs3_xdr_enc_remove3args(struct rpc_rqst *req,
 	encode_diropargs3(xdr, args->fh, args->name.name, args->name.len);
 }
 
+static u32 nfs3_fh_hash_remove(const void *data)
+{
+	const struct nfs_removeargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.14  RENAME3args
  *
@@ -1195,6 +1290,14 @@ static void nfs3_xdr_enc_rename3args(struct rpc_rqst *req,
 	encode_diropargs3(xdr, args->new_dir, new->name, new->len);
 }
 
+static u32 nfs3_fh_hash_rename(const void *data)
+{
+	const struct nfs_renameargs *args = data;
+	const struct nfs_fh *fh = args->old_dir;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.15  LINK3args
  *
@@ -1213,6 +1316,14 @@ static void nfs3_xdr_enc_link3args(struct rpc_rqst *req,
 	encode_diropargs3(xdr, args->tofh, args->toname, args->tolen);
 }
 
+static u32 nfs3_fh_hash_link(const void *data)
+{
+	const struct nfs3_linkargs *args = data;
+	const struct nfs_fh *fh = args->tofh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.16  READDIR3args
  *
@@ -1247,6 +1358,14 @@ static void nfs3_xdr_enc_readdir3args(struct rpc_rqst *req,
 				NFS3_readdirres_sz - NFS3_pagepad_sz);
 }
 
+static u32 nfs3_fh_hash_readdir(const void *data)
+{
+	const struct nfs3_readdirargs *args = data;
+	struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.17  READDIRPLUS3args
  *
@@ -1289,6 +1408,14 @@ static void nfs3_xdr_enc_readdirplus3args(struct rpc_rqst *req,
 				NFS3_readdirres_sz - NFS3_pagepad_sz);
 }
 
+static u32 nfs3_fh_hash_readdirplus(const void *data)
+{
+	const struct nfs3_readdirargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 /*
  * 3.3.21  COMMIT3args
  *
@@ -1319,6 +1446,14 @@ static void nfs3_xdr_enc_commit3args(struct rpc_rqst *req,
 	encode_commit3args(xdr, args);
 }
 
+static u32 nfs3_fh_hash_commit(const void *data)
+{
+	const struct nfs_commitargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 #ifdef CONFIG_NFS_V3_ACL
 
 static void nfs3_xdr_enc_getacl3args(struct rpc_rqst *req,
@@ -1337,6 +1472,14 @@ static void nfs3_xdr_enc_getacl3args(struct rpc_rqst *req,
 	}
 }
 
+static u32 nfs3_fh_hash_getacl(const void *data)
+{
+	const struct nfs3_getaclargs *args = data;
+	const struct nfs_fh *fh = args->fh;
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 static void nfs3_xdr_enc_setacl3args(struct rpc_rqst *req,
 				     struct xdr_stream *xdr,
 				     const void *data)
@@ -1366,6 +1509,14 @@ static void nfs3_xdr_enc_setacl3args(struct rpc_rqst *req,
 	BUG_ON(error < 0);
 }
 
+static u32 nfs3_fh_hash_setacl(const void *data)
+{
+	const struct nfs3_setaclargs *args = data;
+	const struct nfs_fh *fh = NFS_FH(args->inode);
+
+	return jhash(fh->data, fh->size, 0);
+}
+
 #endif  /* CONFIG_NFS_V3_ACL */
 
 /*
@@ -2517,6 +2668,7 @@ static int nfs3_stat_to_errno(enum nfs_stat status)
 	.p_proc      = NFS3PROC_##proc,					\
 	.p_encode    = nfs3_xdr_enc_##argtype##3args,			\
 	.p_decode    = nfs3_xdr_dec_##restype##3res,			\
+	.p_fhhash    = nfs3_fh_hash_##argtype,				\
 	.p_arglen    = NFS3_##argtype##args_sz,				\
 	.p_replen    = NFS3_##restype##res_sz,				\
 	.p_timer     = timer,						\
@@ -2562,6 +2714,7 @@ static const struct rpc_procinfo nfs3_acl_procedures[] = {
 		.p_proc = ACLPROC3_GETACL,
 		.p_encode = nfs3_xdr_enc_getacl3args,
 		.p_decode = nfs3_xdr_dec_getacl3res,
+		.p_fhhash = nfs3_fh_hash_getacl,
 		.p_arglen = ACL3_getaclargs_sz,
 		.p_replen = ACL3_getaclres_sz,
 		.p_timer = 1,
@@ -2571,6 +2724,7 @@ static const struct rpc_procinfo nfs3_acl_procedures[] = {
 		.p_proc = ACLPROC3_SETACL,
 		.p_encode = nfs3_xdr_enc_setacl3args,
 		.p_decode = nfs3_xdr_dec_setacl3res,
+		.p_fhhash = nfs3_fh_hash_setacl,
 		.p_arglen = ACL3_setaclargs_sz,
 		.p_replen = ACL3_setaclres_sz,
 		.p_timer = 0,

                 reply	other threads:[~2021-03-23  5:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SG2P153MB036175692E2D6C18D06C3A1B9E649@SG2P153MB0361.APCP153.PROD.OUTLOOK.COM \
    --to=nagendra.tomar@microsoft.com \
    --cc=anna.schumaker@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@hammerspace.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.