diff mbox series

block: don't run get_page() on pages from non-bvec iov iter

Message ID 20190424110146.17343-1-ming.lei@redhat.com (mailing list archive)
State New, archived
Headers show
Series block: don't run get_page() on pages from non-bvec iov iter | expand

Commit Message

Ming Lei April 24, 2019, 11:01 a.m. UTC
The refcount has been increased for pages retrieved from non-bvec iov iter
via __bio_iov_iter_get_pages(), so don't need to do that again.

Otherwise, IO pages are leaked easily.

Cc: Christoph Hellwig <hch@lst.de>
Fixes: 7321ecbfc7cf ("block: change how we get page references in bio_iov_iter_get_pages")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/bio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chaitanya Kulkarni April 24, 2019, 12:39 p.m. UTC | #1
Looks good.

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

On 4/24/19 4:02 AM, Ming Lei wrote:
> The refcount has been increased for pages retrieved from non-bvec iov iter
> via __bio_iov_iter_get_pages(), so don't need to do that again.
> 
> Otherwise, IO pages are leaked easily.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Fixes: 7321ecbfc7cf ("block: change how we get page references in bio_iov_iter_get_pages")
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
>   block/bio.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block/bio.c b/block/bio.c
> index c81ed2dfee53..662d45752ec5 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -992,7 +992,7 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
>   
>   	if (iov_iter_bvec_no_ref(iter))
>   		bio_set_flag(bio, BIO_NO_PAGE_REF);
> -	else
> +	else if (is_bvec)
>   		bio_get_pages(bio);
>   
>   	return bio->bi_vcnt ? 0 : ret;
>
Jens Axboe April 24, 2019, 2:06 p.m. UTC | #2
On 4/24/19 5:01 AM, Ming Lei wrote:
> The refcount has been increased for pages retrieved from non-bvec iov iter
> via __bio_iov_iter_get_pages(), so don't need to do that again.
> 
> Otherwise, IO pages are leaked easily.

Thanks Ming, applied.
Christoph Hellwig April 24, 2019, 2:33 p.m. UTC | #3
On Wed, Apr 24, 2019 at 07:01:46PM +0800, Ming Lei wrote:
> The refcount has been increased for pages retrieved from non-bvec iov iter
> via __bio_iov_iter_get_pages(), so don't need to do that again.
> 
> Otherwise, IO pages are leaked easily.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/block/bio.c b/block/bio.c
index c81ed2dfee53..662d45752ec5 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -992,7 +992,7 @@  int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
 
 	if (iov_iter_bvec_no_ref(iter))
 		bio_set_flag(bio, BIO_NO_PAGE_REF);
-	else
+	else if (is_bvec)
 		bio_get_pages(bio);
 
 	return bio->bi_vcnt ? 0 : ret;