Commit e51bab4e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: Replace BIO_NO_PAGE_REF with BIO_PAGE_REFFED with inverted logic

Replace BIO_NO_PAGE_REF with a BIO_PAGE_REFFED flag that has the inverted
meaning is only set when a page reference has been acquired that needs to
be released by bio_release_pages().
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarJohn Hubbard <jhubbard@nvidia.com>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: Jens Axboe <axboe@kernel.dk>
cc: Jan Kara <jack@suse.cz>
cc: Matthew Wilcox <willy@infradead.org>
cc: Logan Gunthorpe <logang@deltatee.com>
cc: linux-block@vger.kernel.org
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230522205744.2825689-4-dhowells@redhat.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 09e8c253
...@@ -1191,7 +1191,6 @@ void bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter) ...@@ -1191,7 +1191,6 @@ void bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter)
bio->bi_io_vec = (struct bio_vec *)iter->bvec; bio->bi_io_vec = (struct bio_vec *)iter->bvec;
bio->bi_iter.bi_bvec_done = iter->iov_offset; bio->bi_iter.bi_bvec_done = iter->iov_offset;
bio->bi_iter.bi_size = size; bio->bi_iter.bi_size = size;
bio_set_flag(bio, BIO_NO_PAGE_REF);
bio_set_flag(bio, BIO_CLONED); bio_set_flag(bio, BIO_CLONED);
} }
...@@ -1336,6 +1335,7 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) ...@@ -1336,6 +1335,7 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
return 0; return 0;
} }
bio_set_flag(bio, BIO_PAGE_REFFED);
do { do {
ret = __bio_iov_iter_get_pages(bio, iter); ret = __bio_iov_iter_get_pages(bio, iter);
} while (!ret && iov_iter_count(iter) && !bio_full(bio, 0)); } while (!ret && iov_iter_count(iter) && !bio_full(bio, 0));
......
...@@ -282,6 +282,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, ...@@ -282,6 +282,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,
if (blk_queue_pci_p2pdma(rq->q)) if (blk_queue_pci_p2pdma(rq->q))
extraction_flags |= ITER_ALLOW_P2PDMA; extraction_flags |= ITER_ALLOW_P2PDMA;
bio_set_flag(bio, BIO_PAGE_REFFED);
while (iov_iter_count(iter)) { while (iov_iter_count(iter)) {
struct page **pages, *stack_pages[UIO_FASTIOV]; struct page **pages, *stack_pages[UIO_FASTIOV];
ssize_t bytes; ssize_t bytes;
......
...@@ -402,6 +402,8 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio, ...@@ -402,6 +402,8 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
bio->bi_end_io = dio_bio_end_aio; bio->bi_end_io = dio_bio_end_aio;
else else
bio->bi_end_io = dio_bio_end_io; bio->bi_end_io = dio_bio_end_io;
/* for now require references for all pages */
bio_set_flag(bio, BIO_PAGE_REFFED);
sdio->bio = bio; sdio->bio = bio;
sdio->logical_offset_in_bio = sdio->cur_page_fs_offset; sdio->logical_offset_in_bio = sdio->cur_page_fs_offset;
} }
......
...@@ -203,7 +203,6 @@ static void iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, ...@@ -203,7 +203,6 @@ static void iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio,
bio->bi_private = dio; bio->bi_private = dio;
bio->bi_end_io = iomap_dio_bio_end_io; bio->bi_end_io = iomap_dio_bio_end_io;
bio_set_flag(bio, BIO_NO_PAGE_REF);
__bio_add_page(bio, page, len, 0); __bio_add_page(bio, page, len, 0);
iomap_dio_submit_bio(iter, dio, bio, pos); iomap_dio_submit_bio(iter, dio, bio, pos);
} }
......
...@@ -488,7 +488,7 @@ void zero_fill_bio(struct bio *bio); ...@@ -488,7 +488,7 @@ void zero_fill_bio(struct bio *bio);
static inline void bio_release_pages(struct bio *bio, bool mark_dirty) static inline void bio_release_pages(struct bio *bio, bool mark_dirty)
{ {
if (!bio_flagged(bio, BIO_NO_PAGE_REF)) if (bio_flagged(bio, BIO_PAGE_REFFED))
__bio_release_pages(bio, mark_dirty); __bio_release_pages(bio, mark_dirty);
} }
......
...@@ -323,7 +323,7 @@ struct bio { ...@@ -323,7 +323,7 @@ struct bio {
* bio flags * bio flags
*/ */
enum { enum {
BIO_NO_PAGE_REF, /* don't put release vec pages */ BIO_PAGE_REFFED, /* put pages in bio_release_pages() */
BIO_CLONED, /* doesn't own data */ BIO_CLONED, /* doesn't own data */
BIO_BOUNCED, /* bio is a bounce bio */ BIO_BOUNCED, /* bio is a bounce bio */
BIO_QUIET, /* Make BIO Quiet */ BIO_QUIET, /* Make BIO Quiet */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment