Skip to content

Commit 03507db

Browse files
jdurginSage Weil
authored and
Sage Weil
committed
rbd: fix buffer size for writes to images with snapshots
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 <[email protected]> Signed-off-by: Josh Durgin <[email protected]> Reviewed-by: Alex Elder <[email protected]>
1 parent 9542cf0 commit 03507db

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/block/rbd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,6 +2203,11 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
22032203
rbd_segment_name_free(object_name);
22042204
if (!obj_request)
22052205
goto out_unwind;
2206+
/*
2207+
* set obj_request->img_request before creating the
2208+
* osd_request so that it gets the right snapc
2209+
*/
2210+
rbd_img_obj_request_add(img_request, obj_request);
22062211

22072212
if (type == OBJ_REQUEST_BIO) {
22082213
unsigned int clone_size;
@@ -2244,11 +2249,6 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
22442249
obj_request->pages, length,
22452250
offset & ~PAGE_MASK, false, false);
22462251

2247-
/*
2248-
* set obj_request->img_request before formatting
2249-
* the osd_request so that it gets the right snapc
2250-
*/
2251-
rbd_img_obj_request_add(img_request, obj_request);
22522252
if (write_request)
22532253
rbd_osd_req_format_write(obj_request);
22542254
else

0 commit comments

Comments
 (0)