]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: quickly check for duplicate snap name upon create 9628/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 8 Jun 2016 14:12:04 +0000 (10:12 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 10 Jun 2016 16:44:49 +0000 (12:44 -0400)
During journal replay, quickly check for a duplicate snap name
before allocating a snapshot sequence from the OSDs and
reverting due to the duplicate name.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 8374d45c7644666103f88c410a2b1b781f3a0cb8)

src/librbd/Operations.cc

index c523b912680d3d2a36a2139dbb57207edad72fdd..7766a1222f8652095c0f7e4a0eb9c50896dec33d 100644 (file)
@@ -617,6 +617,14 @@ void Operations<I>::execute_snap_create(const char *snap_name,
   ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
                 << dendl;
 
+  m_image_ctx.snap_lock.get_read();
+  if (m_image_ctx.get_snap_id(snap_name) != CEPH_NOSNAP) {
+    m_image_ctx.snap_lock.put_read();
+    on_finish->complete(-EEXIST);
+    return;
+  }
+  m_image_ctx.snap_lock.put_read();
+
   operation::SnapshotCreateRequest<I> *req =
     new operation::SnapshotCreateRequest<I>(
       m_image_ctx, new C_NotifyUpdate<I>(m_image_ctx, on_finish), snap_name,