@@ -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));
}
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(+)