From 23db15d5c2b428afec27c682052347ad07170413 Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Tue, 23 Aug 2022 16:43:08 +0530 Subject: mon: block monitor managed snaps for fs pools Signed-off-by: Milind Changire --- src/mon/FSCommands.cc | 6 ++++++ src/mon/OSDMonitor.cc | 10 ++++++++++ 2 files changed, 16 insertions(+) (limited to 'src/mon') diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index 5fd1f4a21de..3111dc099b7 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -1545,6 +1545,12 @@ int FileSystemCommandHandler::_check_pool( return -ENOENT; } + if (pool->has_snaps()) { + *ss << "pool(" << pool_id <<") already has mon-managed snaps; " + "can't attach pool to fs"; + return -EOPNOTSUPP; + } + const string& pool_name = osd_map.get_pool_name(pool_id); auto app_map = pool->application_metadata; diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e9e7ce72a8b..b95ee73cdb3 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -14052,6 +14052,16 @@ bool OSDMonitor::prepare_pool_op(MonOpRequestRef op) const pg_pool_t *pool = osdmap.get_pg_pool(m->pool); + if (m->op == POOL_OP_CREATE_SNAP || + m->op == POOL_OP_CREATE_UNMANAGED_SNAP) { + if (const auto& fsmap = mon.mdsmon()->get_fsmap(); fsmap.pool_in_use(m->pool)) { + dout(20) << "monitor-managed snapshots have been disabled for pools " + " attached to an fs - pool:" << m->pool << dendl; + _pool_op_reply(op, -EOPNOTSUPP, osdmap.get_epoch()); + return false; + } + } + switch (m->op) { case POOL_OP_CREATE_SNAP: if (pool->is_tier()) { -- cgit v1.2.3