Message ID | 20220610195830.3574005-1-kbusch@fb.com (mailing list archive) |
---|---|
Headers | show |
Series | direct-io dma alignment | expand |
On Fri, Jun 10, 2022 at 12:58:26PM -0700, Keith Busch wrote: > From: Keith Busch <kbusch@kernel.org> > > Individual bv_len's may not be a sector size. > > Signed-off-by: Keith Busch <kbusch@kernel.org> > Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> > Reviewed-by: Pankaj Raghav <p.raghav@samsung.com> Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
On Fri, 10 Jun 2022 12:58:19 -0700, Keith Busch wrote: > From: Keith Busch <kbusch@kernel.org> > > The previous version is available here: > > https://lore.kernel.org/linux-block/Yp4qQRI5awiycml1@kbusch-mbp.dhcp.thefacebook.com/T/#m0a93b6392038aad6144e066fb5ada2cbf316f78e > > Changes from the previous are all trivial changes: > > [...] Applied, thanks! [01/11] block: fix infinite loop for invalid zone append commit: 1180b55c93f6b060ad930db151fe6d2b425f9215 [02/11] block/bio: remove duplicate append pages code commit: 7a2b81b95a89e578343b1c944ddd64d1b14ee49a [03/11] block: export dma_alignment attribute commit: 5f507439f051daaa1e3273ff536afda3ad1f1505 [04/11] block: introduce bdev_dma_alignment helper commit: 24b10a6e0bc22619535b0ed982b7735910981661 [05/11] block: add a helper function for dio alignment commit: 8a39418810a65f0bcbe559261ef011fe0e298eeb [06/11] block/merge: count bytes instead of sectors commit: 4ff782f24a4cad4b033d0f4f6e38cd50e0d463b0 [07/11] block/bounce: count bytes instead of sectors commit: 4b5310470e72d77c9b52f8544b98aa8cf77d956f [08/11] iov: introduce iov_iter_aligned commit: ab7c0c3abb2e5fa15655e4b87bb7b937ca7e18c3 [09/11] block: introduce bdev_iter_is_aligned helper commit: 72230944b7a53280c1f351a0d5cafed12732ec21 [10/11] block: relax direct io memory alignment commit: 84f970d415ef4d048e664ac308792eb93d0152fc [11/11] iomap: add support for dma aligned direct-io commit: 40e11e7a6cc74f11b5ca23ceefec7c84af5c4c73 Best regards,
On 6/10/22 12:58, Keith Busch wrote: > From: Keith Busch <kbusch@kernel.org> > > Individual bv_len's may not be a sector size. > > Signed-off-by: Keith Busch <kbusch@kernel.org> > Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> > Reviewed-by: Pankaj Raghav <p.raghav@samsung.com> > --- > block/bounce.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/block/bounce.c b/block/bounce.c > index 8f7b6fe3b4db..fbadf179601f 100644 > --- a/block/bounce.c > +++ b/block/bounce.c > @@ -205,19 +205,26 @@ void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig) > int rw = bio_data_dir(*bio_orig); > struct bio_vec *to, from; > struct bvec_iter iter; > - unsigned i = 0; > + unsigned i = 0, bytes = 0; > bool bounce = false; > - int sectors = 0; > + int sectors; > > bio_for_each_segment(from, *bio_orig, iter) { > if (i++ < BIO_MAX_VECS) > - sectors += from.bv_len >> 9; > + bytes += from.bv_len; > if (PageHighMem(from.bv_page)) > bounce = true; > } > if (!bounce) > return; > > + /* > + * Individual bvecs might not be logical block aligned. Round down > + * the split size so that each bio is properly block size aligned, > + * even if we do not use the full hardware limits. > + */ > + sectors = ALIGN_DOWN(bytes, queue_logical_block_size(q)) >> > + SECTOR_SHIFT; > if (sectors < bio_sectors(*bio_orig)) { > bio = bio_split(*bio_orig, sectors, GFP_NOIO, &bounce_bio_split); > bio_chain(bio, *bio_orig); Do I see correctly that there are two changes in this patch: counting bytes instead of sectors and also splitting at logical block boundaries instead of a 512-byte boundary? Should this patch perhaps be split? Thanks, Bart.
On Fri, Jul 22, 2022 at 03:01:06PM -0700, Bart Van Assche wrote: > On 6/10/22 12:58, Keith Busch wrote: > > From: Keith Busch <kbusch@kernel.org> > > > > Individual bv_len's may not be a sector size. > > > > Signed-off-by: Keith Busch <kbusch@kernel.org> > > Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> > > Reviewed-by: Pankaj Raghav <p.raghav@samsung.com> > > --- > > block/bounce.c | 13 ++++++++++--- > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > diff --git a/block/bounce.c b/block/bounce.c > > index 8f7b6fe3b4db..fbadf179601f 100644 > > --- a/block/bounce.c > > +++ b/block/bounce.c > > @@ -205,19 +205,26 @@ void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig) > > int rw = bio_data_dir(*bio_orig); > > struct bio_vec *to, from; > > struct bvec_iter iter; > > - unsigned i = 0; > > + unsigned i = 0, bytes = 0; > > bool bounce = false; > > - int sectors = 0; > > + int sectors; > > bio_for_each_segment(from, *bio_orig, iter) { > > if (i++ < BIO_MAX_VECS) > > - sectors += from.bv_len >> 9; > > + bytes += from.bv_len; > > if (PageHighMem(from.bv_page)) > > bounce = true; > > } > > if (!bounce) > > return; > > + /* > > + * Individual bvecs might not be logical block aligned. Round down > > + * the split size so that each bio is properly block size aligned, > > + * even if we do not use the full hardware limits. > > + */ > > + sectors = ALIGN_DOWN(bytes, queue_logical_block_size(q)) >> > > + SECTOR_SHIFT; > > if (sectors < bio_sectors(*bio_orig)) { > > bio = bio_split(*bio_orig, sectors, GFP_NOIO, &bounce_bio_split); > > bio_chain(bio, *bio_orig); > > Do I see correctly that there are two changes in this patch: counting bytes > instead of sectors and also splitting at logical block boundaries instead of > a 512-byte boundary? Should this patch perhaps be split? The code previously would only split on a bvec boundary. All bvecs were logical block sized, so that part is not changing. We just needed to be able to split mid-bvec since the series enables unaligned offsets to match hardware capabilities.
From: Keith Busch <kbusch@kernel.org> The previous version is available here: https://lore.kernel.org/linux-block/Yp4qQRI5awiycml1@kbusch-mbp.dhcp.thefacebook.com/T/#m0a93b6392038aad6144e066fb5ada2cbf316f78e Changes from the previous are all trivial changes: Fixed a typo, s/bvev_/bdev_/ Updated commit messages and reviews Updated code comments Added a new comment for request_queue dma_alignement expressly documenting the consequences of setting this. All existing users of this attribute were checked to ensure they are on the correct side of those consequences. Keith Busch (11): block: fix infinite loop for invalid zone append block/bio: remove duplicate append pages code block: export dma_alignment attribute block: introduce bdev_dma_alignment helper block: add a helper function for dio alignment block/merge: count bytes instead of sectors block/bounce: count bytes instead of sectors iov: introduce iov_iter_aligned block: introduce bdev_iter_is_aligned helper block: relax direct io memory alignment iomap: add support for dma aligned direct-io Documentation/ABI/stable/sysfs-block | 9 +++ block/bio.c | 114 ++++++++++++--------------- block/blk-merge.c | 41 ++++++---- block/blk-sysfs.c | 7 ++ block/bounce.c | 13 ++- block/fops.c | 16 ++-- fs/iomap/direct-io.c | 4 +- include/linux/blkdev.h | 17 ++++ include/linux/uio.h | 2 + lib/iov_iter.c | 92 +++++++++++++++++++++ 10 files changed, 224 insertions(+), 91 deletions(-)