[pnfs] CVS: nfsv4

Marc Eshel IBM eshel at citi.umich.edu
Thu Sep 28 01:46:16 EDT 2006


CVSROOT:	/cvs
Module name:	nfsv4
Changes by:	eshel at citi.	2006/09/28 01:46:16

Modified files:
	cvs/pnfs/fs/nfs: nfs4proc.c nfs4xdr.c 

Log message:
Add pNFS write that doesn't include getattr. A pnfs4_proc_write_setup was added
to the original patch to include all places that write proc is called from.

Index: nfs4proc.c
===================================================================
RCS file: /cvs/nfsv4/cvs/pnfs/fs/nfs/nfs4proc.c,v
retrieving revision 1.27
diff -u -r1.27 nfs4proc.c
--- nfs4proc.c	18 Sep 2006 19:51:57 -0000	1.27
+++ nfs4proc.c	28 Sep 2006 05:36:05 -0000
@@ -1989,6 +1989,32 @@
return err;
}

+static int _pnfs4_proc_write(struct nfs_write_data *wdata, struct rpc_clnt *clnt)
+{
+	int rpcflags = wdata->flags;
+	struct inode *inode = wdata->inode;
+	struct nfs_server *server = NFS_SERVER(inode);
+	struct rpc_message msg = {
+		.rpc_proc	= &nfs4_procedures[NFSPROC4_CLNT_PNFS_WRITE],
+		.rpc_argp	= &wdata->args,
+		.rpc_resp	= &wdata->res,
+		.rpc_cred	= wdata->cred,
+	};
+	int status;
+
+	dprintk("pNFS call  write %d @ %Ld\n", wdata->args.count,
+			(long long) wdata->args.offset);
+
+	wdata->res.server = server;
+	wdata->timestamp = jiffies;
+	status = rpc_call_sync(clnt, &msg, rpcflags);
+	dprintk("pNFS reply write: %d\n", status);
+	if (status < 0)
+		return status;
+	renew_lease(server, wdata->timestamp);
+	return wdata->res.count;
+}
+
static int pnfs4_proc_write(struct nfs_write_data *wdata)
{
struct nfs4_exception exception = { };
@@ -2008,7 +2034,7 @@
*/
do {
err = nfs4_handle_exception(NFS_SERVER(wdata->inode),
-				_nfs4_proc_write(wdata, clnt),
+				_pnfs4_proc_write(wdata, clnt),
&exception);
} while (exception.retry);
return err;
@@ -2727,10 +2753,8 @@
}

/* Only update lease time and attributes if not using pNFS I/O */
-	if (task->tk_status > 0 && !pnfs_use_write(inode, data->args.count)) {
+	if (task->tk_status > 0 && !pnfs_use_write(inode, data->args.count))
renew_lease(NFS_SERVER(inode), data->timestamp);
-		nfs_post_op_update_inode(inode, data->res.fattr);
-	}
if (task->tk_status > 0)
pnfs_writeback_done_update(data);

@@ -2766,6 +2790,35 @@
rpc_call_setup(&data->task, &msg, 0);
}

+static void pnfs4_proc_write_setup(struct nfs_write_data *data, int how)
+{
+	struct rpc_message msg = {
+		.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_PNFS_WRITE],
+		.rpc_argp = &data->args,
+		.rpc_resp = &data->res,
+		.rpc_cred = data->cred,
+	};
+	struct inode *inode = data->inode;
+	struct nfs_server *server = NFS_SERVER(inode);
+	int stable;
+
+	if (how & FLUSH_STABLE) {
+		if (!NFS_I(inode)->ncommit)
+			stable = NFS_FILE_SYNC;
+		else
+			stable = NFS_DATA_SYNC;
+	} else
+		stable = NFS_UNSTABLE;
+	data->args.stable = stable;
+	data->args.bitmask = server->attr_bitmask;
+	data->res.server = server;
+
+	data->timestamp   = jiffies;
+
+	/* Finalize the task. */
+	rpc_call_setup(&data->task, &msg, 0);
+}
+
static int nfs4_commit_done(struct rpc_task *task, struct nfs_write_data *data)
{
struct inode *inode = data->inode;
@@ -4121,7 +4174,7 @@
.decode_dirent	= nfs4_decode_dirent,
.read_setup	= nfs4_proc_read_setup,
.read_done	= pnfs4_read_done,
-	.write_setup	= nfs4_proc_write_setup,
+	.write_setup	= pnfs4_proc_write_setup,
.write_done	= pnfs4_write_done,
.commit_setup	= pnfs4_proc_commit_setup,
.commit_done	= pnfs4_commit_done,
Index: nfs4xdr.c
===================================================================
RCS file: /cvs/nfsv4/cvs/pnfs/fs/nfs/nfs4xdr.c,v
retrieving revision 1.22
diff -u -r1.22 nfs4xdr.c
--- nfs4xdr.c	14 Sep 2006 15:12:08 -0000	1.22
+++ nfs4xdr.c	28 Sep 2006 05:36:06 -0000
@@ -461,6 +461,12 @@
#define NFS4_dec_pnfs_getdeviceinfo_sz (compound_decode_hdr_maxsz +	\
decode_putfh_maxsz +		\
decode_getdeviceinfo_maxsz)
+#define NFS4_enc_pnfs_write_sz	(compound_encode_hdr_maxsz + \
+				encode_putfh_maxsz + \
+				op_encode_hdr_maxsz + 8)
+#define NFS4_dec_pnfs_write_sz	(compound_decode_hdr_maxsz + \
+				decode_putfh_maxsz + \
+				op_decode_hdr_maxsz + 4)
#define NFS4_enc_fs_locations_sz \
(compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
@@ -4955,6 +4961,50 @@
}

/*
+ * Encode a PNFS WRITE request
+ */
+static int nfs4_xdr_enc_pnfs_write(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *args)
+{
+	struct xdr_stream xdr;
+	struct compound_hdr hdr = {
+		.nops = 2,
+	};
+	int status;
+
+	xdr_init_encode(&xdr, &req->rq_snd_buf, p);
+	encode_compound_hdr(&xdr, &hdr);
+	status = encode_putfh(&xdr, args->fh);
+	if (status)
+		goto out;
+	status = encode_write(&xdr, args);
+out:
+	return status;
+}
+
+/*
+ * Decode PNFS WRITE response
+ */
+static int nfs4_xdr_dec_pnfs_write(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *res)
+{
+	struct xdr_stream xdr;
+	struct compound_hdr hdr;
+	int status;
+
+	xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
+	status = decode_compound_hdr(&xdr, &hdr);
+	if (status)
+		goto out;
+	status = decode_putfh(&xdr);
+	if (status)
+		goto out;
+	status = decode_write(&xdr, res);
+	if (!status)
+		status = res->count;
+out:
+	return status;
+}
+
+/*
* FS_LOCATIONS request
*/
static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, uint32_t *p, struct nfs4_fs_locations *res)
@@ -5153,6 +5203,7 @@
PROC(PNFS_LAYOUTRETURN,	enc_pnfs_layoutreturn,	dec_pnfs_layoutreturn),
PROC(PNFS_GETDEVICELIST,	enc_pnfs_getdevicelist,	dec_pnfs_getdevicelist),
PROC(PNFS_GETDEVICEINFO,	enc_pnfs_getdeviceinfo,	dec_pnfs_getdeviceinfo),
+  PROC(PNFS_WRITE,		enc_pnfs_write,	dec_pnfs_write),
PROC(FS_LOCATIONS,	enc_fs_locations, dec_fs_locations),
};



More information about the pNFS mailing list