Skip to contentSkip to conversation

Clean up NFSv4 READ xdr path

PATCH New Trond Myklebust 1 participant 1 message Dec 17, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Clean up NFSv4 READ xdr path

The following patch creates a clean XDR path for the NFSv4 read requests instead of routing through encode_compound()/decode_compound(). This eliminates the intermediate step of setting up a struct nfs4_compound before proceeding to XDR encoding, and removes the large 'switch()' statements from the codepath altogether.

Cheers,
Trond

fs/nfs/nfs3proc.c +12 -13
diff -u --recursive --new-file linux-2.5.52/fs/nfs/nfs3proc.c linux-2.5.52-01-nfsv4_read/fs/nfs/nfs3proc.c
@@ -685,11 +685,10 @@
 static void
 nfs3_read_done(struct rpc_task *task)
 {
-	struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata;
-
 	if (nfs3_async_handle_jukebox(task))
 		return;
-	nfs_readpage_result(task, data->u.v3.res.count, data->u.v3.res.eof);
+	/* Call back common NFS readpage processing */
+	nfs_readpage_result(task);
 }
 
 static void
@@ -701,20 +700,20 @@
 	int			flags;
 	struct rpc_message	msg = {
 		.rpc_proc	= &nfs3_procedures[NFS3PROC_READ],
-		.rpc_argp	= &data->u.v3.args,
-		.rpc_resp	= &data->u.v3.res,
+		.rpc_argp	= &data->args,
+		.rpc_resp	= &data->res,
 		.rpc_cred	= data->cred,
 	};
 	
 	req = nfs_list_entry(data->pages.next);
-	data->u.v3.args.fh     = NFS_FH(inode);
-	data->u.v3.args.offset = req_offset(req) + req->wb_offset;
-	data->u.v3.args.pgbase = req->wb_offset;
-	data->u.v3.args.pages  = data->pagevec;
-	data->u.v3.args.count  = count;
-	data->u.v3.res.fattr   = &data->fattr;
-	data->u.v3.res.count   = count;
-	data->u.v3.res.eof     = 0;
+	data->args.fh     = NFS_FH(inode);
+	data->args.offset = req_offset(req) + req->wb_offset;
+	data->args.pgbase = req->wb_offset;
+	data->args.pages  = data->pagevec;
+	data->args.count  = count;
+	data->res.fattr   = &data->fattr;
+	data->res.count   = count;
+	data->res.eof     = 0;
 	
 	/* N.B. Do we need to test? Never called for swapfile inode */
 	flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
fs/nfs/nfs4proc.c +54 -50

152 lines not on this page · raw message

fs/nfs/nfs4xdr.c +90 -43

233 lines not on this page · raw message

fs/nfs/proc.c +11 -18
diff -u --recursive --new-file linux-2.5.52/fs/nfs/proc.c linux-2.5.52-01-nfsv4_read/fs/nfs/proc.c
@@ -521,13 +521,6 @@
 extern u32 * nfs_decode_dirent(u32 *, struct nfs_entry *, int);
 
 static void
-nfs_read_done(struct rpc_task *task)
-{
-	struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata;
-	nfs_readpage_result(task, data->u.v3.res.count, data->u.v3.res.eof);
-}
-
-static void
 nfs_proc_read_setup(struct nfs_read_data *data, unsigned int count)
 {
 	struct rpc_task		*task = &data->task;
@@ -536,26 +529,26 @@
 	int			flags;
 	struct rpc_message	msg = {
 		.rpc_proc	= &nfs_procedures[NFSPROC_READ],
-		.rpc_argp	= &data->u.v3.args,
-		.rpc_resp	= &data->u.v3.res,
+		.rpc_argp	= &data->args,
+		.rpc_resp	= &data->res,
 		.rpc_cred	= data->cred,
 	};
 	
 	req = nfs_list_entry(data->pages.next);
-	data->u.v3.args.fh     = NFS_FH(inode);
-	data->u.v3.args.offset = req_offset(req) + req->wb_offset;
-	data->u.v3.args.pgbase = req->wb_offset;
-	data->u.v3.args.pages  = data->pagevec;
-	data->u.v3.args.count  = count;
-	data->u.v3.res.fattr   = &data->fattr;
-	data->u.v3.res.count   = count;
-	data->u.v3.res.eof     = 0;
+	data->args.fh     = NFS_FH(inode);
+	data->args.offset = req_offset(req) + req->wb_offset;
+	data->args.pgbase = req->wb_offset;
+	data->args.pages  = data->pagevec;
+	data->args.count  = count;
+	data->res.fattr   = &data->fattr;
+	data->res.count   = count;
+	data->res.eof     = 0;
 	
 	/* N.B. Do we need to test? Never called for swapfile inode */
 	flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
 
 	/* Finalize the task. */
-	rpc_init_task(task, NFS_CLIENT(inode), nfs_read_done, flags);
+	rpc_init_task(task, NFS_CLIENT(inode), nfs_readpage_result, flags);
 	task->tk_calldata = data;
 	/* Release requests */
 	task->tk_release = nfs_readdata_release;
fs/nfs/read.c +3 -2
diff -u --recursive --new-file linux-2.5.52/fs/nfs/read.c linux-2.5.52-01-nfsv4_read/fs/nfs/read.c
@@ -255,11 +255,12 @@
  * received or some error occurred (timeout or socket shutdown).
  */
 void
-nfs_readpage_result(struct rpc_task *task, unsigned int count, int eof)
+nfs_readpage_result(struct rpc_task *task)
 {
 	struct nfs_read_data	*data = (struct nfs_read_data *) task->tk_calldata;
 	struct inode		*inode = data->inode;
 	struct nfs_fattr	*fattr = &data->fattr;
+	unsigned int count = data->res.count;
 
 	dprintk("NFS: %4d nfs_readpage_result, (status %d)\n",
 		task->tk_pid, task->tk_status);
@@ -279,7 +280,7 @@
 							req->wb_bytes - count);
 				kunmap(page);
 
-				if (eof ||
+				if (data->res.eof ||
 				    ((fattr->valid & NFS_ATTR_FATTR) &&
 				     ((req_offset(req) + req->wb_offset + count) >= fattr->size)))
 					SetPageUptodate(page);
include/linux/nfs4.h +1 -0
diff -u --recursive --new-file linux-2.5.52/include/linux/nfs4.h linux-2.5.52-01-nfsv4_read/include/linux/nfs4.h
@@ -203,6 +203,7 @@
 enum {
 	NFSPROC4_CLNT_NULL = 0,		/* Unused */
 	NFSPROC4_CLNT_COMPOUND,		/* Soon to be unused */
+	NFSPROC4_CLNT_READ,
 };
 
 #endif
include/linux/nfs_fs.h +1 -1
diff -u --recursive --new-file linux-2.5.52/include/linux/nfs_fs.h linux-2.5.52-01-nfsv4_read/include/linux/nfs_fs.h
@@ -369,7 +369,7 @@
 extern int  nfs_readpages(struct file *, struct address_space *,
 		struct list_head *, unsigned);
 extern int  nfs_pagein_list(struct list_head *, int);
-extern void nfs_readpage_result(struct rpc_task *, unsigned int count, int eof);
+extern void nfs_readpage_result(struct rpc_task *);
 extern void nfs_readdata_release(struct rpc_task *);
 
 /*
include/linux/nfs_xdr.h +3 -22
diff -u --recursive --new-file linux-2.5.52/include/linux/nfs_xdr.h linux-2.5.52-01-nfsv4_read/include/linux/nfs_xdr.h
@@ -422,15 +422,6 @@
 	struct nfs_fh *			pf_fhandle;       /* request */
 };
 
-struct nfs4_read {
-	u64				rd_offset;        /* request */
-	u32				rd_length;        /* request */
-	u32				*rd_eof;          /* response */
-	u32				*rd_bytes_read;   /* response */
-	struct page **			rd_pages;   /* zero-copy data */
-	unsigned int			rd_pgbase;  /* zero-copy data */
-};
-
 struct nfs4_readdir {
 	u64				rd_cookie;        /* request */
 	nfs4_verifier			rd_req_verifier;  /* request */
@@ -500,7 +491,6 @@
 		struct nfs4_open	open;
 		struct nfs4_open_confirm open_confirm;
 		struct nfs4_putfh	putfh;
-		struct nfs4_read	read;
 		struct nfs4_readdir	readdir;
 		struct nfs4_readlink	readlink;
 		struct nfs4_remove	remove;
@@ -548,20 +538,11 @@
 	struct nfs_fattr	fattr;	/* fattr storage */
 	struct list_head	pages;	/* Coalesced read requests */
 	struct page		*pagevec[NFS_READ_MAXIOV];
-	union {
-		struct {
-			struct nfs_readargs args;
-			struct nfs_readres  res;
-		} v3;   /* also v2 */
+	struct nfs_readargs args;
+	struct nfs_readres  res;
 #ifdef CONFIG_NFS_V4
-		struct {
-			struct nfs4_compound  compound;
-			struct nfs4_op        ops[3];
-			u32                   res_count;
-			u32                   res_eof;
-		} v4;
+	unsigned long		timestamp;	/* For lease renewal */
 #endif
-	} u;
 };
 
 struct nfs_write_data {

-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs