From 8d59a2dc8ccb48a2e010f5bd1169209fe5dafe83 Mon Sep 17 00:00:00 2001 From: songweibin Date: Sun, 11 Feb 2018 15:12:23 +0800 Subject: [PATCH] librbd: validate if dst group snap name is equal to src Signed-off-by: songweibin --- src/librbd/api/Group.cc | 2 ++ src/librbd/api/Group.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librbd/api/Group.cc b/src/librbd/api/Group.cc index 4f4756205152..99fea4a568da 100644 --- a/src/librbd/api/Group.cc +++ b/src/librbd/api/Group.cc @@ -938,6 +938,8 @@ int Group::snap_rename(librados::IoCtx& group_ioctx, const char *group_name, const char *old_snap_name, const char *new_snap_name) { CephContext *cct = (CephContext *)group_ioctx.cct(); + if (0 == strcmp(old_snap_name, new_snap_name)) + return -EEXIST; std::string group_id; int r = cls_client::dir_get_id(&group_ioctx, RBD_GROUP_DIRECTORY, diff --git a/src/librbd/api/Group.h b/src/librbd/api/Group.h index 7f7e973c90f5..37cb82f7f72b 100644 --- a/src/librbd/api/Group.h +++ b/src/librbd/api/Group.h @@ -19,7 +19,7 @@ namespace api { template struct Group { - static int create(librados::IoCtx& io_ctx, const char *imgname); + static int create(librados::IoCtx& io_ctx, const char *group_name); static int remove(librados::IoCtx& io_ctx, const char *group_name); static int list(librados::IoCtx& io_ctx, std::vector *names); -- 2.47.3