Commit d1c3bc1b authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] nfsd4: revert awkward extension of state lock over xdr for replay encoding

With the addition of a reference count, we no longer need the code that
conditionally extended the nfs4 state lock over the xdr encode stage.
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 415ddd59
...@@ -161,9 +161,6 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_ ...@@ -161,9 +161,6 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_
} }
/*
* nfs4_unlock_state() called in encode
*/
static inline int static inline int
nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open) nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
{ {
...@@ -182,7 +179,6 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open ...@@ -182,7 +179,6 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open
if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL) if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL)
return nfserr_inval; return nfserr_inval;
open->op_stateowner = NULL;
nfs4_lock_state(); nfs4_lock_state();
/* check seqid for replay. set nfs4_owner */ /* check seqid for replay. set nfs4_owner */
...@@ -236,6 +232,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open ...@@ -236,6 +232,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open
out: out:
if (open->op_stateowner) if (open->op_stateowner)
nfs4_get_stateowner(open->op_stateowner); nfs4_get_stateowner(open->op_stateowner);
nfs4_unlock_state();
return status; return status;
} }
......
...@@ -93,9 +93,6 @@ nfs4_lock_state(void) ...@@ -93,9 +93,6 @@ nfs4_lock_state(void)
down(&client_sema); down(&client_sema);
} }
/*
* nfs4_unlock_state(); called in encode
*/
void void
nfs4_unlock_state(void) nfs4_unlock_state(void)
{ {
...@@ -1711,9 +1708,6 @@ first_state(struct nfs4_client *clp) ...@@ -1711,9 +1708,6 @@ first_state(struct nfs4_client *clp)
clp->cl_first_state = get_seconds(); clp->cl_first_state = get_seconds();
} }
/*
* nfs4_unlock_state(); called in encode
*/
int int
nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_confirm *oc) nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_confirm *oc)
{ {
...@@ -1728,7 +1722,6 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs ...@@ -1728,7 +1722,6 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs
if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0))) if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0)))
goto out; goto out;
oc->oc_stateowner = NULL;
nfs4_lock_state(); nfs4_lock_state();
if ((status = nfs4_preprocess_seqid_op(current_fh, oc->oc_seqid, if ((status = nfs4_preprocess_seqid_op(current_fh, oc->oc_seqid,
...@@ -1752,6 +1745,7 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs ...@@ -1752,6 +1745,7 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs
out: out:
if (oc->oc_stateowner) if (oc->oc_stateowner)
nfs4_get_stateowner(oc->oc_stateowner); nfs4_get_stateowner(oc->oc_stateowner);
nfs4_unlock_state();
return status; return status;
} }
...@@ -1780,10 +1774,6 @@ reset_union_bmap_deny(unsigned long deny, unsigned long *bmap) ...@@ -1780,10 +1774,6 @@ reset_union_bmap_deny(unsigned long deny, unsigned long *bmap)
} }
} }
/*
* nfs4_unlock_state(); called in encode
*/
int int
nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_downgrade *od) nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_downgrade *od)
{ {
...@@ -1795,10 +1785,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct n ...@@ -1795,10 +1785,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct n
(int)current_fh->fh_dentry->d_name.len, (int)current_fh->fh_dentry->d_name.len,
current_fh->fh_dentry->d_name.name); current_fh->fh_dentry->d_name.name);
od->od_stateowner = NULL;
status = nfserr_inval;
if (!TEST_ACCESS(od->od_share_access) || !TEST_DENY(od->od_share_deny)) if (!TEST_ACCESS(od->od_share_access) || !TEST_DENY(od->od_share_deny))
goto out; return nfserr_inval;
nfs4_lock_state(); nfs4_lock_state();
if ((status = nfs4_preprocess_seqid_op(current_fh, od->od_seqid, if ((status = nfs4_preprocess_seqid_op(current_fh, od->od_seqid,
...@@ -1831,6 +1819,7 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct n ...@@ -1831,6 +1819,7 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct n
out: out:
if (od->od_stateowner) if (od->od_stateowner)
nfs4_get_stateowner(od->od_stateowner); nfs4_get_stateowner(od->od_stateowner);
nfs4_unlock_state();
return status; return status;
} }
...@@ -1847,7 +1836,6 @@ nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_clos ...@@ -1847,7 +1836,6 @@ nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_clos
(int)current_fh->fh_dentry->d_name.len, (int)current_fh->fh_dentry->d_name.len,
current_fh->fh_dentry->d_name.name); current_fh->fh_dentry->d_name.name);
close->cl_stateowner = NULL;
nfs4_lock_state(); nfs4_lock_state();
/* check close_lru for replay */ /* check close_lru for replay */
if ((status = nfs4_preprocess_seqid_op(current_fh, close->cl_seqid, if ((status = nfs4_preprocess_seqid_op(current_fh, close->cl_seqid,
...@@ -1867,6 +1855,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_clos ...@@ -1867,6 +1855,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_clos
out: out:
if (close->cl_stateowner) if (close->cl_stateowner)
nfs4_get_stateowner(close->cl_stateowner); nfs4_get_stateowner(close->cl_stateowner);
nfs4_unlock_state();
return status; return status;
} }
...@@ -2085,8 +2074,6 @@ check_lock_length(u64 offset, u64 length) ...@@ -2085,8 +2074,6 @@ check_lock_length(u64 offset, u64 length)
/* /*
* LOCK operation * LOCK operation
*
* nfs4_unlock_state(); called in encode
*/ */
int int
nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock *lock) nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock *lock)
...@@ -2111,7 +2098,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock ...@@ -2111,7 +2098,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
if (check_lock_length(lock->lk_offset, lock->lk_length)) if (check_lock_length(lock->lk_offset, lock->lk_length))
return nfserr_inval; return nfserr_inval;
lock->lk_stateowner = NULL;
nfs4_lock_state(); nfs4_lock_state();
if (lock->lk_is_new) { if (lock->lk_is_new) {
...@@ -2268,6 +2254,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock ...@@ -2268,6 +2254,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
out: out:
if (lock->lk_stateowner) if (lock->lk_stateowner)
nfs4_get_stateowner(lock->lk_stateowner); nfs4_get_stateowner(lock->lk_stateowner);
nfs4_unlock_state();
return status; return status;
} }
...@@ -2376,7 +2363,6 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock ...@@ -2376,7 +2363,6 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
if (check_lock_length(locku->lu_offset, locku->lu_length)) if (check_lock_length(locku->lu_offset, locku->lu_length))
return nfserr_inval; return nfserr_inval;
locku->lu_stateowner = NULL;
nfs4_lock_state(); nfs4_lock_state();
if ((status = nfs4_preprocess_seqid_op(current_fh, if ((status = nfs4_preprocess_seqid_op(current_fh,
...@@ -2421,6 +2407,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock ...@@ -2421,6 +2407,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
out: out:
if (locku->lu_stateowner) if (locku->lu_stateowner)
nfs4_get_stateowner(locku->lu_stateowner); nfs4_get_stateowner(locku->lu_stateowner);
nfs4_unlock_state();
return status; return status;
out_nfserr: out_nfserr:
......
...@@ -545,14 +545,12 @@ nfsd4_decode_access(struct nfsd4_compoundargs *argp, struct nfsd4_access *access ...@@ -545,14 +545,12 @@ nfsd4_decode_access(struct nfsd4_compoundargs *argp, struct nfsd4_access *access
DECODE_TAIL; DECODE_TAIL;
} }
#define NFS4_STATE_NOT_LOCKED ((void *)-1)
static int static int
nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close) nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close)
{ {
DECODE_HEAD; DECODE_HEAD;
close->cl_stateowner = NFS4_STATE_NOT_LOCKED; close->cl_stateowner = NULL;
READ_BUF(4 + sizeof(stateid_t)); READ_BUF(4 + sizeof(stateid_t));
READ32(close->cl_seqid); READ32(close->cl_seqid);
READ32(close->cl_stateid.si_generation); READ32(close->cl_stateid.si_generation);
...@@ -642,7 +640,7 @@ nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) ...@@ -642,7 +640,7 @@ nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock)
{ {
DECODE_HEAD; DECODE_HEAD;
lock->lk_stateowner = NFS4_STATE_NOT_LOCKED; lock->lk_stateowner = NULL;
/* /*
* type, reclaim(boolean), offset, length, new_lock_owner(boolean) * type, reclaim(boolean), offset, length, new_lock_owner(boolean)
*/ */
...@@ -700,7 +698,7 @@ nfsd4_decode_locku(struct nfsd4_compoundargs *argp, struct nfsd4_locku *locku) ...@@ -700,7 +698,7 @@ nfsd4_decode_locku(struct nfsd4_compoundargs *argp, struct nfsd4_locku *locku)
{ {
DECODE_HEAD; DECODE_HEAD;
locku->lu_stateowner = NFS4_STATE_NOT_LOCKED; locku->lu_stateowner = NULL;
READ_BUF(24 + sizeof(stateid_t)); READ_BUF(24 + sizeof(stateid_t));
READ32(locku->lu_type); READ32(locku->lu_type);
if ((locku->lu_type < NFS4_READ_LT) || (locku->lu_type > NFS4_WRITEW_LT)) if ((locku->lu_type < NFS4_READ_LT) || (locku->lu_type > NFS4_WRITEW_LT))
...@@ -736,7 +734,7 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) ...@@ -736,7 +734,7 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open)
memset(open->op_bmval, 0, sizeof(open->op_bmval)); memset(open->op_bmval, 0, sizeof(open->op_bmval));
open->op_iattr.ia_valid = 0; open->op_iattr.ia_valid = 0;
open->op_stateowner = NFS4_STATE_NOT_LOCKED; open->op_stateowner = NULL;
/* seqid, share_access, share_deny, clientid, ownerlen */ /* seqid, share_access, share_deny, clientid, ownerlen */
READ_BUF(16 + sizeof(clientid_t)); READ_BUF(16 + sizeof(clientid_t));
...@@ -812,7 +810,7 @@ nfsd4_decode_open_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_open_con ...@@ -812,7 +810,7 @@ nfsd4_decode_open_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_open_con
{ {
DECODE_HEAD; DECODE_HEAD;
open_conf->oc_stateowner = NFS4_STATE_NOT_LOCKED; open_conf->oc_stateowner = NULL;
READ_BUF(4 + sizeof(stateid_t)); READ_BUF(4 + sizeof(stateid_t));
READ32(open_conf->oc_req_stateid.si_generation); READ32(open_conf->oc_req_stateid.si_generation);
COPYMEM(&open_conf->oc_req_stateid.si_opaque, sizeof(stateid_opaque_t)); COPYMEM(&open_conf->oc_req_stateid.si_opaque, sizeof(stateid_opaque_t));
...@@ -826,7 +824,7 @@ nfsd4_decode_open_downgrade(struct nfsd4_compoundargs *argp, struct nfsd4_open_d ...@@ -826,7 +824,7 @@ nfsd4_decode_open_downgrade(struct nfsd4_compoundargs *argp, struct nfsd4_open_d
{ {
DECODE_HEAD; DECODE_HEAD;
open_down->od_stateowner = NFS4_STATE_NOT_LOCKED; open_down->od_stateowner = NULL;
READ_BUF(4 + sizeof(stateid_t)); READ_BUF(4 + sizeof(stateid_t));
READ32(open_down->od_stateid.si_generation); READ32(open_down->od_stateid.si_generation);
COPYMEM(&open_down->od_stateid.si_opaque, sizeof(stateid_opaque_t)); COPYMEM(&open_down->od_stateid.si_opaque, sizeof(stateid_opaque_t));
...@@ -1327,8 +1325,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) ...@@ -1327,8 +1325,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
*/ */
#define ENCODE_SEQID_OP_TAIL(stateowner) do { \ #define ENCODE_SEQID_OP_TAIL(stateowner) do { \
if (seqid_mutating_err(nfserr) && stateowner \ if (seqid_mutating_err(nfserr) && stateowner) { \
&& (stateowner != NFS4_STATE_NOT_LOCKED)) { \
if (stateowner->so_confirmed) \ if (stateowner->so_confirmed) \
stateowner->so_seqid++; \ stateowner->so_seqid++; \
stateowner->so_replay.rp_status = nfserr; \ stateowner->so_replay.rp_status = nfserr; \
...@@ -1336,10 +1333,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) ...@@ -1336,10 +1333,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
(((char *)(resp)->p - (char *)save)); \ (((char *)(resp)->p - (char *)save)); \
memcpy(stateowner->so_replay.rp_buf, save, \ memcpy(stateowner->so_replay.rp_buf, save, \
stateowner->so_replay.rp_buflen); \ stateowner->so_replay.rp_buflen); \
} \ } } while (0);
if (stateowner != NFS4_STATE_NOT_LOCKED) \
nfs4_unlock_state(); \
} while (0);
static u32 nfs4_ftypes[16] = { static u32 nfs4_ftypes[16] = {
...@@ -2573,7 +2567,6 @@ nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op) ...@@ -2573,7 +2567,6 @@ nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
RESERVE_SPACE(rp->rp_buflen); RESERVE_SPACE(rp->rp_buflen);
WRITEMEM(rp->rp_buf, rp->rp_buflen); WRITEMEM(rp->rp_buf, rp->rp_buflen);
ADJUST_ARGS(); ADJUST_ARGS();
nfs4_unlock_state();
} }
/* /*
......
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