diff mbox series

[7/8] direct-io: use bio_release_pages in dio_bio_complete

Message ID 20190502233332.28720-8-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 and bio_set_pages_dirty instead of open coding
them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/direct-io.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

Comments

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

Patch

diff --git a/fs/direct-io.c b/fs/direct-io.c
index fbe885d68035..62d0594a4622 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -537,7 +537,6 @@  static struct bio *dio_await_one(struct dio *dio)
  */
 static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio)
 {
-	struct bio_vec *bvec;
 	blk_status_t err = bio->bi_status;
 
 	if (err) {
@@ -550,17 +549,9 @@  static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio)
 	if (dio->is_async && dio->op == REQ_OP_READ && dio->should_dirty) {
 		bio_check_pages_dirty(bio);	/* transfers ownership */
 	} else {
-		struct bvec_iter_all iter_all;
-
-		bio_for_each_segment_all(bvec, bio, iter_all) {
-			struct page *page = bvec->bv_page;
-
-			if (dio->op == REQ_OP_READ && !PageCompound(page) &&
-					dio->should_dirty)
-				set_page_dirty_lock(page);
-			put_page(page);
-		}
-		bio_put(bio);
+		if (dio->op == REQ_OP_READ && dio->should_dirty)
+			bio_set_pages_dirty(bio);
+		bio_release_pages(bio);
 	}
 	return err;
 }