Skip to content

crimson/os/seastore: avoid getting wrong logical extents through "parent-invalid" lba mappings - #57709

Merged
cyx1231st merged 7 commits into
ceph:mainfrom
xxhdx1985126:wip-seastore-fix-parent_invalid-mappings
Jun 27, 2024
Merged

cyx1231st merged 7 commits into
ceph:mainfrom
xxhdx1985126:wip-seastore-fix-parent_invalid-mappings

Conversation

@xxhdx1985126

@xxhdx1985126 xxhdx1985126 commented May 26, 2024 •

Copy link
Copy Markdown
Member

The parent of an lba mapping may be modified after the mapping's retrieval, so we need to avoid getting extents through the mapping with an outdated view.

Signed-off-by: Xuehan Xu [email protected]

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

@xxhdx1985126
xxhdx1985126 requested a review from cyx1231st May 26, 2024 05:39
@xxhdx1985126
xxhdx1985126 requested a review from a team as a code owner May 26, 2024 05:39
@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-fix-parent_invalid-mappings branch from 296174f to abb141d Compare May 26, 2024 07:17
@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test make check

@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test api

@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test make check

@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test windows

@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-fix-parent_invalid-mappings branch 3 times, most recently from 5f553d7 to d338066 Compare May 28, 2024 01:35
@cyx1231st

cyx1231st commented May 30, 2024 •

Copy link
Copy Markdown
Member

How about:

Introduce a public method void PhysicalNodeMapping::attach_extent_info(), so that user can explicitly instruct the pin to attach necessary information internally upon getting the mapping.

So that:

Only after the "info" is attached to the pin, the according methods, for example:

  • Mapping::is_(data_)stable() directly returns the attatched result.
  • TM::read_pin(_by_type)() knows that the parent is now possible to become invalid, and handle the case properly, either by:
    1. fix the pos by the parent key
    2. query the lba tree again
    3. or even smarter in the future: crimson/os/seastore: lba pointer consolidation #55831 (comment)
  • Which also means user can be further decoupled from the details.

With void PhysicalNodeMapping::attatch_extent_info(), we don't need to generally assume that pos cannot be trusted, and the original get_child() doesn't need extra changes (only assert that key == get_key_from_idx(pos)).

@xxhdx1985126 Does it look reasonable?

@xxhdx1985126

xxhdx1985126 commented May 30, 2024 •

Copy link
Copy Markdown
Member Author

How about:

Introduce a public method void PhysicalNodeMapping::attach_extent_info(), so that user can explicitly instruct the pin to attach necessary information internally upon getting the mapping.

So that:

Only after the "info" is attached to the pin, the according methods, for example:

  • Mapping::is_(data_)stable() directly returns the attatched result.

  • TM::read_pin(_by_type)() knows that the parent is now possible to become invalid, and handle the case properly, either by:

    1. fix the pos by the parent key
    2. query the lba tree again
    3. or even smarter in the future: crimson/os/seastore: lba pointer consolidation #55831 (comment)
  • Which also means user can be decoupled from the details.

With void PhysicalNodeMapping::attatch_extent_info(), we don't need to generally assume that pos cannot be trusted, and the original get_child() doesn't need extra changes (only assert that key == get_key_from_idx(pos)).

@xxhdx1985126 Does it look reasonable?

I'll give it a try:-)

@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-fix-parent_invalid-mappings branch from d338066 to ef39510 Compare June 11, 2024 08:04
@xxhdx1985126

Copy link
Copy Markdown
Member Author

@cyx1231st

I implemented another approach in which we don't have to touch FixedKVNode::get_child() and FixedKVNode::is_child_(data)_stable() and can detect all invalid lba mapping cases.

Specifically, the main modifications are as follows:

  1. assert that the parent of an lba mapping is never in the retired set of the transction
  2. add LBAMapping::parent_modified() to check whether the parent lba leaf has been modified since the retrieval of the lba mapping
  3. re-retrieve the lba mapping if the parent isn't valid anymore. Since we've made sure that the parent of an lba mapping will never be in the retried set of the transaction, this should be the only case in which we need to re-retrieve the mapping
  4. fix lba mappings' pos if necessary before following them to get logical extents

WIth this approach, users of lba mappings, like ObjectDataHandler, OMapManager, OnodeManager, don't have to worry about the validity of the lba mappings anymore.

Please take a look, thanks.

@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-fix-parent_invalid-mappings branch 3 times, most recently from 2a19bff to 07918e5 Compare June 12, 2024 12:26
@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-fix-parent_invalid-mappings branch from 07918e5 to dea5d8d Compare June 14, 2024 10:37
@github-actions github-actions Bot added the tests label Jun 14, 2024
@xxhdx1985126 xxhdx1985126 added DNM and removed DNM labels Jun 14, 2024
@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-fix-parent_invalid-mappings branch from dea5d8d to c8dcd79 Compare June 14, 2024 12:49
@xxhdx1985126

Copy link
Copy Markdown
Member Author

@cyx1231st All comments addressed, please take a look again, thanks:-)

@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-fix-parent_invalid-mappings branch from 7c0d0c1 to beafb15 Compare June 21, 2024 10:19
@cyx1231st

Copy link
Copy Markdown
Member

@xxhdx1985126 Sorry I'm not following which comments have been addressed, the new change looks like a rebase to me, have you pushed a wrong branch?

@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-fix-parent_invalid-mappings branch from beafb15 to 7c0d0c1 Compare June 24, 2024 03:33
@xxhdx1985126

Copy link
Copy Markdown
Member Author

@xxhdx1985126 Sorry I'm not following which comments have been addressed, the new change looks like a rebase to me, have you pushed a wrong branch?

Yes, sorry, I pushed the wrong branch, it's the right one now.

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

LGTM except for the below comments.

Comment thread src/crimson/os/seastore/transaction.h Resolved
@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-fix-parent_invalid-mappings branch from 7c0d0c1 to 8d136a0 Compare June 25, 2024 08:48
@xxhdx1985126

Copy link
Copy Markdown
Member Author

@cyx1231st All done, please take a look again, thanks.

@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test make check

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

LGTM except one last comment.

Comment thread src/crimson/os/seastore/transaction.h Resolved
xxhdx1985126 and others added 7 commits June 26, 2024 10:51
…s are

viewable to transactions

Instead of searching the transaction's retired_set to determine whether
an extent has been retired, we add the transaction that's retiring an
extent to that extent's retired_transactions field and search that field
to do the check. Since the probability of multiple transactions retiring
the same extent is very low, this approach should be more cpu efficient.

Signed-off-by: Xuehan Xu <[email protected]>
mappings following which logical extents are to be retrieved are valid

Signed-off-by: Xuehan Xu <[email protected]>
detecting invalid lba mappings

Signed-off-by: Xuehan Xu <[email protected]>
@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-fix-parent_invalid-mappings branch from 8d136a0 to 4ad6f86 Compare June 26, 2024 03:26
@cyx1231st

Copy link
Copy Markdown
Member

I'll merge once the build approves.

@cyx1231st

Copy link
Copy Markdown
Member

trans_retired_extent_link_t(CachedExtentRef extent, transaction_id_t id)
: extent(extent), trans_view{id}
{
assert(extent->is_stable());

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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