Skip to content

Commit 49bdbdb

Browse files
jtlaytonchucklever
authored andcommitted
nfsd: replace CB_GETATTR_BUSY with NFSD4_CALLBACK_RUNNING
These flags serve essentially the same purpose and get set and cleared at the same time. Drop CB_GETATTR_BUSY and just use NFSD4_CALLBACK_RUNNING instead. For this to work, we must use clear_and_wake_up_bit(), but doing that on for other types of callbacks is wasteful. Declare a new NFSD4_CALLBACK_WAKE flag in cb_flags to indicate that wake_up is needed, and only set that for CB_GETATTRs. Also, make the wait use a TASK_UNINTERRUPTIBLE sleep. This is done in the context of an nfsd thread, and it should never need to deal with signals. Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 424dd3d commit 49bdbdb

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

fs/nfsd/nfs4callback.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,11 @@ static void nfsd41_destroy_cb(struct nfsd4_callback *cb)
13121312

13131313
trace_nfsd_cb_destroy(clp, cb);
13141314
nfsd41_cb_release_slot(cb);
1315-
clear_bit(NFSD4_CALLBACK_RUNNING, &cb->cb_flags);
1315+
if (test_bit(NFSD4_CALLBACK_WAKE, &cb->cb_flags))
1316+
clear_and_wake_up_bit(NFSD4_CALLBACK_RUNNING, &cb->cb_flags);
1317+
else
1318+
clear_bit(NFSD4_CALLBACK_RUNNING, &cb->cb_flags);
1319+
13161320
if (cb->cb_ops && cb->cb_ops->release)
13171321
cb->cb_ops->release(cb);
13181322
nfsd41_cb_inflight_end(clp);

fs/nfsd/nfs4state.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3205,7 +3205,6 @@ nfsd4_cb_getattr_release(struct nfsd4_callback *cb)
32053205
struct nfs4_delegation *dp =
32063206
container_of(ncf, struct nfs4_delegation, dl_cb_fattr);
32073207

3208-
clear_and_wake_up_bit(CB_GETATTR_BUSY, &ncf->ncf_cb_flags);
32093208
nfs4_put_stid(&dp->dl_stid);
32103209
}
32113210

@@ -3226,15 +3225,17 @@ static void nfs4_cb_getattr(struct nfs4_cb_fattr *ncf)
32263225
struct nfs4_delegation *dp =
32273226
container_of(ncf, struct nfs4_delegation, dl_cb_fattr);
32283227

3229-
if (test_and_set_bit(CB_GETATTR_BUSY, &ncf->ncf_cb_flags))
3228+
if (test_and_set_bit(NFSD4_CALLBACK_RUNNING, &ncf->ncf_getattr.cb_flags))
32303229
return;
3230+
32313231
/* set to proper status when nfsd4_cb_getattr_done runs */
32323232
ncf->ncf_cb_status = NFS4ERR_IO;
32333233

3234-
if (!test_and_set_bit(NFSD4_CALLBACK_RUNNING, &ncf->ncf_getattr.cb_flags)) {
3235-
refcount_inc(&dp->dl_stid.sc_count);
3236-
nfsd4_run_cb(&ncf->ncf_getattr);
3237-
}
3234+
/* ensure that wake_bit is done when RUNNING is cleared */
3235+
set_bit(NFSD4_CALLBACK_WAKE, &ncf->ncf_getattr.cb_flags);
3236+
3237+
refcount_inc(&dp->dl_stid.sc_count);
3238+
nfsd4_run_cb(&ncf->ncf_getattr);
32383239
}
32393240

32403241
static struct nfs4_client *create_client(struct xdr_netobj name,
@@ -9210,8 +9211,8 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,
92109211
nfs4_cb_getattr(&dp->dl_cb_fattr);
92119212
spin_unlock(&ctx->flc_lock);
92129213

9213-
wait_on_bit_timeout(&ncf->ncf_cb_flags, CB_GETATTR_BUSY,
9214-
TASK_INTERRUPTIBLE, NFSD_CB_GETATTR_TIMEOUT);
9214+
wait_on_bit_timeout(&ncf->ncf_getattr.cb_flags, NFSD4_CALLBACK_RUNNING,
9215+
TASK_UNINTERRUPTIBLE, NFSD_CB_GETATTR_TIMEOUT);
92159216
if (ncf->ncf_cb_status) {
92169217
/* Recall delegation only if client didn't respond */
92179218
status = nfserrno(nfsd_open_break_lease(inode, NFSD_MAY_READ));

fs/nfsd/state.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct nfsd4_callback {
6868
struct nfs4_client *cb_clp;
6969
struct rpc_message cb_msg;
7070
#define NFSD4_CALLBACK_RUNNING (0)
71+
#define NFSD4_CALLBACK_WAKE (1)
7172
unsigned long cb_flags;
7273
const struct nfsd4_callback_ops *cb_ops;
7374
struct work_struct cb_work;
@@ -164,15 +165,11 @@ struct nfs4_cb_fattr {
164165
struct timespec64 ncf_cb_mtime;
165166
struct timespec64 ncf_cb_atime;
166167

167-
unsigned long ncf_cb_flags;
168168
bool ncf_file_modified;
169169
u64 ncf_initial_cinfo;
170170
u64 ncf_cur_fsize;
171171
};
172172

173-
/* bits for ncf_cb_flags */
174-
#define CB_GETATTR_BUSY 0
175-
176173
/*
177174
* Represents a delegation stateid. The nfs4_client holds references to these
178175
* and they are put when it is being destroyed or when the delegation is

0 commit comments

Comments
 (0)