[09/11] rbd: introduce completion for each img_request
diff mbox series

Message ID 1543841435-13652-10-git-send-email-dongsheng.yang@easystack.cn
State New
Headers show
Series
  • [01/11] libceph: support prefix and suffix in bio_iter
Related show

Commit Message

Dongsheng Yang Dec. 3, 2018, 12:50 p.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(+)

Patch
diff mbox series

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 44d1285..cc9ee8d 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);
 }