Skip to content

Commit 60a27b9

Browse files
Ming Leiaxboe
authored andcommitted
block: fix handling for BIO_NO_PAGE_REF
Commit 399254a ("block: add BIO_NO_PAGE_REF flag") introduces BIO_NO_PAGE_REF, and once this flag is set for one bio, all pages in the bio won't be get/put during IO. However, if one bio is submitted via __blkdev_direct_IO_simple(), even though BIO_NO_PAGE_REF is set, pages still may be put. Fixes this issue by avoiding to put pages if BIO_NO_PAGE_REF is set. Fixes: 399254a ("block: add BIO_NO_PAGE_REF flag") Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 817869d commit 60a27b9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/block_dev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
264264
bio_for_each_segment_all(bvec, &bio, i, iter_all) {
265265
if (should_dirty && !PageCompound(bvec->bv_page))
266266
set_page_dirty_lock(bvec->bv_page);
267-
put_page(bvec->bv_page);
267+
if (!bio_flagged(&bio, BIO_NO_PAGE_REF))
268+
put_page(bvec->bv_page);
268269
}
269270

270271
if (unlikely(bio.bi_status))

0 commit comments

Comments
 (0)