]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: quickly check for duplicate snap name upon create 9594/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 8 Jun 2016 14:12:04 +0000 (10:12 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 8 Jun 2016 15:06:20 +0000 (11:06 -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>
src/librbd/Operations.cc

index 64b59e6154f35454a816fc2355c8c599542fb99e..f19ebf2b891146a1575ae86f3e60137e000d8fe2 100644 (file)
@@ -673,6 +673,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,