]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: block osd pool mksnap for fs pools
authorMilind Changire <mchangir@redhat.com>
Mon, 8 May 2023 07:52:12 +0000 (13:22 +0530)
committerMilind Changire <mchangir@redhat.com>
Tue, 11 Jul 2023 16:06:09 +0000 (21:36 +0530)
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 <mchangir@redhat.com>
(cherry picked from commit 6203fe15289d27bf02441fd413a40371cb0bc516)

src/mon/OSDMonitor.cc

index 2261763b1a8a761e3f1fc162d889bd53093a3e0c..80af0e0c987403c047b06422e836e708284dd05c 100644 (file)
@@ -12901,6 +12901,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;