From c5f382ab2e8600388066ca33094cc8a9d97c5ede Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 22 Jan 2024 15:22:45 -0800 Subject: [PATCH] 5.15-stable patches added patches: block-remove-special-casing-of-compound-pages.patch --- ...ove-special-casing-of-compound-pages.patch | 79 +++++++++++++++++++ queue-5.15/series | 1 + 2 files changed, 80 insertions(+) create mode 100644 queue-5.15/block-remove-special-casing-of-compound-pages.patch diff --git a/queue-5.15/block-remove-special-casing-of-compound-pages.patch b/queue-5.15/block-remove-special-casing-of-compound-pages.patch new file mode 100644 index 00000000000..be8e8cc631c --- /dev/null +++ b/queue-5.15/block-remove-special-casing-of-compound-pages.patch @@ -0,0 +1,79 @@ +From 1b151e2435fc3a9b10c8946c6aebe9f3e1938c55 Mon Sep 17 00:00:00 2001 +From: "Matthew Wilcox (Oracle)" +Date: Mon, 14 Aug 2023 15:41:00 +0100 +Subject: block: Remove special-casing of compound pages + +From: Matthew Wilcox (Oracle) + +commit 1b151e2435fc3a9b10c8946c6aebe9f3e1938c55 upstream. + +The special casing was originally added in pre-git history; reproducing +the commit log here: + +> commit a318a92567d77 +> Author: Andrew Morton +> Date: Sun Sep 21 01:42:22 2003 -0700 +> +> [PATCH] Speed up direct-io hugetlbpage handling +> +> This patch short-circuits all the direct-io page dirtying logic for +> higher-order pages. Without this, we pointlessly bounce BIOs up to +> keventd all the time. + +In the last twenty years, compound pages have become used for more than +just hugetlb. Rewrite these functions to operate on folios instead +of pages and remove the special case for hugetlbfs; I don't think +it's needed any more (and if it is, we can put it back in as a call +to folio_test_hugetlb()). + +This was found by inspection; as far as I can tell, this bug can lead +to pages used as the destination of a direct I/O read not being marked +as dirty. If those pages are then reclaimed by the MM without being +dirtied for some other reason, they won't be written out. Then when +they're faulted back in, they will not contain the data they should. +It'll take a pretty unusual setup to produce this problem with several +races all going the wrong way. + +This problem predates the folio work; it could for example have been +triggered by mmaping a THP in tmpfs and using that as the target of an +O_DIRECT read. + +Fixes: 800d8c63b2e98 ("shmem: add huge pages support") +Cc: +Signed-off-by: Matthew Wilcox (Oracle) +Signed-off-by: Jens Axboe +Signed-off-by: Greg Kroah-Hartman +--- + block/bio.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +--- a/block/bio.c ++++ b/block/bio.c +@@ -1026,7 +1026,7 @@ void bio_release_pages(struct bio *bio, + return; + + bio_for_each_segment_all(bvec, bio, iter_all) { +- if (mark_dirty && !PageCompound(bvec->bv_page)) ++ if (mark_dirty) + set_page_dirty_lock(bvec->bv_page); + put_page(bvec->bv_page); + } +@@ -1345,8 +1345,7 @@ void bio_set_pages_dirty(struct bio *bio + struct bvec_iter_all iter_all; + + bio_for_each_segment_all(bvec, bio, iter_all) { +- if (!PageCompound(bvec->bv_page)) +- set_page_dirty_lock(bvec->bv_page); ++ set_page_dirty_lock(bvec->bv_page); + } + } + +@@ -1394,7 +1393,7 @@ void bio_check_pages_dirty(struct bio *b + struct bvec_iter_all iter_all; + + bio_for_each_segment_all(bvec, bio, iter_all) { +- if (!PageDirty(bvec->bv_page) && !PageCompound(bvec->bv_page)) ++ if (!PageDirty(bvec->bv_page)) + goto defer; + } + diff --git a/queue-5.15/series b/queue-5.15/series index dabe54cafe6..9496e0c4947 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -365,3 +365,4 @@ selftests-mlxsw-qos_pfc-adjust-the-test-to-support-8.patch ipv6-mcast-fix-data-race-in-ipv6_mc_down-mld_ifc_wor.patch i2c-s3c24xx-fix-read-transfers-in-polling-mode.patch i2c-s3c24xx-fix-transferring-more-than-one-message-i.patch +block-remove-special-casing-of-compound-pages.patch -- 2.47.3