From: John Spray Date: Thu, 7 May 2015 13:23:37 +0000 (+0100) Subject: mon: refine check_remove_tier checks X-Git-Tag: v0.94.6~72^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=31e59fbca0ba636fc57c208e612d7488a48a6287;p=ceph.git mon: refine check_remove_tier checks Fixes: #11504 Signed-off-by: John Spray (cherry picked from commit a50c8f1f2ad8845c7f77110868f9376f2d1ff883) --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index cdbb6c752e9..2f08e41bdf6 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -6229,7 +6229,7 @@ done: const pg_pool_t *tp = osdmap.get_pg_pool(tierpool_id); assert(tp); - if (!_check_remove_tier(pool_id, p, &err, &ss)) { + if (!_check_remove_tier(pool_id, p, tp, &err, &ss)) { goto reply; } @@ -6334,7 +6334,7 @@ done: goto reply; } - if (!_check_remove_tier(pool_id, p, &err, &ss)) { + if (!_check_remove_tier(pool_id, p, NULL, &err, &ss)) { goto reply; } @@ -7000,17 +7000,29 @@ bool OSDMonitor::_check_become_tier( */ bool OSDMonitor::_check_remove_tier( const int64_t base_pool_id, const pg_pool_t *base_pool, + const pg_pool_t *tier_pool, int *err, ostream *ss) const { const std::string &base_pool_name = osdmap.get_pool_name(base_pool_id); - // If the pool is in use by CephFS, then refuse to remove its - // tier + // Apply CephFS-specific checks const MDSMap &pending_mdsmap = mon->mdsmon()->pending_mdsmap; if (pending_mdsmap.pool_in_use(base_pool_id)) { - *ss << "pool '" << base_pool_name << "' is in use by CephFS via its tier"; - *err = -EBUSY; - return false; + if (base_pool->type != pg_pool_t::TYPE_REPLICATED) { + // If the underlying pool is erasure coded, we can't permit the + // removal of the replicated tier that CephFS relies on to access it + *ss << "pool '" << base_pool_name << "' is in use by CephFS via its tier"; + *err = -EBUSY; + return false; + } + + if (tier_pool && tier_pool->cache_mode == pg_pool_t::CACHEMODE_WRITEBACK) { + *ss << "pool '" << base_pool_name << "' is in use by CephFS, and this " + "tier is still in use as a writeback cache. Change the cache " + "mode and flush the cache before removing it"; + *err = -EBUSY; + return false; + } } *err = 0; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 414bf082410..d0ecce9dac5 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -259,7 +259,7 @@ private: int64_t base_pool_id, const pg_pool_t *base_pool, int *err, ostream *ss) const; bool _check_remove_tier( - int64_t base_pool_id, const pg_pool_t *base_pool, + int64_t base_pool_id, const pg_pool_t *base_pool, const pg_pool_t *tier_pool, int *err, ostream *ss) const; int _prepare_remove_pool(int64_t pool, ostream *ss);