From 13c8d58da1303cc68d99da19f79d625f91f99d43 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 29 Apr 2015 12:34:25 -0700 Subject: [PATCH] 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) --- qa/workunits/cephtool/test.sh | 10 ++++++++++ src/mon/OSDMonitor.cc | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 906c892890387..e1773f20cf872 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -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 diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 58a70ef2b1996..dc9b8784b6623 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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); -- 2.39.5