]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: set last snapid according to removed snaps in data pools
authorYan, Zheng <zyan@redhat.com>
Mon, 15 Dec 2014 07:43:57 +0000 (15:43 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 5 Feb 2015 14:40:37 +0000 (22:40 +0800)
handle the case that we create cephfs using existing pools and
the existing pools' removed snaps are not empty.

Fixes: #10315
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/SnapServer.cc

index ac0407393edec98518d2584438388bcf1ed1b6ef..04ab36a7fd11c9a0251734b39679ab712734bef8 100644 (file)
@@ -37,6 +37,21 @@ void SnapServer::reset_state()
   last_snap = 1;  /* snapid 1 reserved for initial root snaprealm */
   snaps.clear();
   need_to_purge.clear();
+
+  // find any removed snapshot in data pools
+  snapid_t first_free = 0;
+  const OSDMap *osdmap = mds->objecter->get_osdmap_read();
+  for (set<int64_t>::const_iterator p = mds->mdsmap->get_data_pools().begin();
+       p != mds->mdsmap->get_data_pools().end();
+       ++p) {
+    const pg_pool_t *pi = osdmap->get_pg_pool(*p);
+    if (!pi->removed_snaps.empty() &&
+        pi->removed_snaps.range_end() > first_free)
+      first_free = pi->removed_snaps.range_end();
+  }
+  mds->objecter->put_osdmap_read();
+  if (first_free > last_snap)
+    last_snap = first_free;
 }