Skip to content

Fix decrypt_fault.ksh when zfs_abd_scatter_enabled=0 #17233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tuxoko
Copy link
Contributor

@tuxoko tuxoko commented Apr 10, 2025

Motivation and Context

Description

If we turn off zfs_abd_scatter_enabled, we can allow buffer sharing
during arc_write_ready. However, this will cause decrypt_fault.ksh to
fail. It seems we need to export the pool to guarantee we will attempt
to decrypt the file again so fault injection will work.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@tuxoko
Copy link
Contributor Author

tuxoko commented Apr 10, 2025

For context, if we change arc_buf to take abd instead of normal buffer. We can allow buffer sharing even without turning off scatter abd. In which case this change is needed regardless of scatter abd being disabled or not.

@amotin
Copy link
Member

amotin commented Apr 10, 2025

Buffer sharing may happen for small blocks even with ABD scatter enabled. IIRC on Linux it means only up to 1KB, while on FreeBSD up to 4KB by default. Also it is allowed for UNCACHED headers, which are not supposed to live long.

Copy link
Member

@amotin amotin left a comment

Choose a reason for hiding this comment

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

I am not sure the old code is generally incorrect, even though it is not uniform in its behavior. If we are writing a block in plain-text (not via raw receive) and then encrypt as part of ZIO pipeline, we effectively have two versions of data: one plain-text in buf and one encrypted in zio->io_abd. So at this point we seem to be free to choose whether to put into ARC plain-text or encrypted data (or we may put even both, but it would be a waste of memory). If we put plain-text, then any consumer that later wants encrypted, will have to read it from disk, but consumers that want plain-text will get it as-is without decryption (this I suppose is what breaks the test, since there is just no decryption to fail). If we put encrypted data, then following plain-text read will have to decrypt it, wasting time, while encrypted read will get the data as-is. So the question seems to be what is more efficient (plain-text reads are probably much more likely) or is there any more artifacts hidden.

@tuxoko
Copy link
Contributor Author

tuxoko commented Apr 10, 2025

@amotin
Ok, then we make the test to purge the decrypted buffer instead?

@amotin
Copy link
Member

amotin commented Apr 10, 2025

While it is still a good question what shall we better do with this code, I think the test could instead be fixed by exporting/importing the pool instead of unmounting/mounting the dataset.

@tuxoko
Copy link
Contributor Author

tuxoko commented Apr 10, 2025

Update: revert the change and fix test instead.

@amotin
Copy link
Member

amotin commented Apr 11, 2025

I've never seen it before, but now for some reason it failed on (and only on) fedora41:

  21:48:32.00 SUCCESS: zinject -a -t data -e decrypt -f 20 /testpool/fs/file1
  21:48:32.11 SUCCESS: eval cat /testpool/fs/file1 > /dev/null exited 1
  21:48:32.32 ERROR: eval zpool events testpool | grep -q 'authentication' exited 1

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Apr 11, 2025
@tuxoko
Copy link
Contributor Author

tuxoko commented Apr 11, 2025

Hmm... It seems more likely to fail when running multiple tests, but not single test.

If we turn off zfs_abd_scatter_enabled, we can allow buffer sharing
during arc_write_ready. However, this will cause decrypt_fault.ksh to
fail. It seems we need to export the pool to guarantee we will attempt
to decrypt the file again so fault injection will work.

Signed-off-by: Chunwei Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants