Skip to content

crimson/osd.cc: crimson support SnapMapper::Scrubber - #57491

Closed
guojidan wants to merge 3 commits into
ceph:mainfrom
guojidan:scrubber
Closed

guojidan wants to merge 3 commits into
ceph:mainfrom
guojidan:scrubber

Conversation

@guojidan

@guojidan guojidan commented May 16, 2024 •

Copy link
Copy Markdown
Contributor

fixes: https://tracker.ceph.com/issues/65478
fixes: https://tracker.ceph.com/issues/69626
fixes: https://tracker.ceph.com/issues/71705

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

@guojidan
guojidan requested review from a team as code owners May 16, 2024 01:37
@guojidan
guojidan force-pushed the scrubber branch 6 times, most recently from f2619dd to cb61103 Compare May 16, 2024 09:29
@guojidan

guojidan commented Jun 5, 2024

Copy link
Copy Markdown
Contributor Author

hi @Matan-B @athanatos , please review this PR if you have free time 😃

@Matan-B
Matan-B self-requested a review June 9, 2024 09:48
@athanatos

Copy link
Copy Markdown
Contributor

@guojidan Apologies for the delay -- I'll try to get to this next week.

@athanatos athanatos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd like to avoid creating as much crimson-specific implementation as this PR has. I think it should be possible to use a seastar::async environment to wrap the call to the normal ::run(). Additionally, I think @Matan-B added some testing support for this in classic. I'd like to see that extended to crimson as part of this PR so that we get test coverage in our normal integration test runs.

Comment thread src/crimson/osd/pg.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.

I really don't want to "on_active_actmap()" when we aren't activating a map.

Comment thread src/crimson/osd/osd.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.

This needs to be run in a seastar::async context. As written, I think it will simply crash.

Comment thread src/crimson/osd/osd.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.

This should probably be conditional on a config option. Does classic actually do this unconditionally?

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, but it is not unconditional, it will compute the time interval in the method deep_scrub_purged_snaps.

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.

Classic is calling this based on:

    if (next < ceph_clock_now()) {
      dout(20) << __func__ << " last_purged_snaps_scrub " << last
	       << " next " << next << " ... now" << dendl;
      scrub_purged_snaps();

If you would prefer to call this unconditionally here, a suitable name would probably be maybe_deep_scrub_purged_snaps

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.

It makes sense. Mainly, I don't want to place the logical judgment of whether to execute scrub in the tick_timer.

Comment thread src/osd/SnapMapper.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.

The OSDriver variant for WITH_SEASTAR uses green_get() to suspend a green thread within a seastar::async environment to avoid needing to do as large a rewrite as you have done here. Can we do that here as well? I'm not worried about the performance cost of the extra stack swaps for SnapMapper::Scrubber if it allows us to avoid adding more code as it's purely a debug interface.

@guojidan

guojidan commented Jul 2, 2024

Copy link
Copy Markdown
Contributor Author

I'd like to avoid creating as much crimson-specific implementation as this PR has. I think it should be possible to use a seastar::async environment to wrap the call to the normal ::run(). Additionally, I think @Matan-B added some testing support for this in classic. I'd like to see that extended to crimson as part of this PR so that we get test coverage in our normal integration test runs.

OK,I will re-implement.

@guojidan
guojidan marked this pull request as draft August 5, 2024 07:54
@github-actions

github-actions Bot commented Aug 7, 2024

Copy link
Copy Markdown

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

@guojidan

Copy link
Copy Markdown
Contributor Author

I think @Matan-B added some testing support for this in classic. I'd like to see that extended to crimson as part of this PR so that we get test coverage in our normal integration test runs.

hi @Matan-B ,do you known where the test case file is, I can't find it. 😢

@Matan-B Matan-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think @Matan-B added some testing support for this in classic. I'd like to see that extended to crimson as part of this PR so that we get test coverage in our normal integration test runs.

hi @Matan-B ,do you known where the test case file is, I can't find it. 😢

The testing added was chance_reset_purged_snaps_last in ceph_manager.py (thrash tests).
See: #53579
SnapMapper::Scrubber used PSN keys to perform scrubbing. Once those keys are missing from the OSD, reset_purged_snaps_last was introduced to re-create them.

If you would like to test SnapMapper::Scrubber actual trimming you can try:

  1. Create clone object
  2. Leak the clone object
  3. call scrub_purged_snaps

See: https://gist.github.com/Matan-B/83157a6119587eadbf9998f960827cef for similar reproducer. ("Omit OSD purged_snaps keys" is not relevant here - you can skip it).


I think it should be possible to use a seastar::async environment to wrap the call to the normal ::run()

I agree with Sam's comment above, we should try re-using common (Classic/Crimson) SnapMapper logic as much as possible.
See #58868 for similar common usage.

@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 Dec 12, 2024
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions Bot closed this Jan 11, 2025
@tchaikov tchaikov reopened this Jan 12, 2025
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@github-actions github-actions Bot removed the stale label Jan 12, 2025
@guojidan

guojidan commented Jan 23, 2025 •

Copy link
Copy Markdown
Contributor Author

I think @Matan-B added some testing support for this in classic. I'd like to see that extended to crimson as part of this PR so that we get test coverage in our normal integration test runs.

hi @Matan-B ,do you known where the test case file is, I can't find it. 😢

The testing added was chance_reset_purged_snaps_last in ceph_manager.py (thrash tests). See: #53579 SnapMapper::Scrubber used PSN keys to perform scrubbing. Once those keys are missing from the OSD, reset_purged_snaps_last was introduced to re-create them.

If you would like to test SnapMapper::Scrubber actual trimming you can try:

1. Create clone object

2. Leak the clone object

3. call scrub_purged_snaps

See: https://gist.github.com/Matan-B/83157a6119587eadbf9998f960827cef for similar reproducer. ("Omit OSD purged_snaps keys" is not relevant here - you can skip it).

I think it should be possible to use a seastar::async environment to wrap the call to the normal ::run()

I agree with Sam's comment above, we should try re-using common (Classic/Crimson) SnapMapper logic as much as possible. See #58868 for similar common usage.

thank you for your reply, but ceph-kvstore-tools do not support crimson yet, i am looking for another way to test this pr

@Matan-B

Matan-B commented Jan 23, 2025 •

Copy link
Copy Markdown
Contributor

thank you for your reply, but ceph-kvstore-tools do not support crimson yet, i am looking for another way to test this pr

Ah, perhaps it's time to support offline tools for Crimson. I'll follow up with a tracker.

https://tracker.ceph.com/issues/69640

@github-actions

github-actions Bot commented Apr 3, 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

@github-actions github-actions Bot removed the stale label Apr 3, 2025
@Matan-B Matan-B moved this from In Progress to Unassigned in Crimson May 12, 2025
@github-actions

github-actions Bot commented Jun 2, 2025

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 Jun 2, 2025
@Matan-B Matan-B moved this from Unassigned / Drafts / Discussion to Awaits review in Crimson Jun 8, 2025
@guojidan
guojidan force-pushed the scrubber branch 2 times, most recently from 9aa209b to 5d613ba Compare June 19, 2025 09:45
@guojidan
guojidan marked this pull request as ready for review June 19, 2025 10:13
@guojidan

guojidan commented Jun 19, 2025 •

Copy link
Copy Markdown
Contributor Author

This PR is ready for review. It has passed this test: https://gist.github.com/Matan-B/83157a6119587eadbf9998f960827cef.

The offline tool uses this PR: #63604.

@Matan-B

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

Great work, left some comments!

Comment thread src/crimson/admin/osd_admin.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: I'm re-writing AdminSocket hooks to use the new debugging macro and coroutines in an upcoming PR.
#63523

Comment thread src/crimson/osd/osd.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.

Classic is calling this based on:

    if (next < ceph_clock_now()) {
      dout(20) << __func__ << " last_purged_snaps_scrub " << last
	       << " next " << next << " ... now" << dendl;
      scrub_purged_snaps();

If you would prefer to call this unconditionally here, a suitable name would probably be maybe_deep_scrub_purged_snaps

Comment thread src/crimson/osd/osd.h Resolved
Comment thread src/crimson/osd/osd.cc Resolved
Comment thread src/crimson/osd/osd.cc Resolved
Comment thread src/crimson/osd/osd.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.

This shouldn't be run in an seastar::async block, Crimson has a dedicated futurized osdriver in SnapMapper.

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.

Because the OSDriver::get_next_or_current method requires the use of .get(), record_purged_snaps needs to be wrapped with seastar::async. Otherwise, an error will occur: /home/dandan/code/c++/ceph/src/seastar/src/core/future.cc:271: void seastar::internal::future_base::do_wait(): Assertion thread failed.
like @athanatos said : #57491 (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.

Ah, let's add a comment above the seastar::async block to emphasize the rationale.

Comment thread src/crimson/osd/pg.cc Outdated

@Matan-B Matan-B Jun 23, 2025 •

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.

Crimson trimming doesn't work with kick_snap_trim same as classic.
This is already implemented, please see SnapTrimObjSubEvent and SnapTrimEvent which are being called from PG::trim_snap. I think that we should be able to reuse the existing logic.

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.

Maybe the method name is confusing, so I'll change it to trim_snaps. The main purpose of this method is to cyclically call PG::trim_snap to traverse and delete each snapid_t. My idea is that scrub_purged_snaps may scan out multiple snapids that need trimming. If the PG supports batch trimming of snaps, there will be no need to traverse and call PG::trim_snap in scrub_purged_snaps.

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.

Let's reuse this logic in on_active_actmap instead of copying twice. Added a comment in last review.

Comment thread src/crimson/osd/shard_services.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.

Let's introduce purged_snaps as a member instead of changing the return type here.

@Matan-B Matan-B moved this from Awaits review to In Progress in Crimson Jun 23, 2025
@Matan-B

Matan-B commented Jun 23, 2025

Copy link
Copy Markdown
Contributor

This PR is ready for review. It has passed this test: https://gist.github.com/Matan-B/83157a6119587eadbf9998f960827cef.

The offline tool uses this PR: #63604.

Sounds promising! Can you explain how the offline tool uses it?

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

The implementation looks good! The last commit should not remove the interruption support.

Comment thread src/crimson/osd/osd.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.

Ah, let's add a comment above the seastar::async block to emphasize the rationale.

Comment thread src/crimson/osd/pg.cc
}
}

void PG::trim_snaps()

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.

Since this is the same logic as in PG::on_active_actmap() can we reuse it there? at least the common parts.

class DumpSlowestHistoricOpsHook;
class DumpRecoveryReservationsHook;
class ScrubPurgedSnapsHook;
class ResetPurgedSnapsLastHook;

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.

Let's either squash this or move the implementation of the command here (preferably the latter :)

Comment thread src/crimson/osd/osd.cc
Comment on lines +547 to +548
pg_shard_manager.get_meta_coll().collection(),
std::move(t)).then([] {

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: Doesn't appear to belong here.

Comment thread src/crimson/osd/pg.h Outdated
void set_ready_to_merge_target(eversion_t lu, epoch_t les, epoch_t lec) final {}
void set_ready_to_merge_source(eversion_t lu) final {}

// seastar::future<> scrub_purged_snaps();

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/osd/SnapMapper.cc
CRIMSON_DEBUG("OSDriver::{}", __func__);
using crimson::os::FuturizedStore;
return interruptor::green_get(os->omap_get_values(
return os->omap_get_values(

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.

The reason we use green_get is to support interrupts, we can't remove this usage.
There seem to be a bug around the call to reset which expects ref count to be more than 1 - which makes sense.
Perhaps we are missing a ref_count++? There are many logs around ceph_subsys_crimson_interrupt I would suggest to enable them and see what is the missing bit.

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.

My understanding is as follows: green_get itself should have no bugs. Its original design intention is to run methods decorated by the interruptor, such as interruptor::with_interruption. If this is the case, calling reset first in green_get will not cause an error. In our method, however, the omap_get_values method is just an ordinary future, so there is no need to use green_get.

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.

Your observation is correct. Let's change omap_get_values to return an interruptible errorator then instead. The current return value is read_errorator::future<omap_values_t> particularly read_errorator which is a non-interruption (vanilla future). In order for us to support interruptions and in turn use green_get properly - we should change it to an read_ierrorator. There few examples for this around the code base but this should work:

  using read_ierrorator =
    ::crimson::interruptible::interruptible_errorator<
      IOInterruptCondition, read_errorator>;

Comment thread src/osd/SnapMapper.cc Outdated
return to_test.substr(0, MAPPING_PREFIX.size()) == MAPPING_PREFIX;
}

bool SnapMapper::is_purged(const string &to_test)

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.

Does it belong here? If so, please mention why in the commit message.

@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

@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 Aug 25, 2025
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions Bot closed this Sep 24, 2025
@Matan-B Matan-B moved this from In Progress to Unassigned / Drafts / Discussion in Crimson Sep 25, 2025
@Yohello1

Copy link
Copy Markdown

Hey, any chance I could pick this up?

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

Projects

Status: Unassigned / Drafts / Discussion

Development

Successfully merging this pull request may close these issues.

6 participants