Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0dcc685e authored by Ilya Dryomov's avatar Ilya Dryomov
Browse files

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: default avatarIlya Dryomov <idryomov@gmail.com>
parent 04dc923c
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -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)