Commit fa178f29 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Ensure DELEGRETURN returns attributes

 Upon return of a write delegation, the server will almost always bump the
 change attribute. Ensure that we pick up that change so that we don't
 invalidate our data cache unnecessarily.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent beb2a5ec
...@@ -159,8 +159,6 @@ static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation * ...@@ -159,8 +159,6 @@ static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *
{ {
int res = 0; int res = 0;
__nfs_revalidate_inode(NFS_SERVER(inode), inode);
res = nfs4_proc_delegreturn(inode, delegation->cred, &delegation->stateid); res = nfs4_proc_delegreturn(inode, delegation->cred, &delegation->stateid);
nfs_free_delegation(delegation); nfs_free_delegation(delegation);
return res; return res;
......
...@@ -2920,11 +2920,12 @@ nfs4_proc_setclientid_confirm(struct nfs4_client *clp, struct rpc_cred *cred) ...@@ -2920,11 +2920,12 @@ nfs4_proc_setclientid_confirm(struct nfs4_client *clp, struct rpc_cred *cred)
struct nfs4_delegreturndata { struct nfs4_delegreturndata {
struct nfs4_delegreturnargs args; struct nfs4_delegreturnargs args;
struct nfs4_delegreturnres res;
struct nfs_fh fh; struct nfs_fh fh;
nfs4_stateid stateid; nfs4_stateid stateid;
struct rpc_cred *cred; struct rpc_cred *cred;
unsigned long timestamp; unsigned long timestamp;
const struct nfs_server *server; struct nfs_fattr fattr;
int rpc_status; int rpc_status;
}; };
...@@ -2934,8 +2935,10 @@ static void nfs4_delegreturn_prepare(struct rpc_task *task, void *calldata) ...@@ -2934,8 +2935,10 @@ static void nfs4_delegreturn_prepare(struct rpc_task *task, void *calldata)
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DELEGRETURN], .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DELEGRETURN],
.rpc_argp = &data->args, .rpc_argp = &data->args,
.rpc_resp = &data->res,
.rpc_cred = data->cred, .rpc_cred = data->cred,
}; };
nfs_fattr_init(data->res.fattr);
rpc_call_setup(task, &msg, 0); rpc_call_setup(task, &msg, 0);
} }
...@@ -2944,7 +2947,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) ...@@ -2944,7 +2947,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
struct nfs4_delegreturndata *data = calldata; struct nfs4_delegreturndata *data = calldata;
data->rpc_status = task->tk_status; data->rpc_status = task->tk_status;
if (data->rpc_status == 0) if (data->rpc_status == 0)
renew_lease(data->server, data->timestamp); renew_lease(data->res.server, data->timestamp);
} }
static void nfs4_delegreturn_release(void *calldata) static void nfs4_delegreturn_release(void *calldata)
...@@ -2964,6 +2967,7 @@ const static struct rpc_call_ops nfs4_delegreturn_ops = { ...@@ -2964,6 +2967,7 @@ const static struct rpc_call_ops nfs4_delegreturn_ops = {
static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid) static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid)
{ {
struct nfs4_delegreturndata *data; struct nfs4_delegreturndata *data;
struct nfs_server *server = NFS_SERVER(inode);
struct rpc_task *task; struct rpc_task *task;
int status; int status;
...@@ -2972,11 +2976,13 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co ...@@ -2972,11 +2976,13 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
return -ENOMEM; return -ENOMEM;
data->args.fhandle = &data->fh; data->args.fhandle = &data->fh;
data->args.stateid = &data->stateid; data->args.stateid = &data->stateid;
data->args.bitmask = server->attr_bitmask;
nfs_copy_fh(&data->fh, NFS_FH(inode)); nfs_copy_fh(&data->fh, NFS_FH(inode));
memcpy(&data->stateid, stateid, sizeof(data->stateid)); memcpy(&data->stateid, stateid, sizeof(data->stateid));
data->res.fattr = &data->fattr;
data->res.server = server;
data->cred = get_rpccred(cred); data->cred = get_rpccred(cred);
data->timestamp = jiffies; data->timestamp = jiffies;
data->server = NFS_SERVER(inode);
data->rpc_status = 0; data->rpc_status = 0;
task = rpc_run_task(NFS_CLIENT(inode), RPC_TASK_ASYNC, &nfs4_delegreturn_ops, data); task = rpc_run_task(NFS_CLIENT(inode), RPC_TASK_ASYNC, &nfs4_delegreturn_ops, data);
...@@ -2985,8 +2991,11 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co ...@@ -2985,8 +2991,11 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
return PTR_ERR(task); return PTR_ERR(task);
} }
status = nfs4_wait_for_completion_rpc_task(task); status = nfs4_wait_for_completion_rpc_task(task);
if (status == 0) if (status == 0) {
status = data->rpc_status; status = data->rpc_status;
if (status == 0)
nfs_post_op_update_inode(inode, &data->fattr);
}
rpc_release_task(task); rpc_release_task(task);
return status; return status;
} }
......
...@@ -392,9 +392,11 @@ static int nfs_stat_to_errno(int); ...@@ -392,9 +392,11 @@ static int nfs_stat_to_errno(int);
decode_getattr_maxsz) decode_getattr_maxsz)
#define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \ encode_putfh_maxsz + \
encode_delegreturn_maxsz) encode_delegreturn_maxsz + \
encode_getattr_maxsz)
#define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \
decode_delegreturn_maxsz) decode_delegreturn_maxsz + \
decode_getattr_maxsz)
#define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \ encode_putfh_maxsz + \
encode_getattr_maxsz) encode_getattr_maxsz)
...@@ -1983,14 +1985,20 @@ static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, uint32_t *p, const str ...@@ -1983,14 +1985,20 @@ static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, uint32_t *p, const str
{ {
struct xdr_stream xdr; struct xdr_stream xdr;
struct compound_hdr hdr = { struct compound_hdr hdr = {
.nops = 2, .nops = 3,
}; };
int status; int status;
xdr_init_encode(&xdr, &req->rq_snd_buf, p); xdr_init_encode(&xdr, &req->rq_snd_buf, p);
encode_compound_hdr(&xdr, &hdr); encode_compound_hdr(&xdr, &hdr);
if ((status = encode_putfh(&xdr, args->fhandle)) == 0) status = encode_putfh(&xdr, args->fhandle);
status = encode_delegreturn(&xdr, args->stateid); if (status != 0)
goto out;
status = encode_delegreturn(&xdr, args->stateid);
if (status != 0)
goto out;
status = encode_getfattr(&xdr, args->bitmask);
out:
return status; return status;
} }
...@@ -4184,7 +4192,7 @@ static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, s ...@@ -4184,7 +4192,7 @@ static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, s
/* /*
* DELEGRETURN request * DELEGRETURN request
*/ */
static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, uint32_t *p, void *dummy) static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_delegreturnres *res)
{ {
struct xdr_stream xdr; struct xdr_stream xdr;
struct compound_hdr hdr; struct compound_hdr hdr;
...@@ -4192,11 +4200,14 @@ static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, uint32_t *p, void *d ...@@ -4192,11 +4200,14 @@ static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, uint32_t *p, void *d
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
status = decode_compound_hdr(&xdr, &hdr); status = decode_compound_hdr(&xdr, &hdr);
if (status == 0) { if (status != 0)
status = decode_putfh(&xdr); goto out;
if (status == 0) status = decode_putfh(&xdr);
status = decode_delegreturn(&xdr); if (status != 0)
} goto out;
status = decode_delegreturn(&xdr);
decode_getfattr(&xdr, res->fattr, res->server);
out:
return status; return status;
} }
......
...@@ -220,6 +220,12 @@ struct nfs_lockt_res { ...@@ -220,6 +220,12 @@ struct nfs_lockt_res {
struct nfs4_delegreturnargs { struct nfs4_delegreturnargs {
const struct nfs_fh *fhandle; const struct nfs_fh *fhandle;
const nfs4_stateid *stateid; const nfs4_stateid *stateid;
const u32 * bitmask;
};
struct nfs4_delegreturnres {
struct nfs_fattr * fattr;
const struct nfs_server *server;
}; };
/* /*
......
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