]> 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)
committerNathan Cutler <ncutler@suse.com>
Mon, 5 Oct 2015 13:14:24 +0000 (15:14 +0200)
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)

Conflicts:
qa/workunits/cephtool/test.sh
           properly co-exist with "# make sure we can't create an ec pool tier"
src/mon/OSDMonitor.cc
           properly co-exist with preceding "if (tp->ec_pool())"
        (The changes to both files would have applied cleanly if
        https://github.com/ceph/ceph/pull/5389 had not been merged first.)

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

index 5fd6a188c8b4503f0c02eecaf00b4415ddaf09e1..5ad40edad779dbaf4372d00e8c5c6e3f44fdefed 100755 (executable)
@@ -187,6 +187,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
+
   # make sure we can't create an ec pool tier
   ceph osd pool create eccache 2 2 erasure
   ceph osd pool create repbase 2
index 45fad4b6beb9fb279919e4a2703401214cd20bfa..67bd5328550ca306fd082c0cde56b026b4e54595 100644 (file)
@@ -5329,6 +5329,11 @@ done:
       err = -ENOTSUP;
       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);