block: Replace BIO_NO_PAGE_REF with BIO_PAGE_REFFED with inverted logic
authorChristoph Hellwig <hch@lst.de>
Mon, 22 May 2023 20:57:41 +0000 (21:57 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 24 May 2023 14:42:44 +0000 (08:42 -0600)
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: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: John 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: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230522205744.2825689-4-dhowells@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c
block/blk-map.c
fs/direct-io.c
fs/iomap/direct-io.c
include/linux/bio.h
include/linux/blk_types.h

index 043944fd46ebbcac3c30fe722c52f03f71dfd5ab..8516adeaea268e85e43bd6ba73f3748a5b483089 100644 (file)
@@ -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_iter.bi_bvec_done = iter->iov_offset;
        bio->bi_iter.bi_size = size;
-       bio_set_flag(bio, BIO_NO_PAGE_REF);
        bio_set_flag(bio, BIO_CLONED);
 }
 
@@ -1336,6 +1335,7 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
                return 0;
        }
 
+       bio_set_flag(bio, BIO_PAGE_REFFED);
        do {
                ret = __bio_iov_iter_get_pages(bio, iter);
        } while (!ret && iov_iter_count(iter) && !bio_full(bio, 0));
index 04c55f1c492eb144b332139478b5cc390dbbf075..33d9f6e89ba6214daf4fc998ea53330a294ec89e 100644 (file)
@@ -282,6 +282,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,
        if (blk_queue_pci_p2pdma(rq->q))
                extraction_flags |= ITER_ALLOW_P2PDMA;
 
+       bio_set_flag(bio, BIO_PAGE_REFFED);
        while (iov_iter_count(iter)) {
                struct page **pages, *stack_pages[UIO_FASTIOV];
                ssize_t bytes;
index 0b380bb8a81e11532d4488782d61fb5420198057..ad20f3428bab3e8c37845cc9c536b0f47f75adc2 100644 (file)
@@ -402,6 +402,8 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
                bio->bi_end_io = dio_bio_end_aio;
        else
                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->logical_offset_in_bio = sdio->cur_page_fs_offset;
 }
index 66a9f10e320729f13a9cb8522e633bbdcc3f23f0..08873f0627dd3852768844874a7f0a4cb281f1dc 100644 (file)
@@ -203,7 +203,6 @@ static void iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio,
        bio->bi_private = dio;
        bio->bi_end_io = iomap_dio_bio_end_io;
 
-       bio_set_flag(bio, BIO_NO_PAGE_REF);
        __bio_add_page(bio, page, len, 0);
        iomap_dio_submit_bio(iter, dio, bio, pos);
 }
index 7f53be035cf0e012b59258d4e16910333513aeea..0922729acd26b5d5ad40dab9613f43d08dcce1bf 100644 (file)
@@ -488,7 +488,7 @@ void zero_fill_bio(struct bio *bio);
 
 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);
 }
 
index 740afe80f297868e563fb53c861b08f58b7c511e..dfd2c2cb909df24f0d0178a4ff393b2ac1feea2f 100644 (file)
@@ -323,7 +323,7 @@ struct bio {
  * bio flags
  */
 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_BOUNCED,            /* bio is a bounce bio */
        BIO_QUIET,              /* Make BIO Quiet */