Thread (42 messages) 42 messages, 8 authors, 2022-05-20

Re: [PATCHv2 3/3] block: relax direct io memory alignment

From: Keith Busch <kbusch@kernel.org>
Date: 2022-05-19 22:31:43
Also in: linux-fsdevel

On Thu, May 19, 2022 at 09:39:12AM +0200, Christoph Hellwig wrote:
On Wed, May 18, 2022 at 07:00:39PM -0600, Keith Busch wrote:
quoted
How? This patch ensures every segment is block size aligned. We can always
split a bio in the middle of a bvec for any lower level hardware constraints,
and I'm not finding any splitting criteria that would try to break a bio on a
non-block aligned boundary.
Do you mean bio_vec with segment here?  How do we ensure that?
I may not be understanding what you're asking here, but I'll try to answer.

In this path, we are dealing with ITER_IOVEC type. This patch ensures each
virtually contiguous segment is a block size multiple via the ALIGN_DOWN part
of the patch, and builds the bvec accordingly. An error will occur if the
ALIGN_DOWN ever results in a 0 size, so we will know each segment the user
provided is appropriately sized.

That's not to say each resulting bvec is block sized. Only the sum of all the
bvecs is guaranteed that property.

Consider something like the below userspace snippet reading a 512b sector
crossing a page with an unusual offset. If the two pages are not contiguous:

  bvec[0].bv_offset = 4092
  bvec[0].bv_len = 4

  bvec[1].bv_offset = 0
  bvec[1].bv_len = 508

If they are contiguous, you'd just get 1 bvec with the same bv_offset, but a
512b len.

---
	int ret, fd;
	char *buf;
...
	ret = posix_memalign((void **)&buf, 4096, 8192);
...
	ret = pread(fd, buf + 4092, 512, 0);
--
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help