Commit 49bdbdb1 authored by Jeff Layton's avatar Jeff Layton Committed by Chuck Lever
Browse files

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: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 424dd3df
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1312,7 +1312,11 @@ static void nfsd41_destroy_cb(struct nfsd4_callback *cb)

	trace_nfsd_cb_destroy(clp, cb);
	nfsd41_cb_release_slot(cb);
	if (test_bit(NFSD4_CALLBACK_WAKE, &cb->cb_flags))
		clear_and_wake_up_bit(NFSD4_CALLBACK_RUNNING, &cb->cb_flags);
	else
		clear_bit(NFSD4_CALLBACK_RUNNING, &cb->cb_flags);

	if (cb->cb_ops && cb->cb_ops->release)
		cb->cb_ops->release(cb);
	nfsd41_cb_inflight_end(clp);
+9 −8
Original line number Diff line number Diff line
@@ -3205,7 +3205,6 @@ nfsd4_cb_getattr_release(struct nfsd4_callback *cb)
	struct nfs4_delegation *dp =
			container_of(ncf, struct nfs4_delegation, dl_cb_fattr);

	clear_and_wake_up_bit(CB_GETATTR_BUSY, &ncf->ncf_cb_flags);
	nfs4_put_stid(&dp->dl_stid);
}

@@ -3226,16 +3225,18 @@ static void nfs4_cb_getattr(struct nfs4_cb_fattr *ncf)
	struct nfs4_delegation *dp =
			container_of(ncf, struct nfs4_delegation, dl_cb_fattr);

	if (test_and_set_bit(CB_GETATTR_BUSY, &ncf->ncf_cb_flags))
	if (test_and_set_bit(NFSD4_CALLBACK_RUNNING, &ncf->ncf_getattr.cb_flags))
		return;

	/* set to proper status when nfsd4_cb_getattr_done runs */
	ncf->ncf_cb_status = NFS4ERR_IO;

	if (!test_and_set_bit(NFSD4_CALLBACK_RUNNING, &ncf->ncf_getattr.cb_flags)) {
	/* ensure that wake_bit is done when RUNNING is cleared */
	set_bit(NFSD4_CALLBACK_WAKE, &ncf->ncf_getattr.cb_flags);

	refcount_inc(&dp->dl_stid.sc_count);
	nfsd4_run_cb(&ncf->ncf_getattr);
}
}

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

	wait_on_bit_timeout(&ncf->ncf_cb_flags, CB_GETATTR_BUSY,
			    TASK_INTERRUPTIBLE, NFSD_CB_GETATTR_TIMEOUT);
	wait_on_bit_timeout(&ncf->ncf_getattr.cb_flags, NFSD4_CALLBACK_RUNNING,
			    TASK_UNINTERRUPTIBLE, NFSD_CB_GETATTR_TIMEOUT);
	if (ncf->ncf_cb_status) {
		/* Recall delegation only if client didn't respond */
		status = nfserrno(nfsd_open_break_lease(inode, NFSD_MAY_READ));
+1 −4
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ struct nfsd4_callback {
	struct nfs4_client *cb_clp;
	struct rpc_message cb_msg;
#define NFSD4_CALLBACK_RUNNING		(0)
#define NFSD4_CALLBACK_WAKE		(1)
	unsigned long cb_flags;
	const struct nfsd4_callback_ops *cb_ops;
	struct work_struct cb_work;
@@ -164,15 +165,11 @@ struct nfs4_cb_fattr {
	struct timespec64 ncf_cb_mtime;
	struct timespec64 ncf_cb_atime;

	unsigned long ncf_cb_flags;
	bool ncf_file_modified;
	u64 ncf_initial_cinfo;
	u64 ncf_cur_fsize;
};

/* bits for ncf_cb_flags */
#define	CB_GETATTR_BUSY		0

/*
 * Represents a delegation stateid. The nfs4_client holds references to these
 * and they are put when it is being destroyed or when the delegation is