Skip to content

Commit b95239c

Browse files
jtlaytonchucklever
authored andcommitted
nfsd: make nfsd4_run_cb a bool return function
queue_work can return false and not queue anything, if the work is already queued. If that happens in the case of a CB_RECALL, we'll have taken an extra reference to the stid that will never be put. Ensure we throw a warning in that case. Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 25fbe1f commit b95239c

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

fs/nfsd/nfs4callback.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,11 +1371,21 @@ void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp,
13711371
cb->cb_holds_slot = false;
13721372
}
13731373

1374-
void nfsd4_run_cb(struct nfsd4_callback *cb)
1374+
/**
1375+
* nfsd4_run_cb - queue up a callback job to run
1376+
* @cb: callback to queue
1377+
*
1378+
* Kick off a callback to do its thing. Returns false if it was already
1379+
* on a queue, true otherwise.
1380+
*/
1381+
bool nfsd4_run_cb(struct nfsd4_callback *cb)
13751382
{
13761383
struct nfs4_client *clp = cb->cb_clp;
1384+
bool queued;
13771385

13781386
nfsd41_cb_inflight_begin(clp);
1379-
if (!nfsd4_queue_cb(cb))
1387+
queued = nfsd4_queue_cb(cb);
1388+
if (!queued)
13801389
nfsd41_cb_inflight_end(clp);
1390+
return queued;
13811391
}

fs/nfsd/nfs4state.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4859,14 +4859,13 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp)
48594859
* we know it's safe to take a reference.
48604860
*/
48614861
refcount_inc(&dp->dl_stid.sc_count);
4862-
nfsd4_run_cb(&dp->dl_recall);
4862+
WARN_ON_ONCE(!nfsd4_run_cb(&dp->dl_recall));
48634863
}
48644864

48654865
/* Called from break_lease() with flc_lock held. */
48664866
static bool
48674867
nfsd_break_deleg_cb(struct file_lock *fl)
48684868
{
4869-
bool ret = false;
48704869
struct nfs4_delegation *dp = (struct nfs4_delegation *)fl->fl_owner;
48714870
struct nfs4_file *fp = dp->dl_stid.sc_file;
48724871
struct nfs4_client *clp = dp->dl_stid.sc_client;
@@ -4892,7 +4891,7 @@ nfsd_break_deleg_cb(struct file_lock *fl)
48924891
fp->fi_had_conflict = true;
48934892
nfsd_break_one_deleg(dp);
48944893
spin_unlock(&fp->fi_lock);
4895-
return ret;
4894+
return false;
48964895
}
48974896

48984897
/**

fs/nfsd/state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ extern void nfsd4_probe_callback_sync(struct nfs4_client *clp);
692692
extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *);
693693
extern void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp,
694694
const struct nfsd4_callback_ops *ops, enum nfsd4_cb_op op);
695-
extern void nfsd4_run_cb(struct nfsd4_callback *cb);
695+
extern bool nfsd4_run_cb(struct nfsd4_callback *cb);
696696
extern int nfsd4_create_callback_queue(void);
697697
extern void nfsd4_destroy_callback_queue(void);
698698
extern void nfsd4_shutdown_callback(struct nfs4_client *);

0 commit comments

Comments
 (0)