diff mbox series

[v2,12/16] rbd: introduce completion for each img_request

Message ID 1552900534-29026-13-git-send-email-dongsheng.yang@easystack.cn (mailing list archive)
State New, archived
Headers show
Series rbd journaling feature | expand

Commit Message

Dongsheng Yang March 18, 2019, 9:15 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 | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index a583c2e..cc0642c 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -294,6 +294,8 @@  struct rbd_img_request {
 	u32			obj_request_count;
 	u32			pending_count;
 
+	struct completion	completion;
+
 	struct kref		kref;
 };
 
@@ -1654,6 +1656,7 @@  static struct rbd_img_request *rbd_img_request_create(
 	if (rbd_dev_parent_get(rbd_dev))
 		img_request_layered_set(img_request);
 
+	init_completion(&img_request->completion);
 	spin_lock_init(&img_request->completion_lock);
 	INIT_LIST_HEAD(&img_request->object_extents);
 	kref_init(&img_request->kref);
@@ -2598,6 +2601,7 @@  static void rbd_img_end_request(struct rbd_img_request *img_req)
 
 	blk_mq_end_request(img_req->rq,
 			   errno_to_blk_status(img_req->result));
+	complete_all(&img_req->completion);
 	rbd_img_request_put(img_req);
 }