summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2019-02-28 15:51:39 +0100
committerIlya Dryomov <idryomov@gmail.com>2019-03-05 18:55:17 +0100
commit9b17eb2ce102e3274dafb3776a699969f02f7611 (patch)
treecfc265860bd30c20d66c726af9c3fab32d396c61 /drivers/block
parentrbd: copyup with an empty snapshot context (aka deep-copyup) (diff)
downloadlinux-9b17eb2ce102e3274dafb3776a699969f02f7611.tar.xz
linux-9b17eb2ce102e3274dafb3776a699969f02f7611.zip
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>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 4befd8f6ac9c..ccfbed8741b8 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1445,7 +1445,8 @@ static bool rbd_obj_is_tail(struct rbd_obj_request *obj_req)
static bool rbd_obj_copyup_enabled(struct rbd_obj_request *obj_req)
{
if (!obj_req->num_img_extents ||
- rbd_obj_is_entire(obj_req))
+ (rbd_obj_is_entire(obj_req) &&
+ !obj_req->img_request->snapc->num_snaps))
return false;
return true;
@@ -1955,7 +1956,8 @@ static int count_zeroout_ops(struct rbd_obj_request *obj_req)
{
int num_osd_ops;
- if (rbd_obj_is_entire(obj_req) && obj_req->num_img_extents)
+ if (rbd_obj_is_entire(obj_req) && obj_req->num_img_extents &&
+ !rbd_obj_copyup_enabled(obj_req))
num_osd_ops = 2; /* create + truncate */
else
num_osd_ops = 1; /* delete/truncate/zero */
@@ -1970,8 +1972,9 @@ static void __rbd_obj_setup_zeroout(struct rbd_obj_request *obj_req,
if (rbd_obj_is_entire(obj_req)) {
if (obj_req->num_img_extents) {
- osd_req_op_init(obj_req->osd_req, which++,
- CEPH_OSD_OP_CREATE, 0);
+ if (!rbd_obj_copyup_enabled(obj_req))
+ osd_req_op_init(obj_req->osd_req, which++,
+ CEPH_OSD_OP_CREATE, 0);
opcode = CEPH_OSD_OP_TRUNCATE;
} else {
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)
__rbd_obj_setup_write(obj_req, which);
break;
case OBJ_OP_ZEROOUT:
- rbd_assert(!rbd_obj_is_entire(obj_req));
__rbd_obj_setup_zeroout(obj_req, which);
break;
default: