[8/9] direct-io: use bio_release_pages in dio_bio_complete
diff mbox series

Message ID 20190626134928.7988-9-hch@lst.de
State New
Headers show
Series
  • [1/9] block: move the BIO_NO_PAGE_REF check into bio_release_pages
Related show

Commit Message

Christoph Hellwig June 26, 2019, 1:49 p.m. UTC
Use bio_release_pages instead of duplicating it.

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

Comments

Chaitanya Kulkarni June 26, 2019, 8:49 p.m. UTC | #1
Looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

On 06/26/2019 06:49 AM, Christoph Hellwig wrote:
> Use bio_release_pages instead of duplicating it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   fs/direct-io.c | 15 +++------------
>   1 file changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/fs/direct-io.c b/fs/direct-io.c
> index ac7fb19b6ade..ae196784f487 100644
> --- a/fs/direct-io.c
> +++ b/fs/direct-io.c
> @@ -538,8 +538,8 @@ 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;
> +	bool should_dirty = dio->op == REQ_OP_READ && dio->should_dirty;
>
>   	if (err) {
>   		if (err == BLK_STS_AGAIN && (bio->bi_opf & REQ_NOWAIT))
> @@ -548,19 +548,10 @@ static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio)
>   			dio->io_error = -EIO;
>   	}
>
> -	if (dio->is_async && dio->op == REQ_OP_READ && dio->should_dirty) {
> +	if (dio->is_async && 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_release_pages(bio, should_dirty);
>   		bio_put(bio);
>   	}
>   	return err;
>

Patch
diff mbox series

diff --git a/fs/direct-io.c b/fs/direct-io.c
index ac7fb19b6ade..ae196784f487 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -538,8 +538,8 @@  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;
+	bool should_dirty = dio->op == REQ_OP_READ && dio->should_dirty;
 
 	if (err) {
 		if (err == BLK_STS_AGAIN && (bio->bi_opf & REQ_NOWAIT))
@@ -548,19 +548,10 @@  static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio)
 			dio->io_error = -EIO;
 	}
 
-	if (dio->is_async && dio->op == REQ_OP_READ && dio->should_dirty) {
+	if (dio->is_async && 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_release_pages(bio, should_dirty);
 		bio_put(bio);
 	}
 	return err;