diff mbox series

[2,02/14] NFSD: Convert the callback workqueue to use delayed_work

Message ID 170629112325.20612.15691160218281370004.stgit@manet.1015granger.net (mailing list archive)
State New
Headers show
Series NFSD backchannel fixes | expand

Commit Message

Chuck Lever Jan. 26, 2024, 5:45 p.m. UTC
From: Chuck Lever <chuck.lever@oracle.com>

Normally, NFSv4 callback operations are supposed to be sent to the
client as soon as they are queued up.

In a moment, I will introduce a recovery path where the server has
to wait for the client to reconnect. We don't want a hard busy wait
here -- the callback should be requeued to try again in several
milliseconds.

For now, convert nfsd4_callback from struct work_struct to struct
delayed_work, and queue with a zero delay argument. This should
avoid behavior changes for current operation.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/nfs4callback.c |    6 +++---
 fs/nfsd/state.h        |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Jeffrey Layton Jan. 26, 2024, 7:09 p.m. UTC | #1
On Fri, 2024-01-26 at 12:45 -0500, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
> 
> Normally, NFSv4 callback operations are supposed to be sent to the
> client as soon as they are queued up.
> 
> In a moment, I will introduce a recovery path where the server has
> to wait for the client to reconnect. We don't want a hard busy wait
> here -- the callback should be requeued to try again in several
> milliseconds.
> 
> For now, convert nfsd4_callback from struct work_struct to struct
> delayed_work, and queue with a zero delay argument. This should
> avoid behavior changes for current operation.
> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  fs/nfsd/nfs4callback.c |    6 +++---
>  fs/nfsd/state.h        |    2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
> index 43b0a34a5d5b..1ed2512b3648 100644
> --- a/fs/nfsd/nfs4callback.c
> +++ b/fs/nfsd/nfs4callback.c
> @@ -887,7 +887,7 @@ static struct workqueue_struct *callback_wq;
>  
>  static bool nfsd4_queue_cb(struct nfsd4_callback *cb)
>  {
> -	return queue_work(callback_wq, &cb->cb_work);
> +	return queue_delayed_work(callback_wq, &cb->cb_work, 0);
>  }
>  
>  static void nfsd41_cb_inflight_begin(struct nfs4_client *clp)
> @@ -1370,7 +1370,7 @@ static void
>  nfsd4_run_cb_work(struct work_struct *work)
>  {
>  	struct nfsd4_callback *cb =
> -		container_of(work, struct nfsd4_callback, cb_work);
> +		container_of(work, struct nfsd4_callback, cb_work.work);
>  	struct nfs4_client *clp = cb->cb_clp;
>  	struct rpc_clnt *clnt;
>  	int flags;
> @@ -1415,7 +1415,7 @@ void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp,
>  	cb->cb_msg.rpc_argp = cb;
>  	cb->cb_msg.rpc_resp = cb;
>  	cb->cb_ops = ops;
> -	INIT_WORK(&cb->cb_work, nfsd4_run_cb_work);
> +	INIT_DELAYED_WORK(&cb->cb_work, nfsd4_run_cb_work);
>  	cb->cb_seq_status = 1;
>  	cb->cb_status = 0;
>  	cb->cb_need_restart = false;
> diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
> index 41bdc913fa71..87c4372ba36a 100644
> --- a/fs/nfsd/state.h
> +++ b/fs/nfsd/state.h
> @@ -68,7 +68,7 @@ struct nfsd4_callback {
>  	struct nfs4_client *cb_clp;
>  	struct rpc_message cb_msg;
>  	const struct nfsd4_callback_ops *cb_ops;
> -	struct work_struct cb_work;
> +	struct delayed_work cb_work;
>  	int cb_seq_status;
>  	int cb_status;
>  	bool cb_need_restart;
> 
> 
> 

Reviewed-by: Jeff Layton <jlayton@kernel.org>
diff mbox series

Patch

diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 43b0a34a5d5b..1ed2512b3648 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -887,7 +887,7 @@  static struct workqueue_struct *callback_wq;
 
 static bool nfsd4_queue_cb(struct nfsd4_callback *cb)
 {
-	return queue_work(callback_wq, &cb->cb_work);
+	return queue_delayed_work(callback_wq, &cb->cb_work, 0);
 }
 
 static void nfsd41_cb_inflight_begin(struct nfs4_client *clp)
@@ -1370,7 +1370,7 @@  static void
 nfsd4_run_cb_work(struct work_struct *work)
 {
 	struct nfsd4_callback *cb =
-		container_of(work, struct nfsd4_callback, cb_work);
+		container_of(work, struct nfsd4_callback, cb_work.work);
 	struct nfs4_client *clp = cb->cb_clp;
 	struct rpc_clnt *clnt;
 	int flags;
@@ -1415,7 +1415,7 @@  void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp,
 	cb->cb_msg.rpc_argp = cb;
 	cb->cb_msg.rpc_resp = cb;
 	cb->cb_ops = ops;
-	INIT_WORK(&cb->cb_work, nfsd4_run_cb_work);
+	INIT_DELAYED_WORK(&cb->cb_work, nfsd4_run_cb_work);
 	cb->cb_seq_status = 1;
 	cb->cb_status = 0;
 	cb->cb_need_restart = false;
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index 41bdc913fa71..87c4372ba36a 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -68,7 +68,7 @@  struct nfsd4_callback {
 	struct nfs4_client *cb_clp;
 	struct rpc_message cb_msg;
 	const struct nfsd4_callback_ops *cb_ops;
-	struct work_struct cb_work;
+	struct delayed_work cb_work;
 	int cb_seq_status;
 	int cb_status;
 	bool cb_need_restart;