Re: [PATCHv6 07/11] block/bounce: count bytes instead of sectors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/10/22 12:58, Keith Busch wrote:
From: Keith Busch <kbusch@xxxxxxxxxx>

Individual bv_len's may not be a sector size.

Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
Reviewed-by: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Pankaj Raghav <p.raghav@xxxxxxxxxxx>
---
  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.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux