From 6203fe15289d27bf02441fd413a40371cb0bc516 Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Mon, 8 May 2023 13:22:12 +0530 Subject: [PATCH 1/2] mon: block osd pool mksnap for fs pools Commit 23db15d5c2b disabled pool snaps for the rados mksnap path. But ceph osd pool mksnap was an alternate way that pool snaps could be created. This commit disables pool snaps via this alternate path as well. NOTE: Pool-level snaps and fs-level snaps can't co-exist since snap IDs are likely to clash between the two different mechanisms and can result in unintentional data loss when either of the snaps are deleted. Fixes: https://tracker.ceph.com/issues/59552 Signed-off-by: Milind Changire --- src/mon/OSDMonitor.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 6a05124b366..3acafbb82e6 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -13033,6 +13033,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pp->snap_exists(snapname.c_str())) { ss << "pool " << poolstr << " snap " << snapname << " already exists"; } else { + if (const auto& fsmap = mon.mdsmon()->get_fsmap(); fsmap.pool_in_use(pool)) { + dout(20) << "pool-level snapshots have been disabled for pools " + "attached to an fs - poolid:" << pool << dendl; + err = -EOPNOTSUPP; + goto reply; + } pp->add_snap(snapname.c_str(), ceph_clock_now()); pp->set_snap_epoch(pending_inc.epoch); ss << "created pool " << poolstr << " snap " << snapname; From ab64bfaaf978cb9a14ff0520d4dc51ea32e1e93c Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Wed, 26 Apr 2023 10:41:24 +0530 Subject: [PATCH 2/2] qa: add test to verify blocking of osd pool mksnap for fs pools Signed-off-by: Milind Changire --- qa/tasks/cephfs/test_snapshots.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qa/tasks/cephfs/test_snapshots.py b/qa/tasks/cephfs/test_snapshots.py index 51dcf80abd0..608dcc81f15 100644 --- a/qa/tasks/cephfs/test_snapshots.py +++ b/qa/tasks/cephfs/test_snapshots.py @@ -550,6 +550,16 @@ class TestMonSnapsAndFsPools(CephFSTestCase): with self.assertRaises(CommandFailedError): self.fs.rados(["mksnap", "snap2"], pool=self.fs.get_metadata_pool_name()) + with self.assertRaises(CommandFailedError): + test_pool_name = self.fs.get_data_pool_name() + base_cmd = f'osd pool mksnap {test_pool_name} snap3' + self.run_cluster_cmd(base_cmd) + + with self.assertRaises(CommandFailedError): + test_pool_name = self.fs.get_metadata_pool_name() + base_cmd = f'osd pool mksnap {test_pool_name} snap4' + self.run_cluster_cmd(base_cmd) + def test_attaching_pools_with_snaps_to_fs_fails(self): """ Test that attempt to attach pool with snapshots to an fs fails