[3/9] block: use bio_release_pages in bio_unmap_user
diff mbox series

Message ID 20190626134928.7988-4-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 open coding it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bio.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

Comments

Chaitanya Kulkarni June 26, 2019, 8:47 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 open coding it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   block/bio.c | 21 ++-------------------
>   1 file changed, 2 insertions(+), 19 deletions(-)
>
> diff --git a/block/bio.c b/block/bio.c
> index 7f3920b6baca..20a16347bcbb 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -1437,24 +1437,6 @@ struct bio *bio_map_user_iov(struct request_queue *q,
>   	return ERR_PTR(ret);
>   }
>
> -static void __bio_unmap_user(struct bio *bio)
> -{
> -	struct bio_vec *bvec;
> -	struct bvec_iter_all iter_all;
> -
> -	/*
> -	 * make sure we dirty pages we wrote to
> -	 */
> -	bio_for_each_segment_all(bvec, bio, iter_all) {
> -		if (bio_data_dir(bio) == READ)
> -			set_page_dirty_lock(bvec->bv_page);
> -
> -		put_page(bvec->bv_page);
> -	}
> -
> -	bio_put(bio);
> -}
> -
>   /**
>    *	bio_unmap_user	-	unmap a bio
>    *	@bio:		the bio being unmapped
> @@ -1466,7 +1448,8 @@ static void __bio_unmap_user(struct bio *bio)
>    */
>   void bio_unmap_user(struct bio *bio)
>   {
> -	__bio_unmap_user(bio);
> +	bio_release_pages(bio, bio_data_dir(bio) == READ);
> +	bio_put(bio);
>   	bio_put(bio);
>   }
>
>

Patch
diff mbox series

diff --git a/block/bio.c b/block/bio.c
index 7f3920b6baca..20a16347bcbb 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1437,24 +1437,6 @@  struct bio *bio_map_user_iov(struct request_queue *q,
 	return ERR_PTR(ret);
 }
 
-static void __bio_unmap_user(struct bio *bio)
-{
-	struct bio_vec *bvec;
-	struct bvec_iter_all iter_all;
-
-	/*
-	 * make sure we dirty pages we wrote to
-	 */
-	bio_for_each_segment_all(bvec, bio, iter_all) {
-		if (bio_data_dir(bio) == READ)
-			set_page_dirty_lock(bvec->bv_page);
-
-		put_page(bvec->bv_page);
-	}
-
-	bio_put(bio);
-}
-
 /**
  *	bio_unmap_user	-	unmap a bio
  *	@bio:		the bio being unmapped
@@ -1466,7 +1448,8 @@  static void __bio_unmap_user(struct bio *bio)
  */
 void bio_unmap_user(struct bio *bio)
 {
-	__bio_unmap_user(bio);
+	bio_release_pages(bio, bio_data_dir(bio) == READ);
+	bio_put(bio);
 	bio_put(bio);
 }