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>
This commit is contained in:
Ilya Dryomov 2016-09-26 15:43:52 +02:00
parent 04dc923c9e
commit 0dcc685e7d
1 changed files with 18 additions and 10 deletions

View File

@ -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)