]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: added '(rbd_)snap_set_by_id' API methods
authorJason Dillaman <dillaman@redhat.com>
Tue, 20 Mar 2018 03:53:22 +0000 (11:53 +0800)
committerJason Dillaman <dillaman@redhat.com>
Tue, 20 Mar 2018 04:33:03 +0000 (12:33 +0800)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
17 files changed:
src/include/rbd/librbd.h
src/include/rbd/librbd.hpp
src/librbd/api/Image.cc
src/librbd/api/Image.h
src/librbd/internal.cc
src/librbd/internal.h
src/librbd/librbd.cc
src/test/librbd/deep_copy/test_mock_ObjectCopyRequest.cc
src/test/librbd/image/test_mock_RefreshRequest.cc
src/test/librbd/object_map/test_mock_InvalidateRequest.cc
src/test/librbd/object_map/test_mock_ResizeRequest.cc
src/test/librbd/object_map/test_mock_UpdateRequest.cc
src/test/librbd/test_DeepCopy.cc
src/test/librbd/test_internal.cc
src/test/librbd/test_librbd.cc
src/test/librbd/test_mock_DeepCopyRequest.cc
src/test/rbd_mirror/test_ImageDeleter.cc

index bfa065aa7dbf5f38e9b9c0811cb57efb3d841c23..d9d5f1dc678ab79f1f8e64e06cca07fcaa7ff72c 100644 (file)
@@ -543,6 +543,7 @@ CEPH_RBD_API int rbd_snap_set_limit(rbd_image_t image, uint64_t limit);
 CEPH_RBD_API int rbd_snap_get_timestamp(rbd_image_t image, uint64_t snap_id, struct timespec *timestamp);
 
 CEPH_RBD_API int rbd_snap_set(rbd_image_t image, const char *snapname);
+CEPH_RBD_API int rbd_snap_set_by_id(rbd_image_t image, uint64_t snap_id);
 
 CEPH_RBD_API int rbd_snap_get_namespace_type(rbd_image_t image,
                                             uint64_t snap_id,
index 1c0a3fe3f83a523b4f6ccb47546cb66a5f8a6227..28aa7a03018394a44ac7b732dabde83b81aa049d 100644 (file)
@@ -380,6 +380,7 @@ public:
   int snap_unprotect(const char *snap_name);
   int snap_is_protected(const char *snap_name, bool *is_protected);
   int snap_set(const char *snap_name);
+  int snap_set_by_id(uint64_t snap_id);
   int snap_rename(const char *srcname, const char *dstname);
   int snap_get_limit(uint64_t *limit);
   int snap_set_limit(uint64_t limit);
index 4213383ac42cae63814c4899cf5f1424d586fa35..0d3c8a46ff4d5054ba01c2cdad5d259900f40a0f 100644 (file)
@@ -334,6 +334,54 @@ int Image<I>::deep_copy(I *src, I *dest, ProgressContext &prog_ctx) {
   return 0;
 }
 
+template <typename I>
+int Image<I>::snap_set(I *ictx,
+                       const cls::rbd::SnapshotNamespace &snap_namespace,
+                       const char *snap_name) {
+  ldout(ictx->cct, 20) << "snap_set " << ictx << " snap = "
+                       << (snap_name ? snap_name : "NULL") << dendl;
+
+  // ignore return value, since we may be set to a non-existent
+  // snapshot and the user is trying to fix that
+  ictx->state->refresh_if_required();
+
+  uint64_t snap_id = CEPH_NOSNAP;
+  std::string name(snap_name == nullptr ? "" : snap_name);
+  if (!name.empty()) {
+    RWLock::RLocker snap_locker(ictx->snap_lock);
+    snap_id = ictx->get_snap_id(cls::rbd::UserSnapshotNamespace{},
+                                snap_name);
+    if (snap_id == CEPH_NOSNAP) {
+      return -ENOENT;
+    }
+  }
+
+  return snap_set(ictx, snap_id);
+}
+
+template <typename I>
+int Image<I>::snap_set(I *ictx, uint64_t snap_id) {
+  ldout(ictx->cct, 20) << "snap_set " << ictx << " "
+                       << "snap_id=" << snap_id << dendl;
+
+  // ignore return value, since we may be set to a non-existent
+  // snapshot and the user is trying to fix that
+  ictx->state->refresh_if_required();
+
+  C_SaferCond ctx;
+  ictx->state->snap_set(snap_id, &ctx);
+  int r = ctx.wait();
+  if (r < 0) {
+    if (r != -ENOENT) {
+      lderr(ictx->cct) << "failed to " << (snap_id == CEPH_NOSNAP ? "un" : "")
+                       << "set snapshot: " << cpp_strerror(r) << dendl;
+    }
+    return r;
+  }
+
+  return 0;
+}
+
 } // namespace api
 } // namespace librbd
 
index 1339994a67d1578f000e8000cafe4481bac5774d..cefab1aaea536b04a79adc2955925c30a3d353de 100644 (file)
@@ -40,6 +40,12 @@ struct Image {
                        ProgressContext &prog_ctx);
   static int deep_copy(ImageCtxT *src, ImageCtxT *dest,
                        ProgressContext &prog_ctx);
+
+  static int snap_set(ImageCtxT *ictx,
+                      const cls::rbd::SnapshotNamespace &snap_namespace,
+                     const char *snap_name);
+  static int snap_set(ImageCtxT *ictx, uint64_t snap_id);
+
 };
 
 } // namespace api
index 63af8e74e81dfa2dcb277f1aa737943953d15714..ad6f5ee0afb93aa98585d77eed77d7e3c82587ee 100644 (file)
@@ -1967,42 +1967,6 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2)
     return r;
   }
 
-  int snap_set(ImageCtx *ictx,
-               const cls::rbd::SnapshotNamespace &snap_namespace,
-              const char *snap_name)
-  {
-    ldout(ictx->cct, 20) << "snap_set " << ictx << " snap = "
-                        << (snap_name ? snap_name : "NULL") << dendl;
-
-    // ignore return value, since we may be set to a non-existent
-    // snapshot and the user is trying to fix that
-    ictx->state->refresh_if_required();
-
-    uint64_t snap_id = CEPH_NOSNAP;
-    std::string name(snap_name == nullptr ? "" : snap_name);
-    if (!name.empty()) {
-      RWLock::RLocker snap_locker(ictx->snap_lock);
-      snap_id = ictx->get_snap_id(cls::rbd::UserSnapshotNamespace{},
-                                  snap_name);
-      if (snap_id == CEPH_NOSNAP) {
-        return -ENOENT;
-      }
-    }
-
-    C_SaferCond ctx;
-    ictx->state->snap_set(snap_id, &ctx);
-    int r = ctx.wait();
-    if (r < 0) {
-      if (r != -ENOENT) {
-        lderr(ictx->cct) << "failed to " << (name.empty() ? "un" : "") << "set "
-                         << "snapshot: " << cpp_strerror(r) << dendl;
-      }
-      return r;
-    }
-
-    return 0;
-  }
-
   int list_lockers(ImageCtx *ictx,
                   std::list<locker_t> *lockers,
                   bool *exclusive,
index fb1fb77b042e5f9c00c571add8ea0584448b01e4..3271d902cb0e9543efa09e2ef0d2670367024108 100644 (file)
@@ -60,9 +60,6 @@ namespace librbd {
   void image_options_clear(rbd_image_options_t opts);
   bool image_options_is_empty(rbd_image_options_t opts);
 
-  int snap_set(ImageCtx *ictx, const cls::rbd::SnapshotNamespace &snap_namespace,
-              const char *snap_name);
-
   int list(librados::IoCtx& io_ctx, std::vector<std::string>& names);
   int list_children(ImageCtx *ictx,
                     std::vector<child_info_t> *names);
index 6734a52a500bea7cef03865de19be4c1c12304f1..61ed667a5eb6fd065670ef107eaf59ae18c208f9 100644 (file)
@@ -1662,11 +1662,18 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, snap_set_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-    int r = librbd::snap_set(ictx, cls::rbd::UserSnapshotNamespace(), snap_name);
+    int r = librbd::api::Image<>::snap_set(
+      ictx, cls::rbd::UserSnapshotNamespace(), snap_name);
     tracepoint(librbd, snap_set_exit, r);
     return r;
   }
 
+  int Image::snap_set_by_id(uint64_t snap_id)
+  {
+    ImageCtx *ictx = (ImageCtx *)ctx;
+    return librbd::api::Image<>::snap_set(ictx, snap_id);
+  }
+
   ssize_t Image::read(uint64_t ofs, size_t len, bufferlist& bl)
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
@@ -3558,11 +3565,18 @@ extern "C" int rbd_snap_set(rbd_image_t image, const char *snap_name)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, snap_set_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-  int r = librbd::snap_set(ictx, cls::rbd::UserSnapshotNamespace(), snap_name);
+  int r = librbd::api::Image<>::snap_set(
+    ictx, cls::rbd::UserSnapshotNamespace(), snap_name);
   tracepoint(librbd, snap_set_exit, r);
   return r;
 }
 
+extern "C" int rbd_snap_set_by_id(rbd_image_t image, uint64_t snap_id)
+{
+  librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
+  return librbd::api::Image<>::snap_set(ictx, snap_id);
+}
+
 extern "C" ssize_t rbd_list_children(rbd_image_t image, char *pools,
                                     size_t *pools_len, char *images,
                                     size_t *images_len)
index 3daf3ba581d219382de7a596206b103859e18e60..448e5dda89c4a8729732fe0ea31216ed2c2970cf 100644 (file)
@@ -9,6 +9,7 @@
 #include "librbd/ImageState.h"
 #include "librbd/internal.h"
 #include "librbd/Operations.h"
+#include "librbd/api/Image.h"
 #include "librbd/deep_copy/ObjectCopyRequest.h"
 #include "librbd/io/ImageRequestWQ.h"
 #include "librbd/io/ReadResult.h"
@@ -350,16 +351,16 @@ public:
       std::cout << "comparing '" << snap_name << " (" << src_snap_id
                 << " to " << dst_snap_id << ")" << std::endl;
 
-      r = librbd::snap_set(m_src_image_ctx,
-                          cls::rbd::UserSnapshotNamespace(),
-                          snap_name.c_str());
+      r = librbd::api::Image<>::snap_set(m_src_image_ctx,
+                                        cls::rbd::UserSnapshotNamespace(),
+                                        snap_name.c_str());
       if (r < 0) {
         return r;
       }
 
-      r = librbd::snap_set(m_dst_image_ctx,
-                          cls::rbd::UserSnapshotNamespace(),
-                          snap_name.c_str());
+      r = librbd::api::Image<>::snap_set(m_dst_image_ctx,
+                                        cls::rbd::UserSnapshotNamespace(),
+                                        snap_name.c_str());
       if (r < 0) {
         return r;
       }
@@ -385,15 +386,15 @@ public:
       }
     }
 
-    r = librbd::snap_set(m_src_image_ctx,
-                        cls::rbd::UserSnapshotNamespace(),
-                        nullptr);
+    r = librbd::api::Image<>::snap_set(m_src_image_ctx,
+                                      cls::rbd::UserSnapshotNamespace(),
+                                      nullptr);
     if (r < 0) {
       return r;
     }
-    r = librbd::snap_set(m_dst_image_ctx,
-                        cls::rbd::UserSnapshotNamespace(),
-                        nullptr);
+    r = librbd::api::Image<>::snap_set(m_dst_image_ctx,
+                                      cls::rbd::UserSnapshotNamespace(),
+                                      nullptr);
     if (r < 0) {
       return r;
     }
index 0961c954fb229e66fd93ef735d05256f6f473797..ae8736a9dfb0882e53b05fe25af918a317d1e3ef 100644 (file)
@@ -13,6 +13,7 @@
 #include "librbd/ImageState.h"
 #include "librbd/internal.h"
 #include "librbd/Operations.h"
+#include "librbd/api/Image.h"
 #include "librbd/image/RefreshRequest.h"
 #include "librbd/image/RefreshParentRequest.h"
 #include "librbd/io/ImageDispatchSpec.h"
@@ -578,7 +579,9 @@ TEST_F(TestMockImageRefreshRequest, SuccessSetSnapshotV2) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
   ASSERT_EQ(0, snap_create(*ictx, "snap"));
-  ASSERT_EQ(0, librbd::snap_set(ictx, cls::rbd::UserSnapshotNamespace(), "snap"));
+  ASSERT_EQ(0, librbd::api::Image<>::snap_set(ictx,
+                                              cls::rbd::UserSnapshotNamespace(),
+                                              "snap"));
 
   MockRefreshImageCtx mock_image_ctx(*ictx);
   MockRefreshParentRequest mock_refresh_parent_request;
index e43129f192509a2577817b8da444415687853ad4..038725b748d6f044424b6927922ea4a939495361 100644 (file)
@@ -5,6 +5,7 @@
 #include "test/librbd/test_support.h"
 #include "test/librados_test_stub/MockTestMemIoCtxImpl.h"
 #include "librbd/internal.h"
+#include "librbd/api/Image.h"
 #include "librbd/object_map/InvalidateRequest.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -79,9 +80,9 @@ TEST_F(TestMockObjectMapInvalidateRequest, UpdatesSnapOnDiskFlag) {
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
   ASSERT_EQ(0, snap_create(*ictx, "snap1"));
-  ASSERT_EQ(0, librbd::snap_set(ictx,
-                               cls::rbd::UserSnapshotNamespace(),
-                               "snap1"));
+  ASSERT_EQ(0, librbd::api::Image<>::snap_set(ictx,
+                                             cls::rbd::UserSnapshotNamespace(),
+                                             "snap1"));
 
   C_SaferCond cond_ctx;
   AsyncRequest<> *request = new InvalidateRequest<>(*ictx, ictx->snap_id, false,
index de5aa8af67a792fa1c7305bc5581eb79ecc7a7fb..3cfe34cfd49b7638ee856053493c7d1f1c3ccf9a 100644 (file)
@@ -7,6 +7,7 @@
 #include "common/bit_vector.hpp"
 #include "librbd/internal.h"
 #include "librbd/ObjectMap.h"
+#include "librbd/api/Image.h"
 #include "librbd/object_map/ResizeRequest.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -98,9 +99,9 @@ TEST_F(TestMockObjectMapResizeRequest, UpdateSnapOnDisk) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
   ASSERT_EQ(0, snap_create(*ictx, "snap1"));
-  ASSERT_EQ(0, librbd::snap_set(ictx,
-                               cls::rbd::UserSnapshotNamespace(),
-                               "snap1"));
+  ASSERT_EQ(0, librbd::api::Image<>::snap_set(ictx,
+                                             cls::rbd::UserSnapshotNamespace(),
+                                             "snap1"));
 
   uint64_t snap_id = ictx->snap_id;
   expect_resize(ictx, snap_id, 0);
index 297df7854a4da7e992b89753827814448879db69..380a0350ad884c9d9f8f74416acce6d31cfa5daf 100644 (file)
@@ -9,6 +9,7 @@
 #include "librbd/internal.h"
 #include "librbd/ObjectMap.h"
 #include "librbd/Operations.h"
+#include "librbd/api/Image.h"
 #include "librbd/object_map/UpdateRequest.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -129,9 +130,9 @@ TEST_F(TestMockObjectMapUpdateRequest, UpdateSnapOnDisk) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
   ASSERT_EQ(0, snap_create(*ictx, "snap1"));
-  ASSERT_EQ(0, librbd::snap_set(ictx,
-                               cls::rbd::UserSnapshotNamespace(),
-                               "snap1"));
+  ASSERT_EQ(0, librbd::api::Image<>::snap_set(ictx,
+                                             cls::rbd::UserSnapshotNamespace(),
+                                             "snap1"));
 
   uint64_t snap_id = ictx->snap_id;
   expect_update(ictx, snap_id, 0, 1, OBJECT_NONEXISTENT, OBJECT_EXISTS, 0);
index ec78686a0d94ff7acd26031cb39a5960852bc7b3..05fdd7e1e6a0feb51c59d59d5637ea71f571ab15 100644 (file)
@@ -70,10 +70,12 @@ struct TestDeepCopy : public TestFixture {
         src_snap_name = src_snaps[i].name.c_str();
         dst_snap_name = dst_snaps[i].name.c_str();
       }
-      EXPECT_EQ(0, librbd::snap_set(m_src_ictx, cls::rbd::UserSnapshotNamespace(),
-                                    src_snap_name));
-      EXPECT_EQ(0, librbd::snap_set(m_dst_ictx, cls::rbd::UserSnapshotNamespace(),
-                                    dst_snap_name));
+      EXPECT_EQ(0, librbd::api::Image<>::snap_set(
+                     m_src_ictx, cls::rbd::UserSnapshotNamespace(),
+                     src_snap_name));
+      EXPECT_EQ(0, librbd::api::Image<>::snap_set(
+                     m_dst_ictx, cls::rbd::UserSnapshotNamespace(),
+                     dst_snap_name));
       uint64_t src_size, dst_size;
       {
         RWLock::RLocker src_locker(m_src_ictx->snap_lock);
index 3fb4312b43784a58da8a3e8dfc6c74b77325fae7..2952abfeec197d81e0ec2b53076f230e20bba982 100644 (file)
@@ -12,6 +12,7 @@
 #include "librbd/ObjectMap.h"
 #include "librbd/Operations.h"
 #include "librbd/api/DiffIterate.h"
+#include "librbd/api/Image.h"
 #include "librbd/io/AioCompletion.h"
 #include "librbd/io/ImageRequest.h"
 #include "librbd/io/ImageRequestWQ.h"
@@ -256,7 +257,8 @@ TEST_F(TestInternal, SnapSetReleasesLock) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
-  ASSERT_EQ(0, librbd::snap_set(ictx, cls::rbd::UserSnapshotNamespace(), "snap1"));
+  ASSERT_EQ(0, librbd::api::Image<>::snap_set(
+                 ictx, cls::rbd::UserSnapshotNamespace(), "snap1"));
 
   bool is_owner;
   ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner));
@@ -627,9 +629,8 @@ TEST_F(TestInternal, SnapshotCopyup)
   for (std::list<std::string>::iterator it = snaps.begin();
        it != snaps.end(); ++it) {
     const char *snap_name = it->empty() ? NULL : it->c_str();
-    ASSERT_EQ(0, librbd::snap_set(ictx2,
-                                 cls::rbd::UserSnapshotNamespace(),
-                                 snap_name));
+    ASSERT_EQ(0, librbd::api::Image<>::snap_set(
+                   ictx2, cls::rbd::UserSnapshotNamespace(), snap_name));
 
     ASSERT_EQ(256,
               ictx2->io_work_queue->read(0, 256,
@@ -713,9 +714,9 @@ TEST_F(TestInternal, ResizeCopyup)
                                          true, no_op));
   ASSERT_EQ(0, ictx2->operations->resize(m_image_size - (2 << order) - 32,
                                          true, no_op));
-  ASSERT_EQ(0, librbd::snap_set(ictx2,
-                               cls::rbd::UserSnapshotNamespace(),
-                               "snap1"));
+  ASSERT_EQ(0, librbd::api::Image<>::snap_set(ictx2,
+                                             cls::rbd::UserSnapshotNamespace(),
+                                             "snap1"));
 
   {
     // hide the parent from the snapshot
@@ -780,9 +781,9 @@ TEST_F(TestInternal, DiscardCopyup)
 
   ASSERT_EQ(static_cast<int>(m_image_size - 64),
             ictx2->io_work_queue->discard(32, m_image_size - 64, false));
-  ASSERT_EQ(0, librbd::snap_set(ictx2,
-                               cls::rbd::UserSnapshotNamespace(),
-                               "snap1"));
+  ASSERT_EQ(0, librbd::api::Image<>::snap_set(ictx2,
+                                             cls::rbd::UserSnapshotNamespace(),
+                                             "snap1"));
 
   {
     // hide the parent from the snapshot
@@ -949,9 +950,9 @@ TEST_F(TestInternal, WriteFullCopyup) {
                                        librbd::io::ReadResult{read_result}, 0));
   ASSERT_TRUE(write_full_bl.contents_equal(read_bl));
 
-  ASSERT_EQ(0, librbd::snap_set(ictx2,
-                               cls::rbd::UserSnapshotNamespace(),
-                               "snap1"));
+  ASSERT_EQ(0, librbd::api::Image<>::snap_set(ictx2,
+                                             cls::rbd::UserSnapshotNamespace(),
+                                             "snap1"));
   ASSERT_EQ((ssize_t)read_bl.length(),
             ictx2->io_work_queue->read(0, read_bl.length(),
                                        librbd::io::ReadResult{read_result}, 0));
@@ -1018,7 +1019,9 @@ TEST_F(TestInternal, DiffIterateCloneOverwrite) {
   ASSERT_EQ(0, io_ctx.write(oid, bl, 4096, 4096));
 
   interval_set<uint64_t> diff;
-  ASSERT_EQ(0, librbd::snap_set(ictx, cls::rbd::UserSnapshotNamespace(), "one"));
+  ASSERT_EQ(0, librbd::api::Image<>::snap_set(ictx,
+                                              cls::rbd::UserSnapshotNamespace(),
+                                              "one"));
   ASSERT_EQ(0, librbd::api::DiffIterate<>::diff_iterate(
     ictx, cls::rbd::UserSnapshotNamespace(), nullptr, 0, size, true, false,
     iterate_cb, (void *)&diff));
index 8d08a771ae8b9f08766aede87e956de8520ef71f..3b0661797c4ecf57b21b03e7600f2a7bfa611774 100644 (file)
@@ -6590,6 +6590,29 @@ TEST_F(TestLibRBD, TestListWatchers) {
   ASSERT_EQ(0, image.close());
 }
 
+TEST_F(TestLibRBD, TestSetSnapById) {
+  librados::IoCtx ioctx;
+  ASSERT_EQ(0, _rados.ioctx_create(m_pool_name.c_str(), ioctx));
+
+  librbd::RBD rbd;
+  std::string name = get_temp_image_name();
+
+  uint64_t size = 1 << 18;
+  int order = 12;
+  ASSERT_EQ(0, create_image_pp(rbd, ioctx, name.c_str(), size, &order));
+
+  librbd::Image image;
+  ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), nullptr));
+  ASSERT_EQ(0, image.snap_create("snap"));
+
+  vector<librbd::snap_info_t> snaps;
+  ASSERT_EQ(0, image.snap_list(snaps));
+  ASSERT_EQ(1U, snaps.size());
+
+  ASSERT_EQ(0, image.snap_set_by_id(snaps[0].id));
+  ASSERT_EQ(0, image.snap_set_by_id(CEPH_NOSNAP));
+}
+
 // poorman's assert()
 namespace ceph {
   void __ceph_assert_fail(const char *assertion, const char *file, int line,
index da8bdecdabab5a5e9bde5fc23a028af410272ba7..1148d4584002195c56dec8255170cc763fb8e98a 100644 (file)
@@ -7,6 +7,7 @@
 #include "librbd/ImageState.h"
 #include "librbd/Operations.h"
 #include "librbd/internal.h"
+#include "librbd/api/Image.h"
 #include "librbd/deep_copy/ImageCopyRequest.h"
 #include "librbd/deep_copy/MetadataCopyRequest.h"
 #include "librbd/deep_copy/SnapshotCopyRequest.h"
@@ -340,8 +341,9 @@ TEST_F(TestMockDeepCopyRequest, ErrorOnCopyMetadata) {
 
 TEST_F(TestMockDeepCopyRequest, Snap) {
   EXPECT_EQ(0, snap_create(*m_src_image_ctx, "copy"));
-  EXPECT_EQ(0, librbd::snap_set(m_src_image_ctx,
-                                cls::rbd::UserSnapshotNamespace(), "copy"));
+  EXPECT_EQ(0, librbd::api::Image<>::snap_set(m_src_image_ctx,
+                                              cls::rbd::UserSnapshotNamespace(),
+                                              "copy"));
 
   librbd::MockTestImageCtx mock_src_image_ctx(*m_src_image_ctx);
   librbd::MockTestImageCtx mock_dst_image_ctx(*m_dst_image_ctx);
index 37276f8032961ec378629e11b96dafc618328e03..3f37ca3fb63375404d8ecc33f66000c16f2b2162 100644 (file)
@@ -26,6 +26,7 @@
 #include "librbd/Journal.h"
 #include "librbd/internal.h"
 #include "librbd/Utils.h"
+#include "librbd/api/Image.h"
 #include "librbd/api/Mirror.h"
 #include "librbd/journal/DisabledPolicy.h"
 #include "test/rbd_mirror/test_fixture.h"
@@ -185,8 +186,8 @@ public:
                    cls::rbd::UserSnapshotNamespace(), "snap1"));
     EXPECT_EQ(0, ictx->operations->snap_protect(
                    cls::rbd::UserSnapshotNamespace(), "snap1"));
-    EXPECT_EQ(0, librbd::snap_set(ictx, cls::rbd::UserSnapshotNamespace(),
-                                  "snap1"));
+    EXPECT_EQ(0, librbd::api::Image<>::snap_set(
+                   ictx, cls::rbd::UserSnapshotNamespace(), "snap1"));
 
     std::string clone_id = librbd::util::generate_image_id(m_local_io_ctx);
     librbd::ImageOptions clone_opts;