Skip to content

Commit 935fee5

Browse files
neilbrownchucklever
authored andcommitted
nfsd: use new wake_up_var interfaces.
The wake_up_var interface is fragile as barriers are sometimes needed. There are now new interfaces so that most wake-ups can use an interface that is guaranteed to have all barriers needed. This patch changes the wake up on cl_cb_inflight to use atomic_dec_and_wake_up(). It also changes the wake up on rp_locked to use store_release_wake_up(). This involves changing rp_locked from atomic_t to int. Signed-off-by: NeilBrown <neilb@suse.de> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 19d97ac commit 935fee5

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

fs/nfsd/nfs4callback.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,7 @@ static void nfsd41_cb_inflight_begin(struct nfs4_client *clp)
10361036
static void nfsd41_cb_inflight_end(struct nfs4_client *clp)
10371037
{
10381038

1039-
if (atomic_dec_and_test(&clp->cl_cb_inflight))
1040-
wake_up_var(&clp->cl_cb_inflight);
1039+
atomic_dec_and_wake_up(&clp->cl_cb_inflight);
10411040
}
10421041

10431042
static void nfsd41_cb_inflight_wait_complete(struct nfs4_client *clp)

fs/nfsd/nfs4state.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,17 +4739,17 @@ static void init_nfs4_replay(struct nfs4_replay *rp)
47394739
rp->rp_status = nfserr_serverfault;
47404740
rp->rp_buflen = 0;
47414741
rp->rp_buf = rp->rp_ibuf;
4742-
atomic_set(&rp->rp_locked, RP_UNLOCKED);
4742+
rp->rp_locked = RP_UNLOCKED;
47434743
}
47444744

47454745
static int nfsd4_cstate_assign_replay(struct nfsd4_compound_state *cstate,
47464746
struct nfs4_stateowner *so)
47474747
{
47484748
if (!nfsd4_has_session(cstate)) {
47494749
wait_var_event(&so->so_replay.rp_locked,
4750-
atomic_cmpxchg(&so->so_replay.rp_locked,
4751-
RP_UNLOCKED, RP_LOCKED) != RP_LOCKED);
4752-
if (atomic_read(&so->so_replay.rp_locked) == RP_UNHASHED)
4750+
cmpxchg(&so->so_replay.rp_locked,
4751+
RP_UNLOCKED, RP_LOCKED) != RP_LOCKED);
4752+
if (so->so_replay.rp_locked == RP_UNHASHED)
47534753
return -EAGAIN;
47544754
cstate->replay_owner = nfs4_get_stateowner(so);
47554755
}
@@ -4762,9 +4762,7 @@ void nfsd4_cstate_clear_replay(struct nfsd4_compound_state *cstate)
47624762

47634763
if (so != NULL) {
47644764
cstate->replay_owner = NULL;
4765-
atomic_set(&so->so_replay.rp_locked, RP_UNLOCKED);
4766-
smp_mb__after_atomic();
4767-
wake_up_var(&so->so_replay.rp_locked);
4765+
store_release_wake_up(&so->so_replay.rp_locked, RP_UNLOCKED);
47684766
nfs4_put_stateowner(so);
47694767
}
47704768
}
@@ -5069,9 +5067,7 @@ move_to_close_lru(struct nfs4_ol_stateid *s, struct net *net)
50695067
* Some threads with a reference might be waiting for rp_locked,
50705068
* so tell them to stop waiting.
50715069
*/
5072-
atomic_set(&oo->oo_owner.so_replay.rp_locked, RP_UNHASHED);
5073-
smp_mb__after_atomic();
5074-
wake_up_var(&oo->oo_owner.so_replay.rp_locked);
5070+
store_release_wake_up(&oo->oo_owner.so_replay.rp_locked, RP_UNHASHED);
50755071
wait_event(close_wq, refcount_read(&s->st_stid.sc_count) == 2);
50765072

50775073
release_all_access(s);

fs/nfsd/state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ struct nfs4_replay {
505505
unsigned int rp_buflen;
506506
char *rp_buf;
507507
struct knfsd_fh rp_openfh;
508-
atomic_t rp_locked;
508+
int rp_locked;
509509
char rp_ibuf[NFSD4_REPLAY_ISIZE];
510510
};
511511

0 commit comments

Comments
 (0)