OSDN Git Service

rbd: rbd_obj_request_wait() should cancel the request if interrupted
authorIlya Dryomov <ilya.dryomov@inktank.com>
Thu, 19 Jun 2014 07:38:14 +0000 (11:38 +0400)
committerIlya Dryomov <ilya.dryomov@inktank.com>
Tue, 8 Jul 2014 11:08:45 +0000 (15:08 +0400)
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>
drivers/block/rbd.c

index b2c98c1..20147ae 100644 (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,
                                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);
 }
 
+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)
 {
 
@@ -1558,15 +1584,6 @@ static void rbd_img_request_complete(struct rbd_img_request *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
  * is conditionally set to 1 at image request initialization time