]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: prevent pool with snapshot state from being used as a tier
authorSage Weil <sage@redhat.com>
Wed, 29 Apr 2015 19:34:25 +0000 (12:34 -0700)
committerSage Weil <sage@redhat.com>
Mon, 15 Jun 2015 19:25:43 +0000 (12:25 -0700)
If we add a pool with snap state as a tier the snap state gets clobbered
by OSDMap::Incremental::propogate_snaps_to_tiers(), and may prevent OSDs
from starting.  Disallow this.

Include a test.

Fixes: #11493
Backport: hammer, giant, firefly
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit bbec53edf9e585af4e20bbc9ba9057d6fdfda342)

qa/workunits/cephtool/test.sh
src/mon/OSDMonitor.cc

index 906c89289038763fa58e31bb43690e5d63ad0637..e1773f20cf87212937533c94e1b75629f9581d23 100755 (executable)
@@ -315,6 +315,16 @@ function test_tiering()
   ceph osd pool delete cache cache --yes-i-really-really-mean-it
   ceph osd pool delete cache2 cache2 --yes-i-really-really-mean-it
 
+  # make sure we can't clobber snapshot state
+  ceph osd pool create snap_base 2
+  ceph osd pool create snap_cache 2
+  rbd -p snap_cache create foo --size 10
+  rbd -p snap_cache snap create foo --snap snap1
+  rbd -p snap_cache snap rm foo --snap snap1
+  expect_false ceph osd tier add snap_base snap_cache --force-nonempty
+  ceph osd pool delete snap_base snap_base --yes-i-really-really-mean-it
+  ceph osd pool delete snap_cache snap_cache --yes-i-really-really-mean-it
+
   # convenient add-cache command
   ceph osd pool create cache3 2
   ceph osd tier add-cache slow cache3 1024000
index 58a70ef2b199646ac9c7650f0b89aa6777cb0c75..dc9b8784b6623f8d13699786b89799805d47449a 100644 (file)
@@ -6112,6 +6112,11 @@ done:
       err = -ENOTEMPTY;
       goto reply;
     }
+    if (!tp->removed_snaps.empty() || !tp->snaps.empty()) {
+      ss << "tier pool '" << tierpoolstr << "' has snapshot state; it cannot be added as a tier without breaking the pool";
+      err = -ENOTEMPTY;
+      goto reply;
+    }
     // go
     pg_pool_t *np = pending_inc.get_new_pool(pool_id, p);
     pg_pool_t *ntp = pending_inc.get_new_pool(tierpool_id, tp);