On 2014年09月18日 14:54, Hitoshi Mitake wrote:
The commit a21bf27906b23448b92cca9943e1019105ffac2f makes
$ dog vdi snapshot <vdi>
fail if the <vdi> is an ordinal vdi because newly created VDIs have
snapid 0. This patch avoids the failure with checking the VDI is
snapshot or not.

Cc: Ruoyu <[email protected]>
Signed-off-by: Hitoshi Mitake <[email protected]>
Thanks Hitoshi.
The original purpose is to forbid duplicated snapshot tag.
But I found it is not implemented after applying your patch.

$ dog/dog vdi snapshot test
liangry@linuxmint ~/github/sheepdog.orig $ dog/dog vdi list
Name Id Size Used Shared Creation time VDI id Copies Tag
s test 2 4.0 MB 0.0 MB 4.0 MB 2014-09-10 14:46 7c2b26 3
s test 3 4.0 MB 0.0 MB 4.0 MB 2014-09-10 15:30 7c2b27 3
s test 4 4.0 MB 0.0 MB 4.0 MB 2014-09-18 18:41 7c2b28 3
s test 5 4.0 MB 0.0 MB 4.0 MB 2014-09-18 18:41 7c2b29 3
test 0 4.0 MB 0.0 MB 4.0 MB 2014-09-18 18:43 7c2b2a 3

---
  dog/vdi.c | 14 ++++++++++----
  1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/dog/vdi.c b/dog/vdi.c
index fa6130e..0a8a2e9 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -567,6 +567,7 @@ static int vdi_snapshot(int argc, char **argv)
        int vs_count = 0;
        struct node_id owners[SD_MAX_COPIES];
        int nr_owners = 0, nr_issued_prevent_inode_update = 0;
+       bool fail_if_snapshot = false;
if (vdi_cmd_data.snapshot_id != 0) {
                sd_err("Please specify a non-integer value for "
@@ -584,6 +585,15 @@ static int vdi_snapshot(int argc, char **argv)
        case SD_RES_NO_TAG:
                break;
        default:
+               fail_if_snapshot = true;
+               break;
+       }
+
+       ret = read_vdi_obj(vdiname, 0, "", &vid, inode, SD_INODE_HEADER_SIZE);
+       if (ret != EXIT_SUCCESS)
+               return ret;
+
+       if (fail_if_snapshot && vdi_is_snapshot(inode)) {
                sd_err("Failed to create snapshot for %s, maybe "
                        "snapshot id (%d) or tag (%s) is existed",
                        vdiname, vdi_cmd_data.snapshot_id,
@@ -591,10 +601,6 @@ static int vdi_snapshot(int argc, char **argv)
                return EXIT_FAILURE;
        }
- ret = read_vdi_obj(vdiname, 0, "", &vid, inode, SD_INODE_HEADER_SIZE);
-       if (ret != EXIT_SUCCESS)
-               return ret;
-
        if (inode->store_policy) {
                sd_err("creating a snapshot of hypervolume is not supported");
                return EXIT_FAILURE;


--
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to