diff mbox series

[6/8] block_dev: use bio_release_pages in __blkdev_direct_IO_simple

Message ID 20190502233332.28720-7-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/8] block: move the BIO_NO_PAGE_REF check into bio_release_pages | expand

Commit Message

Christoph Hellwig May 2, 2019, 11:33 p.m. UTC
Use bio_release_pages instead of a manual put_pages loop that fails to
take BIO_NO_PAGE_REF into account.  Also use bio_set_pages_dirty for
the rest of the former loop to reduce code duplication.

Fixes: 399254aaf489 ("block: add BIO_NO_PAGE_REF flag")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/block_dev.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Johannes Thumshirn May 4, 2019, 5:38 p.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
diff mbox series

Patch

diff --git a/fs/block_dev.c b/fs/block_dev.c
index a59ebea9d125..4fc2377884a3 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -204,13 +204,12 @@  __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
 {
 	struct file *file = iocb->ki_filp;
 	struct block_device *bdev = I_BDEV(bdev_file_inode(file));
-	struct bio_vec inline_vecs[DIO_INLINE_BIO_VECS], *vecs, *bvec;
+	struct bio_vec inline_vecs[DIO_INLINE_BIO_VECS], *vecs;
 	loff_t pos = iocb->ki_pos;
 	bool should_dirty = false;
 	struct bio bio;
 	ssize_t ret;
 	blk_qc_t qc;
-	struct bvec_iter_all iter_all;
 
 	if ((pos | iov_iter_alignment(iter)) &
 	    (bdev_logical_block_size(bdev) - 1))
@@ -260,11 +259,9 @@  __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
 	}
 	__set_current_state(TASK_RUNNING);
 
-	bio_for_each_segment_all(bvec, &bio, iter_all) {
-		if (should_dirty && !PageCompound(bvec->bv_page))
-			set_page_dirty_lock(bvec->bv_page);
-		put_page(bvec->bv_page);
-	}
+	if (should_dirty)
+		bio_set_pages_dirty(&bio);
+	bio_release_pages(&bio);
 
 	if (unlikely(bio.bi_status))
 		ret = blk_status_to_errno(bio.bi_status);