diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2016-09-13 15:08:10 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2016-10-03 10:13:47 -0400 |
commit | 4a17dadcae55ca1f5c1ed826d42185e22653c256 (patch) | |
tree | 06b25176db3e0a4675dfa5c94f5d63a310515008 | |
parent | c2e82414884718ad6ec33a7528606cb07cf55cb4 (diff) |
rbd: move bumping img_request refcount into rbd_obj_request_submit()
Commit 0f2d5be792b0 ("rbd: use reference counts for image requests")
added rbd_img_request_get(), which rbd_img_request_fill() calls for
each obj_request added to img_request. It was an urgent band-aid for
the uglyness that is rbd_img_obj_callback() and none of the error paths
were updated.
Given that this img_request reference is meant to represent an
obj_request that hasn't passed through rbd_img_obj_callback() yet,
proper cleanup in appropriate destructors is a challenge. However,
noting that if we don't get a chance to call rbd_obj_request_complete(),
there is not going to be a call to rbd_img_obj_callback(), we can move
rbd_img_request_get() into rbd_obj_request_submit() and fixup the two
places that call rbd_obj_request_complete() directly and not through
rbd_obj_request_submit() to temporarily bump img_request, so that
rbd_img_obj_callback() can put as usual.
This takes care of img_request leaks on errors on the submit side.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
-rw-r--r-- | drivers/block/rbd.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 5e55d1c98471..6db12d9a4291 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -1618,11 +1618,17 @@ static bool obj_request_type_valid(enum obj_request_type type) | |||
1618 | } | 1618 | } |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | static void rbd_img_obj_callback(struct rbd_obj_request *obj_request); | ||
1622 | |||
1621 | static void rbd_obj_request_submit(struct rbd_obj_request *obj_request) | 1623 | static void rbd_obj_request_submit(struct rbd_obj_request *obj_request) |
1622 | { | 1624 | { |
1623 | struct ceph_osd_request *osd_req = obj_request->osd_req; | 1625 | struct ceph_osd_request *osd_req = obj_request->osd_req; |
1624 | 1626 | ||
1625 | dout("%s %p osd_req %p\n", __func__, obj_request, osd_req); | 1627 | dout("%s %p osd_req %p\n", __func__, obj_request, osd_req); |
1628 | if (obj_request_img_data_test(obj_request)) { | ||
1629 | WARN_ON(obj_request->callback != rbd_img_obj_callback); | ||
1630 | rbd_img_request_get(obj_request->img_request); | ||
1631 | } | ||
1626 | ceph_osdc_start_request(osd_req->r_osdc, osd_req, false); | 1632 | ceph_osdc_start_request(osd_req->r_osdc, osd_req, false); |
1627 | } | 1633 | } |
1628 | 1634 | ||
@@ -2588,8 +2594,6 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, | |||
2588 | 2594 | ||
2589 | rbd_img_obj_request_fill(obj_request, osd_req, op_type, 0); | 2595 | rbd_img_obj_request_fill(obj_request, osd_req, op_type, 0); |
2590 | 2596 | ||
2591 | rbd_img_request_get(img_request); | ||
2592 | |||
2593 | img_offset += length; | 2597 | img_offset += length; |
2594 | resid -= length; | 2598 | resid -= length; |
2595 | } | 2599 | } |
@@ -2723,10 +2727,9 @@ rbd_img_obj_parent_read_full_callback(struct rbd_img_request *img_request) | |||
2723 | return; | 2727 | return; |
2724 | 2728 | ||
2725 | out_err: | 2729 | out_err: |
2726 | /* Record the error code and complete the request */ | ||
2727 | |||
2728 | orig_request->result = img_result; | 2730 | orig_request->result = img_result; |
2729 | orig_request->xferred = 0; | 2731 | orig_request->xferred = 0; |
2732 | rbd_img_request_get(orig_request->img_request); | ||
2730 | obj_request_done_set(orig_request); | 2733 | obj_request_done_set(orig_request); |
2731 | rbd_obj_request_complete(orig_request); | 2734 | rbd_obj_request_complete(orig_request); |
2732 | } | 2735 | } |
@@ -2881,6 +2884,7 @@ static void rbd_img_obj_exists_callback(struct rbd_obj_request *obj_request) | |||
2881 | fail_orig_request: | 2884 | fail_orig_request: |
2882 | orig_request->result = result; | 2885 | orig_request->result = result; |
2883 | orig_request->xferred = 0; | 2886 | orig_request->xferred = 0; |
2887 | rbd_img_request_get(orig_request->img_request); | ||
2884 | obj_request_done_set(orig_request); | 2888 | obj_request_done_set(orig_request); |
2885 | rbd_obj_request_complete(orig_request); | 2889 | rbd_obj_request_complete(orig_request); |
2886 | } | 2890 | } |