Skip to content

Commit c654002

Browse files
neilbrownchucklever
authored andcommitted
nfsd: don't call functions with side-effecting inside WARN_ON()
Code like: WARN_ON(foo()) looks like an assertion and might not be expected to have any side effects. When testing if a function with side-effects fails a construct like if (foo()) WARN_ON(1); makes the intent more obvious. nfsd has several WARN_ON calls where the test has side effects, so it would be good to change them. These cases don't really need the WARN_ON. They have never failed in 8 years of usage so let's just remove the WARN_ON wrapper. Suggested-by: Chuck Lever <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 7794572 commit c654002

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/nfsd/nfs4state.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ static void release_open_stateid_locks(struct nfs4_ol_stateid *open_stp,
16001600
while (!list_empty(&open_stp->st_locks)) {
16011601
stp = list_entry(open_stp->st_locks.next,
16021602
struct nfs4_ol_stateid, st_locks);
1603-
WARN_ON(!unhash_lock_stateid(stp));
1603+
unhash_lock_stateid(stp);
16041604
put_ol_stateid_locked(stp, reaplist);
16051605
}
16061606
}
@@ -2229,7 +2229,7 @@ __destroy_client(struct nfs4_client *clp)
22292229
spin_lock(&state_lock);
22302230
while (!list_empty(&clp->cl_delegations)) {
22312231
dp = list_entry(clp->cl_delegations.next, struct nfs4_delegation, dl_perclnt);
2232-
WARN_ON(!unhash_delegation_locked(dp));
2232+
unhash_delegation_locked(dp);
22332233
list_add(&dp->dl_recall_lru, &reaplist);
22342234
}
22352235
spin_unlock(&state_lock);
@@ -6169,7 +6169,7 @@ nfs4_laundromat(struct nfsd_net *nn)
61696169
dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
61706170
if (!state_expired(&lt, dp->dl_time))
61716171
break;
6172-
WARN_ON(!unhash_delegation_locked(dp));
6172+
unhash_delegation_locked(dp);
61736173
list_add(&dp->dl_recall_lru, &reaplist);
61746174
}
61756175
spin_unlock(&state_lock);
@@ -7999,7 +7999,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
79997999
stp = list_first_entry(&lo->lo_owner.so_stateids,
80008000
struct nfs4_ol_stateid,
80018001
st_perstateowner);
8002-
WARN_ON(!unhash_lock_stateid(stp));
8002+
unhash_lock_stateid(stp);
80038003
put_ol_stateid_locked(stp, &reaplist);
80048004
}
80058005
spin_unlock(&clp->cl_lock);
@@ -8292,7 +8292,7 @@ nfs4_state_shutdown_net(struct net *net)
82928292
spin_lock(&state_lock);
82938293
list_for_each_safe(pos, next, &nn->del_recall_lru) {
82948294
dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
8295-
WARN_ON(!unhash_delegation_locked(dp));
8295+
unhash_delegation_locked(dp);
82968296
list_add(&dp->dl_recall_lru, &reaplist);
82978297
}
82988298
spin_unlock(&state_lock);

0 commit comments

Comments
 (0)