Skip to content

crimson/os/seastore: propagate the backref changes about extents remapping to Cache during prepare_record - #59775

Closed
zhscn wants to merge 1 commit into
ceph:mainfrom
zhscn:wip-propagate-remap-changes
Closed

zhscn wants to merge 1 commit into
ceph:mainfrom
zhscn:wip-propagate-remap-changes

Conversation

@zhscn

@zhscn zhscn commented Sep 13, 2024 •

Copy link
Copy Markdown
Member

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
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@zhscn
zhscn requested a review from a team as a code owner September 13, 2024 08:10
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Nov 12, 2024
@cyx1231st

Copy link
Copy Markdown
Member

As discussed, IIRC the specific issue was that reclaiming segments are including segments which still have pending writes.

So it might be simper to exclude those segments until writes are really committed.

@zhscn

zhscn commented Nov 13, 2024 •

Copy link
Copy Markdown
Member Author

exclude those segments until writes are really committed.

Sorry, I forgot to provide feedback on this design. It's tricky to manage all concurrent transactions writing to a specific segment, so that the segment state can only be set to "committed"(could be reclaimed by gc process) after all transactions have finished(at the end of Cache::complete_commit()). This indicates that the transaction should hold the reference counter for the writing segment and update the segment state when the counter decreases to zero.

Is there anything I missed?

@github-actions github-actions Bot removed the stale label Nov 13, 2024
@cyx1231st

Copy link
Copy Markdown
Member

This indicates that the transaction should hold the reference counter for the writing segment and update the segment state when the counter decreases to zero.

Probably possible to be handled at more general SegmentAllocator level:

  1. In SegmentAllocator::close_segment(), segment-provider will mark the segment as closed, and no further writes will be possible after that.
  2. In SegmentAllocator::write(), each write knows when it is started and finished to a specific segment

I think the information is sufficient above to set a segment state from closed to committed, right?

@zhscn

zhscn commented Nov 13, 2024

Copy link
Copy Markdown
Member Author
  • In SegmentAllocator::write(), each write knows when it is started and finished to a specific segment

Probably not enough, at this point, the gc transaction can't retrieve the backref changes about this write.

@zhscn

zhscn commented Nov 13, 2024 •

Copy link
Copy Markdown
Member Author

Here is a simplified model:

drawio

  1. segment is open, gc trans won't select it;
  2. segment is closed, gc trans is possible to select it to reclaim, but the backref changes are not committed to cache.
  3. similar to case 2;
  4. segment is safe to reclaim.

0713e29 propagates the remapped backref changes to cache in Cache::prepare_record, so gc is safe to start at point 3.

711a05c checks the to be reclaimed range in Cache::prepare_record so it's possible to invalidate the gc transaction started at point 2.

@cyx1231st

Copy link
Copy Markdown
Member

Yeah, it should be handled atomically with Cache::complete_commit(). If implemented in SegmentAllocator, it makes the segment available for reclaim unatomically before this point -- they are not guaranteed to be in the same continuation.

@cyx1231st

Copy link
Copy Markdown
Member

For the graph, IIUC writing the record will be started after "prepare record".

@zhscn

zhscn commented Nov 13, 2024 •

Copy link
Copy Markdown
Member Author

For the graph, IIUC writing the record will be started after "prepare record".

Oh, it should be "OOL write". Seems journal segment doesn't have similar issue.

@zhscn

zhscn commented Nov 13, 2024

Copy link
Copy Markdown
Member Author

I'm not sure if there is a more elegant way to handle the gc trans started at point 2, the solution of manually invalidate transaction in this PR looks ugly.

@cyx1231st

cyx1231st commented Nov 13, 2024 •

Copy link
Copy Markdown
Member

0713e29 propagates the remapped backref changes to cache in Cache::prepare_record, so gc is safe to start at point 3.

711a05c checks the to be reclaimed range in Cache::prepare_record so it's possible to invalidate the gc transaction started at point 2.

Refering to #59367, I think it means OOL writes will be allowed be completed after "prepare record" (OOL writes will still be started before "prepare record"), before "record write", and before "complete commit". So without #59775 (comment), the same problem will still be possible, right?

… Cache during prepare_record

Signed-off-by: Zhang Song <[email protected]>
@zhscn
zhscn force-pushed the wip-propagate-remap-changes branch from 5f940b4 to 33b8fa0 Compare November 13, 2024 07:46
@zhscn zhscn changed the title crimson/os/seastore: ensure gc transaction could retrieve the latest changes from Cache crimson/os/seastore: propagate the backref changes about extents remapping to Cache during prepare_record Nov 13, 2024

@cyx1231st cyx1231st left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry about the delay. It's reasonable to me to adjust when backref_entry_mset should be updated.

// entries to ensure the gc transaction could retrieve the latest
// changes. These entries are merged into backref_entryrefs_by_seq
// in Cache::complete_commit
backref_entryrefs_by_trans_id_t backref_entryrefs_by_trans_id;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can it be moved into Transaction?

So there is no need to maintain a separate map.

if (iter != backref_entryrefs_by_trans_id.end()) {
auto &cached_refs = iter->second;
for (backref_entry_ref &e : cached_refs) {
e->seq = seq;

@cyx1231st cyx1231st Nov 22, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where is backref_entry_t::seq being used? The information is already in backref_entryrefs_by_seq.

If no user, probably dropping it is simpler?

i->cast<LogicalCachedExtent>()->get_laddr(),
i->get_length(),
i->get_type(),
start_seq));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it reasonable to stick backref_list to where the extent is added/removed during committing a transaction?

See where add_extent() and commit_retire_extent() are called.

Seems to me they are correlated about when an extent should be visible or not.

extent->get_type());
}

// propagate remapped changes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is about retiring, not only about the remapped changes.

So the method name prepare_remapped_backref_entryrefs() and related comments to claim that it is only for remapping doesn't look correct to me.

L_ADDR_NULL,
extent->get_length(),
extent->get_type(),
JOURNAL_SEQ_NULL)); // will update in complete_commit

@cyx1231st cyx1231st Nov 22, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's take the chance to introduce helper methods create_alloc/retire_backref_mapped_entry(extent).

@github-actions

Copy link
Copy Markdown

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

@cyx1231st

Copy link
Copy Markdown
Member

I'll work with @zhscn to address the reviews.

@cyx1231st

cyx1231st commented Dec 23, 2024 •

Copy link
Copy Markdown
Member

This PR is mostly converted into 58f7b6e in #61144

@zhscn I added you to Signed-off-by there, please let me know if there are any concerns.

@cyx1231st cyx1231st closed this Dec 23, 2024
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.

2 participants