diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2018-02-06 13:26:34 -0500 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2018-04-02 04:12:43 -0400 |
commit | 2bb1e56ec6450ce533c644c5bfa548dc34c551a0 (patch) | |
tree | 10b591e350fc80d19b5a46c3798f3be5fa3acbc8 /drivers/block/rbd.c | |
parent | 86bd7998fa2c1b18fda74cfa4674cfb49ae701c7 (diff) |
rbd: create+truncate for whole-object layered discards
A whole-object layered discard is implemented as a truncate rather
than a delete: a dummy object is needed to prevent the CoW machinery
from kicking in. However, a truncate on a non-existent object is
a no-op. If the object doesn't exist in HEAD, a discard request is
effectively ignored, which violates our "discard zeroes data" promise
and breaks REQ_OP_WRITE_ZEROES implementation.
A non-exclusive create on an existing object is also a no-op, so the
fix is to do a compound create+truncate instead.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r-- | drivers/block/rbd.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 0aa95e08664d..fc94e2c45e28 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -1884,6 +1884,8 @@ static void __rbd_obj_setup_discard(struct rbd_obj_request *obj_req, | |||
1884 | 1884 | ||
1885 | if (rbd_obj_is_entire(obj_req)) { | 1885 | if (rbd_obj_is_entire(obj_req)) { |
1886 | if (obj_req->num_img_extents) { | 1886 | if (obj_req->num_img_extents) { |
1887 | osd_req_op_init(obj_req->osd_req, which++, | ||
1888 | CEPH_OSD_OP_CREATE, 0); | ||
1887 | opcode = CEPH_OSD_OP_TRUNCATE; | 1889 | opcode = CEPH_OSD_OP_TRUNCATE; |
1888 | } else { | 1890 | } else { |
1889 | osd_req_op_init(obj_req->osd_req, which++, | 1891 | osd_req_op_init(obj_req->osd_req, which++, |
@@ -1917,7 +1919,10 @@ static int rbd_obj_setup_discard(struct rbd_obj_request *obj_req) | |||
1917 | 1919 | ||
1918 | if (rbd_obj_is_entire(obj_req)) { | 1920 | if (rbd_obj_is_entire(obj_req)) { |
1919 | obj_req->write_state = RBD_OBJ_WRITE_FLAT; | 1921 | obj_req->write_state = RBD_OBJ_WRITE_FLAT; |
1920 | num_osd_ops = 1; /* truncate/delete */ | 1922 | if (obj_req->num_img_extents) |
1923 | num_osd_ops = 2; /* create + truncate */ | ||
1924 | else | ||
1925 | num_osd_ops = 1; /* delete */ | ||
1921 | } else { | 1926 | } else { |
1922 | if (obj_req->num_img_extents) { | 1927 | if (obj_req->num_img_extents) { |
1923 | obj_req->write_state = RBD_OBJ_WRITE_GUARD; | 1928 | obj_req->write_state = RBD_OBJ_WRITE_GUARD; |