Skip to content
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

Linux: fix zfs_uio_dio_check_for_zero_page #16812

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

snajpa
Copy link
Contributor

@snajpa snajpa commented Nov 27, 2024

Motivation and Context

#16689 #16642

Description

Linux: fix zfs_uio_dio_check_for_zero_page

The intent here is to replace the zero page pointer in the array of
pointers to pages in the struct.

How Has This Been Tested?

locally with reproducer in #16689

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:

The intent here is to replace the zero page pointer in the array of
pointers to pages in the struct.

Signed-off-by: Pavel Snajdr <[email protected]>
@github-actions github-actions bot added the Status: Work in Progress Not yet ready for general review label Nov 27, 2024
@snajpa snajpa marked this pull request as ready for review November 27, 2024 07:59
@github-actions github-actions bot added Status: Code Review Needed Ready for review and testing and removed Status: Work in Progress Not yet ready for general review labels Nov 27, 2024
@robn robn requested a review from bwatkinson November 27, 2024 08:43
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.

The fix makes sense to me.

I am just curios about all this special case: why do we need custom zero page? Can system-wide zero page become non-zero somehow? We are talking about write here, not read.

@mtippmann
Copy link

not directly related but I'm just wondering is running tests additinally with init_on_alloc=0 init_on_free=0 would have catched that earlier? not sure how common usage of this is but wisdom was it's a notable difference in performance.

@snajpa
Copy link
Contributor Author

snajpa commented Nov 27, 2024

The fix makes sense to me.

I am just curios about all this special case: why do we need custom zero page? Can system-wide zero page become non-zero somehow? We are talking about write here, not read.

AFAIK this is because the zero_page symbol is now GPL-only

@amotin
Copy link
Member

amotin commented Nov 27, 2024

AFAIK this is because the zero_page symbol is now GPL-only

That is not what I asked. Why do we even need to know that some page is zero page?

@snajpa
Copy link
Contributor Author

snajpa commented Nov 27, 2024

Well there's this:

			/*
			 * If the user page points the kernels ZERO_PAGE() a
			 * new zero filled page will just be allocated so the
			 * contents of the page can not be changed by the user
			 * while a Direct I/O write is taking place.
			 */

which I just took at face value, but I honestly have no idea how it might happen, the contents being changed by the user, if we didn't do this at all... because ifdef HAVE_ZERO_PAGE_GPL_ONLY, we just don't do it?

and also there's the typo of ZFS_MARKEED_PAGE...

@bwatkinson can you remember any details about this? What if we nuke all these lines of code that are about the zero page? What bad would happen, how can a user change the uio dio buffer content and am I reading it right that the protection isn't really there ifdef HAVE_ZERO_PAGE_GPL_ONLY? I don't hit the path b/c I'm running with gpl_is_licence_compatible(CDDL) == true...

@behlendorf
Copy link
Contributor

What if we nuke all these lines of code that are about the zero page?

We want to keep the zero page check here to handle this case. I suspect we could end up with a zero page in the draid case where we're padding out a write which is smaller than the minimum allocation size.

and also there's the typo of ZFS_MARKEED_PAGE.

Would you mind opening a PR to fix this typo too.

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Dec 3, 2024
@behlendorf behlendorf merged commit c8a326a into openzfs:master Dec 3, 2024
28 checks passed
behlendorf pushed a commit to behlendorf/zfs that referenced this pull request Dec 3, 2024
The intent here is to replace the zero page pointer in the array of
pointers to pages in the struct.

Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Pavel Snajdr <[email protected]>
Closes openzfs#16812 
Closes openzfs#16689
Closes openzfs#16642
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Jan 26, 2025
The intent here is to replace the zero page pointer in the array of
pointers to pages in the struct.

Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Pavel Snajdr <[email protected]>
Closes openzfs#16812 
Closes openzfs#16689
Closes openzfs#16642
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants