Skip to content

Commit 6e02660

Browse files
authored
Merge pull request ceph#51275 from mchangir/mon-block-osd-pool-mksnap-for-fs-pools
mon: block osd pool mksnap for fs pools Reviewed-by: Radoslaw Zarzynski <[email protected]>
2 parents f4d9ed8 + ab64bfa commit 6e02660

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

qa/tasks/cephfs/test_snapshots.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,16 @@ def test_disallow_monitor_managed_snaps_for_fs_pools(self):
550550
with self.assertRaises(CommandFailedError):
551551
self.fs.rados(["mksnap", "snap2"], pool=self.fs.get_metadata_pool_name())
552552

553+
with self.assertRaises(CommandFailedError):
554+
test_pool_name = self.fs.get_data_pool_name()
555+
base_cmd = f'osd pool mksnap {test_pool_name} snap3'
556+
self.run_cluster_cmd(base_cmd)
557+
558+
with self.assertRaises(CommandFailedError):
559+
test_pool_name = self.fs.get_metadata_pool_name()
560+
base_cmd = f'osd pool mksnap {test_pool_name} snap4'
561+
self.run_cluster_cmd(base_cmd)
562+
553563
def test_attaching_pools_with_snaps_to_fs_fails(self):
554564
"""
555565
Test that attempt to attach pool with snapshots to an fs fails

src/mon/OSDMonitor.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12990,6 +12990,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
1299012990
if (pp->snap_exists(snapname.c_str())) {
1299112991
ss << "pool " << poolstr << " snap " << snapname << " already exists";
1299212992
} else {
12993+
if (const auto& fsmap = mon.mdsmon()->get_fsmap(); fsmap.pool_in_use(pool)) {
12994+
dout(20) << "pool-level snapshots have been disabled for pools "
12995+
"attached to an fs - poolid:" << pool << dendl;
12996+
err = -EOPNOTSUPP;
12997+
goto reply;
12998+
}
1299312999
pp->add_snap(snapname.c_str(), ceph_clock_now());
1299413000
pp->set_snap_epoch(pending_inc.epoch);
1299513001
ss << "created pool " << poolstr << " snap " << snapname;

0 commit comments

Comments
 (0)