diff mbox series

[v4,07/12] rbd: introduce completion for each img_request

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

Commit Message

Dongsheng Yang Sept. 25, 2019, 9:07 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(+)
diff mbox series

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index f1fc28d..8a8914a 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));
 	}