[v3,10/15] rbd: introduce completion for each img_request
diff mbox series

Message ID 1564393377-28949-11-git-send-email-dongsheng.yang@easystack.cn
State New
Headers show
Series
  • rbd journaling feature
Related show

Commit Message

Dongsheng Yang July 29, 2019, 9:42 a.m. UTC
When we are going to do a sync IO, we need a way
to wait a img_request to complete. Example, when
we are going to do journal replay, we need to do
a sync replaying, and return after img_request
completed.

Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
---
 drivers/block/rbd.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch
diff mbox series

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index d7ed462..4ff46ac 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -349,6 +349,9 @@  struct rbd_img_request {
 	struct pending_result	pending;
 	struct work_struct	work;
 	int			work_result;
+
+	struct completion	completion;
+
 	struct kref		kref;
 };
 
@@ -1750,6 +1753,7 @@  static struct rbd_img_request *rbd_img_request_create(
 		img_request_layered_set(img_request);
 
 	INIT_LIST_HEAD(&img_request->lock_item);
+	init_completion(&img_request->completion);
 	INIT_LIST_HEAD(&img_request->object_extents);
 	mutex_init(&img_request->state_mutex);
 	kref_init(&img_request->kref);
@@ -3725,6 +3729,7 @@  static void rbd_img_handle_request(struct rbd_img_request *img_req, int result)
 	} else {
 		struct request *rq = img_req->rq;
 
+		complete_all(&img_req->completion);
 		rbd_img_request_put(img_req);
 		blk_mq_end_request(rq, errno_to_blk_status(result));
 	}