diff options
author | Kundan Kumar <kundan.kumar@samsung.com> | 2024-09-11 08:49:35 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-09-11 15:24:01 +0200 |
commit | eb1d46fcd5d672c9da84925ec38f1aca35d40940 (patch) | |
tree | 1ddeed586d710d9ef69ad0f5636748769eda81d8 | |
parent | mm: release number of pages of a folio (diff) | |
download | linux-eb1d46fcd5d672c9da84925ec38f1aca35d40940.tar.xz linux-eb1d46fcd5d672c9da84925ec38f1aca35d40940.zip |
block: unpin user pages belonging to a folio at once
Use newly added mm function unpin_user_folio() to put refs by npages
count.
Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Tested-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20240911064935.5630-5-kundan.kumar@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/bio.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/block/bio.c b/block/bio.c index d8b52bc54549..ac4d77c88932 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1190,7 +1190,6 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty) struct folio_iter fi; bio_for_each_folio_all(fi, bio) { - struct page *page; size_t nr_pages; if (mark_dirty) { @@ -1198,12 +1197,9 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty) folio_mark_dirty(fi.folio); folio_unlock(fi.folio); } - page = folio_page(fi.folio, fi.offset / PAGE_SIZE); nr_pages = (fi.offset + fi.length - 1) / PAGE_SIZE - fi.offset / PAGE_SIZE + 1; - do { - bio_release_page(bio, page++); - } while (--nr_pages != 0); + unpin_user_folio(fi.folio, nr_pages); } } EXPORT_SYMBOL_GPL(__bio_release_pages); @@ -1241,8 +1237,8 @@ static int bio_iov_add_folio(struct bio *bio, struct folio *folio, size_t len, folio_page(folio, 0), len, offset, &same_page)) { bio->bi_iter.bi_size += len; - if (same_page) - bio_release_page(bio, folio_page(folio, 0)); + if (same_page && bio_flagged(bio, BIO_PAGE_PINNED)) + unpin_user_folio(folio, 1); return 0; } bio_add_folio_nofail(bio, folio, len, offset); @@ -1258,8 +1254,8 @@ static int bio_iov_add_zone_append_folio(struct bio *bio, struct folio *folio, if (bio_add_hw_folio(q, bio, folio, len, offset, queue_max_zone_append_sectors(q), &same_page) != len) return -EINVAL; - if (same_page) - bio_release_page(bio, folio_page(folio, 0)); + if (same_page && bio_flagged(bio, BIO_PAGE_PINNED)) + unpin_user_folio(folio, 1); return 0; } |