summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@fys.uio.no>2004-02-07 16:52:03 +0100
committerTrond Myklebust <trond.myklebust@fys.uio.no>2004-02-07 16:52:03 +0100
commitacac57debb7af23d6178e319c1017b24ec847ded (patch)
tree898088f1d89ede43091dfeccb20c474cc98fb38a
parentc2f2ea78e058ca74fe2e674fd8cdfb71966b248c (diff)
NFSv4: Convert the RENEW operation from using nfs4_compound, to
being a standalone RPC call in preparation for the renew daemon overhaul.
-rw-r--r--fs/nfs/nfs4proc.c59
-rw-r--r--fs/nfs/nfs4renewd.c2
-rw-r--r--fs/nfs/nfs4xdr.c46
-rw-r--r--include/linux/nfs4.h1
-rw-r--r--include/linux/nfs_fs.h2
5 files changed, 53 insertions, 57 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 2d6850d65dd3..e7327e3bf484 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -429,18 +429,6 @@ nfs4_setup_rename(struct nfs4_compound *cp, struct qstr *old, struct qstr *new,
}
static void
-nfs4_setup_renew(struct nfs4_compound *cp)
-{
- struct nfs4_client **client_state = GET_OP(cp, renew);
-
- *client_state = cp->server->nfs4_state;
-
- OPNUM(cp) = OP_RENEW;
- cp->req_nops++;
- cp->renew_index = cp->req_nops;
-}
-
-static void
nfs4_setup_restorefh(struct nfs4_compound *cp)
{
OPNUM(cp) = OP_RESTOREFH;
@@ -1648,55 +1636,28 @@ nfs4_proc_commit_setup(struct nfs_write_data *data, u64 start, u32 len, int how)
}
/*
- * nfs4_proc_renew(): This is not one of the nfs_rpc_ops; it is a special
+ * nfs4_proc_async_renew(): This is not one of the nfs_rpc_ops; it is a special
* standalone procedure for queueing an asynchronous RENEW.
*/
-struct renew_desc {
- struct rpc_task task;
- struct nfs4_compound compound;
- struct nfs4_op ops[1];
-};
-
static void
renew_done(struct rpc_task *task)
{
- struct nfs4_compound *cp = (struct nfs4_compound *) task->tk_msg.rpc_argp;
- process_lease(cp);
-}
-
-static void
-renew_release(struct rpc_task *task)
-{
- kfree(task->tk_calldata);
+ struct nfs_server *server = (struct nfs_server *)task->tk_msg.rpc_resp;
+ unsigned long timestamp = (unsigned long)task->tk_calldata;
+ renew_lease(server, timestamp);
}
int
-nfs4_proc_renew(struct nfs_server *server)
+nfs4_proc_async_renew(struct nfs_server *server, struct rpc_cred *cred)
{
- struct renew_desc *rp;
- struct rpc_task *task;
- struct nfs4_compound *cp;
struct rpc_message msg = {
- .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMPOUND],
+ .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW],
+ .rpc_argp = server->nfs4_state,
+ .rpc_resp = server,
+ .rpc_cred = cred,
};
- rp = (struct renew_desc *) kmalloc(sizeof(*rp), GFP_KERNEL);
- if (!rp)
- return -ENOMEM;
- cp = &rp->compound;
- task = &rp->task;
-
- nfs4_setup_compound(cp, rp->ops, server, "renew");
- nfs4_setup_renew(cp);
-
- msg.rpc_argp = cp;
- msg.rpc_resp = cp;
- rpc_init_task(task, server->client, renew_done, RPC_TASK_ASYNC);
- rpc_call_setup(task, &msg, 0);
- task->tk_calldata = rp;
- task->tk_release = renew_release;
-
- return rpc_execute(task);
+ return rpc_call_async(server->client, &msg, 0, renew_done, (void *)jiffies);
}
/*
diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c
index 4ba871885dbc..92176b0b0a9b 100644
--- a/fs/nfs/nfs4renewd.c
+++ b/fs/nfs/nfs4renewd.c
@@ -70,7 +70,7 @@ renewd(struct rpc_task *task)
timeout = (2 * lease) / 3 + last - jiffies;
else {
/* Queue an asynchronous RENEW. */
- nfs4_proc_renew(server);
+ nfs4_proc_async_renew(server, NULL);
timeout = (2 * lease) / 3;
}
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 35a28e9e7d21..add338c9be56 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -90,6 +90,8 @@ extern int nfs_stat_to_errno(int);
#define decode_pre_write_getattr_maxsz op_decode_hdr_maxsz + 5
#define encode_post_write_getattr_maxsz op_encode_hdr_maxsz + 2
#define decode_post_write_getattr_maxsz op_decode_hdr_maxsz + 13
+#define encode_renew_maxsz op_encode_hdr_maxsz + 3
+#define decode_renew_maxsz op_decode_hdr_maxsz
#define NFS4_enc_compound_sz 1024 /* XXX: large enough? */
#define NFS4_dec_compound_sz 1024 /* XXX: large enough? */
@@ -159,6 +161,10 @@ extern int nfs_stat_to_errno(int);
#define NFS4_dec_setattr_sz compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
op_decode_hdr_maxsz + 3
+#define NFS4_enc_renew_sz compound_encode_hdr_maxsz + \
+ encode_renew_maxsz
+#define NFS4_dec_renew_sz compound_decode_hdr_maxsz + \
+ decode_renew_maxsz
static struct {
@@ -889,9 +895,6 @@ encode_compound(struct xdr_stream *xdr, struct nfs4_compound *cp, struct rpc_rqs
case OP_RENAME:
status = encode_rename(xdr, &cp->ops[i].u.rename);
break;
- case OP_RENEW:
- status = encode_renew(xdr, cp->ops[i].u.renew);
- break;
case OP_RESTOREFH:
status = encode_restorefh(xdr);
break;
@@ -1132,6 +1135,22 @@ out:
}
/*
+ * a RENEW request
+ */
+static int
+nfs4_xdr_enc_renew(struct rpc_rqst *req, uint32_t *p, struct nfs4_client *clp)
+{
+ struct xdr_stream xdr;
+ struct compound_hdr hdr = {
+ .nops = 1,
+ };
+
+ xdr_init_encode(&xdr, &req->rq_snd_buf, p);
+ encode_compound_hdr(&xdr, &hdr);
+ return encode_renew(&xdr, clp);
+}
+
+/*
* START OF "GENERIC" DECODE ROUTINES.
* These may look a little ugly since they are imported from a "generic"
* set of XDR encode/decode routines which are intended to be shared by
@@ -2137,9 +2156,6 @@ decode_compound(struct xdr_stream *xdr, struct nfs4_compound *cp, struct rpc_rqs
case OP_RENAME:
status = decode_rename(xdr, &op->u.rename);
break;
- case OP_RENEW:
- status = decode_renew(xdr);
- break;
case OP_SAVEFH:
status = decode_savefh(xdr);
break;
@@ -2387,6 +2403,23 @@ out:
return status;
}
+/*
+ * Decode RENEW response
+ */
+static int
+nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, uint32_t *p, void *dummy)
+{
+ 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)
+ status = decode_renew(&xdr);
+ return status;
+}
+
uint32_t *
nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus)
{
@@ -2443,6 +2476,7 @@ struct rpc_procinfo nfs4_procedures[] = {
PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm),
PROC(CLOSE, enc_close, dec_close),
PROC(SETATTR, enc_setattr, dec_setattr),
+ PROC(RENEW, enc_renew, dec_renew),
};
struct rpc_version nfs_version4 = {
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
index 8bb512eb2b43..1598d1b3c739 100644
--- a/include/linux/nfs4.h
+++ b/include/linux/nfs4.h
@@ -221,6 +221,7 @@ enum {
NFSPROC4_CLNT_OPEN_CONFIRM,
NFSPROC4_CLNT_CLOSE,
NFSPROC4_CLNT_SETATTR,
+ NFSPROC4_CLNT_RENEW,
};
#endif
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 1ba074302796..a8dc94ea12d3 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -545,7 +545,7 @@ struct nfs4_state {
/* nfs4proc.c */
-extern int nfs4_proc_renew(struct nfs_server *server);
+extern int nfs4_proc_async_renew(struct nfs_server *server, struct rpc_cred *);
extern int nfs4_do_close(struct inode *, struct nfs4_state *);
/* nfs4renewd.c */