Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2d1f17

Browse files
jdurginSage Weil
authored andcommitted
rbd: send snapshot context with writes
Sending the right snapshot context with each write is required for snapshots to work. Due to the ordering of calls, the snapshot context is never set for any requests. This causes writes to the current version of the image to be reflected in all snapshots, which are supposed to be read-only. This happens because rbd_osd_req_format_write() sets the snapshot context based on obj_request->img_request. At this point, however, obj_request->img_request has not been set yet, to the snapshot context is set to NULL. Fix this by moving rbd_img_obj_request_add(), which sets obj_request->img_request, before the osd request formatting calls. This resolves: http://tracker.ceph.com/issues/5465 Reported-by: Karol Jurak <[email protected]> Signed-off-by: Josh Durgin <[email protected]> Reviewed-by: Sage Weil <[email protected]> Reviewed-by: Alex Elder <[email protected]>
1 parent 1617e40 commit d2d1f17

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/block/rbd.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2254,13 +2254,17 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
22542254
obj_request->pages, length,
22552255
offset & ~PAGE_MASK, false, false);
22562256

2257+
/*
2258+
* set obj_request->img_request before formatting
2259+
* the osd_request so that it gets the right snapc
2260+
*/
2261+
rbd_img_obj_request_add(img_request, obj_request);
22572262
if (write_request)
22582263
rbd_osd_req_format_write(obj_request);
22592264
else
22602265
rbd_osd_req_format_read(obj_request);
22612266

22622267
obj_request->img_offset = img_offset;
2263-
rbd_img_obj_request_add(img_request, obj_request);
22642268

22652269
img_offset += length;
22662270
resid -= length;

0 commit comments

Comments
 (0)