Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iomap: simplify iomap_dio_bio_iter

Use iov_iter_count to check if we need to continue as that just reads
a field in the iov_iter, and only use bio_iov_vecs_to_alloc to calculate
the actual number of vectors to allocate for the bio.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Tested-by: Anuj Gupta <anuj20.g@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
6e7a6c80 4ad357e3

+6 -7
+6 -7
fs/iomap/direct-io.c
··· 312 312 blk_opf_t bio_opf = REQ_SYNC | REQ_IDLE; 313 313 struct bio *bio; 314 314 bool need_zeroout = false; 315 - int nr_pages, ret = 0; 315 + int ret = 0; 316 316 u64 copied = 0; 317 317 size_t orig_count; 318 318 unsigned int alignment; ··· 440 440 goto out; 441 441 } 442 442 443 - nr_pages = bio_iov_vecs_to_alloc(dio->submit.iter, BIO_MAX_VECS); 444 443 do { 445 444 size_t n; 446 445 ··· 452 453 goto out; 453 454 } 454 455 455 - bio = iomap_dio_alloc_bio(iter, dio, nr_pages, bio_opf); 456 + bio = iomap_dio_alloc_bio(iter, dio, 457 + bio_iov_vecs_to_alloc(dio->submit.iter, 458 + BIO_MAX_VECS), bio_opf); 456 459 fscrypt_set_bio_crypt_ctx(bio, inode, pos >> inode->i_blkbits, 457 460 GFP_KERNEL); 458 461 bio->bi_iter.bi_sector = iomap_sector(iomap, pos); ··· 496 495 dio->size += n; 497 496 copied += n; 498 497 499 - nr_pages = bio_iov_vecs_to_alloc(dio->submit.iter, 500 - BIO_MAX_VECS); 501 498 /* 502 499 * We can only poll for single bio I/Os. 503 500 */ 504 - if (nr_pages) 501 + if (iov_iter_count(dio->submit.iter)) 505 502 dio->iocb->ki_flags &= ~IOCB_HIPRI; 506 503 iomap_dio_submit_bio(iter, dio, bio, pos); 507 504 pos += n; 508 - } while (nr_pages); 505 + } while (iov_iter_count(dio->submit.iter)); 509 506 510 507 /* 511 508 * We need to zeroout the tail of a sub-block write if the extent type