From 709d159e171c51213de8c8fe006762f6e839c40c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 26 Jun 2019 15:49:28 +0200 Subject: [PATCH 0614/2944] block: never take page references for ITER_BVEC Cherry-pick from commit b620743077e291ae7d0debd21f50413a8c266229 upstream. If we pass pages through an iov_iter we always already have a reference in the caller. Thus remove the ITER_BVEC_FLAG_NO_REF and don't take reference to pages by default for bvec backed iov_iters. [Joseph] Resolve conflicts since we don't have: 81ba6abd2bcd "block: loop: mark bvec as ITER_BVEC_FLAG_NO_REF" 7321ecbfc7cf "block: change how we get page references in bio_iov_iter_get_pages" Reviewed-by: Minwoo Im Reviewed-by: Johannes Thumshirn Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe Signed-off-by: Joseph Qi Reviewed-by: Xiaoguang Wang --- block/bio.c | 2 +- fs/io_uring.c | 3 --- include/linux/uio.h | 10 +--------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/block/bio.c b/block/bio.c index 89c862a..17a1145 100644 --- a/block/bio.c +++ b/block/bio.c @@ -933,7 +933,7 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) * If this is a BVEC iter, then the pages are kernel pages. Don't * release them on IO completion, if the caller asked us to. */ - if (is_bvec && iov_iter_bvec_no_ref(iter)) + if (is_bvec) bio_set_flag(bio, BIO_NO_PAGE_REF); do { diff --git a/fs/io_uring.c b/fs/io_uring.c index 40fc84a..cd1aeb7 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1063,9 +1063,6 @@ static int io_import_fixed(struct io_ring_ctx *ctx, int rw, iov_iter_bvec(iter, rw, imu->bvec, imu->nr_bvecs, offset + len); if (offset) iov_iter_advance(iter, offset); - - /* don't drop a reference to these pages */ - iter->type |= ITER_BVEC_FLAG_NO_REF; return 0; } diff --git a/include/linux/uio.h b/include/linux/uio.h index edf5aafe..127742f 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -22,9 +22,6 @@ struct kvec { }; enum iter_type { - /* set if ITER_BVEC doesn't hold a bv_page ref */ - ITER_BVEC_FLAG_NO_REF = 2, - /* iter types */ ITER_IOVEC = 4, ITER_KVEC = 8, @@ -58,7 +55,7 @@ struct iov_iter { static inline enum iter_type iov_iter_type(const struct iov_iter *i) { - return i->type & ~(READ | WRITE | ITER_BVEC_FLAG_NO_REF); + return i->type & ~(READ | WRITE); } static inline bool iter_is_iovec(const struct iov_iter *i) @@ -86,11 +83,6 @@ static inline unsigned char iov_iter_rw(const struct iov_iter *i) return i->type & (READ | WRITE); } -static inline bool iov_iter_bvec_no_ref(const struct iov_iter *i) -{ - return (i->type & ITER_BVEC_FLAG_NO_REF) != 0; -} - /* * Total number of bytes covered by an iovec. * -- 1.8.3.1