]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
rbd: encapsulate image object end request handling
authorAlex Elder <elder@inktank.com>
Fri, 8 Feb 2013 15:55:49 +0000 (09:55 -0600)
committerSage Weil <sage@inktank.com>
Thu, 2 May 2013 04:18:43 +0000 (21:18 -0700)
Encapsulate the code that completes processing of an object request
that's part of an image request.

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
drivers/block/rbd.c

index a77157d8791558b2293db6c19a4844639e95e1e2..2d2711537537033185d7d9cad8ec08f27f611a88 100644 (file)
@@ -1603,6 +1603,34 @@ static void rbd_img_request_destroy(struct kref *kref)
        kfree(img_request);
 }
 
+static bool rbd_img_obj_end_request(struct rbd_obj_request *obj_request)
+{
+       struct rbd_img_request *img_request = obj_request->img_request;
+       unsigned int xferred;
+       int result;
+
+       rbd_assert(!img_request_child_test(img_request));
+       rbd_assert(img_request->rq != NULL);
+
+       rbd_assert(obj_request->xferred <= (u64)UINT_MAX);
+       xferred = (unsigned int)obj_request->xferred;
+       result = obj_request->result;
+       if (result) {
+               struct rbd_device *rbd_dev = img_request->rbd_dev;
+
+               rbd_warn(rbd_dev, "%s %llx at %llx (%llx)\n",
+                       img_request_write_test(img_request) ? "write" : "read",
+                       obj_request->length, obj_request->img_offset,
+                       obj_request->offset);
+               rbd_warn(rbd_dev, "  result %d xferred %x\n",
+                       result, xferred);
+               if (!img_request->result)
+                       img_request->result = result;
+       }
+
+       return blk_end_request(img_request->rq, result, xferred);
+}
+
 static void rbd_img_obj_callback(struct rbd_obj_request *obj_request)
 {
        struct rbd_img_request *img_request;
@@ -1613,9 +1641,6 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request)
 
        dout("%s: img %p obj %p\n", __func__, img_request, obj_request);
        rbd_assert(img_request != NULL);
-       rbd_assert(!img_request_child_test(img_request))
-       rbd_assert(img_request->rq != NULL);
-
        rbd_assert(img_request->obj_request_count > 0);
        rbd_assert(which != BAD_WHICH);
        rbd_assert(which < img_request->obj_request_count);
@@ -1626,33 +1651,12 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request)
                goto out;
 
        for_each_obj_request_from(img_request, obj_request) {
-               unsigned int xferred;
-               int result;
-
                rbd_assert(more);
                rbd_assert(which < img_request->obj_request_count);
 
                if (!obj_request_done_test(obj_request))
                        break;
-
-               rbd_assert(obj_request->xferred <= (u64)UINT_MAX);
-               xferred = (unsigned int)obj_request->xferred;
-               result = obj_request->result;
-               if (result) {
-                       struct rbd_device *rbd_dev = img_request->rbd_dev;
-
-                       rbd_warn(rbd_dev, "%s %llx at %llx (%llx)\n",
-                               img_request_write_test(img_request) ? "write"
-                                                                   : "read",
-                               obj_request->length, obj_request->img_offset,
-                               obj_request->offset);
-                       rbd_warn(rbd_dev, "  result %d xferred %x\n",
-                               result, xferred);
-                       if (!img_request->result)
-                               img_request->result = result;
-               }
-
-               more = blk_end_request(img_request->rq, result, xferred);
+               more = rbd_img_obj_end_request(obj_request);
                which++;
        }