Skip to content

crimson/os/seastore: support extent checksum verification - #55449

Merged
cyx1231st merged 11 commits into
ceph:mainfrom
xxhdx1985126:wip-seastore-extent-chksum
Apr 29, 2024
Merged

cyx1231st merged 11 commits into
ceph:mainfrom
xxhdx1985126:wip-seastore-extent-chksum

Conversation

@xxhdx1985126

@xxhdx1985126 xxhdx1985126 commented Feb 5, 2024 •

Copy link
Copy Markdown
Member

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 a team as a code owner February 5, 2024 05:52
@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-extent-chksum branch from 337808b to 05fc0c2 Compare February 5, 2024 07:55
@github-actions github-actions Bot added the tests label Feb 5, 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.

Initial comments.

Other questions:

  • Does this PR completely supports extent read integrity? If not, where might be missing?
  • I suppose performance will be impacted, so it might be better to have rough/simple performance comparison with/without this PR.

Comment thread src/crimson/os/seastore/transaction.h Resolved
Comment thread src/crimson/os/seastore/lba_manager.cc Resolved
Comment thread src/crimson/os/seastore/lba_manager.cc Resolved

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.

I suppose traversing the lba-tree (again) is expensive. Is it possible to instead leverage the lba parent-child-pointer to update the mapping of the logical extent?

@xxhdx1985126 xxhdx1985126 Feb 5, 2024 •

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.

I suppose traversing the lba-tree (again) is expensive. Is it possible to instead leverage the lba parent-child-pointer to update the mapping of the logical extent?

This may be non-trivial, because the lba tree structure may be changed after the retrieval of an lba mapping, so we might not be able to update the mapping directly through the LBAMapping structure. To archieve this, we may have to expose the lba tree iterator somehow?

On the other hand, we already are updating the lba mappings for the written ool extents here. The major difference is that we update the checksum field of lba_map_val_t in addition to the paddr field, so I think there may not be so much increased costs, am I right?

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 may be non-trivial, because the lba tree structure may be changed after the retrieval of an lba mapping, so we might not be able to update the mapping directly through the LBAMapping structure. To archieve this, we may have to expose the lba tree iterator somehow?

Maybe I'm missing something. Quoted:

3. if nodes are initial_pending
    a. parent points at its pending parent on this transaction (must exist)
    b. prior_instance is empty or, if it's the result of rewrite, points to
        its stable predecessor
    ...
    d. copy_sources contains the set of stable nodes at the same tree-level(only
       its "prior_instance" if the node is the result of a rewrite), with which
       the lba range of this node overlaps.

Seems to me this design is already sufficient to find the parent node, which is always kept updated with tree split/merge, right?

Or, does the relationship between LBA leaf node and the child LogicalExtent follow the above property?

On the other hand, we already are updating the lba mappings for the written ool extents here. The major difference is that we update the checksum field of lba_map_val_t in addition to the paddr field, so I think there may not be so much increased costs, am I right?

If the above method makes sense, it should apply to the update_mapping path generally, including updating the paddr field.

@xxhdx1985126 xxhdx1985126 Feb 6, 2024 •

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.

This may be non-trivial, because the lba tree structure may be changed after the retrieval of an lba mapping, so we might not be able to update the mapping directly through the LBAMapping structure. To archieve this, we may have to expose the lba tree iterator somehow?

Maybe I'm missing something. Quoted:

3. if nodes are initial_pending
    a. parent points at its pending parent on this transaction (must exist)
    b. prior_instance is empty or, if it's the result of rewrite, points to
        its stable predecessor
    ...
    d. copy_sources contains the set of stable nodes at the same tree-level(only
       its "prior_instance" if the node is the result of a rewrite), with which
       the lba range of this node overlaps.

Seems to me this design is already sufficient to find the parent node, which is always kept updated with tree split/merge, right?

So you're suggesting that update_mapping go backward to the parent when the current leaf node doesn't contain a specific key? If so, I think it's feasible.

Or, does the relationship between LBA leaf node and the child LogicalExtent follow the above property?

It follows the property.

On the other hand, we already are updating the lba mappings for the written ool extents here. The major difference is that we update the checksum field of lba_map_val_t in addition to the paddr field, so I think there may not be so much increased costs, am I right?

If the above method makes sense, it should apply to the update_mapping path generally, including updating the paddr field.

Yeah, I think we can implement this in a dedicated lba mapping update perf optimization PR.

@cyx1231st cyx1231st Mar 26, 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.

Per discussion, the optimization relies on the ability for a child (LogicalCachedExtent) to identify its direct parent (LBALeafNode) within the transaction.

The missing piece is that if the parent is initial-pending and the child is stable or mutation-pending, the child cannot identify the parent because the pointers from an initial-pending extent to its stable version is currently only one-directional though its copy_sources.

Also see #55831 (comment)

@xxhdx1985126

Copy link
Copy Markdown
Member Author

Initial comments.

Other questions:

  • Does this PR completely supports extent read integrity? If not, where might be missing?

The checksum of remapped extents are the missing part which I planned on implementing in follow-up PRs.

  • I suppose performance will be impacted, so it might be better to have rough/simple performance comparison with/without this PR.

Yeah, will do.

@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-extent-chksum branch from 05fc0c2 to cd65bc7 Compare February 5, 2024 10:06
@cyx1231st

Copy link
Copy Markdown
Member

The checksum of remapped extents are the missing part which I planned on implementing in follow-up PRs.

I think it is not trivial because under the current design, the extent buffer doesn't need to be loaded from disk under remapping @aisakaki.

If the read integrity must be enforced, I can't think of a good way to make it compatible with the above feature.

Another question is that if we need to check read integrity, should physical extents be considerred as well? @athanatos

@xxhdx1985126

xxhdx1985126 commented Feb 6, 2024 •

Copy link
Copy Markdown
Member Author

The checksum of remapped extents are the missing part which I planned on implementing in follow-up PRs.

I think it is not trivial because under the current design, the extent buffer doesn't need to be loaded from disk under remapping @aisakaki.

If the read integrity must be enforced, I can't think of a good way to make it compatible with the above feature.

Yeah, I was think adding a configuration item for users to choose between full read integrity check and non-fully-loaded extents remapping.

IIUC, the point of having data integrity check in the io path is to discover data corruption at the time of user reads, so that the upper level in OSDs can recover the data from other replicas and prevent users from getting the corrupted data, which I think is one of the major causes for having replicas.

Meanwhile, there are cases in which performance is the higher priority in which data reliability may not be so important, for example, the HPC scenarios. So having a configuration to choose between the two options should be a good solution.

BTW, although we are asserting the checksum verification for now, we'll change it to return EIO in the future, so that upper layers in OSDs can catch it and recover the data.

@xxhdx1985126

Copy link
Copy Markdown
Member Author

Another question is that if we need to check read integrity, should physical extents be considerred as well? @athanatos

I think it does, we can add a checksum field in lba/backref nodes' meta, and check it on successful lba/backref extents load. Will add it.

@xxhdx1985126

xxhdx1985126 commented Feb 6, 2024 •

Copy link
Copy Markdown
Member Author

It seems that the inplace rewrite function also fails the checksum verification, because we can't recalculate the checksum of the extent when doing patrial inplace rewrite on it.

To fully support data integrity check, I think we might need to have a maximum data integrity check size for seastore. Specifically, say we have an extent of size 64KB, and we set max_data_integrity_check_size to 8KB, that this extent is stored on disk as eight 8KB extents; when overwrite happens, the overwritten extents must be completely rewritten. With this approach, we can have full data integrity check ability and avoid to much write/read amplification. This function only need to take effect when users config SeaStore to choose the full data integrity check ability(as mentioned above). What do you think? @cyx1231st @athanatos

BTW, this comes at the price of a larger lba tree.

@cyx1231st

Copy link
Copy Markdown
Member

It seems that the inplace rewrite function also fails the checksum verification, because we can't recalculate the checksum of the extent when doing patrial inplace rewrite on it.

Do you mean delta-based overwrite (#50419) or inplace-rewrite (#54525)? They are different concepts.

After a quick think, I suppose they are both compatible because for delta-based overwrite extent, it isn't special as a mutation-pending extent, and for inplace-rewrite, the latest content of the extent should be present in cache as a dirty extent.

Also, perhaps @myoungwon wants to disable the checksum in case of RBM if the SSD has some special supports (https://github.com/ceph/ceph/blob/main/src/crimson/os/seastore/random_block_manager/nvme_block_device.h#L281-L288).

@cyx1231st

Copy link
Copy Markdown
Member

To fully support data integrity check, I think we might need to have a maximum data integrity check size for seastore. Specifically, say we have an extent of size 64KB, and we set max_data_integrity_check_size to 8KB, that this extent is stored on disk as eight 8KB extents; when overwrite happens, the overwritten extents must be completely rewritten.

I recall that @athanatos has mentioned about a configuration "max_allocation_size" (default to 64K), which seems to be the same concept, right?

@xxhdx1985126

xxhdx1985126 commented Feb 6, 2024 •

Copy link
Copy Markdown
Member Author

It seems that the inplace rewrite function also fails the checksum verification, because we can't recalculate the checksum of the extent when doing patrial inplace rewrite on it.

Do you mean delta-based overwrite (#50419) or inplace-rewrite (#54525)? They are different concepts.

After a quick think, I suppose they are both compatible because for delta-based overwrite extent, it isn't special as a mutation-pending extent, and for inplace-rewrite, the latest content of the extent should be present in cache as a dirty extent.

Oh, maybe I was wrong. Actually, I meant partial overwrite which I thought was a feature that overwrites a part of an extent without fully loading the extent. Sorry for this misunderstanding if I'm wrong.

@xxhdx1985126

Copy link
Copy Markdown
Member Author

To fully support data integrity check, I think we might need to have a maximum data integrity check size for seastore. Specifically, say we have an extent of size 64KB, and we set max_data_integrity_check_size to 8KB, that this extent is stored on disk as eight 8KB extents; when overwrite happens, the overwritten extents must be completely rewritten.

I recall that @athanatos has mentioned about a configuration "max_allocation_size" (default to 64K), which seems to be the same concept, right?

Not quite the same, but I think that configuration can serve both purposes.

@cyx1231st

Copy link
Copy Markdown
Member

Oh, maybe I was wrong. Actually, I meant partial overwrite which I thought was a feature that overwrites a part of an extent without fully loading the extent. Sorry for this misunderstanding if I'm wrong.

NP, just wanted to clarify. I'll try to point out the code where might need to be adjusted in this case. And I suppose inplace-rewrite UT should fail if the implementation isn't complete.

@github-actions

github-actions Bot commented Feb 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

@xxhdx1985126

Copy link
Copy Markdown
Member Author

Oh, maybe I was wrong. Actually, I meant partial overwrite which I thought was a feature that overwrites a part of an extent without fully loading the extent. Sorry for this misunderstanding if I'm wrong.

NP, just wanted to clarify. I'll try to point out the code where might need to be adjusted in this case. And I suppose inplace-rewrite UT should fail if the implementation isn't complete.

I think I've found the code, Transaction::pre_inplace_rewrite_list also need to have their lba mappings updated, am I right?

@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-extent-chksum branch 3 times, most recently from 4b0145e to d4f373c Compare February 8, 2024 06:16
@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-extent-chksum branch from d4f373c to 82c4f10 Compare February 8, 2024 07:06
@cyx1231st

Copy link
Copy Markdown
Member

I think I've found the code, Transaction::pre_inplace_rewrite_list also need to have their lba mappings updated, am I right?

Right, I suppose we just need to add it to the step of TransactionManager::update_lba_mappings() during committing.

@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-extent-chksum branch 3 times, most recently from 8d54f0b to 9383771 Compare February 8, 2024 09:00
@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test make check

@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

xxhdx1985126 and others added 8 commits April 22, 2024 11:26
This is necessary because continuous data may be splitted into multiple
extents if the size of each data extent is constrained

Signed-off-by: Xuehan Xu <[email protected]>
…size

configuration

Limit the max size of extents in seastore, which can avoid much read
amplification in case of remapping extents when extents integrity check
is mandatory

Signed-off-by: Xuehan Xu <[email protected]>
@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-extent-chksum branch from dcd314e to e9b646f Compare April 22, 2024 03:32
remapping extents with full extent integrity check enabled

Signed-off-by: Xuehan Xu <[email protected]>
@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-extent-chksum branch 2 times, most recently from 8c97acf to c4941e7 Compare April 22, 2024 10:17
@xxhdx1985126
xxhdx1985126 force-pushed the wip-seastore-extent-chksum branch from c4941e7 to 898efa7 Compare April 22, 2024 10:24
@xxhdx1985126

Copy link
Copy Markdown
Member Author

INFO 2024-04-22 11:37:13,762 [shard 0:main] seastore_cleaner - SegmentCleaner::clean_space: released Seg[Dev(0),6], SegmentCleaner(should_block_io_on_clean=0, should_clean=0, projected_avail_ratio=0.991978, reclaim_ratio=0.999049, alive_ratio=7.62939e-06)
INFO 2024-04-22 11:37:13,762 [shard 0:main] test - EphemeralTestState::restart_fut: finish
INFO 2024-04-22 11:37:13,762 [shard 0:main] test - EphemeralTestState::tm_setup: finish
=================================================================
==101736==ERROR: AddressSanitizer: heap-use-after-free on address 0x617000466540 at pc 0x563b899a1fb8 bp 0x7f473ec54a70 sp 0x7f473ec54a68
READ of size 8 at 0x617000466540 thread T1
#0 0x563b899a1fb7 in crimson::os::seastore::Transaction::get_trans_id() const /home/jenkins-build/build/workspace/ceph-pull-requests/src/crimson/os/seastore/transaction.h:512:12
#1 0x563b89ea6330 in crimson::os::seastore::CachedExtent::get_transactional_view(crimson::os::seastore::Transaction&) /home/jenkins-build/build/workspace/ceph-pull-requests/src/crimson/os/seastore/cached_extent.cc:84:35
#2 0x563b8ac3ed54 in crimson::os::seastore::Cache::get_extent_viewable_by_trans(crimson::os::seastore::Transaction&, boost::intrusive_ptrcrimson::os::seastore::CachedExtent) /home/jenkins-build/build/workspace/ceph-pull-requests/src/crimson/os/seastore/cache.h:462:29
#3 0x563b8ba7f6ab in crimson::errorator<crimson::unthrowable_wrapper<std::error_code const&, crimson::ec<5> > >::_future<crimson::errorated_future_marker<boost::intrusive_ptrcrimson::os::seastore::LogicalCachedExtent > > crimson::os::seastore::Cache::get_extent_viewable_by_transcrimson::os::seastore::LogicalCachedExtent(crimson::os::seastore::Transaction&, boost::intrusive_ptrcrimson::os::seastore::LogicalCachedExtent) /home/jenkins-build/build/workspace/ceph-pull-requests/src/crimson/os/seastore/cache.h:498:12
#4 0x563b8ba7b146 in crimson::os::seastore::get_child_ret_tcrimson::os::seastore::LogicalCachedExtent crimson::os::seastore::FixedKVNode::get_childcrimson::os::seastore::LogicalCachedExtent(crimson::os::seastore::op_context_t, unsigned short, unsigned long) /home/jenkins-build/build/workspace/ceph-pull-requests/src/crimson/os/seastore/btree/fixed_kv_node.h:241:31

the failure of make check is fixed by #57035

@cyx1231st

Copy link
Copy Markdown
Member

jenkins retest this please

@cyx1231st

Copy link
Copy Markdown
Member

jenkins test make check

1 similar comment
@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test make check

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.

4 participants