[for-6.11 PATCH 17/29] NFS: Use completion rather than flush_work() in nfs_local_commit()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>

Make the code consistent with other routines.

Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
Signed-off-by: Mike Snitzer <snitzer@xxxxxxxxxx>
---
 fs/nfs/localio.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c
index d997f0a96627..d7918e26aeb6 100644
--- a/fs/nfs/localio.c
+++ b/fs/nfs/localio.c
@@ -60,6 +60,7 @@ struct nfs_local_fsync_ctx {
 	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);
 
@@ -813,6 +814,7 @@ nfs_local_fsync_ctx_alloc(struct nfs_commit_data *data, struct file *filp,
 		ctx->data = data;
 		INIT_WORK(&ctx->work, nfs_local_fsync_work);
 		kref_init(&ctx->kref);
+		ctx->done = NULL;
 	}
 	return ctx;
 }
@@ -847,6 +849,8 @@ nfs_local_fsync_work(struct work_struct *work)
 
 	status = nfs_local_run_commit(ctx->filp, ctx->data);
 	nfs_local_commit_done(ctx->data, status);
+	if (ctx->done != NULL)
+		complete(ctx->done);
 	nfs_local_fsync_ctx_free(ctx);
 }
 
@@ -866,9 +870,13 @@ nfs_local_commit(struct nfs_client *clp, struct file *filp,
 
 	nfs_local_init_commit(data, call_ops);
 	kref_get(&ctx->kref);
-	queue_work(nfsiod_workqueue, &ctx->work);
-	if (how & FLUSH_SYNC)
-		flush_work(&ctx->work);
+	if (how & FLUSH_SYNC) {
+		DECLARE_COMPLETION_ONSTACK(done);
+		ctx->done = &done;
+		queue_work(nfsiod_workqueue, &ctx->work);
+		wait_for_completion(&done);
+	} else
+		queue_work(nfsiod_workqueue, &ctx->work);
 	nfs_local_fsync_ctx_put(ctx);
 	return 0;
 }
-- 
2.44.0





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux