]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/SnapMapper: fix SnapMapper::Scrubber pg shard parsing
authorethanwu <ethanwu@synology.com>
Mon, 15 Sep 2025 08:36:54 +0000 (16:36 +0800)
committerethanwu <ethanwu@synology.com>
Thu, 18 Sep 2025 01:38:39 +0000 (09:38 +0800)
Note: the following only applies to EC pools as replicated pools have no
shard in the SNA_ keys.

Note: The Scrubber is only responsible for clearing entries that (_for
some anomalous reason_) remained in the store and should have been
purged.

SnapMapper::Scrubber::_parse_m is using the wrong key format (See:
napMapper::get_prefix) to obtain the pg shard.
While the correct format in EC pgs is:

<MAPPING_PREFIX><pool>_<snapid>_.<shardid>_<hobject_t::to_str()>
*******************************^

Or in replicated case:

<MAPPING_PREFIX><pool>_<snapid>_<hobject_t::to_str()>
*******************************^

The Scrubber is parsing the key a `.` instead of `_`.

---

`sscanf` should return the 3 if the third parameter (shard) was
successfully parsed.
Otherwise, we assume no shard is present in this key.

Fixes: https://tracker.ceph.com/issues/73018
Signed-off-by: ethanwu <ethanwu@synology.com>
src/osd/SnapMapper.cc

index 2f22ea9c9ee1777f6588c4f7a5ab17a2fa07f44b..d9d27dfabc69233965927d3bf1025432159b600d 100644 (file)
@@ -976,8 +976,8 @@ bool SnapMapper::Scrubber::_parse_m(
   {
     unsigned long long p, s;
     long sh;
-    int r = sscanf(key.data(), "SNA_%lld_%llx.%lx", &p, &s, &sh);
-    if (r != 1) {
+    int r = sscanf(key.data(), "SNA_%lld_%llx_.%lx", &p, &s, &sh);
+    if (r != 3) {
       shard = shard_id_t::NO_SHARD;
     } else {
       shard = shard_id_t(sh);