Skip to content

osd: EC optimizations: changes to rollback to support partial writes - #62497

Merged
ljflores merged 1 commit into
ceph:mainfrom
bill-scales:ec_rollback_changes
Apr 18, 2025
Merged

ljflores merged 1 commit into
ceph:mainfrom
bill-scales:ec_rollback_changes

Conversation

@bill-scales

@bill-scales bill-scales commented Mar 25, 2025 •

Copy link
Copy Markdown
Contributor

Changes to rollback to support optimized EC pools.

Optimized pools do not update all shards the same way, avoiding writing data that has not changed and only storing attribute updates on a subset of shards. Rollback uses a single ObjectModDesc entry in the PG log entry to work out how to undo the changes to a shard. This entry is extended to store extra details about the update so it can work out what
needs to be undo on each shard.

The changes are designed to be backwards compatible, the legacy EC code still updates all shards the same way and needs rollback to perform the same updates to all shards. When optimizations are enabled the PG log may consist of a mixture of log entries written by the legacy and new code.

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

Comment thread src/osd/ECBackend.h Outdated

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: Probably my code... but I think google coding style would have you do this style, rather than break on the bracket.

ReturnType ClassName::ReallyLongFunctionName(Type par_name1, Type par_name2,
                                             Type par_name3) {
  DoSomething();
  ...
}

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.

If this is from ec_optimisations_main, then I have accidentally introduced some formatting like the above by mistake.

Comment thread src/osd/PGBackend.cc Outdated

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: For loops should always have a space after the ";"

Comment thread src/osd/PGBackend.cc Outdated

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: Same again

Comment thread src/osd/PGBackend.h Outdated

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.

Missing const?

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.

No - the function can modify length. The offset and length here are a range within the shard to rollback. The same range is applied to each shard, however for optimized EC pools if the object is not a multiple of stripe_width in size then some of the shards will be smaller than others (because we no longer add padding). In this case it may be necessary to reduce the length to avoid the rollback clone from exceeding the length of the shard.

Comment thread src/osd/osd_types.cc Outdated

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.

Can function be const?

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.

No. I guess this implementation of the Visitor could have const functions because it is just dumping fields to the Formatter, however this isn't performance critical code. The two other implementations of this Vistor (one used for rollback which is also not performance critical code, and one used for trim which is) both contain an ObjectStore::Transaction t in the Vistor class which is modified by rollback_extents (and other functions in the visitor) - these cannot be const

Comment thread src/osd/osd_types.h Outdated

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.

Missing brackets. {}

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 multiple instances of this within ObjectModDesc as this style leads to bugs when code is edited. osd_types.h in general appears to be lacking braces on many of its if's - I won't fix the whole file, only the area of code this PR is changing.

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

Looks sane.

Comment thread src/osd/PGBackend.cc Outdated

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.

OK, most of the members are references, so I'm less worried about introducing new problems with life-time management.

Comment thread src/osd/PGBackend.cc Outdated

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.

Written, non-primary. ACK.

Comment thread src/osd/PGBackend.cc Outdated

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.

Comment thread src/osd/PGBackend.cc Outdated

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.

Comment thread src/osd/PGBackend.cc Outdated

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: spaces within the ternary operator help readability IMHO.

Comment thread src/osd/osd_types.h Outdated

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: bracing. How about

Suggested change
const std::vector<shard_id_set> &shards) {
const std::vector<shard_id_set> &shards)
{

?

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.

Disagree - while I prefer your style the rest of src/osd/osd_types.h is written with the braces on the same line as the function. I think consistency of style in a file is more important, even if this file has a different style to most of the rest of Ceph!

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.

Ouch, sorry for missing that. I agree the spatial consistency is more important.

@bill-scales
bill-scales force-pushed the ec_rollback_changes branch from f79457b to a14d798 Compare March 31, 2025 16:40
@bill-scales

Copy link
Copy Markdown
Contributor Author

New push with fixes for the nits

@github-actions

github-actions Bot commented Apr 2, 2025

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@bill-scales

Copy link
Copy Markdown
Contributor Author

Rebased - no other changes

@bill-scales

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@bill-scales

Copy link
Copy Markdown
Contributor Author

jenkins test api

@bill-scales

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@bill-scales

Copy link
Copy Markdown
Contributor Author

jenkins test api

@aainscow
aainscow self-requested a review April 8, 2025 07:00

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

Only nits and observations. I would not be upset if they were all ignored.

Comment thread src/osd/osd_types.cc
f->dump_stream("log_tail") << log_tail;
f->dump_int("last_user_version", last_user_version);
f->dump_stream("last_backfill") << last_backfill;
f->open_array_section("partial_writes_last_complete");

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/comment: Recently added "with_array_section" in Formatter.h does this slightly more concisely:

  f->with_obj_array_section(
      "partial_writes_last_complete"sv, partial_writes_last_complete,
      [](Formatter& f, const shard_id_t& shard, const version_range_type& v) {
          auto & [from, to] = versionrange;
          f->dump_int("id", int(shard));
          f->dump_stream("from") << from;
          f->dump_stream("to") << to;
      });

Maybe not worth refactoring, but its nice to know about it.

Comment thread src/osd/osd_types.h Outdated

interval_set<snapid_t> purged_snaps;

std::map<shard_id_t,std::pair<eversion_t,eversion_t>> partial_writes_last_complete; ///< last_complete for shards not modified by a partial write

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: Line width.

Comment thread src/osd/osd_types.h
eversion_t last_update;
eversion_t last_complete;
version_t last_user_version;
std::map<shard_id_t,std::pair<eversion_t,eversion_t>> partial_writes_last_complete;

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.

Why not shard_id_map ?

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.

.. because mini_flat_map does not have encode/decode. Worth adding? We would not see the same encode/decode gains that we did in bitset_set.

Comment thread src/osd/osd_types.h
f->dump_stream("last_update") << last_update;
f->dump_stream("last_complete") << last_complete;
f->dump_stream("last_user_version") << last_user_version;
f->open_array_section("partial_writes_last_complete");

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.

See above comment about new Formatter

@bill-scales

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@bill-scales

Copy link
Copy Markdown
Contributor Author

jenkins test api

@github-actions

github-actions Bot commented Apr 9, 2025

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

EC Pools create an ObjectModDesc entry in each log entry that describes
how to undo the modifcation. During peering if it is determined that
only some of the shards completed an update then these shards are
instructed to rollback the change. This ensures that each update
is either applied to all or none of the shards.

For EC optimized pools rollback becomes a bit more complicated.
Firstly because not all shards may have been updated the rollback
needs to be more selective in what is undone. Secondly optimized
pools do not pad objects to be a multiple of the stripe width
which means shards can be different sizes.

There is a single ObjectModDesc entry that contains a set of
operations applied by every shard, individial operations need
to include enough information to work out what has to be undone
on each shard.

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

Copy link
Copy Markdown
Contributor Author

Rebased now that 62451 has merged, no other changes

@bill-scales

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@aainscow aainscow mentioned this pull request Apr 11, 2025
4 of 14 tasks
@kamoltat

Copy link
Copy Markdown
Member

@ljflores

Copy link
Copy Markdown
Member

@ljflores
ljflores merged commit ac8d74a into ceph:main Apr 18, 2025
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