]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: require osd_pg_max_concurrent_snap_trims > 0 45322/head
authorDan van der Ster <daniel.vanderster@cern.ch>
Thu, 24 Feb 2022 08:42:00 +0000 (09:42 +0100)
committerLaura Flores <lflores@redhat.com>
Wed, 9 Mar 2022 16:42:49 +0000 (16:42 +0000)
If osd_pg_max_concurrent_snap_trims is zero, we mistakenly clear
the snaptrim queue. Require it to be > 0.

Fixes: https://tracker.ceph.com/issues/54396
Signed-off-by: Dan van der Ster <daniel.vanderster@cern.ch>
(cherry picked from commit 29545b617b3b0324f9b0b20e032e3e38557115eb)

src/common/options/global.yaml.in
src/osd/PrimaryLogPG.cc
src/osd/SnapMapper.cc

index c0e3b014d9a6495bf80ca70127a05963b2b9d27a..7a4e581fbec59d388b9eb7817edac7227fa56607 100644 (file)
@@ -2817,6 +2817,7 @@ options:
   type: uint
   level: advanced
   default: 2
+  min: 1
   with_legacy: true
 # max number of trimming pgs
 - name: osd_max_trimming_pgs
index b4b8f00ba8b1cb08c1c3bf34b295c62782e83703..dc2160356a816bb0d5de07767447b25b31639777 100644 (file)
@@ -15594,6 +15594,9 @@ boost::statechart::result PrimaryLogPG::AwaitAsyncWork::react(const DoSnapWork&)
 
   vector<hobject_t> to_trim;
   unsigned max = pg->cct->_conf->osd_pg_max_concurrent_snap_trims;
+  // we need to look for at least 1 snaptrim, otherwise we'll misinterpret
+  // the ENOENT below and erase snap_to_trim.
+  ceph_assert(max > 0);
   to_trim.reserve(max);
   int r = pg->snap_mapper.get_next_objects_to_trim(
     snap_to_trim,
index 912c539b8bcf886dd4416264d2f937498918ce93..07c6f57c78ae4ac0efbdc01a4f947b520a3feb71 100644 (file)
@@ -322,6 +322,10 @@ int SnapMapper::get_next_objects_to_trim(
 {
   ceph_assert(out);
   ceph_assert(out->empty());
+
+  // if max would be 0, we return ENOENT and the caller would mistakenly
+  // trim the snaptrim queue
+  ceph_assert(max > 0);
   int r = 0;
   for (set<string>::iterator i = prefixes.begin();
        i != prefixes.end() && out->size() < max && r == 0;