diff options
| author | J. Bruce Fields <bfields@redhat.com> | 2011-08-24 12:27:31 -0400 |
|---|---|---|
| committer | J. Bruce Fields <bfields@redhat.com> | 2011-08-31 17:56:02 -0400 |
| commit | f3e4223751392b9bc0195a806a6e99b4cc399ac0 (patch) | |
| tree | 32a6401b29c2c96371bb4aeed5812b1ae58ab90f /fs/nfsd | |
| parent | 73997dc4183c580278ea8cb41c7a9655940801e0 (diff) | |
nfsd4: centralize handling of replay owners
Set the stateowner associated with a replay in one spot in
nfs4_preprocess_seqid_op() and keep it in cstate. This allows removing
a few lines of boilerplate from all the nfs4_preprocess_seqid_op()
callers.
Also turn ENCODE_SEQID_OP_TAIL into a function while we're here.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
| -rw-r--r-- | fs/nfsd/nfs4state.c | 25 | ||||
| -rw-r--r-- | fs/nfsd/nfs4xdr.c | 34 |
2 files changed, 23 insertions, 36 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 80af79ee5d51..e4535ff92876 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
| @@ -3425,12 +3425,15 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, | |||
| 3425 | /* It's not stale; let's assume it's expired: */ | 3425 | /* It's not stale; let's assume it's expired: */ |
| 3426 | if (sop == NULL) | 3426 | if (sop == NULL) |
| 3427 | return nfserr_expired; | 3427 | return nfserr_expired; |
| 3428 | *sopp = sop; | 3428 | nfs4_get_stateowner(sop); |
| 3429 | cstate->replay_owner = sop; | ||
| 3429 | goto check_replay; | 3430 | goto check_replay; |
| 3430 | } | 3431 | } |
| 3431 | 3432 | ||
| 3432 | *stpp = stp; | 3433 | *stpp = stp; |
| 3433 | *sopp = sop = stp->st_stateowner; | 3434 | *sopp = sop = stp->st_stateowner; |
| 3435 | nfs4_get_stateowner(sop); | ||
| 3436 | cstate->replay_owner = sop; | ||
| 3434 | 3437 | ||
| 3435 | if (nfs4_check_fh(current_fh, stp)) { | 3438 | if (nfs4_check_fh(current_fh, stp)) { |
| 3436 | dprintk("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n"); | 3439 | dprintk("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n"); |
| @@ -3501,10 +3504,6 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
| 3501 | 3504 | ||
| 3502 | nfsd4_create_clid_dir(sop->so_client); | 3505 | nfsd4_create_clid_dir(sop->so_client); |
| 3503 | out: | 3506 | out: |
| 3504 | if (oc->oc_stateowner) { | ||
| 3505 | nfs4_get_stateowner(oc->oc_stateowner); | ||
| 3506 | cstate->replay_owner = oc->oc_stateowner; | ||
| 3507 | } | ||
| 3508 | nfs4_unlock_state(); | 3507 | nfs4_unlock_state(); |
| 3509 | return status; | 3508 | return status; |
| 3510 | } | 3509 | } |
| @@ -3574,10 +3573,6 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, | |||
| 3574 | memcpy(&od->od_stateid, &stp->st_stateid, sizeof(stateid_t)); | 3573 | memcpy(&od->od_stateid, &stp->st_stateid, sizeof(stateid_t)); |
| 3575 | status = nfs_ok; | 3574 | status = nfs_ok; |
| 3576 | out: | 3575 | out: |
| 3577 | if (od->od_stateowner) { | ||
| 3578 | nfs4_get_stateowner(od->od_stateowner); | ||
| 3579 | cstate->replay_owner = od->od_stateowner; | ||
| 3580 | } | ||
| 3581 | nfs4_unlock_state(); | 3576 | nfs4_unlock_state(); |
| 3582 | return status; | 3577 | return status; |
| 3583 | } | 3578 | } |
| @@ -3618,10 +3613,6 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
| 3618 | if (list_empty(&close->cl_stateowner->so_stateids)) | 3613 | if (list_empty(&close->cl_stateowner->so_stateids)) |
| 3619 | move_to_close_lru(close->cl_stateowner); | 3614 | move_to_close_lru(close->cl_stateowner); |
| 3620 | out: | 3615 | out: |
| 3621 | if (close->cl_stateowner) { | ||
| 3622 | nfs4_get_stateowner(close->cl_stateowner); | ||
| 3623 | cstate->replay_owner = close->cl_stateowner; | ||
| 3624 | } | ||
| 3625 | nfs4_unlock_state(); | 3616 | nfs4_unlock_state(); |
| 3626 | return status; | 3617 | return status; |
| 3627 | } | 3618 | } |
| @@ -4086,10 +4077,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
| 4086 | out: | 4077 | out: |
| 4087 | if (status && lock->lk_is_new && lock_sop) | 4078 | if (status && lock->lk_is_new && lock_sop) |
| 4088 | release_lockowner(lock_sop); | 4079 | release_lockowner(lock_sop); |
| 4089 | if (lock->lk_replay_owner) { | ||
| 4090 | nfs4_get_stateowner(lock->lk_replay_owner); | ||
| 4091 | cstate->replay_owner = lock->lk_replay_owner; | ||
| 4092 | } | ||
| 4093 | nfs4_unlock_state(); | 4080 | nfs4_unlock_state(); |
| 4094 | return status; | 4081 | return status; |
| 4095 | } | 4082 | } |
| @@ -4244,10 +4231,6 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
| 4244 | memcpy(&locku->lu_stateid, &stp->st_stateid, sizeof(stateid_t)); | 4231 | memcpy(&locku->lu_stateid, &stp->st_stateid, sizeof(stateid_t)); |
| 4245 | 4232 | ||
| 4246 | out: | 4233 | out: |
| 4247 | if (locku->lu_stateowner) { | ||
| 4248 | nfs4_get_stateowner(locku->lu_stateowner); | ||
| 4249 | cstate->replay_owner = locku->lu_stateowner; | ||
| 4250 | } | ||
| 4251 | nfs4_unlock_state(); | 4234 | nfs4_unlock_state(); |
| 4252 | return status; | 4235 | return status; |
| 4253 | 4236 | ||
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index f982d8574d95..ee1267838719 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
| @@ -1630,15 +1630,19 @@ static void write_cinfo(__be32 **p, struct nfsd4_change_info *c) | |||
| 1630 | * we know whether the error to be returned is a sequence id mutating error. | 1630 | * we know whether the error to be returned is a sequence id mutating error. |
| 1631 | */ | 1631 | */ |
| 1632 | 1632 | ||
| 1633 | #define ENCODE_SEQID_OP_TAIL(stateowner) do { \ | 1633 | static void encode_seqid_op_tail(struct nfsd4_compoundres *resp, __be32 *save, __be32 nfserr) |
| 1634 | if (seqid_mutating_err(ntohl(nfserr)) && stateowner) { \ | 1634 | { |
| 1635 | stateowner->so_seqid++; \ | 1635 | struct nfs4_stateowner *stateowner = resp->cstate.replay_owner; |
| 1636 | stateowner->so_replay.rp_status = nfserr; \ | 1636 | |
| 1637 | stateowner->so_replay.rp_buflen = \ | 1637 | if (seqid_mutating_err(ntohl(nfserr)) && stateowner) { |
| 1638 | (((char *)(resp)->p - (char *)save)); \ | 1638 | stateowner->so_seqid++; |
| 1639 | memcpy(stateowner->so_replay.rp_buf, save, \ | 1639 | stateowner->so_replay.rp_status = nfserr; |
| 1640 | stateowner->so_replay.rp_buflen); \ | 1640 | stateowner->so_replay.rp_buflen = |
| 1641 | } } while (0); | 1641 | (char *)resp->p - (char *)save; |
| 1642 | memcpy(stateowner->so_replay.rp_buf, save, | ||
| 1643 | stateowner->so_replay.rp_buflen); | ||
| 1644 | } | ||
| 1645 | } | ||
| 1642 | 1646 | ||
| 1643 | /* Encode as an array of strings the string given with components | 1647 | /* Encode as an array of strings the string given with components |
| 1644 | * separated @sep. | 1648 | * separated @sep. |
| @@ -2495,7 +2499,7 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_c | |||
| 2495 | if (!nfserr) | 2499 | if (!nfserr) |
| 2496 | nfsd4_encode_stateid(resp, &close->cl_stateid); | 2500 | nfsd4_encode_stateid(resp, &close->cl_stateid); |
| 2497 | 2501 | ||
| 2498 | ENCODE_SEQID_OP_TAIL(close->cl_stateowner); | 2502 | encode_seqid_op_tail(resp, save, nfserr); |
| 2499 | return nfserr; | 2503 | return nfserr; |
| 2500 | } | 2504 | } |
| 2501 | 2505 | ||
| @@ -2599,7 +2603,7 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lo | |||
| 2599 | else if (nfserr == nfserr_denied) | 2603 | else if (nfserr == nfserr_denied) |
| 2600 | nfsd4_encode_lock_denied(resp, &lock->lk_denied); | 2604 | nfsd4_encode_lock_denied(resp, &lock->lk_denied); |
| 2601 | 2605 | ||
| 2602 | ENCODE_SEQID_OP_TAIL(lock->lk_replay_owner); | 2606 | encode_seqid_op_tail(resp, save, nfserr); |
| 2603 | return nfserr; | 2607 | return nfserr; |
| 2604 | } | 2608 | } |
| 2605 | 2609 | ||
| @@ -2619,7 +2623,7 @@ nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_l | |||
| 2619 | if (!nfserr) | 2623 | if (!nfserr) |
| 2620 | nfsd4_encode_stateid(resp, &locku->lu_stateid); | 2624 | nfsd4_encode_stateid(resp, &locku->lu_stateid); |
| 2621 | 2625 | ||
| 2622 | ENCODE_SEQID_OP_TAIL(locku->lu_stateowner); | 2626 | encode_seqid_op_tail(resp, save, nfserr); |
| 2623 | return nfserr; | 2627 | return nfserr; |
| 2624 | } | 2628 | } |
| 2625 | 2629 | ||
| @@ -2700,7 +2704,7 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op | |||
| 2700 | } | 2704 | } |
| 2701 | /* XXX save filehandle here */ | 2705 | /* XXX save filehandle here */ |
| 2702 | out: | 2706 | out: |
| 2703 | ENCODE_SEQID_OP_TAIL(open->op_stateowner); | 2707 | encode_seqid_op_tail(resp, save, nfserr); |
| 2704 | return nfserr; | 2708 | return nfserr; |
| 2705 | } | 2709 | } |
| 2706 | 2710 | ||
| @@ -2712,7 +2716,7 @@ nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct | |||
| 2712 | if (!nfserr) | 2716 | if (!nfserr) |
| 2713 | nfsd4_encode_stateid(resp, &oc->oc_resp_stateid); | 2717 | nfsd4_encode_stateid(resp, &oc->oc_resp_stateid); |
| 2714 | 2718 | ||
| 2715 | ENCODE_SEQID_OP_TAIL(oc->oc_stateowner); | 2719 | encode_seqid_op_tail(resp, save, nfserr); |
| 2716 | return nfserr; | 2720 | return nfserr; |
| 2717 | } | 2721 | } |
| 2718 | 2722 | ||
| @@ -2724,7 +2728,7 @@ nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struc | |||
| 2724 | if (!nfserr) | 2728 | if (!nfserr) |
| 2725 | nfsd4_encode_stateid(resp, &od->od_stateid); | 2729 | nfsd4_encode_stateid(resp, &od->od_stateid); |
| 2726 | 2730 | ||
| 2727 | ENCODE_SEQID_OP_TAIL(od->od_stateowner); | 2731 | encode_seqid_op_tail(resp, save, nfserr); |
| 2728 | return nfserr; | 2732 | return nfserr; |
| 2729 | } | 2733 | } |
| 2730 | 2734 | ||
