diff options
author | Alex Elder <elder@inktank.com> | 2013-02-08 10:55:49 -0500 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:18:43 -0400 |
commit | 1217857fbf0fe6245aa0ce775480a759a0bbadeb (patch) | |
tree | 02dbab79eea258ca31f43efe88ace03a9bb5a09f /drivers/block/rbd.c | |
parent | d0b2e944555d1f06cf6df8a37b76367d10b05b01 (diff) |
rbd: encapsulate image object end request handling
Encapsulate the code that completes processing of an object request
that's part of an image request.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r-- | drivers/block/rbd.c | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index a77157d87915..2d2711537537 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -1603,6 +1603,34 @@ static void rbd_img_request_destroy(struct kref *kref) | |||
1603 | kfree(img_request); | 1603 | kfree(img_request); |
1604 | } | 1604 | } |
1605 | 1605 | ||
1606 | static bool rbd_img_obj_end_request(struct rbd_obj_request *obj_request) | ||
1607 | { | ||
1608 | struct rbd_img_request *img_request = obj_request->img_request; | ||
1609 | unsigned int xferred; | ||
1610 | int result; | ||
1611 | |||
1612 | rbd_assert(!img_request_child_test(img_request)); | ||
1613 | rbd_assert(img_request->rq != NULL); | ||
1614 | |||
1615 | rbd_assert(obj_request->xferred <= (u64)UINT_MAX); | ||
1616 | xferred = (unsigned int)obj_request->xferred; | ||
1617 | result = obj_request->result; | ||
1618 | if (result) { | ||
1619 | struct rbd_device *rbd_dev = img_request->rbd_dev; | ||
1620 | |||
1621 | rbd_warn(rbd_dev, "%s %llx at %llx (%llx)\n", | ||
1622 | img_request_write_test(img_request) ? "write" : "read", | ||
1623 | obj_request->length, obj_request->img_offset, | ||
1624 | obj_request->offset); | ||
1625 | rbd_warn(rbd_dev, " result %d xferred %x\n", | ||
1626 | result, xferred); | ||
1627 | if (!img_request->result) | ||
1628 | img_request->result = result; | ||
1629 | } | ||
1630 | |||
1631 | return blk_end_request(img_request->rq, result, xferred); | ||
1632 | } | ||
1633 | |||
1606 | static void rbd_img_obj_callback(struct rbd_obj_request *obj_request) | 1634 | static void rbd_img_obj_callback(struct rbd_obj_request *obj_request) |
1607 | { | 1635 | { |
1608 | struct rbd_img_request *img_request; | 1636 | struct rbd_img_request *img_request; |
@@ -1613,9 +1641,6 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request) | |||
1613 | 1641 | ||
1614 | dout("%s: img %p obj %p\n", __func__, img_request, obj_request); | 1642 | dout("%s: img %p obj %p\n", __func__, img_request, obj_request); |
1615 | rbd_assert(img_request != NULL); | 1643 | rbd_assert(img_request != NULL); |
1616 | rbd_assert(!img_request_child_test(img_request)) | ||
1617 | rbd_assert(img_request->rq != NULL); | ||
1618 | |||
1619 | rbd_assert(img_request->obj_request_count > 0); | 1644 | rbd_assert(img_request->obj_request_count > 0); |
1620 | rbd_assert(which != BAD_WHICH); | 1645 | rbd_assert(which != BAD_WHICH); |
1621 | rbd_assert(which < img_request->obj_request_count); | 1646 | rbd_assert(which < img_request->obj_request_count); |
@@ -1626,33 +1651,12 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request) | |||
1626 | goto out; | 1651 | goto out; |
1627 | 1652 | ||
1628 | for_each_obj_request_from(img_request, obj_request) { | 1653 | for_each_obj_request_from(img_request, obj_request) { |
1629 | unsigned int xferred; | ||
1630 | int result; | ||
1631 | |||
1632 | rbd_assert(more); | 1654 | rbd_assert(more); |
1633 | rbd_assert(which < img_request->obj_request_count); | 1655 | rbd_assert(which < img_request->obj_request_count); |
1634 | 1656 | ||
1635 | if (!obj_request_done_test(obj_request)) | 1657 | if (!obj_request_done_test(obj_request)) |
1636 | break; | 1658 | break; |
1637 | 1659 | more = rbd_img_obj_end_request(obj_request); | |
1638 | rbd_assert(obj_request->xferred <= (u64)UINT_MAX); | ||
1639 | xferred = (unsigned int)obj_request->xferred; | ||
1640 | result = obj_request->result; | ||
1641 | if (result) { | ||
1642 | struct rbd_device *rbd_dev = img_request->rbd_dev; | ||
1643 | |||
1644 | rbd_warn(rbd_dev, "%s %llx at %llx (%llx)\n", | ||
1645 | img_request_write_test(img_request) ? "write" | ||
1646 | : "read", | ||
1647 | obj_request->length, obj_request->img_offset, | ||
1648 | obj_request->offset); | ||
1649 | rbd_warn(rbd_dev, " result %d xferred %x\n", | ||
1650 | result, xferred); | ||
1651 | if (!img_request->result) | ||
1652 | img_request->result = result; | ||
1653 | } | ||
1654 | |||
1655 | more = blk_end_request(img_request->rq, result, xferred); | ||
1656 | which++; | 1660 | which++; |
1657 | } | 1661 | } |
1658 | 1662 | ||