Skip to content

Commit 9b17eb2

Browse files
committed
rbd: whole-object write and zeroout should copyup when snapshots exist
Otherwise, once the parent snapshot is removed, the clone's snapshot wouldn't reflect the state of the clone prior to whole-object write or zeroout because a deep-copyup was never done ("rbd flatten" wouldn't do it because the modified object would exist in HEAD). Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 89a59c1 commit 9b17eb2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/block/rbd.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,8 @@ static bool rbd_obj_is_tail(struct rbd_obj_request *obj_req)
14451445
static bool rbd_obj_copyup_enabled(struct rbd_obj_request *obj_req)
14461446
{
14471447
if (!obj_req->num_img_extents ||
1448-
rbd_obj_is_entire(obj_req))
1448+
(rbd_obj_is_entire(obj_req) &&
1449+
!obj_req->img_request->snapc->num_snaps))
14491450
return false;
14501451

14511452
return true;
@@ -1955,7 +1956,8 @@ static int count_zeroout_ops(struct rbd_obj_request *obj_req)
19551956
{
19561957
int num_osd_ops;
19571958

1958-
if (rbd_obj_is_entire(obj_req) && obj_req->num_img_extents)
1959+
if (rbd_obj_is_entire(obj_req) && obj_req->num_img_extents &&
1960+
!rbd_obj_copyup_enabled(obj_req))
19591961
num_osd_ops = 2; /* create + truncate */
19601962
else
19611963
num_osd_ops = 1; /* delete/truncate/zero */
@@ -1970,8 +1972,9 @@ static void __rbd_obj_setup_zeroout(struct rbd_obj_request *obj_req,
19701972

19711973
if (rbd_obj_is_entire(obj_req)) {
19721974
if (obj_req->num_img_extents) {
1973-
osd_req_op_init(obj_req->osd_req, which++,
1974-
CEPH_OSD_OP_CREATE, 0);
1975+
if (!rbd_obj_copyup_enabled(obj_req))
1976+
osd_req_op_init(obj_req->osd_req, which++,
1977+
CEPH_OSD_OP_CREATE, 0);
19751978
opcode = CEPH_OSD_OP_TRUNCATE;
19761979
} else {
19771980
osd_req_op_init(obj_req->osd_req, which++,
@@ -2551,7 +2554,6 @@ static int rbd_obj_issue_copyup_ops(struct rbd_obj_request *obj_req, u32 bytes)
25512554
__rbd_obj_setup_write(obj_req, which);
25522555
break;
25532556
case OBJ_OP_ZEROOUT:
2554-
rbd_assert(!rbd_obj_is_entire(obj_req));
25552557
__rbd_obj_setup_zeroout(obj_req, which);
25562558
break;
25572559
default:

0 commit comments

Comments
 (0)