Skip to content

osd/PrimaryLogPG: redirect non-sparse EC direct reads that hit -EIO to the primary - #72292

Merged
ljflores merged 3 commits into
ceph:mainfrom
aainscow:wip-ec-direct-read-eio
Oct 21, 2026
Merged

ljflores merged 3 commits into
ceph:mainfrom
aainscow:wip-ec-direct-read-eio

Conversation

@aainscow

@aainscow aainscow commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

An EC direct read, used by balanced and localized reads, reads only the shard on
the OSD it is sent to, so that OSD cannot rebuild the data around a medium error.
The read must be sent back to the primary, which can decode it from the other
shards. For a non-sparse read (CEPH_OSD_OP_READ) this does not happen: the
client gets -EIO, and every retry hits the same bad sector.

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

What goes wrong

In PrimaryLogPG::do_read(), the ec_direct_read() branch calls
ECBackend::objects_read_local(). That returns the object store's -EIO unchanged,
and do_read() passes it straight back as the op result. It does not call
rep_repair_primary_object(), as the replicated branch of the same function does.

The Objecter only resubmits to the primary on -EAGAIN, and SplitOp returns the
first non-EAGAIN error from its sub-reads. So a single direct read and a split
read both fail with -EIO, and the primary is never asked.

This affects any client using read_from_replica balance or localize on an
optimized EC pool, for example librbd with rbd_read_from_replica_policy.

Fix

On -EIO, the non-sparse EC direct-read branch of do_read() now calls
rep_repair_primary_object(), as the replicated path does. With #71910 that
replies -EAGAIN, and the Objecter (or SplitOp) resubmits the read 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; that is
existing behaviour.

Replicated pools and EC reads that are not direct reads are unchanged.

Relationship to #71910

#71910 fixes the sparse-read side: do_sparse_read() calls
rep_repair_primary_object() on -EIO or on a full-object CRC mismatch. That
function asserted the pool was not erasure coded, so a medium error hit by a
localized RBD read aborted the OSD. #71910 replaces the assert with an -EAGAIN
reply whenever the OSD is not the primary or the pool is erasure coded. It does
not touch the non-sparse do_read() path, which this PR fixes. The change here is
three lines, and it relies on #71910's version of rep_repair_primary_object().

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.

Comment thread src/test/osd/TestBackendBasics.cc Resolved
Comment thread src/osd/PrimaryLogPG.cc Resolved
aainscow added a commit to aainscow/ceph that referenced this pull request Oct 8, 2026
…eadEIO

Answers Jon Bailey's review comment on TestBackendBasics.DirectReadEIO
in ceph#72292
(ceph#72292 (comment)): the
test never reaches PrimaryLogPG::do_read(), the code changed by
"osd/PrimaryLogPG: redirect non-sparse EC direct reads that hit -EIO to
the primary", so it passes with or without that change. Remove it.

Add TEST_ec_direct_read_eio to test-erasure-eio.sh, which does go
through do_read(). It sets allow_ec_optimizations on a k=2 m=1 pool,
which gives the pool split_reads, injects a data EIO on shard 1 of a
20 KiB object and reads the whole object with
rados_replica_read_policy=balance. The client splits the read into
direct reads of shards 0 and 1. Without the change, shard 1 returns
-EIO and rados get fails with (5) Input/output error. With it, shard 1
answers -EAGAIN and the client sends the read to the primary, which
decodes around shard 1. The test compares the data and checks for the
EAGAIN line in shard 1's OSD log.

To be squashed into "test/osd: check EC direct reads of a bad local
shard return -EIO for a retry" before merge; the squashed commit then
only adds the standalone test and needs a title and message to match.
The last paragraph of the fix commit's message, which points at the
unit test, needs rewording to match too.

Assisted-by: Claude Code

@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, PR just needs the squashing and commit rewording to be done that the final commit message talks about.

@aainscow
aainscow force-pushed the wip-ec-direct-read-eio branch from 1be4fbf to a47eeae Compare October 8, 2026 15:50
@aainscow

Copy link
Copy Markdown
Contributor Author

Thanks Jon. The squash and rewording are done: the PR is rebased on main (the #71910 commits dropped out as they are merged), the test commits are squashed into 3361f18, and the last paragraph of b21cff5 now points at the standalone test. I've also added a47eeae, a fix to the test_ec_sparse_read_repair_assert.sh workunit from #71910. ceph config set osd osd_pool_default_flag_ec_optimizations true has no effect because only the mon reads that option, and grep -q allow_ec_optimizations also matches "allow_ec_optimizations: false". The workunit only took the direct-read path because the first ceph_test_rados_io_sequence run turns on allow_ec_optimizations for the pool. It now sets the flag on the pool itself and checks for split_reads. Could you take a look at that one?

…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]>
…e primary

Tests "osd/PrimaryLogPG: redirect non-sparse EC direct reads that hit
-EIO to the primary".

Add TEST_ec_direct_read_eio to test-erasure-eio.sh. It sets
allow_ec_optimizations on a k=2 m=1 pool, which gives the pool
split_reads, injects a data EIO on shard 1 of a 20 KiB object and reads
the whole object with rados_replica_read_policy=balance. The client
splits the read into direct reads of shards 0 and 1. Without the fix,
shard 1 returns -EIO and rados get fails with (5) Input/output error.
With it, shard 1 answers -EAGAIN and the client sends the read to the
primary, which decodes around shard 1. The test compares the data and
checks for the EAGAIN line in shard 1's OSD log.

Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
test_ec_sparse_read_repair_assert.sh sets
osd_pool_default_flag_ec_optimizations with `ceph config set osd`, but
only the monitor reads that option, so the pool is created without EC
optimizations. The check `grep -q allow_ec_optimizations` also matches
"allow_ec_optimizations: false". The sparse read only takes the EC
direct read path because the first ceph_test_rados_io_sequence run
enables allow_ec_optimizations on the pool it is given.

Set allow_ec_optimizations on the pool, drop the config option, and
check that the flag is true and that the pool has split_reads before
writing the object.

Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test api

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

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

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@kamoltat

Copy link
Copy Markdown
Member

jenkins test make check

@aainscow
aainscow requested a review from rzarzynski October 20, 2026 09:16
@aainscow
aainscow requested a review from bill-scales October 20, 2026 09:16
@ljflores

Copy link
Copy Markdown
Member

RE: https://github.com/ceph/ceph/actions/runs/39460371609/job/119461156936?pr=72292

Bill has since been added to .githubmap. I think the branch would need to be rebased for the check to pass, but I don't think we need to go through that.

@ljflores
ljflores merged commit 814da6c into ceph:main Oct 21, 2026
25 of 31 checks passed
mmgaggle added a commit to mmgaggle/ceph that referenced this pull request Oct 27, 2026
Since 0f17b4c (ceph#72292), an EC direct read that fails with EIO on
its shard goes back to the client with EAGAIN. The client then sends
the read to the primary, which decodes the data from the other shards.
Only a debug log line shows such a bounce, so a damaged shard that
clients read again and again stays hidden.

Now the shard counts each bounce in the new perf counter
ec_direct_read_redirect_eio, and writes it to the OSD log. The cluster
log gets the 1st, 2nd, 4th, 8th and later bounces of each PG. If fiemap
fails with EIO, a sparse direct read also bounces. A sparse direct read
also skips the whole-object digest check, because the digest does not
cover the chunks of one shard.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
aainscow pushed a commit to mmgaggle/ceph that referenced this pull request Nov 27, 2026
Since 0f17b4c (ceph#72292), an EC direct read that fails with EIO on
its shard goes back to the client with EAGAIN. The client then sends
the read to the primary, which decodes the data from the other shards.
Only a debug log line shows such a bounce, so a damaged shard that
clients read again and again stays hidden.

Now the shard counts each bounce in the new perf counter
ec_direct_read_redirect_eio, and writes it to the OSD log. The cluster
log gets the 1st, 2nd, 4th, 8th and later bounces of each PG. If fiemap
fails with EIO, a sparse direct read also bounces. A sparse direct read
also skips the whole-object digest check, because the digest does not
cover the chunks of one shard.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
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