Skip to content

osd: Fix PrimaryLogPG::rep_repair_primary_object assert for Direct EC Read - #71910

Merged
ljflores merged 3 commits into
ceph:mainfrom
bill-scales:issue79319
Oct 6, 2026
Merged

ljflores merged 3 commits into
ceph:mainfrom
bill-scales:issue79319

Conversation

@bill-scales

@bill-scales bill-scales commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

A sparse read sent as a direct EC read to a non-primary shard which then fails with a medium error hits an assert in rep_repair_primary_object. This is another case where the request should be failed with EAGAIN and resent to the primary which can then perform recovery.

Fixes: https://tracker.ceph.com/issues/79319

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@bill-scales
bill-scales marked this pull request as ready for review September 18, 2026 17:36
@bill-scales
bill-scales requested a review from a team as a code owner September 18, 2026 17:36

@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.

I need @JonBailey1993 to verify whether the RadosIo.cc use-after-free is genuine.

rop.sparse_read(sparseOp.offset[0] * block_size,
sparseOp.length[0] * block_size,
extents.get(),
&op_info->bufferlist[0],

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.

Doesn't op_info get freed when it gets out of scope, so this pointer will point at freed memory?

@JonBailey1993 JonBailey1993 Sep 21, 2026 •

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.

Yes, I believe it is a use-after-free - it seems not to be hit frequently as it appears it exists in Create, Write1/2/3, FailedWrite1/2/3 and Truncate1/2/3 too.

I think the fix is just to do what read does and have the sparse_read_cb lambda capture op_info so the shared_pointer will still be owned by something up until the callback finishes executing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Its only a bug in sparse-read - the write paths copy the bufferlist before it is freed. Will fix by adding op_info to the lambda to copy the read path.

Comment thread src/osd/PrimaryLogPG.cc
if (!is_primary() || pool.info.is_erasure()) {
// Must be a balanced/localized/EC direct read that has failed on a replica.
// Replicas cannot run recovery, so the request need to be
// failed with EAGAIN to the client which will then retry the

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.

nit: Potential AI-misleading comment here. This comment implies that this only happens on non-primary OSDs, but this is not true for EC direct reads. Code is correct, comment is very slightly misleading.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed comment and log message below

bill-scales and others added 3 commits September 23, 2026 09:38
With the introduction of EC direct reads it is possible that
an EC sparse reads encounters a medium error and ends up
calling rep_repair_primary_object. Instead of asserting
the direct read should be failed back to the client with
-EAGAIN so that it can be resent to the primary which can
then perform recovery.

Fixes: https://tracker.ceph.com/issues/79319

Signed-off-by: Bill Scales <[email protected]>
This test shows how we can hit the ceph_assert(!pool.info.is_erasure()); on an ec pool

Signed-off-by: Jon Bailey <[email protected]>
Assisted-by: IBM Bob 2.0.2
Test injecting a medium error for an EC direct sparse read to a
non-primary shard. EC Direct Reads allows clients to send requests
to the shard that has the data rather than to the Primary which
then has to forward the request. However if this direct read
fails (e.g. because of a medium error) the request needs to be
failed to the client with EAGAIN which will then resubmit the
request to the Primary. This is required because only the
Primary can perform recovery.

Signed-off-by: Bill Scales <[email protected]>
@bill-scales

Copy link
Copy Markdown
Contributor Author

A few force pushes to tweak the set of ignored health warnings for the test - in particular the -EIO for the read that we are deliberately injecting is expected.

Here's a teuthology run showing the new test passing:

https://pulpito-ng.ceph.com/runs/billscales-2026-09-23_08:40:28-rados:singleton-main-distro-default-smithi

@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.

LGTM

There is a quirk in the script which means the code to detect crashes wont work, but that doesn't matter for teuthology.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath10-testing-20260924.010810-main.

@JonBailey1993 JonBailey1993 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

@aainscow
aainscow requested a review from rzarzynski September 30, 2026 09:34
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 1, 2026
…o the primary

Builds on "osd: rep_repair_primary_object needs to handle direct reads"
(PR ceph#71910), which makes rep_repair_primary_object() fail an EC read
with -EAGAIN instead of asserting, so the sparse path (do_sparse_read)
now bounces an EC direct read that hits -EIO or a full-object crc
mismatch back to the client for a retry at the primary.

An EC direct read only reads the local shard, so it cannot reconstruct
around a medium error. The design (ec_stretch_cluster.rst 7.2 and
direct_reads.rst) requires any such failure to send the client back to
the primary, which can decode from the other shards (in a stretch pool,
from remote-zone shards if need be). The non-sparse path (do_read,
objects_read_local) still passed -EIO straight back to the client,
failing the application's read.

Call rep_repair_primary_object() from the non-sparse EC direct-read path on
-EIO, as the replicated path does, so it takes the same -EAGAIN bounce,
which the Objecter (and SplitOp) resubmits to the primary without the
direct-read flags. -EAGAIN from do_osd_ops() means the reply has already
been sent, so execute_ctx() just closes the context.

Replicated pools and non-direct EC reads are unchanged. The unit
harness does not reach PrimaryLogPG::do_osd_ops(); the next commit
checks the backend half (objects_read_local() returning -EIO) only.

Fixes: https://tracker.ceph.com/issues/81286
Assisted-by: Claude Code
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 6, 2026
…o the primary

Builds on "osd: rep_repair_primary_object needs to handle direct reads"
(PR ceph#71910), which makes rep_repair_primary_object() fail an EC read
with -EAGAIN instead of asserting, so the sparse path (do_sparse_read)
now bounces an EC direct read that hits -EIO or a full-object crc
mismatch back to the client for a retry at the primary.

An EC direct read only reads the local shard, so it cannot reconstruct
around a medium error. The design (ec_stretch_cluster.rst 7.2 and
direct_reads.rst) requires any such failure to send the client back to
the primary, which can decode from the other shards (in a stretch pool,
from remote-zone shards if need be). The non-sparse path (do_read,
objects_read_local) still passed -EIO straight back to the client,
failing the application's read.

Call rep_repair_primary_object() from the non-sparse EC direct-read path on
-EIO, as the replicated path does, so it takes the same -EAGAIN bounce,
which the Objecter (and SplitOp) resubmits to the primary without the
direct-read flags. -EAGAIN from do_osd_ops() means the reply has already
been sent, so execute_ctx() just closes the context.

Replicated pools and non-direct EC reads are unchanged. The unit
harness does not reach PrimaryLogPG::do_osd_ops(); the next commit
checks the backend half (objects_read_local() returning -EIO) only.

Fixes: https://tracker.ceph.com/issues/81286
Assisted-by: Claude Code

Signed-off-by: Alex Ainscow <[email protected]>
@JonBailey1993

Copy link
Copy Markdown
Contributor

@ljflores
ljflores merged commit da65b56 into ceph:main Oct 6, 2026
16 checks passed
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 8, 2026
…o the primary

Builds on "osd: rep_repair_primary_object needs to handle direct reads"
(PR ceph#71910), which makes rep_repair_primary_object() fail an EC read
with -EAGAIN instead of asserting, so the sparse path (do_sparse_read)
now bounces an EC direct read that hits -EIO or a full-object crc
mismatch back to the client for a retry at the primary.

An EC direct read only reads the local shard, so it cannot reconstruct
around a medium error. The design (ec_stretch_cluster.rst 7.2 and
direct_reads.rst) requires any such failure to send the client back to
the primary, which can decode from the other shards (in a stretch pool,
from remote-zone shards if need be). The non-sparse path (do_read,
objects_read_local) still passed -EIO straight back to the client,
failing the application's read.

Call rep_repair_primary_object() from the non-sparse EC direct-read path on
-EIO, as the replicated path does, so it takes the same -EAGAIN bounce,
which the Objecter (and SplitOp) resubmits to the primary without the
direct-read flags. -EAGAIN from do_osd_ops() means the reply has already
been sent, so execute_ctx() just closes the context.

Replicated pools and non-direct EC reads are unchanged. The next commit
adds a standalone test that takes this path.

Fixes: https://tracker.ceph.com/issues/81286
Assisted-by: Claude Code

Signed-off-by: Alex Ainscow <[email protected]>
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 12, 2026
…o the primary

Builds on "osd: rep_repair_primary_object needs to handle direct reads"
(PR ceph#71910), which makes rep_repair_primary_object() fail an EC read
with -EAGAIN instead of asserting, so the sparse path (do_sparse_read)
now bounces an EC direct read that hits -EIO or a full-object crc
mismatch back to the client for a retry at the primary.

An EC direct read only reads the local shard, so it cannot reconstruct
around a medium error. The design (ec_stretch_cluster.rst 7.2 and
direct_reads.rst) requires any such failure to send the client back to
the primary, which can decode from the other shards (in a stretch pool,
from remote-zone shards if need be). The non-sparse path (do_read,
objects_read_local) still passed -EIO straight back to the client,
failing the application's read.

Call rep_repair_primary_object() from the non-sparse EC direct-read path on
-EIO, as the replicated path does, so it takes the same -EAGAIN bounce,
which the Objecter (and SplitOp) resubmits to the primary without the
direct-read flags. -EAGAIN from do_osd_ops() means the reply has already
been sent, so execute_ctx() just closes the context.

Replicated pools and non-direct EC reads are unchanged. The next commit
adds a standalone test that takes this path.

Fixes: https://tracker.ceph.com/issues/81286
Assisted-by: Claude Code

Signed-off-by: Alex Ainscow <[email protected]>
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 12, 2026
Follows up Jon Bailey's review comment on
ceph#72383
(ceph#72383 (comment)), which
asked for every OpType to have a case so that a new op fails the build
until this test considers it.

ceph#71910 has since added
OpType::SparseRead to main. With this PR rebased onto main, the make
check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails:
"enumeration value 'SparseRead' not handled in switch". A SparseRead
reads the primary object, so check it like the other reads. No sequence
issues one yet.

To be squashed into "test/osd: demonstrate Seq15 reading while a copy or
truncate is in flight" before merge.

Assisted-by: Claude Code
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 12, 2026
Follows up Jon Bailey's review comment on
ceph#72383
(ceph#72383 (comment)), which
asked for every OpType to have a case so that a new op fails the build
until this test considers it.

ceph#71910 has since added
OpType::SparseRead to main. With this PR rebased onto main, the make
check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails:
"enumeration value 'SparseRead' not handled in switch". A SparseRead
reads the primary object, so check it like the other reads. No sequence
issues one yet.

To be squashed into "test/osd: demonstrate Seq15 reading while a copy or
truncate is in flight" before merge.

Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 14, 2026
…rier test

Follows up Jon Bailey's review comment on
ceph#72383
(ceph#72383 (comment)), which
asked for every OpType to have a case so that a new op fails the build
until this test considers it.

ceph#71910 has since added
OpType::SparseRead to main. With this PR rebased onto main, the make
check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails:
"enumeration value 'SparseRead' not handled in switch". A SparseRead
reads the primary object, so check it like the other reads. No sequence
issues one yet.

To be squashed into "test/osd: demonstrate Seq15 reading while a copy or
truncate is in flight" before merge.

Assisted-by: Claude Code
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 14, 2026
…rier test

Follows up Jon Bailey's review comment on
ceph#72383
(ceph#72383 (comment)), which
asked for every OpType to have a case so that a new op fails the build
until this test considers it.

ceph#71910 has since added
OpType::SparseRead to main. With this PR rebased onto main, the make
check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails:
"enumeration value 'SparseRead' not handled in switch". A SparseRead
reads the primary object, so check it like the other reads. No sequence
issues one yet.

To be squashed into "test/osd: demonstrate Seq15 reading while a copy or
truncate is in flight" before merge.

Assisted-by: Claude Code
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 14, 2026
…rier test

Follows up Jon Bailey's review comment on
ceph#72383
(ceph#72383 (comment)), which
asked for every OpType to have a case so that a new op fails the build
until this test considers it.

ceph#71910 has since added
OpType::SparseRead to main. With this PR rebased onto main, the make
check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails:
"enumeration value 'SparseRead' not handled in switch". A SparseRead
reads the primary object, so check it like the other reads. No sequence
issues one yet.

To be squashed into "test/osd: demonstrate Seq15 reading while a copy or
truncate is in flight" before merge.

Assisted-by: Claude Code
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 14, 2026
…rier test

Follows up Jon Bailey's review comment on
ceph#72383
(ceph#72383 (comment)), which
asked for every OpType to have a case so that a new op fails the build
until this test considers it.

ceph#71910 has since added
OpType::SparseRead to main. With this PR rebased onto main, the make
check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails:
"enumeration value 'SparseRead' not handled in switch". A SparseRead
reads the primary object, so check it like the other reads. No sequence
issues one yet.

To be squashed into "test/osd: demonstrate Seq15 reading while a copy or
truncate is in flight" before merge.

Assisted-by: Claude Code
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 15, 2026
…rier test

Follows up Jon Bailey's review comment on
ceph#72383
(ceph#72383 (comment)), which
asked for every OpType to have a case so that a new op fails the build
until this test considers it.

ceph#71910 has since added
OpType::SparseRead to main. With this PR rebased onto main, the make
check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails:
"enumeration value 'SparseRead' not handled in switch". A SparseRead
reads the primary object, so check it like the other reads. No sequence
issues one yet.

To be squashed into "test/osd: demonstrate Seq15 reading while a copy or
truncate is in flight" before merge.

Assisted-by: Claude Code
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 16, 2026
…rier test

Follows up Jon Bailey's review comment on
ceph#72383
(ceph#72383 (comment)), which
asked for every OpType to have a case so that a new op fails the build
until this test considers it.

ceph#71910 has since added
OpType::SparseRead to main. With this PR rebased onto main, the make
check build (-Werror) of NoReadWhileWholeObjectWriteInFlight fails:
"enumeration value 'SparseRead' not handled in switch". A SparseRead
reads the primary object, so check it like the other reads. No sequence
issues one yet.

To be squashed into "test/osd: demonstrate Seq15 reading while a copy or
truncate is in flight" before merge.

Assisted-by: Claude Code
aainscow added a commit to aainscow/ceph that referenced this pull request Nov 17, 2026
…o the primary

Builds on "osd: rep_repair_primary_object needs to handle direct reads"
(PR ceph#71910), which makes rep_repair_primary_object() fail an EC read
with -EAGAIN instead of asserting, so the sparse path (do_sparse_read)
now bounces an EC direct read that hits -EIO or a full-object crc
mismatch back to the client for a retry at the primary.

An EC direct read only reads the local shard, so it cannot reconstruct
around a medium error. The design (ec_stretch_cluster.rst 7.2 and
direct_reads.rst) requires any such failure to send the client back to
the primary, which can decode from the other shards (in a stretch pool,
from remote-zone shards if need be). The non-sparse path (do_read,
objects_read_local) still passed -EIO straight back to the client,
failing the application's read.

Call rep_repair_primary_object() from the non-sparse EC direct-read path on
-EIO, as the replicated path does, so it takes the same -EAGAIN bounce,
which the Objecter (and SplitOp) resubmits to the primary without the
direct-read flags. -EAGAIN from do_osd_ops() means the reply has already
been sent, so execute_ctx() just closes the context.

Replicated pools and non-direct EC reads are unchanged. The next commit
adds a standalone test that takes this path.

Fixes: https://tracker.ceph.com/issues/81286
Assisted-by: Claude Code

Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit 0f17b4c)
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.

5 participants