From: Mykola Golub Date: Mon, 15 Apr 2019 10:35:53 +0000 (+0100) Subject: librbd: optionally move parent image to trash on remove X-Git-Tag: v15.1.0~2871^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F27521%2Fhead;p=ceph.git librbd: optionally move parent image to trash on remove and auto-delete when the last clone is detached Signed-off-by: Mykola Golub --- diff --git a/qa/workunits/rbd/cli_generic.sh b/qa/workunits/rbd/cli_generic.sh index 1a46df10c5103..b4b8f4774c850 100755 --- a/qa/workunits/rbd/cli_generic.sh +++ b/qa/workunits/rbd/cli_generic.sh @@ -576,6 +576,21 @@ test_clone_v2() { rbd snap list --all test1 | wc -l | grep '^0$' rbd rm test1 rbd rm test2 + + rbd create $RBD_CREATE_ARGS -s 1 test1 + rbd snap create test1@1 + rbd snap create test1@2 + rbd clone test1@1 test2 --rbd-default-clone-format 2 + rbd clone test1@2 test3 --rbd-default-clone-format 2 + rbd snap rm test1@1 + rbd snap rm test1@2 + expect_fail rbd rm test1 + rbd rm test1 --rbd-move-parent-to-trash-on-remove=true + rbd trash ls -a | grep test1 + rbd rm test2 + rbd trash ls -a | grep test1 + rbd rm test3 + rbd trash ls -a | expect_fail grep test1 } test_thick_provision() { diff --git a/src/cls/rbd/cls_rbd_types.h b/src/cls/rbd/cls_rbd_types.h index bbfc85870b21b..74dfe1d99de20 100644 --- a/src/cls/rbd/cls_rbd_types.h +++ b/src/cls/rbd/cls_rbd_types.h @@ -560,6 +560,7 @@ enum TrashImageSource { TRASH_IMAGE_SOURCE_MIRRORING = 1, TRASH_IMAGE_SOURCE_MIGRATION = 2, TRASH_IMAGE_SOURCE_REMOVING = 3, + TRASH_IMAGE_SOURCE_USER_PARENT= 4, }; inline std::ostream& operator<<(std::ostream& os, diff --git a/src/common/options.cc b/src/common/options.cc index f7db2a72aaa05..34cf35ca5356d 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -7153,6 +7153,10 @@ static std::vector