Skip to content

EC Direct Reads: First PR, background work - #65771

Merged
aainscow merged 15 commits into
ceph:mainfrom
aainscow:ec_direct_reads_pr_1
Nov 27, 2025
Merged

aainscow merged 15 commits into
ceph:mainfrom
aainscow:ec_direct_reads_pr_1

Conversation

@aainscow

@aainscow aainscow commented Oct 3, 2025 •

Copy link
Copy Markdown
Contributor

This PR provides a significant amount of refactoring and preparation work for the up coming EC Direct Reads.

The main tasks are:

  1. Pool level flags and switches to enable the code.
  2. Code to remove balanced read flag from legacy clients.
  3. Introduce sparse reads for EC
  4. Introduce sync reads for EC
  5. Refactor _calc_target to remove unnecessary parameter
  6. Add force_shard in target.

This should have no functional changes.

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/osd/PrimaryLogPG.cc Resolved
Comment thread src/mon/OSDMonitor.cc Resolved
@aainscow
aainscow force-pushed the ec_direct_reads_pr_1 branch from a57b81c to 152f439 Compare October 13, 2025 12:22
@aainscow
aainscow force-pushed the ec_direct_reads_pr_1 branch from 152f439 to de7f3f4 Compare October 13, 2025 12:42
@aainscow aainscow added needs-qa no-backport-required Label that can be optionally added to show that we do not need to backport. labels Oct 13, 2025
@aainscow
aainscow force-pushed the ec_direct_reads_pr_1 branch 2 times, most recently from 2f2a811 to 256b76c Compare October 14, 2025 08:26
@aainscow

Copy link
Copy Markdown
Contributor Author

Latest push to remove accidental commit to a submodule.

@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

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

Few minor comments plus one bug - SplitOp is broken when EC has an acting set with the same OSD representing more than one shard

Comment thread src/osd/PG.cc Resolved
Comment thread src/include/rados.h Resolved
Comment thread src/osd/ECBackend.cc Resolved
Comment thread src/osd/PrimaryLogPG.cc Resolved
Comment thread src/osdc/SplitOp.cc Resolved
Comment thread src/osdc/SplitOp.cc Resolved
Comment thread src/osdc/SplitOp.cc Resolved
@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test api

@shraddhaag

Copy link
Copy Markdown
Contributor

Hey folks, I was reviewing the QA run which contains this PR, https://tracker.ceph.com/issues/73579, and found an error which might be related to this PR:

Error in scrape.log: https://qa-proxy.ceph.com/teuthology/skanta-2025-10-30_09:05:41-rados-wip-bharath2-testing-2025-10-29-2053-distro-default-smithi/scrape.log

Failure: Command failed (workunit test erasure-code/test-erasure-code.sh) on smithi190 with status 1: 'mkdir -p -- /home/ubuntu/cephtest/mnt.0/client.0/tmp && cd -- /home/ubuntu/cephtest/mnt.0/client.0/tmp && CEPH_CLI_TEST_DUP_COMMAND=1 CEPH_REF=ed8330e9becbc0532ab9f441d46db0faf885f0dc TESTDIR="/home/ubuntu/cephtest" CEPH_ARGS="--cluster ceph" CEPH_ID="0" PATH=$PATH:/usr/sbin CEPH_BASE=/home/ubuntu/cephtest/clone.client.0 CEPH_ROOT=/home/ubuntu/cephtest/clone.client.0 CEPH_MNT=/home/ubuntu/cephtest/mnt.0 adjust-ulimits ceph-coverage /home/ubuntu/cephtest/archive/coverage timeout 3h /home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh'
1 jobs: ['8576470']
suites: ['rados/standalone/{supported-random-distro$/{ubuntu_latest}', 'workloads/erasure-code}']

Error in teuthology.log:

2025-10-30T09:56:38.961 INFO:tasks.workunit.client.0.smithi190.stderr:///home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:255: chunk_size:  local ec_opt=false
2025-10-30T09:56:38.961 INFO:tasks.workunit.client.0.smithi190.stderr:///home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:256: chunk_size:  '[' false = true ']'
2025-10-30T09:56:38.961 INFO:tasks.workunit.client.0.smithi190.stderr:///home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:259: chunk_size:  chunk_size=4096
2025-10-30T09:56:38.961 INFO:tasks.workunit.client.0.smithi190.stderr:///home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:262: chunk_size:  echo 4096
2025-10-30T09:56:38.961 INFO:tasks.workunit.client.0.smithi190.stderr://home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:295: verify_chunk_mapping:  printf '%*s' 4096 SECONDremap-pool
2025-10-30T09:56:38.962 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:295: verify_chunk_mapping:  local 'payload=                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 FIRSTremap-pool                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                SECONDremap-pool'
2025-10-30T09:56:38.962 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:296: verify_chunk_mapping:  echo -n '                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 FIRSTremap-pool                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                SECONDremap-pool'
2025-10-30T09:56:38.962 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:298: verify_chunk_mapping:  rados --pool remap-pool put SOMETHINGremap-pool td/test-erasure-code/ORIGINAL
2025-10-30T10:01:38.990 INFO:tasks.workunit.client.0.smithi190.stderr:failed to fetch mon config (--no-mon-config to skip)
2025-10-30T10:01:38.992 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:298: verify_chunk_mapping:  return 1
2025-10-30T10:01:38.992 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:336: TEST_chunk_mapping:  return 1
2025-10-30T10:01:38.993 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:48: run:  return 1
2025-10-30T10:01:38.993 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/ceph-helpers.sh:2403: main:  code=1

Could you please check if this is related to the PR?

@aainscow

aainscow commented Nov 7, 2025

Copy link
Copy Markdown
Contributor Author

Test failure was due to #65940 Nothing to do with this PR.

@SrinivasaBharath Can you makes sure this is in the re-runs?

Cheers

Hey folks, I was reviewing the QA run which contains this PR, https://tracker.ceph.com/issues/73579, and found an error which might be related to this PR:

Error in scrape.log: https://qa-proxy.ceph.com/teuthology/skanta-2025-10-30_09:05:41-rados-wip-bharath2-testing-2025-10-29-2053-distro-default-smithi/scrape.log

Failure: Command failed (workunit test erasure-code/test-erasure-code.sh) on smithi190 with status 1: 'mkdir -p -- /home/ubuntu/cephtest/mnt.0/client.0/tmp && cd -- /home/ubuntu/cephtest/mnt.0/client.0/tmp && CEPH_CLI_TEST_DUP_COMMAND=1 CEPH_REF=ed8330e9becbc0532ab9f441d46db0faf885f0dc TESTDIR="/home/ubuntu/cephtest" CEPH_ARGS="--cluster ceph" CEPH_ID="0" PATH=$PATH:/usr/sbin CEPH_BASE=/home/ubuntu/cephtest/clone.client.0 CEPH_ROOT=/home/ubuntu/cephtest/clone.client.0 CEPH_MNT=/home/ubuntu/cephtest/mnt.0 adjust-ulimits ceph-coverage /home/ubuntu/cephtest/archive/coverage timeout 3h /home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh'
1 jobs: ['8576470']
suites: ['rados/standalone/{supported-random-distro$/{ubuntu_latest}', 'workloads/erasure-code}']

Error in teuthology.log:

2025-10-30T09:56:38.961 INFO:tasks.workunit.client.0.smithi190.stderr:///home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:255: chunk_size:  local ec_opt=false
2025-10-30T09:56:38.961 INFO:tasks.workunit.client.0.smithi190.stderr:///home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:256: chunk_size:  '[' false = true ']'
2025-10-30T09:56:38.961 INFO:tasks.workunit.client.0.smithi190.stderr:///home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:259: chunk_size:  chunk_size=4096
2025-10-30T09:56:38.961 INFO:tasks.workunit.client.0.smithi190.stderr:///home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:262: chunk_size:  echo 4096
2025-10-30T09:56:38.961 INFO:tasks.workunit.client.0.smithi190.stderr://home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:295: verify_chunk_mapping:  printf '%*s' 4096 SECONDremap-pool
2025-10-30T09:56:38.962 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:295: verify_chunk_mapping:  local 'payload=                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 FIRSTremap-pool                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                SECONDremap-pool'
2025-10-30T09:56:38.962 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:296: verify_chunk_mapping:  echo -n '                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 FIRSTremap-pool                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                SECONDremap-pool'
2025-10-30T09:56:38.962 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:298: verify_chunk_mapping:  rados --pool remap-pool put SOMETHINGremap-pool td/test-erasure-code/ORIGINAL
2025-10-30T10:01:38.990 INFO:tasks.workunit.client.0.smithi190.stderr:failed to fetch mon config (--no-mon-config to skip)
2025-10-30T10:01:38.992 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:298: verify_chunk_mapping:  return 1
2025-10-30T10:01:38.992 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:336: TEST_chunk_mapping:  return 1
2025-10-30T10:01:38.993 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/erasure-code/test-erasure-code.sh:48: run:  return 1
2025-10-30T10:01:38.993 INFO:tasks.workunit.client.0.smithi190.stderr:/home/ubuntu/cephtest/clone.client.0/qa/standalone/ceph-helpers.sh:2403: main:  code=1

Could you please check if this is related to the PR?

@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test api

@aainscow
aainscow force-pushed the ec_direct_reads_pr_1 branch from 218f35b to 4b7c559 Compare November 17, 2025 15:07

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

Review-in-progress. Looks good so far. The nits can be addressed as a follow-up.

Comment thread src/mon/OSDMonitor.cc
@@ -8451,6 +8453,29 @@ int OSDMonitor::enable_pool_ec_optimizations(pg_pool_t &p,
return 0;
}

void OSDMonitor::enable_pool_ec_direct_reads(pg_pool_t &p) {
if (p.is_erasure()) {

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: an early exit would be more readable (reader doesn't need to keep in mind the possibility of else); saving one indentation would also reduce visual clutter.

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 locally, ready for next PR.

Comment thread src/osd/osd_types.h Resolved
Comment thread src/osd/ECUtil.h Resolved
Comment thread src/include/rados.h Resolved
Comment thread src/osd/PG.cc Resolved
Comment thread src/osd/PrimaryLogPG.cc
@@ -2047,16 +2047,22 @@ void PrimaryLogPG::do_op(OpRequestRef& op)
}

// check for op with rwordered and rebalance or localize reads
if ((m->has_flag(CEPH_OSD_FLAG_BALANCE_READS) || m->has_flag(CEPH_OSD_FLAG_LOCALIZE_READS)) &&
op->rwordered()) {
if (m->has_flag(CEPH_OSD_FLAGS_DIRECT_READ) && op->rwordered()) {

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.

Yeah, the macro helps. My only concern is CEPH_OSD_FLAGS_DIRECT_READ is (too?) similar to CEPH_OSD_FLAG_EC_DIRECT_READ.

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.

Fair point. I will try to come up with something better... NON-PRIMARY read doesn't work, because EC has special cases of "direct reads" to the primary.

Comment thread src/osd/PrimaryLogPG.cc
if ((m->get_flags() & (CEPH_OSD_FLAG_BALANCE_READS |
CEPH_OSD_FLAG_LOCALIZE_READS)) &&
if (m->get_flags() & CEPH_OSD_FLAG_EC_DIRECT_READ) {
if (is_primary() || is_nonprimary()) {

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.

This is confusing and makes the condition look like always true. A comment would be helpful.

  /// acting osd that is not the primary
  bool is_nonprimary() const {
    return role >= 0 && pg_whoami != primary;
  }
  /// primary osd
  bool is_primary() const {
    return pg_whoami == primary;
  }

Comment thread src/osd/PeeringState.cc
{
ceph_assert(!is_primary());
std::string_view storage_object = "replica";
if (pool.info.is_erasure()) {
storage_object = "shard";

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.

Suggested change
storage_object = "shard";
const auto storage_object = pool.info.is_erasure() ? "shard"sv : "replica"sv;

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.

Yes, I debated putting in this code as you say, but it did not result in any faster code from what I could tell by reading around. I went for this because it looks more conventional (and therefore more readable).

However, given you are the second person to query this, I think its probably better to change it to the more obviously efficient variant.

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 would argue that the performance isn't so important unless a profiller says it is ;-).

My comment is purely about human readability. I think the crux is in const, which reduces the number of moving parts I need to track in my mind – const means can I delegate out the checking no-modifications of this part-of-state to a compiler.

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 locally, will be in next PR

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

Went through all commits. Generally LGTM; just a bunch of questions and nits.

Comment thread src/osd/ECBackend.cc
@@ -281,6 +281,7 @@ bool ECBackend::_handle_message(
reply->min_epoch = get_parent()->get_interval_start_epoch();
handle_sub_read(op->op.from, op->op, &(reply->op), _op->pg_trace);
reply->trace = _op->pg_trace;
reply->pgid.reset_shard(op->op.from.shard);

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.

ACK. As directs reads become possible only after all OSDs are at U, there is no worry about compatibility.

Comment thread src/osd/ECBackend.cc
}

if (get_parent()->get_local_missing().is_missing(hoid)) {
return -EIO; // Permission denied (cos its missing)

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.

How a client is going to behave in that case? Will it fallback to reading-through-primary?

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.

This is wrong.

This should be -EAGAIN. You cannot do that here due to a quirk of PrimaryLogPG, which would discard the op if this function returned -EAGAIN. The missing detection should be in PrimaryLogPG before it gets to the EC sync read calls.

It worked in this version, because any failure gets failed up to split ops, which retries the IO. I want to clean this up and optimised to use the original op if no splitting is required.

TL;DR: This is being fixed in next PR.

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.

This code is never called unless the split ops flag is enabled, so its safe to merge.

Comment thread src/osd/ECBackend.cc
uint32_t op_flags,
ceph::buffer::list *bl) {
if (get_parent()->get_local_missing().is_missing(hoid)) {
return -EACCES; // Permission denied (cos its missing)

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.

Same question as above.

Also, isn't mixing EIO / EACCESS confusing?

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.

Same answer as before ;-)

Comment thread src/osd/PrimaryLogPG.cc
soid, op.extent.offset, op.extent.length, op.flags, &osd_op.outdata);

dout(20) << " EC sync read for " << soid << " result=" << result << dendl;
} else {
ctx->pending_async_reads.push_back(

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: indentation.

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.

Refactoring this code in next PR.

Comment thread src/osd/PrimaryLogPG.cc
@@ -6000,6 +6009,7 @@ int PrimaryLogPG::do_sparse_read(OpContext *ctx, OSDOp& osd_op) {
r = rep_repair_primary_object(soid, ctx);
}
if (r < 0) {
dout(10) << " sparse_read failed r=" << r << " from object " << soid << dendl;

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.

Just to the record: I was looking how the new objects_readv_sync() is triggered. The answer is: just above PGBackend::objects_readv_sync() is called already:

    bufferlist data_bl;
    r = pgbackend->objects_readv_sync(soid, m, op.flags, &data_bl);
    if (r == -EIO) {
      r = rep_repair_primary_object(soid, ctx);
    }

ECSwitch overloads the stub of PGBackend:

   virtual int objects_readv_sync(
     const hobject_t &hoid,
     std::map<uint64_t, uint64_t>& m,
     uint32_t op_flags,
     ceph::buffer::list *bl) {
     return -EOPNOTSUPP;
   }

Comment thread src/osdc/SplitOp.h Resolved
Comment thread src/osdc/SplitOp.cc

// Reject if direct reads not supported by profile.
if (!pi->has_flag(pg_pool_t::FLAG_CLIENT_SPLIT_READS)) {
ldout(cct, DBG_LVL) << __func__ <<" REJECT: split reads off" << dendl;

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.

Not sure we want to keep everything at 20 but fine for now.

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.

This is to allow me to switch everything to LVL 0 to just get split ops debug in the client debug, without having to filter it.

I will review it later, when code is stable.

Comment thread src/osdc/SplitOp.cc
}

if (split_read->abort) {
ldout(cct, DBG_LVL) << __func__ <<" ABORTED 1" << dendl;return false;

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.

Ditto.

Comment thread src/osdc/SplitOp.cc
}

if (split_read->abort) {
ldout(cct, DBG_LVL) << __func__ <<" ABORTED 2" << dendl;

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.

Ditto.

Comment thread src/osdc/SplitOp.cc

// This may not actually be the primary, but since all shards are kept current
// in replica, it does not actually matter which we choose here. Choose 0 since
// there will always be a read to this shard.

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.

Hmm, what about creating load asymmetry?

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.

I will address in comment, but I don't think it will create significant asymmetry.

The shard that we will pick here is that chosen by calc_target for replica balanced reads. i.e. it should be well balanced.

I do plan on refactoring the code to change the name of this field to be something other than "primary_shard". Perhaps "reference_shard" is good... with a note that reference shard is always primary on EC.

…ead"

These flags will currently behave as follows:

1. The pool flag is never set, unless by a user with the osd_pool_default_flags
   config option.
2. The pool flag will be removed for EC pools where the plugin does not support
   direct reads.
3. Replica pools will never remove the flag.

The intention is to eventually invert this logic and allow split IOs upon
upgrade to Umberella in this same function.

Signed-off-by: Alex Ainscow <[email protected]>
The old chunk_aligned_shard_offset_to_ro_offset was not only unused, it
didn't actually have the correct logic. We replace it here with similar,
but more useful function that will be used in sparse reads for EC

Signed-off-by: Alex Ainscow <[email protected]>
This is in preperation for supporting sparse and sync reads in EC.
Such ops will only be supported for "balance reads".

Signed-off-by: Alex Ainscow <[email protected]>
The can_serve_replica_read() function is called by replica to determine whether there are
any uncommitted writes.  If such writes exist, then the system will reject the IO to avoid
the risk of reading data from a write which may yet be rolled back.

The same code is going to be useful for EC direct reads.

The string_view code is not expensive.

Signed-off-by: Alex Ainscow <[email protected]>
This was not necessary prior to direct reads, but is essential when the
client needs to know which shard the read came from.

Signed-off-by: Alex Ainscow <[email protected]>
This allows a backend to expose how an object offset/length translates to
an offset/length on a particular shard.

For Replica, this is trivial.

For EC, this means looking up the start and end offsets, then translating
this to shard address space.

Signed-off-by: Alex Ainscow <[email protected]>
Sparse reads for EC are simple to implement, as the code is essentially
identical to that of replica, with some address translation.

When doing a direct read in EC, only a single OSD is involved and
that OSD, by definition is the only OSD involved. As such we can
do the more performant sync read, rather than async read.

Signed-off-by: Alex Ainscow <[email protected]>
This function is necessary for balanced reads and as such is required for EC too.

Rename the function to make sense, given this change of purpose, but the
functionality does not change.

Signed-off-by: Alex Ainscow <[email protected]>
For direct read failures, the locking is such that we cannot
immediately send a new IO without deadlocking. This new interface
allows an op to be sent as an asio post.

Signed-off-by: Alex Ainscow <[email protected]>
This parameter is not used by the _calc_target code.  It is being
removed just to clean up the code, as we are making some changes
to _calc_target in later stages of the split io PR.

Signed-off-by: Alex Ainscow <[email protected]>
The functionality is not altered by this commit.

In the future we want to post-process split-ios after
recombining the read data.

Signed-off-by: Alex Ainscow <[email protected]>
…r shard

This will eventually be used by SplitIo to direct ops to the correct OSD.

Signed-off-by: Alex Ainscow <[email protected]>
…it op

When spliting ops, certain addition sub ops (e.g. get xattr) can be simply passed
through to the child op.

Signed-off-by: Alex Ainscow <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
This will provide the ability for Objecter to split up
certain ops and distribute them to the OSDs directly if
that provides a preformance advantage.

This is experimental code and is switched off unless the
magic pool flags are enabled. These magic pool flags were
pushed in an earlier commit in the same PR.

Signed-off-by: Alex Ainscow <[email protected]>
@aainscow
aainscow force-pushed the ec_direct_reads_pr_1 branch from 4b7c559 to d0724a2 Compare November 26, 2025 11:28
@aainscow

Copy link
Copy Markdown
Contributor Author

Added copyright statements. No code changes in latest merge.

@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@rzarzynski

Copy link
Copy Markdown
Contributor

jenkins test make check

4 similar comments
@bill-scales

Copy link
Copy Markdown
Contributor

jenkins test make check

@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@aainscow

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@aainscow
aainscow merged commit 2053c2e into ceph:main Nov 27, 2025
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/19749750381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build/ops core crimson mon no-backport-required Label that can be optionally added to show that we do not need to backport. performance TESTED tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants