Blob Blame History Raw
From e69e12b89233f31c3210a1ad9752a6fbbaca098b Mon Sep 17 00:00:00 2001
From: Mike Christie <michaelc@cs.wisc.edu>
Date: Tue, 14 Jan 2020 16:33:36 +0100
Subject: [PATCH] rbd: export some functions used by lio rbd backend
References: fate#318836
Patch-mainline: Not yet, SES clustered LIO/RBD

The lio rbd backend will make img_request rbd calls, so this
patch exports the functions it uses.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
[ddiss: export bvecs API for data payload]
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
 drivers/block/rbd.c |   38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -642,7 +642,7 @@ static int _rbd_dev_v2_snap_size(struct
 static int rbd_dev_v2_get_flags(struct rbd_device *rbd_dev);
 
 static void rbd_obj_handle_request(struct rbd_obj_request *obj_req, int result);
-static void rbd_img_handle_request(struct rbd_img_request *img_req, int result);
+void rbd_img_handle_request(struct rbd_img_request *img_req, int result);
 
 /*
  * Return true if nothing else is pending.
@@ -1590,6 +1590,22 @@ static void rbd_img_request_init(struct
 	mutex_init(&img_request->state_mutex);
 }
 
+/* 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)
+{
+	struct rbd_img_request *img_request;
+
+	img_request = kmem_cache_alloc(rbd_img_request_cache, GFP_NOIO);
+	if (!img_request)
+		return NULL;
+
+	rbd_img_request_init(img_request, rbd_dev, op_type);
+	return img_request;
+}
+EXPORT_SYMBOL(rbd_img_request_create);
+
 static void rbd_img_capture_header(struct rbd_img_request *img_req)
 {
 	struct rbd_device *rbd_dev = img_req->rbd_dev;
@@ -1605,7 +1621,7 @@ static void rbd_img_capture_header(struc
 		img_request_layered_set(img_req);
 }
 
-static void rbd_img_request_destroy(struct rbd_img_request *img_request)
+void rbd_img_request_destroy(struct rbd_img_request *img_request)
 {
 	struct rbd_obj_request *obj_request;
 	struct rbd_obj_request *next_obj_request;
@@ -1625,6 +1641,7 @@ static void rbd_img_request_destroy(stru
 	if (test_bit(IMG_REQ_CHILD, &img_request->flags))
 		kmem_cache_free(rbd_img_request_cache, img_request);
 }
+EXPORT_SYMBOL(rbd_img_request_destroy);
 
 #define BITS_PER_OBJ	2
 #define OBJS_PER_BYTE	(BITS_PER_BYTE / BITS_PER_OBJ)
@@ -2591,8 +2608,8 @@ static int rbd_img_fill_request(struct r
 	return __rbd_img_fill_request(img_req);
 }
 
-static int rbd_img_fill_nodata(struct rbd_img_request *img_req,
-			       u64 off, u64 len)
+int rbd_img_fill_nodata(struct rbd_img_request *img_req,
+			u64 off, u64 len)
 {
 	struct ceph_file_extent ex = { off, len };
 	union rbd_img_fill_iter dummy = {};
@@ -2603,6 +2620,7 @@ static int rbd_img_fill_nodata(struct rb
 
 	return rbd_img_fill_request(img_req, &ex, 1, &fctx);
 }
+EXPORT_SYMBOL(rbd_img_fill_nodata);
 
 static void set_bio_pos(struct ceph_object_extent *ex, u32 bytes, void *arg)
 {
@@ -2718,10 +2736,10 @@ static int __rbd_img_fill_from_bvecs(str
 				    &fctx);
 }
 
-static int rbd_img_fill_from_bvecs(struct rbd_img_request *img_req,
-				   struct ceph_file_extent *img_extents,
-				   u32 num_img_extents,
-				   struct bio_vec *bvecs)
+int rbd_img_fill_from_bvecs(struct rbd_img_request *img_req,
+			    struct ceph_file_extent *img_extents,
+			    u32 num_img_extents,
+			    struct bio_vec *bvecs)
 {
 	struct ceph_bvec_iter it = {
 		.bvecs = bvecs,
@@ -2732,6 +2750,7 @@ static int rbd_img_fill_from_bvecs(struc
 	return __rbd_img_fill_from_bvecs(img_req, img_extents, num_img_extents,
 					 &it);
 }
+EXPORT_SYMBOL(rbd_img_fill_from_bvecs);
 
 static void rbd_img_handle_request_work(struct work_struct *work)
 {
@@ -3581,7 +3600,7 @@ static bool __rbd_img_handle_request(str
 	return done;
 }
 
-static void rbd_img_handle_request(struct rbd_img_request *img_req, int result)
+void rbd_img_handle_request(struct rbd_img_request *img_req, int result)
 {
 again:
 	if (!__rbd_img_handle_request(img_req, &result))
@@ -3602,6 +3621,7 @@ again:
 		blk_mq_end_request(rq, errno_to_blk_status(result));
 	}
 }
+EXPORT_SYMBOL(rbd_img_handle_request);
 
 static const struct rbd_client_id rbd_empty_cid;