Commit acac57de authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Convert the RENEW operation from using nfs4_compound, to

being a standalone RPC call in preparation for the renew daemon
overhaul.
parent c2f2ea78
...@@ -428,18 +428,6 @@ nfs4_setup_rename(struct nfs4_compound *cp, struct qstr *old, struct qstr *new, ...@@ -428,18 +428,6 @@ nfs4_setup_rename(struct nfs4_compound *cp, struct qstr *old, struct qstr *new,
cp->req_nops++; cp->req_nops++;
} }
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 static void
nfs4_setup_restorefh(struct nfs4_compound *cp) nfs4_setup_restorefh(struct nfs4_compound *cp)
{ {
...@@ -1648,55 +1636,28 @@ nfs4_proc_commit_setup(struct nfs_write_data *data, u64 start, u32 len, int how) ...@@ -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. * 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 static void
renew_done(struct rpc_task *task) renew_done(struct rpc_task *task)
{ {
struct nfs4_compound *cp = (struct nfs4_compound *) task->tk_msg.rpc_argp; struct nfs_server *server = (struct nfs_server *)task->tk_msg.rpc_resp;
process_lease(cp); unsigned long timestamp = (unsigned long)task->tk_calldata;
} renew_lease(server, timestamp);
static void
renew_release(struct rpc_task *task)
{
kfree(task->tk_calldata);
} }
int 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 = { 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); return rpc_call_async(server->client, &msg, 0, renew_done, (void *)jiffies);
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);
} }
/* /*
......
...@@ -70,7 +70,7 @@ renewd(struct rpc_task *task) ...@@ -70,7 +70,7 @@ renewd(struct rpc_task *task)
timeout = (2 * lease) / 3 + last - jiffies; timeout = (2 * lease) / 3 + last - jiffies;
else { else {
/* Queue an asynchronous RENEW. */ /* Queue an asynchronous RENEW. */
nfs4_proc_renew(server); nfs4_proc_async_renew(server, NULL);
timeout = (2 * lease) / 3; timeout = (2 * lease) / 3;
} }
......
...@@ -90,6 +90,8 @@ extern int nfs_stat_to_errno(int); ...@@ -90,6 +90,8 @@ extern int nfs_stat_to_errno(int);
#define decode_pre_write_getattr_maxsz op_decode_hdr_maxsz + 5 #define decode_pre_write_getattr_maxsz op_decode_hdr_maxsz + 5
#define encode_post_write_getattr_maxsz op_encode_hdr_maxsz + 2 #define encode_post_write_getattr_maxsz op_encode_hdr_maxsz + 2
#define decode_post_write_getattr_maxsz op_decode_hdr_maxsz + 13 #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_enc_compound_sz 1024 /* XXX: large enough? */
#define NFS4_dec_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); ...@@ -159,6 +161,10 @@ extern int nfs_stat_to_errno(int);
#define NFS4_dec_setattr_sz compound_decode_hdr_maxsz + \ #define NFS4_dec_setattr_sz compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \ decode_putfh_maxsz + \
op_decode_hdr_maxsz + 3 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 { static struct {
...@@ -889,9 +895,6 @@ encode_compound(struct xdr_stream *xdr, struct nfs4_compound *cp, struct rpc_rqs ...@@ -889,9 +895,6 @@ encode_compound(struct xdr_stream *xdr, struct nfs4_compound *cp, struct rpc_rqs
case OP_RENAME: case OP_RENAME:
status = encode_rename(xdr, &cp->ops[i].u.rename); status = encode_rename(xdr, &cp->ops[i].u.rename);
break; break;
case OP_RENEW:
status = encode_renew(xdr, cp->ops[i].u.renew);
break;
case OP_RESTOREFH: case OP_RESTOREFH:
status = encode_restorefh(xdr); status = encode_restorefh(xdr);
break; break;
...@@ -1131,6 +1134,22 @@ nfs4_xdr_enc_commit(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *arg ...@@ -1131,6 +1134,22 @@ nfs4_xdr_enc_commit(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *arg
return status; return status;
} }
/*
* 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. * START OF "GENERIC" DECODE ROUTINES.
* These may look a little ugly since they are imported from a "generic" * These may look a little ugly since they are imported from a "generic"
...@@ -2137,9 +2156,6 @@ decode_compound(struct xdr_stream *xdr, struct nfs4_compound *cp, struct rpc_rqs ...@@ -2137,9 +2156,6 @@ decode_compound(struct xdr_stream *xdr, struct nfs4_compound *cp, struct rpc_rqs
case OP_RENAME: case OP_RENAME:
status = decode_rename(xdr, &op->u.rename); status = decode_rename(xdr, &op->u.rename);
break; break;
case OP_RENEW:
status = decode_renew(xdr);
break;
case OP_SAVEFH: case OP_SAVEFH:
status = decode_savefh(xdr); status = decode_savefh(xdr);
break; break;
...@@ -2387,6 +2403,23 @@ nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *re ...@@ -2387,6 +2403,23 @@ nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *re
return status; 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 * uint32_t *
nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus) nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus)
{ {
...@@ -2443,6 +2476,7 @@ struct rpc_procinfo nfs4_procedures[] = { ...@@ -2443,6 +2476,7 @@ struct rpc_procinfo nfs4_procedures[] = {
PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm),
PROC(CLOSE, enc_close, dec_close), PROC(CLOSE, enc_close, dec_close),
PROC(SETATTR, enc_setattr, dec_setattr), PROC(SETATTR, enc_setattr, dec_setattr),
PROC(RENEW, enc_renew, dec_renew),
}; };
struct rpc_version nfs_version4 = { struct rpc_version nfs_version4 = {
......
...@@ -221,6 +221,7 @@ enum { ...@@ -221,6 +221,7 @@ enum {
NFSPROC4_CLNT_OPEN_CONFIRM, NFSPROC4_CLNT_OPEN_CONFIRM,
NFSPROC4_CLNT_CLOSE, NFSPROC4_CLNT_CLOSE,
NFSPROC4_CLNT_SETATTR, NFSPROC4_CLNT_SETATTR,
NFSPROC4_CLNT_RENEW,
}; };
#endif #endif
......
...@@ -545,7 +545,7 @@ struct nfs4_state { ...@@ -545,7 +545,7 @@ struct nfs4_state {
/* nfs4proc.c */ /* 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 *); extern int nfs4_do_close(struct inode *, struct nfs4_state *);
/* nfs4renewd.c */ /* nfs4renewd.c */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment