[PATCH 4/5] nfs: Add mount option for forcing RPC requests to one file over one connection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Nagendra S Tomar <natomar@xxxxxxxxxxxxx>

Functions for computing target filehandles' hash for NFSv3.

Signed-off-by: Nagendra S Tomar <natomar@xxxxxxxxxxxxx>
---
 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,




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux