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
commit15961b44947d9d53bfec0a89b5ebbcf30afeb6ac (patch)
treec5ed2d3cf0fc085f7b8f7105dca7ad6ae8ee95bd /drivers/block/rbd.c
parent7114edac357b8cc27cf95a4d7eed75d07c41970d (diff)
rbd: remove old request completion code
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c175
1 files changed, 3 insertions, 172 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 2eb0abd104f5..959aa95cd626 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -209,12 +209,6 @@ struct rbd_client {
209}; 209};
210 210
211struct rbd_img_request; 211struct rbd_img_request;
212typedef void (*rbd_img_callback_t)(struct rbd_img_request *);
213
214#define BAD_WHICH U32_MAX /* Good which or bad which, which? */
215
216struct rbd_obj_request;
217typedef void (*rbd_obj_callback_t)(struct rbd_obj_request *);
218 212
219enum obj_request_type { 213enum obj_request_type {
220 OBJ_REQUEST_NODATA = 1, 214 OBJ_REQUEST_NODATA = 1,
@@ -229,7 +223,6 @@ enum obj_operation_type {
229}; 223};
230 224
231enum obj_req_flags { 225enum obj_req_flags {
232 OBJ_REQ_DONE, /* completion flag: not done = 0, done = 1 */
233 OBJ_REQ_IMG_DATA, /* object usage: standalone = 0, image = 1 */ 226 OBJ_REQ_IMG_DATA, /* object usage: standalone = 0, image = 1 */
234}; 227};
235 228
@@ -268,17 +261,11 @@ struct rbd_obj_request {
268 /* 261 /*
269 * An object request associated with an image will have its 262 * An object request associated with an image will have its
270 * img_data flag set; a standalone object request will not. 263 * img_data flag set; a standalone object request will not.
271 *
272 * Finally, an object request for rbd image data will have
273 * which != BAD_WHICH, and will have a non-null img_request
274 * pointer. The value of which will be in the range
275 * 0..(img_request->obj_request_count-1).
276 */ 264 */
277 struct rbd_img_request *img_request; 265 struct rbd_img_request *img_request;
278 u64 img_offset; 266 u64 img_offset;
279 /* links for img_request->obj_requests list */ 267 /* links for img_request->obj_requests list */
280 struct list_head links; 268 struct list_head links;
281 u32 which; /* posn image request list */
282 269
283 enum obj_request_type type; 270 enum obj_request_type type;
284 union { 271 union {
@@ -296,8 +283,6 @@ struct rbd_obj_request {
296 u64 xferred; /* bytes transferred */ 283 u64 xferred; /* bytes transferred */
297 int result; 284 int result;
298 285
299 rbd_obj_callback_t callback;
300
301 struct kref kref; 286 struct kref kref;
302}; 287};
303 288
@@ -320,9 +305,7 @@ struct rbd_img_request {
320 struct request *rq; /* block request */ 305 struct request *rq; /* block request */
321 struct rbd_obj_request *obj_request; /* obj req initiator */ 306 struct rbd_obj_request *obj_request; /* obj req initiator */
322 }; 307 };
323 spinlock_t completion_lock;/* protects next_completion */ 308 spinlock_t completion_lock;
324 u32 next_completion;
325 rbd_img_callback_t callback;
326 u64 xferred;/* aggregate bytes transferred */ 309 u64 xferred;/* aggregate bytes transferred */
327 int result; /* first nonzero obj_request result */ 310 int result; /* first nonzero obj_request result */
328 311
@@ -335,8 +318,6 @@ struct rbd_img_request {
335 318
336#define for_each_obj_request(ireq, oreq) \ 319#define for_each_obj_request(ireq, oreq) \
337 list_for_each_entry(oreq, &(ireq)->obj_requests, links) 320 list_for_each_entry(oreq, &(ireq)->obj_requests, links)
338#define for_each_obj_request_from(ireq, oreq) \
339 list_for_each_entry_from(oreq, &(ireq)->obj_requests, links)
340#define for_each_obj_request_safe(ireq, oreq, n) \ 321#define for_each_obj_request_safe(ireq, oreq, n) \
341 list_for_each_entry_safe_reverse(oreq, n, &(ireq)->obj_requests, links) 322 list_for_each_entry_safe_reverse(oreq, n, &(ireq)->obj_requests, links)
342 323
@@ -1332,24 +1313,6 @@ static bool obj_request_img_data_test(struct rbd_obj_request *obj_request)
1332 return test_bit(OBJ_REQ_IMG_DATA, &obj_request->flags) != 0; 1313 return test_bit(OBJ_REQ_IMG_DATA, &obj_request->flags) != 0;
1333} 1314}
1334 1315
1335static void obj_request_done_set(struct rbd_obj_request *obj_request)
1336{
1337 if (test_and_set_bit(OBJ_REQ_DONE, &obj_request->flags)) {
1338 struct rbd_device *rbd_dev = NULL;
1339
1340 if (obj_request_img_data_test(obj_request))
1341 rbd_dev = obj_request->img_request->rbd_dev;
1342 rbd_warn(rbd_dev, "obj_request %p already marked done",
1343 obj_request);
1344 }
1345}
1346
1347static bool obj_request_done_test(struct rbd_obj_request *obj_request)
1348{
1349 smp_mb();
1350 return test_bit(OBJ_REQ_DONE, &obj_request->flags) != 0;
1351}
1352
1353static bool obj_request_overlaps_parent(struct rbd_obj_request *obj_request) 1316static bool obj_request_overlaps_parent(struct rbd_obj_request *obj_request)
1354{ 1317{
1355 struct rbd_device *rbd_dev = obj_request->img_request->rbd_dev; 1318 struct rbd_device *rbd_dev = obj_request->img_request->rbd_dev;
@@ -1402,33 +1365,24 @@ static inline void rbd_img_obj_request_add(struct rbd_img_request *img_request,
1402 1365
1403 /* Image request now owns object's original reference */ 1366 /* Image request now owns object's original reference */
1404 obj_request->img_request = img_request; 1367 obj_request->img_request = img_request;
1405 obj_request->which = img_request->obj_request_count;
1406 rbd_assert(!obj_request_img_data_test(obj_request)); 1368 rbd_assert(!obj_request_img_data_test(obj_request));
1407 obj_request_img_data_set(obj_request); 1369 obj_request_img_data_set(obj_request);
1408 rbd_assert(obj_request->which != BAD_WHICH);
1409 img_request->obj_request_count++; 1370 img_request->obj_request_count++;
1410 img_request->pending_count++; 1371 img_request->pending_count++;
1411 list_add_tail(&obj_request->links, &img_request->obj_requests); 1372 list_add_tail(&obj_request->links, &img_request->obj_requests);
1412 dout("%s: img %p obj %p w=%u\n", __func__, img_request, obj_request, 1373 dout("%s: img %p obj %p\n", __func__, img_request, obj_request);
1413 obj_request->which);
1414} 1374}
1415 1375
1416static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request, 1376static inline void rbd_img_obj_request_del(struct rbd_img_request *img_request,
1417 struct rbd_obj_request *obj_request) 1377 struct rbd_obj_request *obj_request)
1418{ 1378{
1419 rbd_assert(obj_request->which != BAD_WHICH); 1379 dout("%s: img %p obj %p\n", __func__, img_request, obj_request);
1420
1421 dout("%s: img %p obj %p w=%u\n", __func__, img_request, obj_request,
1422 obj_request->which);
1423 list_del(&obj_request->links); 1380 list_del(&obj_request->links);
1424 rbd_assert(img_request->obj_request_count > 0); 1381 rbd_assert(img_request->obj_request_count > 0);
1425 img_request->obj_request_count--; 1382 img_request->obj_request_count--;
1426 rbd_assert(obj_request->which == img_request->obj_request_count);
1427 obj_request->which = BAD_WHICH;
1428 rbd_assert(obj_request_img_data_test(obj_request)); 1383 rbd_assert(obj_request_img_data_test(obj_request));
1429 rbd_assert(obj_request->img_request == img_request); 1384 rbd_assert(obj_request->img_request == img_request);
1430 obj_request->img_request = NULL; 1385 obj_request->img_request = NULL;
1431 obj_request->callback = NULL;
1432 rbd_obj_request_put(obj_request); 1386 rbd_obj_request_put(obj_request);
1433} 1387}
1434 1388
@@ -1444,8 +1398,6 @@ static bool obj_request_type_valid(enum obj_request_type type)
1444 } 1398 }
1445} 1399}
1446 1400
1447static void rbd_img_obj_callback(struct rbd_obj_request *obj_request);
1448
1449static void rbd_obj_request_submit(struct rbd_obj_request *obj_request) 1401static void rbd_obj_request_submit(struct rbd_obj_request *obj_request)
1450{ 1402{
1451 struct ceph_osd_request *osd_req = obj_request->osd_req; 1403 struct ceph_osd_request *osd_req = obj_request->osd_req;
@@ -1456,32 +1408,6 @@ static void rbd_obj_request_submit(struct rbd_obj_request *obj_request)
1456 ceph_osdc_start_request(osd_req->r_osdc, osd_req, false); 1408 ceph_osdc_start_request(osd_req->r_osdc, osd_req, false);
1457} 1409}
1458 1410
1459static void rbd_img_request_complete(struct rbd_img_request *img_request)
1460{
1461
1462 dout("%s: img %p\n", __func__, img_request);
1463
1464 /*
1465 * If no error occurred, compute the aggregate transfer
1466 * count for the image request. We could instead use
1467 * atomic64_cmpxchg() to update it as each object request
1468 * completes; not clear which way is better off hand.
1469 */
1470 if (!img_request->result) {
1471 struct rbd_obj_request *obj_request;
1472 u64 xferred = 0;
1473
1474 for_each_obj_request(img_request, obj_request)
1475 xferred += obj_request->xferred;
1476 img_request->xferred = xferred;
1477 }
1478
1479 if (img_request->callback)
1480 img_request->callback(img_request);
1481 else
1482 rbd_img_request_put(img_request);
1483}
1484
1485/* 1411/*
1486 * The default/initial value for all image request flags is 0. Each 1412 * The default/initial value for all image request flags is 0. Each
1487 * is conditionally set to 1 at image request initialization time 1413 * is conditionally set to 1 at image request initialization time
@@ -1552,13 +1478,6 @@ static bool rbd_img_is_write(struct rbd_img_request *img_req)
1552 } 1478 }
1553} 1479}
1554 1480
1555static void rbd_obj_request_complete(struct rbd_obj_request *obj_request)
1556{
1557 dout("%s: obj %p cb %p\n", __func__, obj_request,
1558 obj_request->callback);
1559 obj_request->callback(obj_request);
1560}
1561
1562static void rbd_obj_handle_request(struct rbd_obj_request *obj_req); 1481static void rbd_obj_handle_request(struct rbd_obj_request *obj_req);
1563 1482
1564static void rbd_osd_req_callback(struct ceph_osd_request *osd_req) 1483static void rbd_osd_req_callback(struct ceph_osd_request *osd_req)
@@ -1651,7 +1570,6 @@ rbd_obj_request_create(enum obj_request_type type)
1651 if (!obj_request) 1570 if (!obj_request)
1652 return NULL; 1571 return NULL;
1653 1572
1654 obj_request->which = BAD_WHICH;
1655 obj_request->type = type; 1573 obj_request->type = type;
1656 INIT_LIST_HEAD(&obj_request->links); 1574 INIT_LIST_HEAD(&obj_request->links);
1657 kref_init(&obj_request->kref); 1575 kref_init(&obj_request->kref);
@@ -1670,7 +1588,6 @@ static void rbd_obj_request_destroy(struct kref *kref)
1670 dout("%s: obj %p\n", __func__, obj_request); 1588 dout("%s: obj %p\n", __func__, obj_request);
1671 1589
1672 rbd_assert(obj_request->img_request == NULL); 1590 rbd_assert(obj_request->img_request == NULL);
1673 rbd_assert(obj_request->which == BAD_WHICH);
1674 1591
1675 if (obj_request->osd_req) 1592 if (obj_request->osd_req)
1676 rbd_osd_req_destroy(obj_request->osd_req); 1593 rbd_osd_req_destroy(obj_request->osd_req);
@@ -1858,91 +1775,6 @@ static void rbd_parent_request_destroy(struct kref *kref)
1858 rbd_img_request_destroy(kref); 1775 rbd_img_request_destroy(kref);
1859} 1776}
1860 1777
1861static bool rbd_img_obj_end_request(struct rbd_obj_request *obj_request)
1862{
1863 struct rbd_img_request *img_request;
1864 unsigned int xferred;
1865 int result;
1866 bool more;
1867
1868 rbd_assert(obj_request_img_data_test(obj_request));
1869 img_request = obj_request->img_request;
1870
1871 rbd_assert(obj_request->xferred <= (u64)UINT_MAX);
1872 xferred = (unsigned int)obj_request->xferred;
1873 result = obj_request->result;
1874 if (result) {
1875 struct rbd_device *rbd_dev = img_request->rbd_dev;
1876
1877 rbd_warn(rbd_dev, "%s %llx at %llx (%llx)",
1878 obj_op_name(img_request->op_type), obj_request->length,
1879 obj_request->img_offset, obj_request->offset);
1880 rbd_warn(rbd_dev, " result %d xferred %x",
1881 result, xferred);
1882 if (!img_request->result)
1883 img_request->result = result;
1884 /*
1885 * Need to end I/O on the entire obj_request worth of
1886 * bytes in case of error.
1887 */
1888 xferred = obj_request->length;
1889 }
1890
1891 if (img_request_child_test(img_request)) {
1892 rbd_assert(img_request->obj_request != NULL);
1893 more = obj_request->which < img_request->obj_request_count - 1;
1894 } else {
1895 blk_status_t status = errno_to_blk_status(result);
1896
1897 rbd_assert(img_request->rq != NULL);
1898
1899 more = blk_update_request(img_request->rq, status, xferred);
1900 if (!more)
1901 __blk_mq_end_request(img_request->rq, status);
1902 }
1903
1904 return more;
1905}
1906
1907static void rbd_img_obj_callback(struct rbd_obj_request *obj_request)
1908{
1909 struct rbd_img_request *img_request;
1910 u32 which = obj_request->which;
1911 bool more = true;
1912
1913 rbd_assert(obj_request_img_data_test(obj_request));
1914 img_request = obj_request->img_request;
1915
1916 dout("%s: img %p obj %p\n", __func__, img_request, obj_request);
1917 rbd_assert(img_request != NULL);
1918 rbd_assert(img_request->obj_request_count > 0);
1919 rbd_assert(which != BAD_WHICH);
1920 rbd_assert(which < img_request->obj_request_count);
1921
1922 spin_lock_irq(&img_request->completion_lock);
1923 if (which != img_request->next_completion)
1924 goto out;
1925
1926 for_each_obj_request_from(img_request, obj_request) {
1927 rbd_assert(more);
1928 rbd_assert(which < img_request->obj_request_count);
1929
1930 if (!obj_request_done_test(obj_request))
1931 break;
1932 more = rbd_img_obj_end_request(obj_request);
1933 which++;
1934 }
1935
1936 rbd_assert(more ^ (which == img_request->obj_request_count));
1937 img_request->next_completion = which;
1938out:
1939 spin_unlock_irq(&img_request->completion_lock);
1940 rbd_img_request_put(img_request);
1941
1942 if (!more)
1943 rbd_img_request_complete(img_request);
1944}
1945
1946static void rbd_osd_req_setup_data(struct rbd_obj_request *obj_req, u32 which) 1778static void rbd_osd_req_setup_data(struct rbd_obj_request *obj_req, u32 which)
1947{ 1779{
1948 switch (obj_req->type) { 1780 switch (obj_req->type) {
@@ -2205,7 +2037,6 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
2205 ceph_bvec_iter_advance(&bvec_it, length); 2037 ceph_bvec_iter_advance(&bvec_it, length);
2206 } 2038 }
2207 2039
2208 obj_request->callback = rbd_img_obj_callback;
2209 obj_request->img_offset = img_offset; 2040 obj_request->img_offset = img_offset;
2210 2041
2211 img_offset += length; 2042 img_offset += length;