summaryrefslogtreecommitdiffstats
path: root/block/bio.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-06-26 15:49:21 +0200
committerJens Axboe <axboe@kernel.dk>2019-06-29 09:47:31 -0600
commitd241a95f3514a5eb544dfd8d9d141ffd1c89b707 (patch)
tree4e0545aab26f747bbe890cc9756dff3d276a2de6 /block/bio.c
parentb2d0d99135ad145667765cbd27f148c1a4cd50d1 (diff)
downloadlinux-d241a95f3514a5eb544dfd8d9d141ffd1c89b707.tar.gz
linux-d241a95f3514a5eb544dfd8d9d141ffd1c89b707.tar.bz2
linux-d241a95f3514a5eb544dfd8d9d141ffd1c89b707.zip
block: optionally mark pages dirty in bio_release_pages
A lot of callers of bio_release_pages also want to mark the released pages as dirty. Add a mark_dirty parameter to avoid a second relatively expensive bio_for_each_segment_all loop. Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/bio.c')
-rw-r--r--block/bio.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/block/bio.c b/block/bio.c
index b35356c6093b..8a7b315630ce 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -845,7 +845,7 @@ static void bio_get_pages(struct bio *bio)
get_page(bvec->bv_page);
}
-void bio_release_pages(struct bio *bio)
+void bio_release_pages(struct bio *bio, bool mark_dirty)
{
struct bvec_iter_all iter_all;
struct bio_vec *bvec;
@@ -853,8 +853,11 @@ void bio_release_pages(struct bio *bio)
if (bio_flagged(bio, BIO_NO_PAGE_REF))
return;
- bio_for_each_segment_all(bvec, bio, iter_all)
+ bio_for_each_segment_all(bvec, bio, iter_all) {
+ if (mark_dirty && !PageCompound(bvec->bv_page))
+ set_page_dirty_lock(bvec->bv_page);
put_page(bvec->bv_page);
+ }
}
static int __bio_iov_bvec_add_pages(struct bio *bio, struct iov_iter *iter)
@@ -1683,8 +1686,7 @@ static void bio_dirty_fn(struct work_struct *work)
while ((bio = next) != NULL) {
next = bio->bi_private;
- bio_set_pages_dirty(bio);
- bio_release_pages(bio);
+ bio_release_pages(bio, true);
bio_put(bio);
}
}
@@ -1700,7 +1702,7 @@ void bio_check_pages_dirty(struct bio *bio)
goto defer;
}
- bio_release_pages(bio);
+ bio_release_pages(bio, false);
bio_put(bio);
return;
defer: