From: Sage Weil Date: Wed, 29 Apr 2015 19:34:25 +0000 (-0700) Subject: mon: prevent pool with snapshot state from being used as a tier X-Git-Tag: v0.80.11~24^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d7f53442260dcfc92e7afa8bba2dd116c15e030d;p=ceph.git mon: prevent pool with snapshot state from being used as a tier 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 (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.) --- diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 5fd6a188c8b45..5ad40edad779d 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -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 diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 45fad4b6beb9f..67bd5328550ca 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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);