]> git.karo-electronics.de Git - linux-beck.git/commitdiff
rbd: fix buffer size for writes to images with snapshots
authorJosh Durgin <josh.durgin@inktank.com>
Tue, 27 Aug 2013 21:45:46 +0000 (14:45 -0700)
committerSage Weil <sage@inktank.com>
Wed, 4 Sep 2013 05:08:46 +0000 (22:08 -0700)
rbd_osd_req_create() needs to know the snapshot context size to create
a buffer large enough to send it with the message front. It gets this
from the img_request, which was not set for the obj_request yet. This
resulted in trying to write past the end of the front payload, hitting
this BUG:

libceph: BUG_ON(p > msg->front.iov_base + msg->front.iov_len);

Fix this by associating the obj_request with its img_request
immediately after it's created, before the osd request is created.

Fixes: http://tracker.ceph.com/issues/5760
Suggested-by: Alex Elder <alex.elder@linaro.org>
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Reviewed-by: Alex Elder <alex.elder@linaro.org>
drivers/block/rbd.c

index f8fd7d3c13ba52bc414660f4d063f57b04472f19..80f787b6226ecb449212bfb1d5b06ef6013a2057 100644 (file)
@@ -2203,6 +2203,11 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
                rbd_segment_name_free(object_name);
                if (!obj_request)
                        goto out_unwind;
+               /*
+                * set obj_request->img_request before creating the
+                * osd_request so that it gets the right snapc
+                */
+               rbd_img_obj_request_add(img_request, obj_request);
 
                if (type == OBJ_REQUEST_BIO) {
                        unsigned int clone_size;
@@ -2244,11 +2249,6 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
                                        obj_request->pages, length,
                                        offset & ~PAGE_MASK, false, false);
 
-               /*
-                * set obj_request->img_request before formatting
-                * the osd_request so that it gets the right snapc
-                */
-               rbd_img_obj_request_add(img_request, obj_request);
                if (write_request)
                        rbd_osd_req_format_write(obj_request);
                else