Re: [for-6.13 PATCH 04/19] nfs/localio: eliminate unnecessary kref in nfs_local_fsync_ctx

NeilBrown
2024-11-11T01:15:19Z

On Sat, 09 Nov 2024, Mike Snitzer wrote:
> nfs_local_commit() doesn't need async cleanup of nfs_local_fsync_ctx,
> so there is no need to use a kref.
>
> Signed-off-by: Mike Snitzer <snitzer@kernel.org>

Reviewed-by: NeilBrown <neilb@suse.de>

thanks,
NeilBrown

> ---
> fs/nfs/localio.c | 20 +++-----------------
> 1 file changed, 3 insertions(+), 17 deletions(-)
>
> diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c
> index 4b24933093b6..a7eb83a604d0 100644
> --- a/fs/nfs/localio.c
> +++ b/fs/nfs/localio.c
> @@ -42,7 +42,6 @@ struct nfs_local_fsync_ctx {
> struct nfsd_file *localio;
> struct nfs_commit_data *data;
> struct work_struct work;
> - struct kref kref;
> struct completion *done;
> };
> static void nfs_local_fsync_work(struct work_struct *work);
> @@ -689,30 +688,17 @@ nfs_local_fsync_ctx_alloc(struct nfs_commit_data *data,
> ctx->localio = localio;
> ctx->data = data;
> INIT_WORK(&ctx->work, nfs_local_fsync_work);
> - kref_init(&ctx->kref);
> ctx->done = NULL;
> }
> return ctx;
> }
>
> -static void
> -nfs_local_fsync_ctx_kref_free(struct kref *kref)
> -{
> - kfree(container_of(kref, struct nfs_local_fsync_ctx, kref));
> -}
> -
> -static void
> -nfs_local_fsync_ctx_put(struct nfs_local_fsync_ctx *ctx)
> -{
> - kref_put(&ctx->kref, nfs_local_fsync_ctx_kref_free);
> -}
> -
> static void
> nfs_local_fsync_ctx_free(struct nfs_local_fsync_ctx *ctx)
> {
> nfs_local_release_commit_data(ctx->localio, ctx->data,
> ctx->data->task.tk_ops);
> - nfs_local_fsync_ctx_put(ctx);
> + kfree(ctx);
> }
>
> static void
> @@ -745,7 +731,7 @@ int nfs_local_commit(struct nfsd_file *localio,
> }
>
> nfs_local_init_commit(data, call_ops);
> - kref_get(&ctx->kref);
> +
> if (how & FLUSH_SYNC) {
> DECLARE_COMPLETION_ONSTACK(done);
> ctx->done = &done;
> @@ -753,6 +739,6 @@ int nfs_local_commit(struct nfsd_file *localio,
> wait_for_completion(&done);
> } else
> queue_work(nfsiod_workqueue, &ctx->work);
> - nfs_local_fsync_ctx_put(ctx);
> +
> return 0;
> }
> --
> 2.44.0
>
>