From 941f841c8d396d957381fcd4de003d8f2201e741 Mon Sep 17 00:00:00 2001
From: David Disseldorp <ddiss@suse.de>
Date: Wed, 15 Jan 2020 13:33:50 +0100
Subject: [PATCH] rbd: add img_request done callback
References: fate#318836
Patch-mainline: Not yet, SES clustered LIO/RBD
This allows LIO to properly handle SCSI command completion.
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
drivers/block/rbd.c | 29 ++++++++++++++++++++---------
include/linux/ceph/librbd.h | 6 +++++-
2 files changed, 25 insertions(+), 10 deletions(-)
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1354,7 +1354,8 @@ static bool rbd_dev_parent_get(struct rb
static void rbd_img_request_init(struct rbd_img_request *img_request,
struct rbd_device *rbd_dev,
- enum obj_operation_type op_type)
+ enum obj_operation_type op_type,
+ rbd_img_request_end_cb_t end_cb)
{
memset(img_request, 0, sizeof(*img_request));
@@ -1364,12 +1365,14 @@ static void rbd_img_request_init(struct
INIT_LIST_HEAD(&img_request->lock_item);
INIT_LIST_HEAD(&img_request->object_extents);
mutex_init(&img_request->state_mutex);
+ img_request->callback = end_cb;
}
/* This is for use by LIO RBD so we don't export the caches directly */
struct rbd_img_request *rbd_img_request_create(
struct rbd_device *rbd_dev,
- enum obj_operation_type op_type)
+ enum obj_operation_type op_type,
+ rbd_img_request_end_cb_t end_cb)
{
struct rbd_img_request *img_request;
@@ -1377,7 +1380,7 @@ struct rbd_img_request *rbd_img_request_
if (!img_request)
return NULL;
- rbd_img_request_init(img_request, rbd_dev, op_type);
+ rbd_img_request_init(img_request, rbd_dev, op_type, end_cb);
return img_request;
}
EXPORT_SYMBOL(rbd_img_request_create);
@@ -2579,6 +2582,8 @@ static int rbd_obj_read_object(struct rb
return 0;
}
+static void rbd_img_end_request(struct rbd_img_request *img_req, int result);
+
static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req)
{
struct rbd_img_request *img_req = obj_req->img_request;
@@ -2590,7 +2595,8 @@ static int rbd_obj_read_from_parent(stru
if (!child_img_req)
return -ENOMEM;
- rbd_img_request_init(child_img_req, parent, OBJ_OP_READ);
+ rbd_img_request_init(child_img_req, parent, OBJ_OP_READ,
+ rbd_img_end_request);
__set_bit(IMG_REQ_CHILD, &child_img_req->flags);
child_img_req->obj_request = obj_req;
@@ -3376,6 +3382,14 @@ static bool __rbd_img_handle_request(str
return done;
}
+static void rbd_img_end_request(struct rbd_img_request *img_req, int result)
+{
+ struct request *rq = blk_mq_rq_from_pdu(img_req);
+
+ rbd_img_request_destroy(img_req);
+ blk_mq_end_request(rq, errno_to_blk_status(result));
+}
+
void rbd_img_handle_request(struct rbd_img_request *img_req, int result)
{
again:
@@ -3391,10 +3405,7 @@ again:
goto again;
}
} else {
- struct request *rq = blk_mq_rq_from_pdu(img_req);
-
- rbd_img_request_destroy(img_req);
- blk_mq_end_request(rq, errno_to_blk_status(result));
+ img_req->callback(img_req, result);
}
}
EXPORT_SYMBOL(rbd_img_handle_request);
@@ -4528,7 +4539,7 @@ static blk_status_t rbd_queue_rq(struct
return BLK_STS_IOERR;
}
- rbd_img_request_init(img_req, rbd_dev, op_type);
+ rbd_img_request_init(img_req, rbd_dev, op_type, rbd_img_end_request);
if (rbd_img_is_write(img_req)) {
if (rbd_is_ro(rbd_dev)) {
--- a/include/linux/ceph/librbd.h
+++ b/include/linux/ceph/librbd.h
@@ -101,6 +101,8 @@ enum rbd_img_state {
};
struct rbd_obj_request;
+typedef void (*rbd_img_request_end_cb_t)(struct rbd_img_request *img_request,
+ int result);
struct rbd_img_request {
struct rbd_device *rbd_dev;
@@ -113,6 +115,7 @@ struct rbd_img_request {
struct ceph_snap_context *snapc; /* for writes */
};
struct rbd_obj_request *obj_request; /* obj req initiator */
+ rbd_img_request_end_cb_t callback;
struct list_head lock_item;
struct list_head object_extents; /* obj_req.ex structs */
@@ -234,7 +237,8 @@ enum rbd_dev_flags {
extern struct rbd_img_request *rbd_img_request_create(
struct rbd_device *rbd_dev,
- enum obj_operation_type op_type);
+ enum obj_operation_type op_type,
+ rbd_img_request_end_cb_t end_cb);
extern int rbd_img_fill_nodata(struct rbd_img_request *img_req,
u64 off, u64 len);
extern int rbd_img_fill_from_bvecs(struct rbd_img_request *img_req,