summaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2018-02-01 05:50:47 -0500
committerIlya Dryomov <idryomov@gmail.com>2018-04-02 04:12:42 -0400
commitecc633caebcc84a1469892e3f6f6f4b6a16f41af (patch)
tree8a6b081e60332b0bb210ff1126d0a42cb0f6728f /drivers/block/rbd.c
parent0be2d60ed888a25016a05148e52feea4bf401b0e (diff)
rbd: store data_type in img_req instead of obj_req
All object requests are associated with an image request now -- avoid duplicating the same info in each object request. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 7ec4d143f534..6ce9e0b35461 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -258,7 +258,6 @@ struct rbd_obj_request {
258 /* links for img_request->obj_requests list */ 258 /* links for img_request->obj_requests list */
259 struct list_head links; 259 struct list_head links;
260 260
261 enum obj_request_type type;
262 union { 261 union {
263 struct ceph_bio_iter bio_pos; 262 struct ceph_bio_iter bio_pos;
264 struct { 263 struct {
@@ -285,6 +284,7 @@ enum img_req_flags {
285struct rbd_img_request { 284struct rbd_img_request {
286 struct rbd_device *rbd_dev; 285 struct rbd_device *rbd_dev;
287 enum obj_operation_type op_type; 286 enum obj_operation_type op_type;
287 enum obj_request_type data_type;
288 u64 offset; /* starting image byte offset */ 288 u64 offset; /* starting image byte offset */
289 u64 length; /* byte count from offset */ 289 u64 length; /* byte count from offset */
290 unsigned long flags; 290 unsigned long flags;
@@ -1270,7 +1270,7 @@ static void zero_bvecs(struct ceph_bvec_iter *bvec_pos, u32 off, u32 bytes)
1270static void rbd_obj_zero_range(struct rbd_obj_request *obj_req, u32 off, 1270static void rbd_obj_zero_range(struct rbd_obj_request *obj_req, u32 off,
1271 u32 bytes) 1271 u32 bytes)
1272{ 1272{
1273 switch (obj_req->type) { 1273 switch (obj_req->img_request->data_type) {
1274 case OBJ_REQUEST_BIO: 1274 case OBJ_REQUEST_BIO:
1275 zero_bios(&obj_req->bio_pos, off, bytes); 1275 zero_bios(&obj_req->bio_pos, off, bytes);
1276 break; 1276 break;
@@ -1348,22 +1348,9 @@ static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request,
1348 rbd_assert(img_request->obj_request_count > 0); 1348 rbd_assert(img_request->obj_request_count > 0);
1349 img_request->obj_request_count--; 1349 img_request->obj_request_count--;
1350 rbd_assert(obj_request->img_request == img_request); 1350 rbd_assert(obj_request->img_request == img_request);
1351 obj_request->img_request = NULL;
1352 rbd_obj_request_put(obj_request); 1351 rbd_obj_request_put(obj_request);
1353} 1352}
1354 1353
1355static bool obj_request_type_valid(enum obj_request_type type)
1356{
1357 switch (type) {
1358 case OBJ_REQUEST_NODATA:
1359 case OBJ_REQUEST_BIO:
1360 case OBJ_REQUEST_BVECS:
1361 return true;
1362 default:
1363 return false;
1364 }
1365}
1366
1367static void rbd_obj_request_submit(struct rbd_obj_request *obj_request) 1354static void rbd_obj_request_submit(struct rbd_obj_request *obj_request)
1368{ 1355{
1369 struct ceph_osd_request *osd_req = obj_request->osd_req; 1356 struct ceph_osd_request *osd_req = obj_request->osd_req;
@@ -1524,18 +1511,14 @@ static void rbd_osd_req_destroy(struct ceph_osd_request *osd_req)
1524 ceph_osdc_put_request(osd_req); 1511 ceph_osdc_put_request(osd_req);
1525} 1512}
1526 1513
1527static struct rbd_obj_request * 1514static struct rbd_obj_request *rbd_obj_request_create(void)
1528rbd_obj_request_create(enum obj_request_type type)
1529{ 1515{
1530 struct rbd_obj_request *obj_request; 1516 struct rbd_obj_request *obj_request;
1531 1517
1532 rbd_assert(obj_request_type_valid(type));
1533
1534 obj_request = kmem_cache_zalloc(rbd_obj_request_cache, GFP_NOIO); 1518 obj_request = kmem_cache_zalloc(rbd_obj_request_cache, GFP_NOIO);
1535 if (!obj_request) 1519 if (!obj_request)
1536 return NULL; 1520 return NULL;
1537 1521
1538 obj_request->type = type;
1539 INIT_LIST_HEAD(&obj_request->links); 1522 INIT_LIST_HEAD(&obj_request->links);
1540 kref_init(&obj_request->kref); 1523 kref_init(&obj_request->kref);
1541 1524
@@ -1552,12 +1535,10 @@ static void rbd_obj_request_destroy(struct kref *kref)
1552 1535
1553 dout("%s: obj %p\n", __func__, obj_request); 1536 dout("%s: obj %p\n", __func__, obj_request);
1554 1537
1555 rbd_assert(obj_request->img_request == NULL);
1556
1557 if (obj_request->osd_req) 1538 if (obj_request->osd_req)
1558 rbd_osd_req_destroy(obj_request->osd_req); 1539 rbd_osd_req_destroy(obj_request->osd_req);
1559 1540
1560 switch (obj_request->type) { 1541 switch (obj_request->img_request->data_type) {
1561 case OBJ_REQUEST_NODATA: 1542 case OBJ_REQUEST_NODATA:
1562 case OBJ_REQUEST_BIO: 1543 case OBJ_REQUEST_BIO:
1563 case OBJ_REQUEST_BVECS: 1544 case OBJ_REQUEST_BVECS:
@@ -1742,7 +1723,7 @@ static void rbd_parent_request_destroy(struct kref *kref)
1742 1723
1743static void rbd_osd_req_setup_data(struct rbd_obj_request *obj_req, u32 which) 1724static void rbd_osd_req_setup_data(struct rbd_obj_request *obj_req, u32 which)
1744{ 1725{
1745 switch (obj_req->type) { 1726 switch (obj_req->img_request->data_type) {
1746 case OBJ_REQUEST_BIO: 1727 case OBJ_REQUEST_BIO:
1747 osd_req_op_extent_osd_data_bio(obj_req->osd_req, which, 1728 osd_req_op_extent_osd_data_bio(obj_req->osd_req, which,
1748 &obj_req->bio_pos, 1729 &obj_req->bio_pos,
@@ -1979,7 +1960,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
1979 u64 offset = rbd_segment_offset(rbd_dev, img_offset); 1960 u64 offset = rbd_segment_offset(rbd_dev, img_offset);
1980 u64 length = rbd_segment_length(rbd_dev, img_offset, resid); 1961 u64 length = rbd_segment_length(rbd_dev, img_offset, resid);
1981 1962
1982 obj_request = rbd_obj_request_create(type); 1963 obj_request = rbd_obj_request_create();
1983 if (!obj_request) 1964 if (!obj_request)
1984 goto out_unwind; 1965 goto out_unwind;
1985 1966
@@ -2008,6 +1989,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
2008 resid -= length; 1989 resid -= length;
2009 } 1990 }
2010 1991
1992 img_request->data_type = type;
2011 return __rbd_img_fill_request(img_request); 1993 return __rbd_img_fill_request(img_request);
2012 1994
2013out_unwind: 1995out_unwind:
@@ -2042,7 +2024,7 @@ static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req,
2042 return -ENOMEM; 2024 return -ENOMEM;
2043 2025
2044 if (!rbd_img_is_write(img_req)) { 2026 if (!rbd_img_is_write(img_req)) {
2045 switch (obj_req->type) { 2027 switch (img_req->data_type) {
2046 case OBJ_REQUEST_BIO: 2028 case OBJ_REQUEST_BIO:
2047 ret = rbd_img_request_fill(child_img_req, 2029 ret = rbd_img_request_fill(child_img_req,
2048 OBJ_REQUEST_BIO, 2030 OBJ_REQUEST_BIO,