diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2016-09-26 15:43:52 +0200 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2016-10-03 16:13:49 +0200 |
commit | 0dcc685e7dd7190dcaa5435e9c14150f1d405b7b (patch) | |
tree | 42a0cb0231eecec7b9fedd5808a6a336695325db /drivers/block/rbd.c | |
parent | 04dc923c9e4c43df7d2d94f290189785d3172326 (diff) |
rbd: add rbd_obj_request_error() helper
Pull setting an error and marking a request done code into a new
helper. obj_request_img_data_test() check isn't strictly needed right
now, but makes it applicable to !img_data requests and a bit safer.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r-- | drivers/block/rbd.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index e46f4f05fb01..c842b8911936 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1819,6 +1819,22 @@ static void rbd_obj_request_complete(struct rbd_obj_request *obj_request) complete_all(&obj_request->completion); } +static void rbd_obj_request_error(struct rbd_obj_request *obj_request, int err) +{ + obj_request->result = err; + obj_request->xferred = 0; + /* + * kludge - mirror rbd_obj_request_submit() to match a put in + * rbd_img_obj_callback() + */ + if (obj_request_img_data_test(obj_request)) { + WARN_ON(obj_request->callback != rbd_img_obj_callback); + rbd_img_request_get(obj_request->img_request); + } + obj_request_done_set(obj_request); + rbd_obj_request_complete(obj_request); +} + static void rbd_osd_read_callback(struct rbd_obj_request *obj_request) { struct rbd_img_request *img_request = NULL; @@ -2722,11 +2738,7 @@ rbd_img_obj_parent_read_full_callback(struct rbd_img_request *img_request) out_err: ceph_release_page_vector(pages, page_count); - orig_request->result = img_result; - orig_request->xferred = 0; - rbd_img_request_get(orig_request->img_request); - obj_request_done_set(orig_request); - rbd_obj_request_complete(orig_request); + rbd_obj_request_error(orig_request, img_result); } /* @@ -2877,11 +2889,7 @@ static void rbd_img_obj_exists_callback(struct rbd_obj_request *obj_request) return; fail_orig_request: - orig_request->result = result; - orig_request->xferred = 0; - rbd_img_request_get(orig_request->img_request); - obj_request_done_set(orig_request); - rbd_obj_request_complete(orig_request); + rbd_obj_request_error(orig_request, result); } static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request) |