]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: Encode shard mappings.
authorAlex Ainscow <aainscow@uk.ibm.com>
Thu, 5 Feb 2026 15:02:31 +0000 (15:02 +0000)
committerAlex Ainscow <aainscow@uk.ibm.com>
Fri, 6 Feb 2026 10:31:55 +0000 (10:31 +0000)
The split ops code will need to know how "raw" shards map to the actual shards.

This change add the data to the pool configuration.

Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
src/osd/osd_types.cc
src/osd/osd_types.h

index 91adfdd40f6c257387c6b0df5f5c6e4b0562d5ad..b0c6b0c4549d67d5b232114be1e75d97ad3d7297 100644 (file)
@@ -1987,7 +1987,7 @@ void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
     return;
   }
 
-  uint8_t v = 32;
+  uint8_t v = 33;
   // NOTE: any new encoding dependencies must be reflected by
   // SIGNIFICANT_FEATURES
   if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_TENTACLE)) {
@@ -2109,6 +2109,9 @@ void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
   if (v >= 32) {
     encode(nonprimary_shards, bl);
   }
+  if (v >= 33) {
+    encode(shard_mapping, bl);
+  }
   ENCODE_FINISH(bl);
 }
 
@@ -2310,6 +2313,12 @@ void pg_pool_t::decode(ceph::buffer::list::const_iterator& bl)
   } else {
     nonprimary_shards.clear();
   }
+
+  if (struct_v >= 33) {
+    decode(shard_mapping, bl);
+  } else {
+    shard_mapping.clear();
+  }
   DECODE_FINISH(bl);
   calc_pg_masks();
   calc_grade_table();
index 28f37d0645a8383ea42c9334cb8e75ea653afc21..bfcbc1a71cd367210c7716c6b117a602826e9f53 100644 (file)
@@ -1747,6 +1747,7 @@ public:
 
 private:
   std::vector<uint32_t> grade_table;
+  std::vector<shard_id_t> shard_mapping; // Used by EC direct reads.
 
 public:
   uint32_t get_grade(unsigned i) const {
@@ -1964,6 +1965,17 @@ public:
     return !nonprimary_shards.empty() && nonprimary_shards.contains(shard);
   }
 
+  void set_shard_mapping(std::vector<shard_id_t> && mapping) {
+    shard_mapping = mapping;
+  }
+
+  shard_id_t get_shard(raw_shard_id_t raw) const {
+    if (shard_mapping.size() == 0) {
+      return shard_id_t((int)raw);
+    }
+    return shard_mapping[(int)raw];
+  }
+
   void encode(ceph::buffer::list& bl, uint64_t features) const;
   void decode(ceph::buffer::list::const_iterator& bl);