Commit c1d51931 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Only increment the sequence id if the server saw it

It is quite possible that the OPEN, CLOSE, LOCK, LOCKU,... compounds fail
before the actual stateful operation has been executed (for instance in the
PUTFH call). There is no way to tell from the overall status result which
operations were executed from the COMPOUND.

The fix is to move incrementing of the sequence id into the XDR layer,
so that we do it as we process the results from the stateful operation.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 35d05778
...@@ -240,6 +240,8 @@ static void nfs4_init_opendata_res(struct nfs4_opendata *p) ...@@ -240,6 +240,8 @@ static void nfs4_init_opendata_res(struct nfs4_opendata *p)
{ {
p->o_res.f_attr = &p->f_attr; p->o_res.f_attr = &p->f_attr;
p->o_res.dir_attr = &p->dir_attr; p->o_res.dir_attr = &p->dir_attr;
p->o_res.seqid = p->o_arg.seqid;
p->c_res.seqid = p->c_arg.seqid;
p->o_res.server = p->o_arg.server; p->o_res.server = p->o_arg.server;
nfs_fattr_init(&p->f_attr); nfs_fattr_init(&p->f_attr);
nfs_fattr_init(&p->dir_attr); nfs_fattr_init(&p->dir_attr);
...@@ -730,7 +732,6 @@ static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata) ...@@ -730,7 +732,6 @@ static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata)
renew_lease(data->o_res.server, data->timestamp); renew_lease(data->o_res.server, data->timestamp);
data->rpc_done = 1; data->rpc_done = 1;
} }
nfs_increment_open_seqid(data->rpc_status, data->c_arg.seqid);
} }
static void nfs4_open_confirm_release(void *calldata) static void nfs4_open_confirm_release(void *calldata)
...@@ -860,7 +861,6 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata) ...@@ -860,7 +861,6 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata)
if (!(data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM)) if (!(data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM))
nfs_confirm_seqid(&data->owner->so_seqid, 0); nfs_confirm_seqid(&data->owner->so_seqid, 0);
} }
nfs_increment_open_seqid(data->rpc_status, data->o_arg.seqid);
data->rpc_done = 1; data->rpc_done = 1;
} }
...@@ -1226,7 +1226,6 @@ static void nfs4_close_done(struct rpc_task *task, void *data) ...@@ -1226,7 +1226,6 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
/* hmm. we are done with the inode, and in the process of freeing /* hmm. we are done with the inode, and in the process of freeing
* the state_owner. we keep this around to process errors * the state_owner. we keep this around to process errors
*/ */
nfs_increment_open_seqid(task->tk_status, calldata->arg.seqid);
switch (task->tk_status) { switch (task->tk_status) {
case 0: case 0:
nfs_set_open_stateid(state, &calldata->res.stateid, 0); nfs_set_open_stateid(state, &calldata->res.stateid, 0);
...@@ -1333,6 +1332,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait) ...@@ -1333,6 +1332,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)
goto out_free_calldata; goto out_free_calldata;
calldata->arg.bitmask = server->attr_bitmask; calldata->arg.bitmask = server->attr_bitmask;
calldata->res.fattr = &calldata->fattr; calldata->res.fattr = &calldata->fattr;
calldata->res.seqid = calldata->arg.seqid;
calldata->res.server = server; calldata->res.server = server;
calldata->path.mnt = mntget(path->mnt); calldata->path.mnt = mntget(path->mnt);
calldata->path.dentry = dget(path->dentry); calldata->path.dentry = dget(path->dentry);
...@@ -3159,6 +3159,7 @@ static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl, ...@@ -3159,6 +3159,7 @@ static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl,
p->arg.fh = NFS_FH(inode); p->arg.fh = NFS_FH(inode);
p->arg.fl = &p->fl; p->arg.fl = &p->fl;
p->arg.seqid = seqid; p->arg.seqid = seqid;
p->res.seqid = seqid;
p->arg.stateid = &lsp->ls_stateid; p->arg.stateid = &lsp->ls_stateid;
p->lsp = lsp; p->lsp = lsp;
atomic_inc(&lsp->ls_count); atomic_inc(&lsp->ls_count);
...@@ -3184,7 +3185,6 @@ static void nfs4_locku_done(struct rpc_task *task, void *data) ...@@ -3184,7 +3185,6 @@ static void nfs4_locku_done(struct rpc_task *task, void *data)
if (RPC_ASSASSINATED(task)) if (RPC_ASSASSINATED(task))
return; return;
nfs_increment_lock_seqid(task->tk_status, calldata->arg.seqid);
switch (task->tk_status) { switch (task->tk_status) {
case 0: case 0:
memcpy(calldata->lsp->ls_stateid.data, memcpy(calldata->lsp->ls_stateid.data,
...@@ -3322,6 +3322,7 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl, ...@@ -3322,6 +3322,7 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
p->arg.lock_stateid = &lsp->ls_stateid; p->arg.lock_stateid = &lsp->ls_stateid;
p->arg.lock_owner.clientid = server->nfs_client->cl_clientid; p->arg.lock_owner.clientid = server->nfs_client->cl_clientid;
p->arg.lock_owner.id = lsp->ls_id.id; p->arg.lock_owner.id = lsp->ls_id.id;
p->res.lock_seqid = p->arg.lock_seqid;
p->lsp = lsp; p->lsp = lsp;
atomic_inc(&lsp->ls_count); atomic_inc(&lsp->ls_count);
p->ctx = get_nfs_open_context(ctx); p->ctx = get_nfs_open_context(ctx);
...@@ -3348,6 +3349,7 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata) ...@@ -3348,6 +3349,7 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
return; return;
data->arg.open_stateid = &state->stateid; data->arg.open_stateid = &state->stateid;
data->arg.new_lock_owner = 1; data->arg.new_lock_owner = 1;
data->res.open_seqid = data->arg.open_seqid;
} else } else
data->arg.new_lock_owner = 0; data->arg.new_lock_owner = 0;
data->timestamp = jiffies; data->timestamp = jiffies;
...@@ -3365,7 +3367,6 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata) ...@@ -3365,7 +3367,6 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
if (RPC_ASSASSINATED(task)) if (RPC_ASSASSINATED(task))
goto out; goto out;
if (data->arg.new_lock_owner != 0) { if (data->arg.new_lock_owner != 0) {
nfs_increment_open_seqid(data->rpc_status, data->arg.open_seqid);
if (data->rpc_status == 0) if (data->rpc_status == 0)
nfs_confirm_seqid(&data->lsp->ls_seqid, 0); nfs_confirm_seqid(&data->lsp->ls_seqid, 0);
else else
...@@ -3377,7 +3378,6 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata) ...@@ -3377,7 +3378,6 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
data->lsp->ls_flags |= NFS_LOCK_INITIALIZED; data->lsp->ls_flags |= NFS_LOCK_INITIALIZED;
renew_lease(NFS_SERVER(data->ctx->path.dentry->d_inode), data->timestamp); renew_lease(NFS_SERVER(data->ctx->path.dentry->d_inode), data->timestamp);
} }
nfs_increment_lock_seqid(data->rpc_status, data->arg.lock_seqid);
out: out:
dprintk("%s: done, ret = %d!\n", __FUNCTION__, data->rpc_status); dprintk("%s: done, ret = %d!\n", __FUNCTION__, data->rpc_status);
} }
......
...@@ -3005,6 +3005,8 @@ static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) ...@@ -3005,6 +3005,8 @@ static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
int status; int status;
status = decode_op_hdr(xdr, OP_CLOSE); status = decode_op_hdr(xdr, OP_CLOSE);
if (status != -EIO)
nfs_increment_open_seqid(status, res->seqid);
if (status) if (status)
return status; return status;
READ_BUF(NFS4_STATEID_SIZE); READ_BUF(NFS4_STATEID_SIZE);
...@@ -3296,11 +3298,17 @@ static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) ...@@ -3296,11 +3298,17 @@ static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
int status; int status;
status = decode_op_hdr(xdr, OP_LOCK); status = decode_op_hdr(xdr, OP_LOCK);
if (status == -EIO)
goto out;
if (status == 0) { if (status == 0) {
READ_BUF(NFS4_STATEID_SIZE); READ_BUF(NFS4_STATEID_SIZE);
COPYMEM(res->stateid.data, NFS4_STATEID_SIZE); COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
} else if (status == -NFS4ERR_DENIED) } else if (status == -NFS4ERR_DENIED)
return decode_lock_denied(xdr, NULL); status = decode_lock_denied(xdr, NULL);
if (res->open_seqid != NULL)
nfs_increment_open_seqid(status, res->open_seqid);
nfs_increment_lock_seqid(status, res->lock_seqid);
out:
return status; return status;
} }
...@@ -3319,6 +3327,8 @@ static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res) ...@@ -3319,6 +3327,8 @@ static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
int status; int status;
status = decode_op_hdr(xdr, OP_LOCKU); status = decode_op_hdr(xdr, OP_LOCKU);
if (status != -EIO)
nfs_increment_lock_seqid(status, res->seqid);
if (status == 0) { if (status == 0) {
READ_BUF(NFS4_STATEID_SIZE); READ_BUF(NFS4_STATEID_SIZE);
COPYMEM(res->stateid.data, NFS4_STATEID_SIZE); COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
...@@ -3384,6 +3394,8 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) ...@@ -3384,6 +3394,8 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
int status; int status;
status = decode_op_hdr(xdr, OP_OPEN); status = decode_op_hdr(xdr, OP_OPEN);
if (status != -EIO)
nfs_increment_open_seqid(status, res->seqid);
if (status) if (status)
return status; return status;
READ_BUF(NFS4_STATEID_SIZE); READ_BUF(NFS4_STATEID_SIZE);
...@@ -3416,6 +3428,8 @@ static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmre ...@@ -3416,6 +3428,8 @@ static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmre
int status; int status;
status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
if (status != -EIO)
nfs_increment_open_seqid(status, res->seqid);
if (status) if (status)
return status; return status;
READ_BUF(NFS4_STATEID_SIZE); READ_BUF(NFS4_STATEID_SIZE);
...@@ -3429,6 +3443,8 @@ static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *re ...@@ -3429,6 +3443,8 @@ static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *re
int status; int status;
status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
if (status != -EIO)
nfs_increment_open_seqid(status, res->seqid);
if (status) if (status)
return status; return status;
READ_BUF(NFS4_STATEID_SIZE); READ_BUF(NFS4_STATEID_SIZE);
......
...@@ -140,6 +140,7 @@ struct nfs_openres { ...@@ -140,6 +140,7 @@ struct nfs_openres {
__u32 rflags; __u32 rflags;
struct nfs_fattr * f_attr; struct nfs_fattr * f_attr;
struct nfs_fattr * dir_attr; struct nfs_fattr * dir_attr;
struct nfs_seqid * seqid;
const struct nfs_server *server; const struct nfs_server *server;
int delegation_type; int delegation_type;
nfs4_stateid delegation; nfs4_stateid delegation;
...@@ -159,6 +160,7 @@ struct nfs_open_confirmargs { ...@@ -159,6 +160,7 @@ struct nfs_open_confirmargs {
struct nfs_open_confirmres { struct nfs_open_confirmres {
nfs4_stateid stateid; nfs4_stateid stateid;
struct nfs_seqid * seqid;
}; };
/* /*
...@@ -175,6 +177,7 @@ struct nfs_closeargs { ...@@ -175,6 +177,7 @@ struct nfs_closeargs {
struct nfs_closeres { struct nfs_closeres {
nfs4_stateid stateid; nfs4_stateid stateid;
struct nfs_fattr * fattr; struct nfs_fattr * fattr;
struct nfs_seqid * seqid;
const struct nfs_server *server; const struct nfs_server *server;
}; };
/* /*
...@@ -199,7 +202,9 @@ struct nfs_lock_args { ...@@ -199,7 +202,9 @@ struct nfs_lock_args {
}; };
struct nfs_lock_res { struct nfs_lock_res {
nfs4_stateid stateid; nfs4_stateid stateid;
struct nfs_seqid * lock_seqid;
struct nfs_seqid * open_seqid;
}; };
struct nfs_locku_args { struct nfs_locku_args {
...@@ -210,7 +215,8 @@ struct nfs_locku_args { ...@@ -210,7 +215,8 @@ struct nfs_locku_args {
}; };
struct nfs_locku_res { struct nfs_locku_res {
nfs4_stateid stateid; nfs4_stateid stateid;
struct nfs_seqid * seqid;
}; };
struct nfs_lockt_args { struct nfs_lockt_args {
......
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