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

Fix zdb crash with 4K-only devices #4821

Closed
wants to merge 1 commit into from

Conversation

behlendorf
Copy link
Contributor

Here's the problem - on 4K native devices in userland on
Linux using O_DIRECT, buffers must be 4K aligned or I/O
will fail with EINVAL, causing zdb (and others) to coredump.
Since userland probably doesn't need optimized buffer caches,
we just force 4K alignment on everything.

Issue #4479

* Since userland probably doesn't need optimized buffer caches,
* we just force 4K alignment on everything.
*/
align = PAGESIZE;
Copy link
Contributor

@ironMann ironMann Jul 1, 2016

Choose a reason for hiding this comment

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

Maybe this should be 4096 explicitly, instead of PAGESIZE.
XFS requires logical sector size of the target for alignment link

But how this translates to kernel slabs, is alignment required there as well?
Currently, zio_buf slabs are setup like this:

size: 512   align: 512  
size: 1024  align: 512  
size: 1536  align: 512  
size: 2048  align: 512  
size: 2560  align: 512  
size: 3072  align: 512  
size: 3584  align: 512  
size: 4096  align: 1024  <==
size: 5120  align: 1024
size: 6144  align: 1024
size: 7168  align: 1024
size: 8192  align: 2048
size: 10240 align: 2048
size: 12288 align: 2048
size: 14336 align: 2048
size: 16384 align: 4096
size: 20480 align: 4096
....        align: 4096

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe this should be 4096 explicitly, instead of PAGESIZE.

That's not a bad idea, assuming PAGESIZE in 4096 is a bit x86_64 centric.

There is a similar restriction for the kernel slabs but the per-disk ashift is used for the alignment. The biovec which is constructed for the IO maps the appropriate portions of the pages which make up the slab buffer in to the bios.

Here's the problem - on 4K native devices in userland on
Linux using O_DIRECT, buffers must be 4K aligned or I/O
will fail with EINVAL, causing zdb (and others) to coredump.
Since userland probably doesn't need optimized buffer caches,
we just force 4K alignment on everything.

Issue openzfs#4479
@behlendorf
Copy link
Contributor Author

Merged as:

fcf64f4 Fix zdb crash with 4K-only devices

@behlendorf behlendorf closed this Jul 28, 2016
@behlendorf behlendorf deleted the zdb-4k branch April 19, 2021 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants