Skip to content

osd/ECUtil: fix offset accumulation in slice_map - #70151

Merged
rzarzynski merged 2 commits into
ceph:mainfrom
sunyuechi:fix-ec-slice-map-offset
Jul 27, 2026
Merged

rzarzynski merged 2 commits into
ceph:mainfrom
sunyuechi:fix-ec-slice-map-offset

Conversation

@sunyuechi

Copy link
Copy Markdown
Contributor

slice_map() accumulated the slice bounds with the wrong operands:
end_offset took max() against start_offset instead of the previous
end_offset, ro_start took min() against start_offset instead of
ro_start, and ro_end used min() instead of max()

Introduced by 9e2841a ("osd: Introduce optimized EC").

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

@sunyuechi
sunyuechi requested a review from a team as a code owner July 13, 2026 07:23
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

16 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@github-actions github-actions Bot added the core label Jul 13, 2026
@tchaikov

Copy link
Copy Markdown
Contributor

ok to test

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tchaikov
tchaikov requested a review from aainscow July 14, 2026 02:01
@tchaikov

Copy link
Copy Markdown
Contributor

@aainscow hi Alex, could you take a look?

@aainscow aainscow left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankyou for your proposed fix - much appreciated that the community is spotting bugs in the code.

The original code is wrong, but the fix is not quite right. The RO bounds cache only covers the data and not the parity shards. As such, the calculation was wrong.

ecutils_test.patch

@aainscow

Copy link
Copy Markdown
Contributor

@sunyuechi - Thankyou for your contribution, it is very much appreciated.

Can you tell us how you came across this issue? I am interested, because I want to know whether we should be backporting this patch to Tentacle and Umbrella releases, or just including in main.

@sunyuechi
sunyuechi force-pushed the fix-ec-slice-map-offset branch from 1bdf52b to 636a20b Compare July 14, 2026 08:35
@sunyuechi

Copy link
Copy Markdown
Contributor Author

@aainscow

The patch https://github.com/user-attachments/files/29999040/ecutils_test.patch shows "Not Found".

Can you tell us how you came across this issue?

I was just reading the code and it looked like a typo. Now it seems better to just use compute_ro_range() instead of computing manually, updated. How about it?

@aainscow

aainscow commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Here is the contents of the patch:

Index: src/test/osd/TestECUtil.cc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/test/osd/TestECUtil.cc b/src/test/osd/TestECUtil.cc
--- a/src/test/osd/TestECUtil.cc	(revision 7407db4b27b9983ce6b345ca6bf7df43e04a5d6b)
+++ b/src/test/osd/TestECUtil.cc	(date 1784015674848)
@@ -24,6 +24,17 @@
 using namespace std;
 using namespace ECUtil;
 
+namespace {
+
+void verify_offset_cache(const shard_extent_map_t& sem)
+{
+  shard_extent_map_t cached = sem;
+  cached.compute_ro_range();
+  ASSERT_EQ(cached, sem);
+}
+
+} // anonymous namespace
+
 TEST(ECUtil, stripe_info_t)
 {
   const uint64_t swidth = 4096;
@@ -1051,28 +1062,31 @@
   {
     auto slice_map = sem.slice_map(512, 1024);
     ASSERT_EQ(4, slice_map.get_extent_maps().size());
-    ASSERT_EQ(512, slice_map.get_start_offset());
-    ASSERT_EQ(512+1024, slice_map.get_end_offset());
+    verify_offset_cache(slice_map);
+  }
+
+  {
+    shard_extent_map_t single(&sinfo);
+    single.insert_in_shard(shard_id_t(1), 512, bl1k);
 
-    for (int i=1; i<5; i++) {
-      ASSERT_EQ(512, slice_map.get_extent_map(shard_id_t(i)).get_start_off());
-      ASSERT_EQ(512+1024, slice_map.get_extent_map(shard_id_t(i)).get_end_off());
-    }
+    auto slice_map = single.slice_map(512, 1024);
+    ASSERT_EQ(1, slice_map.get_extent_maps().size());
+    verify_offset_cache(slice_map);
+  }
+
+  {
+    shard_extent_map_t single(&sinfo);
+    single.insert_in_shard(shard_id_t(1), 512, bl1k);
+
+    auto slice_map = single.slice_map(0, 4096);
+    ASSERT_EQ(1, slice_map.get_extent_maps().size());
+    verify_offset_cache(slice_map);
   }
 
   {
     auto slice_map = sem.slice_map(0, 4096);
     ASSERT_EQ(4, slice_map.get_extent_maps().size());
-    ASSERT_EQ(5, slice_map.get_start_offset());
-    ASSERT_EQ(4096, slice_map.get_end_offset());
-    ASSERT_EQ(512, slice_map.get_extent_map(shard_id_t(1)).get_start_off());
-    ASSERT_EQ(512 + 1024, slice_map.get_extent_map(shard_id_t(1)).get_end_off());
-    ASSERT_EQ(5, slice_map.get_extent_map(shard_id_t(2)).get_start_off());
-    ASSERT_EQ(4096, slice_map.get_extent_map(shard_id_t(2)).get_end_off());
-    ASSERT_EQ(256, slice_map.get_extent_map(shard_id_t(3)).get_start_off());
-    ASSERT_EQ(4096, slice_map.get_extent_map(shard_id_t(3)).get_end_off());
-    ASSERT_EQ(5, slice_map.get_extent_map(shard_id_t(4)).get_start_off());
-    ASSERT_EQ(4096, slice_map.get_extent_map(shard_id_t(4)).get_end_off());
+    verify_offset_cache(slice_map);
   }
 
   {

I prefer your original fix, but with a tweak to ignore parity shards.

slice_map() accumulated the slice bounds against the wrong operands,
and included parity shards in ro_start and ro_end, which only track
data.

Introduced by 9e2841a ("osd: Introduce optimized EC").

Signed-off-by: Sun Yuechi <[email protected]>
Recompute ro_start and ro_end with compute_ro_range() and compare them
against the cached values, and cover single-shard maps.

Signed-off-by: Sun Yuechi <[email protected]>
@sunyuechi
sunyuechi force-pushed the fix-ec-slice-map-offset branch from 636a20b to 84fc350 Compare July 14, 2026 09:13
@github-actions github-actions Bot added the tests label Jul 14, 2026
@sunyuechi

Copy link
Copy Markdown
Contributor Author

@aainscow Thanks for the help. I've changed it back to the original fix then.
Test commit has you as author, replace the Signed-off-by with yours?

@aainscow aainscow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankyou. LGTM

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by skanta started 2026-07-17-04:58.

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@rzarzynski
rzarzynski merged commit c2709f5 into ceph:main Jul 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants