rbd: rbd_obj_request_wait() should cancel the request if interrupted

rbd_obj_request_wait() should cancel the underlying OSD request if
interrupted.  Otherwise libceph will hold onto it indefinitely, causing
assert failures or leaking the original object request.

This also adds an rbd wrapper around ceph_osdc_cancel_request() to
match rbd_obj_request_submit() and rbd_obj_request_wait().

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Alex Elder <elder@linaro.org>
This commit is contained in:
Ilya Dryomov 2014-06-19 11:38:14 +04:00
parent c9f9b93ddf
commit 71c20a066f

View File

@ -1527,11 +1527,37 @@ static bool obj_request_type_valid(enum obj_request_type type)
static int rbd_obj_request_submit(struct ceph_osd_client *osdc, static int rbd_obj_request_submit(struct ceph_osd_client *osdc,
struct rbd_obj_request *obj_request) struct rbd_obj_request *obj_request)
{ {
dout("%s: osdc %p obj %p\n", __func__, osdc, obj_request); dout("%s %p\n", __func__, obj_request);
return ceph_osdc_start_request(osdc, obj_request->osd_req, false); return ceph_osdc_start_request(osdc, obj_request->osd_req, false);
} }
static void rbd_obj_request_end(struct rbd_obj_request *obj_request)
{
dout("%s %p\n", __func__, obj_request);
ceph_osdc_cancel_request(obj_request->osd_req);
}
/*
* Wait for an object request to complete. If interrupted, cancel the
* underlying osd request.
*/
static int rbd_obj_request_wait(struct rbd_obj_request *obj_request)
{
int ret;
dout("%s %p\n", __func__, obj_request);
ret = wait_for_completion_interruptible(&obj_request->completion);
if (ret < 0) {
dout("%s %p interrupted\n", __func__, obj_request);
rbd_obj_request_end(obj_request);
return ret;
}
dout("%s %p done\n", __func__, obj_request);
return 0;
}
static void rbd_img_request_complete(struct rbd_img_request *img_request) static void rbd_img_request_complete(struct rbd_img_request *img_request)
{ {
@ -1558,15 +1584,6 @@ static void rbd_img_request_complete(struct rbd_img_request *img_request)
rbd_img_request_put(img_request); rbd_img_request_put(img_request);
} }
/* Caller is responsible for rbd_obj_request_destroy(obj_request) */
static int rbd_obj_request_wait(struct rbd_obj_request *obj_request)
{
dout("%s: obj %p\n", __func__, obj_request);
return wait_for_completion_interruptible(&obj_request->completion);
}
/* /*
* The default/initial value for all image request flags is 0. Each * The default/initial value for all image request flags is 0. Each
* is conditionally set to 1 at image request initialization time * is conditionally set to 1 at image request initialization time