* [PATCH 01/10] btrfs: tests: rename process_page_range() to process_folio_range()
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
@ 2026-09-06 22:29 ` Tal Zussman
2026-09-07 6:30 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 02/10] btrfs: tests: convert test_find_delalloc() to use folios Tal Zussman
` (8 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 22:29 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel, Tal Zussman
It already operates on folios. No functional change.
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/btrfs/tests/extent-io-tests.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index 23459cd4e503..6eb55bfb2bd4 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -18,8 +18,8 @@
#define PROCESS_RELEASE (1U << 1)
#define PROCESS_TEST_LOCKED (1U << 2)
-static noinline int process_page_range(struct inode *inode, u64 start, u64 end,
- unsigned long flags)
+static noinline int process_folio_range(struct inode *inode, u64 start, u64 end,
+ unsigned long flags)
{
int ret;
struct folio_batch fbatch;
@@ -221,8 +221,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
test_start, max_bytes - 1, start, end);
goto out_bits;
}
- if (process_page_range(inode, start, end,
- PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
+ if (process_folio_range(inode, start, end,
+ PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
test_err("there were unlocked pages in the range");
goto out_bits;
}
@@ -276,8 +276,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
test_start, total_dirty - 1, start, end);
goto out_bits;
}
- if (process_page_range(inode, start, end,
- PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
+ if (process_folio_range(inode, start, end,
+ PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
test_err("pages in range were not all locked");
goto out_bits;
}
@@ -317,8 +317,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
test_start, test_start + PAGE_SIZE - 1, start, end);
goto out_bits;
}
- if (process_page_range(inode, start, end, PROCESS_TEST_LOCKED |
- PROCESS_UNLOCK)) {
+ if (process_folio_range(inode, start, end, PROCESS_TEST_LOCKED |
+ PROCESS_UNLOCK)) {
test_err("pages in range were not all locked");
goto out_bits;
}
@@ -330,8 +330,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
out:
if (locked_page)
put_page(locked_page);
- process_page_range(inode, 0, total_dirty - 1,
- PROCESS_UNLOCK | PROCESS_RELEASE);
+ process_folio_range(inode, 0, total_dirty - 1,
+ PROCESS_UNLOCK | PROCESS_RELEASE);
iput(inode);
out_root_info:
btrfs_free_dummy_root(root);
--
2.39.5
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 01/10] btrfs: tests: rename process_page_range() to process_folio_range()
2026-09-06 22:29 ` [PATCH 01/10] btrfs: tests: rename process_page_range() to process_folio_range() Tal Zussman
@ 2026-09-07 6:30 ` Qu Wenruo
0 siblings, 0 replies; 23+ messages in thread
From: Qu Wenruo @ 2026-09-07 6:30 UTC (permalink / raw)
To: Tal Zussman, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
在 2026/9/7 07:59, Tal Zussman 写道:
> It already operates on folios. No functional change.
>
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/tests/extent-io-tests.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
> index 23459cd4e503..6eb55bfb2bd4 100644
> --- a/fs/btrfs/tests/extent-io-tests.c
> +++ b/fs/btrfs/tests/extent-io-tests.c
> @@ -18,8 +18,8 @@
> #define PROCESS_RELEASE (1U << 1)
> #define PROCESS_TEST_LOCKED (1U << 2)
>
> -static noinline int process_page_range(struct inode *inode, u64 start, u64 end,
> - unsigned long flags)
> +static noinline int process_folio_range(struct inode *inode, u64 start, u64 end,
> + unsigned long flags)
> {
> int ret;
> struct folio_batch fbatch;
> @@ -221,8 +221,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> test_start, max_bytes - 1, start, end);
> goto out_bits;
> }
> - if (process_page_range(inode, start, end,
> - PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
> + if (process_folio_range(inode, start, end,
> + PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
> test_err("there were unlocked pages in the range");
> goto out_bits;
> }
> @@ -276,8 +276,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> test_start, total_dirty - 1, start, end);
> goto out_bits;
> }
> - if (process_page_range(inode, start, end,
> - PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
> + if (process_folio_range(inode, start, end,
> + PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
> test_err("pages in range were not all locked");
> goto out_bits;
> }
> @@ -317,8 +317,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> test_start, test_start + PAGE_SIZE - 1, start, end);
> goto out_bits;
> }
> - if (process_page_range(inode, start, end, PROCESS_TEST_LOCKED |
> - PROCESS_UNLOCK)) {
> + if (process_folio_range(inode, start, end, PROCESS_TEST_LOCKED |
> + PROCESS_UNLOCK)) {
> test_err("pages in range were not all locked");
> goto out_bits;
> }
> @@ -330,8 +330,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> out:
> if (locked_page)
> put_page(locked_page);
> - process_page_range(inode, 0, total_dirty - 1,
> - PROCESS_UNLOCK | PROCESS_RELEASE);
> + process_folio_range(inode, 0, total_dirty - 1,
> + PROCESS_UNLOCK | PROCESS_RELEASE);
> iput(inode);
> out_root_info:
> btrfs_free_dummy_root(root);
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 02/10] btrfs: tests: convert test_find_delalloc() to use folios
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
2026-09-06 22:29 ` [PATCH 01/10] btrfs: tests: rename process_page_range() to process_folio_range() Tal Zussman
@ 2026-09-06 22:29 ` Tal Zussman
2026-09-07 6:29 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 03/10] btrfs: tests: use eb folio helpers in extent buffer memory checks Tal Zussman
` (7 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 22:29 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel, Tal Zussman
This removes the last btrfs callers of find_or_create_page(),
find_lock_page(), SetPageDirty(), ClearPageDirty(), and get_page(), and
15 calls to compound_head(). The folio lookups return an ERR_PTR instead
of NULL, so adjust the error handling.
Update the comments and test messages accordingly.
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/btrfs/tests/extent-io-tests.c | 94 ++++++++++++++++++++--------------------
1 file changed, 46 insertions(+), 48 deletions(-)
diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index 6eb55bfb2bd4..3056dd934b54 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -112,8 +112,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
struct btrfs_root *root = NULL;
struct inode *inode = NULL;
struct extent_io_tree *tmp;
- struct page *page;
- struct page *locked_page = NULL;
+ struct folio *folio;
+ struct folio *locked_folio = NULL;
/* In this test we need at least 2 file extents at its maximum size */
u64 max_bytes = BTRFS_MAX_EXTENT_SIZE;
u64 total_dirty = 2 * max_bytes;
@@ -152,23 +152,24 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
btrfs_extent_io_tree_init(NULL, tmp, IO_TREE_SELFTEST);
/*
- * First go through and create and mark all of our pages dirty, we pin
- * everything to make sure our pages don't get evicted and screw up our
+ * First go through and create and mark all of our folios dirty, we pin
+ * everything to make sure our folios don't get evicted and screw up our
* test.
*/
for (pgoff_t index = 0; index < (total_dirty >> PAGE_SHIFT); index++) {
- page = find_or_create_page(inode->i_mapping, index, GFP_KERNEL);
- if (!page) {
- test_err("failed to allocate test page");
- ret = -ENOMEM;
+ folio = __filemap_get_folio(inode->i_mapping, index,
+ FGP_LOCK | FGP_ACCESSED | FGP_CREAT, GFP_KERNEL);
+ if (IS_ERR(folio)) {
+ test_err("failed to allocate test folio");
+ ret = PTR_ERR(folio);
goto out;
}
- SetPageDirty(page);
+ folio_set_dirty(folio);
if (index) {
- unlock_page(page);
+ folio_unlock(folio);
} else {
- get_page(page);
- locked_page = page;
+ folio_get(folio);
+ locked_folio = folio;
}
}
@@ -179,8 +180,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
btrfs_set_extent_bit(tmp, 0, sectorsize - 1, EXTENT_DELALLOC, NULL);
start = 0;
end = start + PAGE_SIZE - 1;
- found = find_lock_delalloc_range(inode, page_folio(locked_page), &start,
- &end);
+ found = find_lock_delalloc_range(inode, locked_folio, &start, &end);
if (!found) {
test_err("should have found at least one delalloc");
goto out_bits;
@@ -191,8 +191,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
goto out_bits;
}
btrfs_unlock_extent(tmp, start, end, NULL);
- unlock_page(locked_page);
- put_page(locked_page);
+ folio_unlock(locked_folio);
+ folio_put(locked_folio);
/*
* Test this scenario
@@ -201,17 +201,17 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
* |--- search ---|
*/
test_start = SZ_64M;
- locked_page = find_lock_page(inode->i_mapping,
- test_start >> PAGE_SHIFT);
- if (!locked_page) {
- test_err("couldn't find the locked page");
+ locked_folio = filemap_lock_folio(inode->i_mapping,
+ test_start >> PAGE_SHIFT);
+ if (IS_ERR(locked_folio)) {
+ test_err("couldn't find the locked folio");
+ locked_folio = NULL;
goto out_bits;
}
btrfs_set_extent_bit(tmp, sectorsize, max_bytes - 1, EXTENT_DELALLOC, NULL);
start = test_start;
end = start + PAGE_SIZE - 1;
- found = find_lock_delalloc_range(inode, page_folio(locked_page), &start,
- &end);
+ found = find_lock_delalloc_range(inode, locked_folio, &start, &end);
if (!found) {
test_err("couldn't find delalloc in our range");
goto out_bits;
@@ -223,12 +223,12 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
}
if (process_folio_range(inode, start, end,
PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
- test_err("there were unlocked pages in the range");
+ test_err("there were unlocked folios in the range");
goto out_bits;
}
btrfs_unlock_extent(tmp, start, end, NULL);
- /* locked_page was unlocked above */
- put_page(locked_page);
+ /* locked_folio was unlocked above */
+ folio_put(locked_folio);
/*
* Test this scenario
@@ -236,16 +236,16 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
* |--- search ---|
*/
test_start = max_bytes + sectorsize;
- locked_page = find_lock_page(inode->i_mapping, test_start >>
- PAGE_SHIFT);
- if (!locked_page) {
- test_err("couldn't find the locked page");
+ locked_folio = filemap_lock_folio(inode->i_mapping,
+ test_start >> PAGE_SHIFT);
+ if (IS_ERR(locked_folio)) {
+ test_err("couldn't find the locked folio");
+ locked_folio = NULL;
goto out_bits;
}
start = test_start;
end = start + PAGE_SIZE - 1;
- found = find_lock_delalloc_range(inode, page_folio(locked_page), &start,
- &end);
+ found = find_lock_delalloc_range(inode, locked_folio, &start, &end);
if (found) {
test_err("found range when we shouldn't have");
goto out_bits;
@@ -265,8 +265,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
btrfs_set_extent_bit(tmp, max_bytes, total_dirty - 1, EXTENT_DELALLOC, NULL);
start = test_start;
end = start + PAGE_SIZE - 1;
- found = find_lock_delalloc_range(inode, page_folio(locked_page), &start,
- &end);
+ found = find_lock_delalloc_range(inode, locked_folio, &start, &end);
if (!found) {
test_err("didn't find our range");
goto out_bits;
@@ -278,36 +277,35 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
}
if (process_folio_range(inode, start, end,
PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
- test_err("pages in range were not all locked");
+ test_err("folios in range were not all locked");
goto out_bits;
}
btrfs_unlock_extent(tmp, start, end, NULL);
/*
- * Now to test where we run into a page that is no longer dirty in the
+ * Now to test where we run into a folio that is no longer dirty in the
* range we want to find.
*/
- page = find_get_page(inode->i_mapping,
- (max_bytes + SZ_1M) >> PAGE_SHIFT);
- if (!page) {
- test_err("couldn't find our page");
+ folio = filemap_get_folio(inode->i_mapping,
+ (max_bytes + SZ_1M) >> PAGE_SHIFT);
+ if (IS_ERR(folio)) {
+ test_err("couldn't find our folio");
goto out_bits;
}
- ClearPageDirty(page);
- put_page(page);
+ folio_clear_dirty(folio);
+ folio_put(folio);
/* We unlocked it in the previous test */
- lock_page(locked_page);
+ folio_lock(locked_folio);
start = test_start;
end = start + PAGE_SIZE - 1;
/*
- * Currently if we fail to find dirty pages in the delalloc range we
+ * Currently if we fail to find dirty folios in the delalloc range we
* will adjust max_bytes down to PAGE_SIZE and then re-search. If
* this changes at any point in the future we will need to fix this
* tests expected behavior.
*/
- found = find_lock_delalloc_range(inode, page_folio(locked_page), &start,
- &end);
+ found = find_lock_delalloc_range(inode, locked_folio, &start, &end);
if (!found) {
test_err("didn't find our range");
goto out_bits;
@@ -319,7 +317,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
}
if (process_folio_range(inode, start, end, PROCESS_TEST_LOCKED |
PROCESS_UNLOCK)) {
- test_err("pages in range were not all locked");
+ test_err("folios in range were not all locked");
goto out_bits;
}
ret = 0;
@@ -328,8 +326,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
dump_extent_io_tree(tmp);
btrfs_clear_extent_bit(tmp, 0, total_dirty - 1, (unsigned)-1, NULL);
out:
- if (locked_page)
- put_page(locked_page);
+ if (locked_folio)
+ folio_put(locked_folio);
process_folio_range(inode, 0, total_dirty - 1,
PROCESS_UNLOCK | PROCESS_RELEASE);
iput(inode);
--
2.39.5
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 02/10] btrfs: tests: convert test_find_delalloc() to use folios
2026-09-06 22:29 ` [PATCH 02/10] btrfs: tests: convert test_find_delalloc() to use folios Tal Zussman
@ 2026-09-07 6:29 ` Qu Wenruo
0 siblings, 0 replies; 23+ messages in thread
From: Qu Wenruo @ 2026-09-07 6:29 UTC (permalink / raw)
To: Tal Zussman, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
在 2026/9/7 07:59, Tal Zussman 写道:
> This removes the last btrfs callers of find_or_create_page(),
> find_lock_page(), SetPageDirty(), ClearPageDirty(), and get_page(), and
> 15 calls to compound_head(). The folio lookups return an ERR_PTR instead
> of NULL, so adjust the error handling.
>
> Update the comments and test messages accordingly.
I think the interface change itself is fine, although still some minor
concerns inlined below.
>
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
> ---
> fs/btrfs/tests/extent-io-tests.c | 94 ++++++++++++++++++++--------------------
> 1 file changed, 46 insertions(+), 48 deletions(-)
>
> diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
> index 6eb55bfb2bd4..3056dd934b54 100644
> --- a/fs/btrfs/tests/extent-io-tests.c
> +++ b/fs/btrfs/tests/extent-io-tests.c
> @@ -112,8 +112,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> struct btrfs_root *root = NULL;
> struct inode *inode = NULL;
> struct extent_io_tree *tmp;
> - struct page *page;
> - struct page *locked_page = NULL;
> + struct folio *folio;
> + struct folio *locked_folio = NULL;
> /* In this test we need at least 2 file extents at its maximum size */
> u64 max_bytes = BTRFS_MAX_EXTENT_SIZE;
> u64 total_dirty = 2 * max_bytes;
> @@ -152,23 +152,24 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> btrfs_extent_io_tree_init(NULL, tmp, IO_TREE_SELFTEST);
>
> /*
> - * First go through and create and mark all of our pages dirty, we pin
> - * everything to make sure our pages don't get evicted and screw up our
> + * First go through and create and mark all of our folios dirty, we pin
> + * everything to make sure our folios don't get evicted and screw up our
> * test.
> */
> for (pgoff_t index = 0; index < (total_dirty >> PAGE_SHIFT); index++) {
> - page = find_or_create_page(inode->i_mapping, index, GFP_KERNEL);
> - if (!page) {
> - test_err("failed to allocate test page");
> - ret = -ENOMEM;
> + folio = __filemap_get_folio(inode->i_mapping, index,
> + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, GFP_KERNEL);
No matter if it's the older or newer code, it's not exactly following
the real kernel behavior.
We're relying on the fact that the test inode doesn't have a folio order
range set, thus we always get page size folios.
> + if (IS_ERR(folio)) {
> + test_err("failed to allocate test folio");
> + ret = PTR_ERR(folio);
> goto out;
> }
> - SetPageDirty(page);
> + folio_set_dirty(folio);
We only need to update the folio flags, no need to bother the possible
bitmaps for bs < ps cases, or large folio cases exactly because we
always get page sized folio, and for now the test case only handles bs
== ps cases.
I'm not pushing for using btrfs_folio_set_dirty() helpers immediately,
but an "ASSERT(folio_order(folio) == 0);" would be a little safer.
> if (index) {
> - unlock_page(page);
> + folio_unlock(folio);
> } else {
> - get_page(page);
> - locked_page = page;
> + folio_get(folio);
> + locked_folio = folio;
> }
> }
>
> @@ -179,8 +180,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> btrfs_set_extent_bit(tmp, 0, sectorsize - 1, EXTENT_DELALLOC, NULL);
> start = 0;
> end = start + PAGE_SIZE - 1;
> - found = find_lock_delalloc_range(inode, page_folio(locked_page), &start,
> - &end);
> + found = find_lock_delalloc_range(inode, locked_folio, &start, &end);
> if (!found) {
> test_err("should have found at least one delalloc");
> goto out_bits;
> @@ -191,8 +191,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> goto out_bits;
> }
> btrfs_unlock_extent(tmp, start, end, NULL);
> - unlock_page(locked_page);
> - put_page(locked_page);
> + folio_unlock(locked_folio);
> + folio_put(locked_folio);
>
> /*
> * Test this scenario
> @@ -201,17 +201,17 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> * |--- search ---|
> */
> test_start = SZ_64M;
> - locked_page = find_lock_page(inode->i_mapping,
> - test_start >> PAGE_SHIFT);
> - if (!locked_page) {
> - test_err("couldn't find the locked page");
> + locked_folio = filemap_lock_folio(inode->i_mapping,
> + test_start >> PAGE_SHIFT);
> + if (IS_ERR(locked_folio)) {
> + test_err("couldn't find the locked folio");
> + locked_folio = NULL;
> goto out_bits;
> }
> btrfs_set_extent_bit(tmp, sectorsize, max_bytes - 1, EXTENT_DELALLOC, NULL);
> start = test_start;
> end = start + PAGE_SIZE - 1;
The same here, the range only works if the folio is page sized.
Thus an ASSERT() would be preferred for every range that is still based
on PAGE_SIZE.
Otherwise looks good to me.
Thanks,
Qu
> - found = find_lock_delalloc_range(inode, page_folio(locked_page), &start,
> - &end);
> + found = find_lock_delalloc_range(inode, locked_folio, &start, &end);
> if (!found) {
> test_err("couldn't find delalloc in our range");
> goto out_bits;
> @@ -223,12 +223,12 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> }
> if (process_folio_range(inode, start, end,
> PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
> - test_err("there were unlocked pages in the range");
> + test_err("there were unlocked folios in the range");
> goto out_bits;
> }
> btrfs_unlock_extent(tmp, start, end, NULL);
> - /* locked_page was unlocked above */
> - put_page(locked_page);
> + /* locked_folio was unlocked above */
> + folio_put(locked_folio);
>
> /*
> * Test this scenario
> @@ -236,16 +236,16 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> * |--- search ---|
> */
> test_start = max_bytes + sectorsize;
> - locked_page = find_lock_page(inode->i_mapping, test_start >>
> - PAGE_SHIFT);
> - if (!locked_page) {
> - test_err("couldn't find the locked page");
> + locked_folio = filemap_lock_folio(inode->i_mapping,
> + test_start >> PAGE_SHIFT);
> + if (IS_ERR(locked_folio)) {
> + test_err("couldn't find the locked folio");
> + locked_folio = NULL;
> goto out_bits;
> }
> start = test_start;
> end = start + PAGE_SIZE - 1;
> - found = find_lock_delalloc_range(inode, page_folio(locked_page), &start,
> - &end);
> + found = find_lock_delalloc_range(inode, locked_folio, &start, &end);
> if (found) {
> test_err("found range when we shouldn't have");
> goto out_bits;
> @@ -265,8 +265,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> btrfs_set_extent_bit(tmp, max_bytes, total_dirty - 1, EXTENT_DELALLOC, NULL);
> start = test_start;
> end = start + PAGE_SIZE - 1;
> - found = find_lock_delalloc_range(inode, page_folio(locked_page), &start,
> - &end);
> + found = find_lock_delalloc_range(inode, locked_folio, &start, &end);
> if (!found) {
> test_err("didn't find our range");
> goto out_bits;
> @@ -278,36 +277,35 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> }
> if (process_folio_range(inode, start, end,
> PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
> - test_err("pages in range were not all locked");
> + test_err("folios in range were not all locked");
> goto out_bits;
> }
> btrfs_unlock_extent(tmp, start, end, NULL);
>
> /*
> - * Now to test where we run into a page that is no longer dirty in the
> + * Now to test where we run into a folio that is no longer dirty in the
> * range we want to find.
> */
> - page = find_get_page(inode->i_mapping,
> - (max_bytes + SZ_1M) >> PAGE_SHIFT);
> - if (!page) {
> - test_err("couldn't find our page");
> + folio = filemap_get_folio(inode->i_mapping,
> + (max_bytes + SZ_1M) >> PAGE_SHIFT);
> + if (IS_ERR(folio)) {
> + test_err("couldn't find our folio");
> goto out_bits;
> }
> - ClearPageDirty(page);
> - put_page(page);
> + folio_clear_dirty(folio);
> + folio_put(folio);
>
> /* We unlocked it in the previous test */
> - lock_page(locked_page);
> + folio_lock(locked_folio);
> start = test_start;
> end = start + PAGE_SIZE - 1;
> /*
> - * Currently if we fail to find dirty pages in the delalloc range we
> + * Currently if we fail to find dirty folios in the delalloc range we
> * will adjust max_bytes down to PAGE_SIZE and then re-search. If
> * this changes at any point in the future we will need to fix this
> * tests expected behavior.
> */
> - found = find_lock_delalloc_range(inode, page_folio(locked_page), &start,
> - &end);
> + found = find_lock_delalloc_range(inode, locked_folio, &start, &end);
> if (!found) {
> test_err("didn't find our range");
> goto out_bits;
> @@ -319,7 +317,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> }
> if (process_folio_range(inode, start, end, PROCESS_TEST_LOCKED |
> PROCESS_UNLOCK)) {
> - test_err("pages in range were not all locked");
> + test_err("folios in range were not all locked");
> goto out_bits;
> }
> ret = 0;
> @@ -328,8 +326,8 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> dump_extent_io_tree(tmp);
> btrfs_clear_extent_bit(tmp, 0, total_dirty - 1, (unsigned)-1, NULL);
> out:
> - if (locked_page)
> - put_page(locked_page);
> + if (locked_folio)
> + folio_put(locked_folio);
> process_folio_range(inode, 0, total_dirty - 1,
> PROCESS_UNLOCK | PROCESS_RELEASE);
> iput(inode);
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 03/10] btrfs: tests: use eb folio helpers in extent buffer memory checks
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
2026-09-06 22:29 ` [PATCH 01/10] btrfs: tests: rename process_page_range() to process_folio_range() Tal Zussman
2026-09-06 22:29 ` [PATCH 02/10] btrfs: tests: convert test_find_delalloc() to use folios Tal Zussman
@ 2026-09-06 22:29 ` Tal Zussman
2026-09-07 6:33 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 04/10] btrfs: convert btrfs_compr_pool_scan() to use folios Tal Zussman
` (6 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 22:29 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel, Tal Zussman
dump_eb_and_memory_contents() and verify_eb_and_memory() hardcode one
page per folio instead of using get_eb_folio_index() and
get_eb_offset_in_folio() like the rest of the extent buffer code. Use
the helpers and folio_address(). This removes the last struct page usage
in the file.
No functional change. The tests only run with sectorsize == PAGE_SIZE,
and the test extent buffers are backed by order-0 folios.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/btrfs/tests/extent-io-tests.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index 3056dd934b54..7a68b321608e 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -669,8 +669,9 @@ static void dump_eb_and_memory_contents(struct extent_buffer *eb, void *memory,
const char *test_name)
{
for (int i = 0; i < eb->len; i++) {
- struct page *page = folio_page(eb->folios[i >> PAGE_SHIFT], 0);
- void *addr = page_address(page) + offset_in_page(i);
+ const unsigned long idx = get_eb_folio_index(eb, i);
+ void *addr = folio_address(eb->folios[idx]) +
+ get_eb_offset_in_folio(eb, i);
if (memcmp(addr, memory + i, 1) != 0) {
test_err("%s failed", test_name);
@@ -685,9 +686,12 @@ static int verify_eb_and_memory(struct extent_buffer *eb, void *memory,
const char *test_name)
{
for (int i = 0; i < (eb->len >> PAGE_SHIFT); i++) {
- void *eb_addr = folio_address(eb->folios[i]);
+ const unsigned long offset = i << PAGE_SHIFT;
+ const unsigned long idx = get_eb_folio_index(eb, offset);
+ void *eb_addr = folio_address(eb->folios[idx]) +
+ get_eb_offset_in_folio(eb, offset);
- if (memcmp(memory + (i << PAGE_SHIFT), eb_addr, PAGE_SIZE) != 0) {
+ if (memcmp(memory + offset, eb_addr, PAGE_SIZE) != 0) {
dump_eb_and_memory_contents(eb, memory, test_name);
return -EUCLEAN;
}
--
2.39.5
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 03/10] btrfs: tests: use eb folio helpers in extent buffer memory checks
2026-09-06 22:29 ` [PATCH 03/10] btrfs: tests: use eb folio helpers in extent buffer memory checks Tal Zussman
@ 2026-09-07 6:33 ` Qu Wenruo
0 siblings, 0 replies; 23+ messages in thread
From: Qu Wenruo @ 2026-09-07 6:33 UTC (permalink / raw)
To: Tal Zussman, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
在 2026/9/7 07:59, Tal Zussman 写道:
> dump_eb_and_memory_contents() and verify_eb_and_memory() hardcode one
> page per folio instead of using get_eb_folio_index() and
> get_eb_offset_in_folio() like the rest of the extent buffer code. Use
> the helpers and folio_address(). This removes the last struct page usage
> in the file.
>
> No functional change. The tests only run with sectorsize == PAGE_SIZE,
> and the test extent buffers are backed by order-0 folios.
>
> Assisted-by: Claude:claude-fable-5-1
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu> ---
> fs/btrfs/tests/extent-io-tests.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
> index 3056dd934b54..7a68b321608e 100644
> --- a/fs/btrfs/tests/extent-io-tests.c
> +++ b/fs/btrfs/tests/extent-io-tests.c
> @@ -669,8 +669,9 @@ static void dump_eb_and_memory_contents(struct extent_buffer *eb, void *memory,
> const char *test_name)
> {
> for (int i = 0; i < eb->len; i++) {
> - struct page *page = folio_page(eb->folios[i >> PAGE_SHIFT], 0);
> - void *addr = page_address(page) + offset_in_page(i);
> + const unsigned long idx = get_eb_folio_index(eb, i);
> + void *addr = folio_address(eb->folios[idx]) +
> + get_eb_offset_in_folio(eb, i);
>
> if (memcmp(addr, memory + i, 1) != 0) {
> test_err("%s failed", test_name);
> @@ -685,9 +686,12 @@ static int verify_eb_and_memory(struct extent_buffer *eb, void *memory,
> const char *test_name)
> {
> for (int i = 0; i < (eb->len >> PAGE_SHIFT); i++) {
> - void *eb_addr = folio_address(eb->folios[i]);
> + const unsigned long offset = i << PAGE_SHIFT;
> + const unsigned long idx = get_eb_folio_index(eb, offset);
> + void *eb_addr = folio_address(eb->folios[idx]) +
> + get_eb_offset_in_folio(eb, offset);
>
> - if (memcmp(memory + (i << PAGE_SHIFT), eb_addr, PAGE_SIZE) != 0) {
> + if (memcmp(memory + offset, eb_addr, PAGE_SIZE) != 0) {
> dump_eb_and_memory_contents(eb, memory, test_name);
> return -EUCLEAN;
> }
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 04/10] btrfs: convert btrfs_compr_pool_scan() to use folios
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
` (2 preceding siblings ...)
2026-09-06 22:29 ` [PATCH 03/10] btrfs: tests: use eb folio helpers in extent buffer memory checks Tal Zussman
@ 2026-09-06 22:29 ` Tal Zussman
2026-09-07 6:36 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 05/10] btrfs: convert heuristic_collect_sample() " Tal Zussman
` (5 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 22:29 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel, Tal Zussman
The compression pool holds order-0 folios, but btrfs_compr_pool_scan()
walks it as struct page through page->lru. Walk it as folios, matching
the other compression pool functions. This removes the last use of
page->lru in btrfs and saves a call to compound_head() per freed
folio.
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/btrfs/compression.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index c62b5148d5ac..979b2ffbd8fc 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -168,10 +168,10 @@ static unsigned long btrfs_compr_pool_scan(struct shrinker *sh, struct shrink_co
spin_unlock(&compr_pool.lock);
list_for_each_safe(tmp, next, &remove) {
- struct page *page = list_entry(tmp, struct page, lru);
+ struct folio *folio = list_entry(tmp, struct folio, lru);
- ASSERT(page_ref_count(page) == 1);
- put_page(page);
+ ASSERT(folio_ref_count(folio) == 1);
+ folio_put(folio);
}
return freed;
--
2.39.5
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 04/10] btrfs: convert btrfs_compr_pool_scan() to use folios
2026-09-06 22:29 ` [PATCH 04/10] btrfs: convert btrfs_compr_pool_scan() to use folios Tal Zussman
@ 2026-09-07 6:36 ` Qu Wenruo
0 siblings, 0 replies; 23+ messages in thread
From: Qu Wenruo @ 2026-09-07 6:36 UTC (permalink / raw)
To: Tal Zussman, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
在 2026/9/7 07:59, Tal Zussman 写道:
> The compression pool holds order-0 folios, but btrfs_compr_pool_scan()
> walks it as struct page through page->lru. Walk it as folios, matching
> the other compression pool functions. This removes the last use of
> page->lru in btrfs and saves a call to compound_head() per freed
> folio.
>
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/compression.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
> index c62b5148d5ac..979b2ffbd8fc 100644
> --- a/fs/btrfs/compression.c
> +++ b/fs/btrfs/compression.c
> @@ -168,10 +168,10 @@ static unsigned long btrfs_compr_pool_scan(struct shrinker *sh, struct shrink_co
> spin_unlock(&compr_pool.lock);
>
> list_for_each_safe(tmp, next, &remove) {
> - struct page *page = list_entry(tmp, struct page, lru);
> + struct folio *folio = list_entry(tmp, struct folio, lru);
>
> - ASSERT(page_ref_count(page) == 1);
> - put_page(page);
> + ASSERT(folio_ref_count(folio) == 1);
> + folio_put(folio);
> }
>
> return freed;
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 05/10] btrfs: convert heuristic_collect_sample() to use folios
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
` (3 preceding siblings ...)
2026-09-06 22:29 ` [PATCH 04/10] btrfs: convert btrfs_compr_pool_scan() to use folios Tal Zussman
@ 2026-09-06 22:29 ` Tal Zussman
2026-09-07 6:44 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 06/10] btrfs: fix stale function references in compression comments Tal Zussman
` (4 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 22:29 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel, Tal Zussman
Convert the sampling loop to folios. This removes the last caller of
find_get_page() in btrfs and saves a call to compound_head() per sampled
page. Document that the lookup is not supposed to fail with an ASSERT().
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/btrfs/compression.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 979b2ffbd8fc..fa8b92592321 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -1488,7 +1488,7 @@ static bool sample_repeated_patterns(struct heuristic_ws *ws)
static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
struct heuristic_ws *ws)
{
- struct page *page;
+ struct folio *folio;
pgoff_t index, index_end;
u32 i, curr_sample_pos;
u8 *in_data;
@@ -1514,8 +1514,10 @@ static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
curr_sample_pos = 0;
while (index < index_end) {
- page = find_get_page(inode->i_mapping, index);
- in_data = kmap_local_page(page);
+ folio = filemap_get_folio(inode->i_mapping, index);
+ ASSERT(!IS_ERR(folio));
+ in_data = kmap_local_folio(folio,
+ offset_in_folio(folio, (u64)index << PAGE_SHIFT));
/* Handle case where the start is not aligned to PAGE_SIZE */
i = start % PAGE_SIZE;
while (i < PAGE_SIZE - SAMPLING_READ_SIZE) {
@@ -1529,7 +1531,7 @@ static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
curr_sample_pos += SAMPLING_READ_SIZE;
}
kunmap_local(in_data);
- put_page(page);
+ folio_put(folio);
index++;
}
--
2.39.5
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 05/10] btrfs: convert heuristic_collect_sample() to use folios
2026-09-06 22:29 ` [PATCH 05/10] btrfs: convert heuristic_collect_sample() " Tal Zussman
@ 2026-09-07 6:44 ` Qu Wenruo
0 siblings, 0 replies; 23+ messages in thread
From: Qu Wenruo @ 2026-09-07 6:44 UTC (permalink / raw)
To: Tal Zussman, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
在 2026/9/7 07:59, Tal Zussman 写道:
> Convert the sampling loop to folios. This removes the last caller of
> find_get_page() in btrfs and saves a call to compound_head() per sampled
> page. Document that the lookup is not supposed to fail with an ASSERT().
>
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Although the existing code doesn't looks particularly well, e.g. it's
still fully based on page index, and not handling large folios correctly
that well.
E.g. if we hit a large folio, we can handle the whole range inside the
folio in one go, without the need to grab example pages by pages.
But that's for future improvement, and shouldn't bother your page->folio
interface change.
Thanks,
Qu
> ---
> fs/btrfs/compression.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
> index 979b2ffbd8fc..fa8b92592321 100644
> --- a/fs/btrfs/compression.c
> +++ b/fs/btrfs/compression.c
> @@ -1488,7 +1488,7 @@ static bool sample_repeated_patterns(struct heuristic_ws *ws)
> static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
> struct heuristic_ws *ws)
> {
> - struct page *page;
> + struct folio *folio;
> pgoff_t index, index_end;
> u32 i, curr_sample_pos;
> u8 *in_data;
> @@ -1514,8 +1514,10 @@ static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
>
> curr_sample_pos = 0;
> while (index < index_end) {
> - page = find_get_page(inode->i_mapping, index);
> - in_data = kmap_local_page(page);
> + folio = filemap_get_folio(inode->i_mapping, index);
> + ASSERT(!IS_ERR(folio));
> + in_data = kmap_local_folio(folio,
> + offset_in_folio(folio, (u64)index << PAGE_SHIFT));
> /* Handle case where the start is not aligned to PAGE_SIZE */
> i = start % PAGE_SIZE;
> while (i < PAGE_SIZE - SAMPLING_READ_SIZE) {
> @@ -1529,7 +1531,7 @@ static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
> curr_sample_pos += SAMPLING_READ_SIZE;
> }
> kunmap_local(in_data);
> - put_page(page);
> + folio_put(folio);
>
> index++;
> }
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 06/10] btrfs: fix stale function references in compression comments
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
` (4 preceding siblings ...)
2026-09-06 22:29 ` [PATCH 05/10] btrfs: convert heuristic_collect_sample() " Tal Zussman
@ 2026-09-06 22:29 ` Tal Zussman
2026-09-07 6:44 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 07/10] btrfs: use folios for reading super blocks from the block device Tal Zussman
` (3 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 22:29 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel, Tal Zussman
add_ra_bio_pages() was renamed to add_ra_bio_folios(), and
btrfs_compress_filemap_get_folio() wraps filemap_get_folio(), not
find_get_page(). Update the comments accordingly.
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/btrfs/compression.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index fa8b92592321..20169d028961 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -431,7 +431,7 @@ static noinline int add_ra_bio_folios(struct inode *inode, u64 compressed_end,
}
/*
- * Since add_ra_bio_pages() is always speculative, suppress
+ * Since add_ra_bio_folios() is always speculative, suppress
* allocation warnings.
*/
masked_constraint_gfp = mapping_gfp_constraint(mapping, constraint_gfp);
@@ -960,7 +960,7 @@ bool btrfs_compress_level_valid(unsigned int type, int level)
return levels->min_level <= level && level <= levels->max_level;
}
-/* Wrapper around find_get_page(), with extra error message. */
+/* Wrapper around filemap_get_folio(), with extra error message. */
int btrfs_compress_filemap_get_folio(struct address_space *mapping, u64 start,
struct folio **in_folio_ret)
{
--
2.39.5
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 06/10] btrfs: fix stale function references in compression comments
2026-09-06 22:29 ` [PATCH 06/10] btrfs: fix stale function references in compression comments Tal Zussman
@ 2026-09-07 6:44 ` Qu Wenruo
0 siblings, 0 replies; 23+ messages in thread
From: Qu Wenruo @ 2026-09-07 6:44 UTC (permalink / raw)
To: Tal Zussman, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
在 2026/9/7 07:59, Tal Zussman 写道:
> add_ra_bio_pages() was renamed to add_ra_bio_folios(), and
> btrfs_compress_filemap_get_folio() wraps filemap_get_folio(), not
> find_get_page(). Update the comments accordingly.
>
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/compression.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
> index fa8b92592321..20169d028961 100644
> --- a/fs/btrfs/compression.c
> +++ b/fs/btrfs/compression.c
> @@ -431,7 +431,7 @@ static noinline int add_ra_bio_folios(struct inode *inode, u64 compressed_end,
> }
>
> /*
> - * Since add_ra_bio_pages() is always speculative, suppress
> + * Since add_ra_bio_folios() is always speculative, suppress
> * allocation warnings.
> */
> masked_constraint_gfp = mapping_gfp_constraint(mapping, constraint_gfp);
> @@ -960,7 +960,7 @@ bool btrfs_compress_level_valid(unsigned int type, int level)
> return levels->min_level <= level && level <= levels->max_level;
> }
>
> -/* Wrapper around find_get_page(), with extra error message. */
> +/* Wrapper around filemap_get_folio(), with extra error message. */
> int btrfs_compress_filemap_get_folio(struct address_space *mapping, u64 start,
> struct folio **in_folio_ret)
> {
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 07/10] btrfs: use folios for reading super blocks from the block device
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
` (5 preceding siblings ...)
2026-09-06 22:29 ` [PATCH 06/10] btrfs: fix stale function references in compression comments Tal Zussman
@ 2026-09-06 22:29 ` Tal Zussman
2026-09-07 6:51 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 08/10] btrfs: keep the free space cache inode mapping at order 0 Tal Zussman
` (2 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 22:29 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel, Tal Zussman
btrfs_read_disk_super() and the zoned super block log comparison go
through read_cache_page_gfp() and page_address(), and
btrfs_release_disk_super() recovers the page with virt_to_page(). Use
mapping_read_folio_gfp(), folio_address(), and virt_to_folio() instead.
This removes the last callers of read_cache_page_gfp() and put_page()
in btrfs.
Compute the super block address with offset_in_folio() as
write_dev_supers() does, rather than assuming it is at the start of
the page.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/btrfs/volumes.c | 16 +++++++---------
fs/btrfs/zoned.c | 12 ++++++------
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 949e40baff33..4ddabadc9188 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1327,16 +1327,14 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
void btrfs_release_disk_super(struct btrfs_super_block *super)
{
- struct page *page = virt_to_page(super);
-
- put_page(page);
+ folio_put(virt_to_folio(super));
}
struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,
int copy_num, bool drop_cache)
{
struct btrfs_super_block *super;
- struct page *page;
+ struct folio *folio;
u64 bytenr, bytenr_orig;
struct address_space *mapping = bdev->bd_mapping;
int ret;
@@ -1357,7 +1355,7 @@ struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,
ASSERT(copy_num == 0);
/*
- * Drop the page of the primary superblock, so later read will
+ * Drop the folio of the primary superblock, so later read will
* always read from the device.
*/
invalidate_inode_pages2_range(mapping, bytenr >> PAGE_SHIFT,
@@ -1365,12 +1363,12 @@ struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,
}
filemap_invalidate_lock_shared(mapping);
- page = read_cache_page_gfp(mapping, bytenr >> PAGE_SHIFT, GFP_NOFS);
+ folio = mapping_read_folio_gfp(mapping, bytenr >> PAGE_SHIFT, GFP_NOFS);
filemap_invalidate_unlock_shared(mapping);
- if (IS_ERR(page))
- return ERR_CAST(page);
+ if (IS_ERR(folio))
+ return ERR_CAST(folio);
- super = page_address(page);
+ super = folio_address(folio) + offset_in_folio(folio, bytenr);
if (btrfs_super_magic(super) != BTRFS_MAGIC ||
btrfs_super_bytenr(super) != bytenr_orig) {
btrfs_release_disk_super(super);
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 08a15465a087..a1ef8caaacda 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -123,24 +123,24 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
} else if (full[0] && full[1]) {
/* Compare two super blocks */
struct address_space *mapping = bdev->bd_mapping;
- struct page *page[BTRFS_NR_SB_LOG_ZONES];
struct btrfs_super_block *super[BTRFS_NR_SB_LOG_ZONES];
for (int i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++) {
u64 zone_end = (zones[i].start + zones[i].capacity) << SECTOR_SHIFT;
u64 bytenr = ALIGN_DOWN(zone_end, BTRFS_SUPER_INFO_SIZE) -
BTRFS_SUPER_INFO_SIZE;
+ struct folio *folio;
filemap_invalidate_lock_shared(mapping);
- page[i] = read_cache_page_gfp(mapping,
- bytenr >> PAGE_SHIFT, GFP_NOFS);
+ folio = mapping_read_folio_gfp(mapping, bytenr >> PAGE_SHIFT,
+ GFP_NOFS);
filemap_invalidate_unlock_shared(mapping);
- if (IS_ERR(page[i])) {
+ if (IS_ERR(folio)) {
if (i == 1)
btrfs_release_disk_super(super[0]);
- return PTR_ERR(page[i]);
+ return PTR_ERR(folio);
}
- super[i] = page_address(page[i]);
+ super[i] = folio_address(folio) + offset_in_folio(folio, bytenr);
}
if (btrfs_super_generation(super[0]) >
--
2.39.5
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 07/10] btrfs: use folios for reading super blocks from the block device
2026-09-06 22:29 ` [PATCH 07/10] btrfs: use folios for reading super blocks from the block device Tal Zussman
@ 2026-09-07 6:51 ` Qu Wenruo
0 siblings, 0 replies; 23+ messages in thread
From: Qu Wenruo @ 2026-09-07 6:51 UTC (permalink / raw)
To: Tal Zussman, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
在 2026/9/7 07:59, Tal Zussman 写道:
> btrfs_read_disk_super() and the zoned super block log comparison go
> through read_cache_page_gfp() and page_address(), and
> btrfs_release_disk_super() recovers the page with virt_to_page(). Use
> mapping_read_folio_gfp(), folio_address(), and virt_to_folio() instead.
> This removes the last callers of read_cache_page_gfp() and put_page()
> in btrfs.
>
> Compute the super block address with offset_in_folio() as
> write_dev_supers() does, rather than assuming it is at the start of
> the page.
>
> Assisted-by: Claude:claude-fable-5-1
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/volumes.c | 16 +++++++---------
> fs/btrfs/zoned.c | 12 ++++++------
> 2 files changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 949e40baff33..4ddabadc9188 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1327,16 +1327,14 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
>
> void btrfs_release_disk_super(struct btrfs_super_block *super)
> {
> - struct page *page = virt_to_page(super);
> -
> - put_page(page);
> + folio_put(virt_to_folio(super));
> }
>
> struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,
> int copy_num, bool drop_cache)
> {
> struct btrfs_super_block *super;
> - struct page *page;
> + struct folio *folio;
> u64 bytenr, bytenr_orig;
> struct address_space *mapping = bdev->bd_mapping;
> int ret;
> @@ -1357,7 +1355,7 @@ struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,
> ASSERT(copy_num == 0);
>
> /*
> - * Drop the page of the primary superblock, so later read will
> + * Drop the folio of the primary superblock, so later read will
> * always read from the device.
> */
> invalidate_inode_pages2_range(mapping, bytenr >> PAGE_SHIFT,
> @@ -1365,12 +1363,12 @@ struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,
> }
>
> filemap_invalidate_lock_shared(mapping);
> - page = read_cache_page_gfp(mapping, bytenr >> PAGE_SHIFT, GFP_NOFS);
> + folio = mapping_read_folio_gfp(mapping, bytenr >> PAGE_SHIFT, GFP_NOFS);
> filemap_invalidate_unlock_shared(mapping);
> - if (IS_ERR(page))
> - return ERR_CAST(page);
> + if (IS_ERR(folio))
> + return ERR_CAST(folio);
>
> - super = page_address(page);
> + super = folio_address(folio) + offset_in_folio(folio, bytenr);
> if (btrfs_super_magic(super) != BTRFS_MAGIC ||
> btrfs_super_bytenr(super) != bytenr_orig) {
> btrfs_release_disk_super(super);
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index 08a15465a087..a1ef8caaacda 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -123,24 +123,24 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
> } else if (full[0] && full[1]) {
> /* Compare two super blocks */
> struct address_space *mapping = bdev->bd_mapping;
> - struct page *page[BTRFS_NR_SB_LOG_ZONES];
> struct btrfs_super_block *super[BTRFS_NR_SB_LOG_ZONES];
>
> for (int i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++) {
> u64 zone_end = (zones[i].start + zones[i].capacity) << SECTOR_SHIFT;
> u64 bytenr = ALIGN_DOWN(zone_end, BTRFS_SUPER_INFO_SIZE) -
> BTRFS_SUPER_INFO_SIZE;
> + struct folio *folio;
>
> filemap_invalidate_lock_shared(mapping);
> - page[i] = read_cache_page_gfp(mapping,
> - bytenr >> PAGE_SHIFT, GFP_NOFS);
> + folio = mapping_read_folio_gfp(mapping, bytenr >> PAGE_SHIFT,
> + GFP_NOFS);
> filemap_invalidate_unlock_shared(mapping);
> - if (IS_ERR(page[i])) {
> + if (IS_ERR(folio)) {
> if (i == 1)
> btrfs_release_disk_super(super[0]);
> - return PTR_ERR(page[i]);
> + return PTR_ERR(folio);
> }
> - super[i] = page_address(page[i]);
> + super[i] = folio_address(folio) + offset_in_folio(folio, bytenr);
> }
>
> if (btrfs_super_generation(super[0]) >
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 08/10] btrfs: keep the free space cache inode mapping at order 0
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
` (6 preceding siblings ...)
2026-09-06 22:29 ` [PATCH 07/10] btrfs: use folios for reading super blocks from the block device Tal Zussman
@ 2026-09-06 22:29 ` Tal Zussman
2026-09-06 23:10 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 09/10] btrfs: convert struct btrfs_io_ctl to use folios Tal Zussman
2026-09-06 22:29 ` [PATCH 10/10] btrfs: rename io_ctl page helpers to folio helpers Tal Zussman
9 siblings, 1 reply; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 22:29 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel, Tal Zussman
The free space cache inode is a data inode, so the read path enables
large folios on its mapping. The v1 cache code assumes one page per
folio. With a large folio, consecutive __filemap_get_folio() calls in
io_ctl_prepare_pages() would return the same folio and deadlock on the
second FGP_LOCK.
The v1 on-disk format is PAGE_SIZE granular, so keep the mapping at
order 0 rather than teaching the io_ctl code about large folios.
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/btrfs/btrfs_inode.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 89e5e9c0c904..5d85aa69db13 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -502,6 +502,13 @@ static inline void btrfs_set_inode_mapping_order(struct btrfs_inode *inode)
/* Metadata inode should not reach here. */
ASSERT(is_data_inode(inode));
+ /*
+ * The v1 free space cache operates on PAGE_SIZE chunks and assumes
+ * one page per folio. Leave it at order 0.
+ */
+ if (btrfs_is_free_space_inode(inode))
+ return;
+
mapping_set_folio_order_range(inode->vfs_inode.i_mapping,
inode->root->fs_info->block_min_order,
inode->root->fs_info->block_max_order);
--
2.39.5
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 08/10] btrfs: keep the free space cache inode mapping at order 0
2026-09-06 22:29 ` [PATCH 08/10] btrfs: keep the free space cache inode mapping at order 0 Tal Zussman
@ 2026-09-06 23:10 ` Qu Wenruo
0 siblings, 0 replies; 23+ messages in thread
From: Qu Wenruo @ 2026-09-06 23:10 UTC (permalink / raw)
To: Tal Zussman, David Sterba, Chris Mason; +Cc: linux-btrfs, linux-kernel
在 2026/9/7 07:59, Tal Zussman 写道:
> The free space cache inode is a data inode, so the read path enables
> large folios on its mapping. The v1 cache code assumes one page per
> folio. With a large folio, consecutive __filemap_get_folio() calls in
> io_ctl_prepare_pages() would return the same folio and deadlock on the
> second FGP_LOCK.
>
> The v1 on-disk format is PAGE_SIZE granular, so keep the mapping at
> order 0 rather than teaching the io_ctl code about large folios.
>
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
V1 space cache is already disabled by commit 545e560a5b0f ("btrfs:
disable v1 space cache").
I do not think you should add such check for things that we're already
planning to fully remove.
> ---
> fs/btrfs/btrfs_inode.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
> index 89e5e9c0c904..5d85aa69db13 100644
> --- a/fs/btrfs/btrfs_inode.h
> +++ b/fs/btrfs/btrfs_inode.h
> @@ -502,6 +502,13 @@ static inline void btrfs_set_inode_mapping_order(struct btrfs_inode *inode)
> /* Metadata inode should not reach here. */
> ASSERT(is_data_inode(inode));
>
> + /*
> + * The v1 free space cache operates on PAGE_SIZE chunks and assumes
> + * one page per folio. Leave it at order 0.
> + */
> + if (btrfs_is_free_space_inode(inode))
> + return;
> +
> mapping_set_folio_order_range(inode->vfs_inode.i_mapping,
> inode->root->fs_info->block_min_order,
> inode->root->fs_info->block_max_order);
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 09/10] btrfs: convert struct btrfs_io_ctl to use folios
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
` (7 preceding siblings ...)
2026-09-06 22:29 ` [PATCH 08/10] btrfs: keep the free space cache inode mapping at order 0 Tal Zussman
@ 2026-09-06 22:29 ` Tal Zussman
2026-09-06 22:29 ` [PATCH 10/10] btrfs: rename io_ctl page helpers to folio helpers Tal Zussman
9 siblings, 0 replies; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 22:29 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel, Tal Zussman
io_ctl_prepare_pages() gets folios from __filemap_get_folio() and
immediately converts them to pages. Store folios instead and use the
folio APIs throughout. This removes the last btrfs callers of
unlock_page() and clear_page_dirty_for_io(), and four calls to
compound_head().
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/btrfs/disk-io.c | 2 +-
fs/btrfs/free-space-cache.c | 68 ++++++++++++++++++++++-----------------------
fs/btrfs/free-space-cache.h | 8 +++---
3 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index a1d83ad9a4c0..1accc2fd17f5 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -4889,7 +4889,7 @@ static void btrfs_cleanup_bg_io(struct btrfs_block_group *cache)
cache->io_ctl.inode = NULL;
iput(inode);
}
- ASSERT(cache->io_ctl.pages == NULL);
+ ASSERT(cache->io_ctl.folios == NULL);
btrfs_put_block_group(cache);
}
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index e2af75a205ea..ab933ee6f19c 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -378,21 +378,21 @@ static void readahead_cache(struct inode *inode)
static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
int write)
{
- int num_pages;
+ int num_folios;
- num_pages = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
+ num_folios = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
/* Make sure we can fit our crcs and generation into the first page */
- if (write && (num_pages * sizeof(u32) + sizeof(u64)) > PAGE_SIZE)
+ if (write && (num_folios * sizeof(u32) + sizeof(u64)) > PAGE_SIZE)
return -ENOSPC;
memset(io_ctl, 0, sizeof(struct btrfs_io_ctl));
- io_ctl->pages = kzalloc_objs(struct page *, num_pages, GFP_NOFS);
- if (!io_ctl->pages)
+ io_ctl->folios = kzalloc_objs(struct folio *, num_folios, GFP_NOFS);
+ if (!io_ctl->folios)
return -ENOMEM;
- io_ctl->num_pages = num_pages;
+ io_ctl->num_folios = num_folios;
io_ctl->fs_info = inode_to_fs_info(inode);
io_ctl->inode = inode;
@@ -402,8 +402,8 @@ ALLOW_ERROR_INJECTION(io_ctl_init, ERRNO);
static void io_ctl_free(struct btrfs_io_ctl *io_ctl)
{
- kfree(io_ctl->pages);
- io_ctl->pages = NULL;
+ kfree(io_ctl->folios);
+ io_ctl->folios = NULL;
}
static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
@@ -416,9 +416,9 @@ static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
{
- ASSERT(io_ctl->index < io_ctl->num_pages);
- io_ctl->page = io_ctl->pages[io_ctl->index++];
- io_ctl->cur = page_address(io_ctl->page);
+ ASSERT(io_ctl->index < io_ctl->num_folios);
+ io_ctl->folio = io_ctl->folios[io_ctl->index++];
+ io_ctl->cur = folio_address(io_ctl->folio);
io_ctl->orig = io_ctl->cur;
io_ctl->size = PAGE_SIZE;
if (clear)
@@ -431,10 +431,10 @@ static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
io_ctl_unmap_page(io_ctl);
- for (i = 0; i < io_ctl->num_pages; i++) {
- if (io_ctl->pages[i]) {
- unlock_page(io_ctl->pages[i]);
- put_page(io_ctl->pages[i]);
+ for (i = 0; i < io_ctl->num_folios; i++) {
+ if (io_ctl->folios[i]) {
+ folio_unlock(io_ctl->folios[i]);
+ folio_put(io_ctl->folios[i]);
}
}
}
@@ -446,7 +446,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
int i;
- for (i = 0; i < io_ctl->num_pages; i++) {
+ for (i = 0; i < io_ctl->num_folios; i++) {
int ret;
folio = __filemap_get_folio(inode->i_mapping, i,
@@ -465,7 +465,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
return ret;
}
- io_ctl->pages[i] = &folio->page;
+ io_ctl->folios[i] = folio;
if (uptodate && !folio_test_uptodate(folio)) {
btrfs_read_folio(NULL, folio);
folio_lock(folio);
@@ -484,8 +484,8 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
}
}
- for (i = 0; i < io_ctl->num_pages; i++)
- clear_page_dirty_for_io(io_ctl->pages[i]);
+ for (i = 0; i < io_ctl->num_folios; i++)
+ folio_clear_dirty_for_io(io_ctl->folios[i]);
return 0;
}
@@ -498,8 +498,8 @@ static void io_ctl_set_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
* Skip the csum areas. If we don't check crcs then we just have a
* 64bit chunk at the front of the first page.
*/
- io_ctl->cur += (sizeof(u32) * io_ctl->num_pages);
- io_ctl->size -= sizeof(u64) + (sizeof(u32) * io_ctl->num_pages);
+ io_ctl->cur += (sizeof(u32) * io_ctl->num_folios);
+ io_ctl->size -= sizeof(u64) + (sizeof(u32) * io_ctl->num_folios);
put_unaligned_le64(generation, io_ctl->cur);
io_ctl->cur += sizeof(u64);
@@ -513,8 +513,8 @@ static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
* Skip the crc area. If we don't check crcs then we just have a 64bit
* chunk at the front of the first page.
*/
- io_ctl->cur += sizeof(u32) * io_ctl->num_pages;
- io_ctl->size -= sizeof(u64) + (sizeof(u32) * io_ctl->num_pages);
+ io_ctl->cur += sizeof(u32) * io_ctl->num_folios;
+ io_ctl->size -= sizeof(u64) + (sizeof(u32) * io_ctl->num_folios);
cache_gen = get_unaligned_le64(io_ctl->cur);
if (cache_gen != generation) {
@@ -535,12 +535,12 @@ static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index)
unsigned offset = 0;
if (index == 0)
- offset = sizeof(u32) * io_ctl->num_pages;
+ offset = sizeof(u32) * io_ctl->num_folios;
crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
btrfs_crc32c_final(crc, (u8 *)&crc);
io_ctl_unmap_page(io_ctl);
- tmp = page_address(io_ctl->pages[0]);
+ tmp = folio_address(io_ctl->folios[0]);
tmp += index;
*tmp = crc;
}
@@ -551,13 +551,13 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index)
u32 crc = ~(u32)0;
unsigned offset = 0;
- if (index >= io_ctl->num_pages)
+ if (index >= io_ctl->num_folios)
return -EIO;
if (index == 0)
- offset = sizeof(u32) * io_ctl->num_pages;
+ offset = sizeof(u32) * io_ctl->num_folios;
- tmp = page_address(io_ctl->pages[0]);
+ tmp = folio_address(io_ctl->folios[0]);
tmp += index;
val = *tmp;
@@ -596,7 +596,7 @@ static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes,
io_ctl_set_crc(io_ctl, io_ctl->index - 1);
/* No more pages to map */
- if (io_ctl->index >= io_ctl->num_pages)
+ if (io_ctl->index >= io_ctl->num_folios)
return 0;
/* map the next page */
@@ -615,14 +615,14 @@ static int io_ctl_add_bitmap(struct btrfs_io_ctl *io_ctl, void *bitmap)
*/
if (io_ctl->cur != io_ctl->orig) {
io_ctl_set_crc(io_ctl, io_ctl->index - 1);
- if (io_ctl->index >= io_ctl->num_pages)
+ if (io_ctl->index >= io_ctl->num_folios)
return -ENOSPC;
io_ctl_map_page(io_ctl, 0);
}
copy_page(io_ctl->cur, bitmap);
io_ctl_set_crc(io_ctl, io_ctl->index - 1);
- if (io_ctl->index < io_ctl->num_pages)
+ if (io_ctl->index < io_ctl->num_folios)
io_ctl_map_page(io_ctl, 0);
return 0;
}
@@ -638,7 +638,7 @@ static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
else
io_ctl_unmap_page(io_ctl);
- while (io_ctl->index < io_ctl->num_pages) {
+ while (io_ctl->index < io_ctl->num_folios) {
io_ctl_map_page(io_ctl, 1);
io_ctl_set_crc(io_ctl, io_ctl->index - 1);
}
@@ -1382,7 +1382,7 @@ static int __btrfs_write_out_cache(struct inode *inode,
if (!i_size_read(inode))
return -EIO;
- WARN_ON(io_ctl->pages);
+ WARN_ON(io_ctl->folios);
ret = io_ctl_init(io_ctl, inode, 1);
if (ret)
return ret;
@@ -1452,7 +1452,7 @@ static int __btrfs_write_out_cache(struct inode *inode,
u64 dirty_start = i * PAGE_SIZE;
u64 dirty_len = min_t(u64, dirty_start + PAGE_SIZE, i_size) - dirty_start;
- ret = btrfs_dirty_folio(BTRFS_I(inode), page_folio(io_ctl->pages[i]),
+ ret = btrfs_dirty_folio(BTRFS_I(inode), io_ctl->folios[i],
dirty_start, dirty_len, &cached_state, false);
if (ret < 0)
goto out_nospc;
diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h
index 53fe8e293af1..8c9892192af1 100644
--- a/fs/btrfs/free-space-cache.h
+++ b/fs/btrfs/free-space-cache.h
@@ -14,7 +14,7 @@
#include "fs.h"
struct inode;
-struct page;
+struct folio;
struct btrfs_fs_info;
struct btrfs_path;
struct btrfs_trans_handle;
@@ -90,13 +90,13 @@ struct btrfs_free_space_ctl {
struct btrfs_io_ctl {
void *cur, *orig;
- struct page *page;
- struct page **pages;
+ struct folio *folio;
+ struct folio **folios;
struct btrfs_fs_info *fs_info;
struct inode *inode;
unsigned long size;
int index;
- int num_pages;
+ int num_folios;
int entries;
int bitmaps;
};
--
2.39.5
^ permalink raw reply [flat|nested] 23+ messages in thread* [PATCH 10/10] btrfs: rename io_ctl page helpers to folio helpers
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
` (8 preceding siblings ...)
2026-09-06 22:29 ` [PATCH 09/10] btrfs: convert struct btrfs_io_ctl to use folios Tal Zussman
@ 2026-09-06 22:29 ` Tal Zussman
2026-09-06 23:12 ` Qu Wenruo
9 siblings, 1 reply; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 22:29 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel, Tal Zussman
These functions now operate on folios. Rename them and update comments
accordingly.
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/btrfs/free-space-cache.c | 78 ++++++++++++++++++++++-----------------------
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index ab933ee6f19c..73cfc1d1a5c1 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -406,7 +406,7 @@ static void io_ctl_free(struct btrfs_io_ctl *io_ctl)
io_ctl->folios = NULL;
}
-static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
+static void io_ctl_unmap_folio(struct btrfs_io_ctl *io_ctl)
{
if (io_ctl->cur) {
io_ctl->cur = NULL;
@@ -414,7 +414,7 @@ static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
}
}
-static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
+static void io_ctl_map_folio(struct btrfs_io_ctl *io_ctl, int clear)
{
ASSERT(io_ctl->index < io_ctl->num_folios);
io_ctl->folio = io_ctl->folios[io_ctl->index++];
@@ -425,11 +425,11 @@ static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
clear_page(io_ctl->cur);
}
-static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
+static void io_ctl_drop_folios(struct btrfs_io_ctl *io_ctl)
{
int i;
- io_ctl_unmap_page(io_ctl);
+ io_ctl_unmap_folio(io_ctl);
for (i = 0; i < io_ctl->num_folios; i++) {
if (io_ctl->folios[i]) {
@@ -439,7 +439,7 @@ static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
}
}
-static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
+static int io_ctl_prepare_folios(struct btrfs_io_ctl *io_ctl, bool uptodate)
{
struct folio *folio;
struct inode *inode = io_ctl->inode;
@@ -453,7 +453,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
mask);
if (IS_ERR(folio)) {
- io_ctl_drop_pages(io_ctl);
+ io_ctl_drop_folios(io_ctl);
return PTR_ERR(folio);
}
@@ -461,7 +461,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
if (ret < 0) {
folio_unlock(folio);
folio_put(folio);
- io_ctl_drop_pages(io_ctl);
+ io_ctl_drop_folios(io_ctl);
return ret;
}
@@ -472,13 +472,13 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
if (folio->mapping != inode->i_mapping) {
btrfs_err(BTRFS_I(inode)->root->fs_info,
"free space cache page truncated");
- io_ctl_drop_pages(io_ctl);
+ io_ctl_drop_folios(io_ctl);
return -EIO;
}
if (!folio_test_uptodate(folio)) {
btrfs_err(BTRFS_I(inode)->root->fs_info,
"error reading free space cache");
- io_ctl_drop_pages(io_ctl);
+ io_ctl_drop_folios(io_ctl);
return -EIO;
}
}
@@ -492,7 +492,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
static void io_ctl_set_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
{
- io_ctl_map_page(io_ctl, 1);
+ io_ctl_map_folio(io_ctl, 1);
/*
* Skip the csum areas. If we don't check crcs then we just have a
@@ -521,7 +521,7 @@ static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
btrfs_err_rl(io_ctl->fs_info,
"space cache generation (%llu) does not match inode (%llu)",
cache_gen, generation);
- io_ctl_unmap_page(io_ctl);
+ io_ctl_unmap_folio(io_ctl);
return -EIO;
}
io_ctl->cur += sizeof(u64);
@@ -539,7 +539,7 @@ static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index)
crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
btrfs_crc32c_final(crc, (u8 *)&crc);
- io_ctl_unmap_page(io_ctl);
+ io_ctl_unmap_folio(io_ctl);
tmp = folio_address(io_ctl->folios[0]);
tmp += index;
*tmp = crc;
@@ -561,13 +561,13 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index)
tmp += index;
val = *tmp;
- io_ctl_map_page(io_ctl, 0);
+ io_ctl_map_folio(io_ctl, 0);
crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
btrfs_crc32c_final(crc, (u8 *)&crc);
if (val != crc) {
btrfs_err_rl(io_ctl->fs_info,
"csum mismatch on free space cache");
- io_ctl_unmap_page(io_ctl);
+ io_ctl_unmap_folio(io_ctl);
return -EIO;
}
@@ -595,12 +595,12 @@ static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes,
io_ctl_set_crc(io_ctl, io_ctl->index - 1);
- /* No more pages to map */
+ /* No more folios to map */
if (io_ctl->index >= io_ctl->num_folios)
return 0;
- /* map the next page */
- io_ctl_map_page(io_ctl, 1);
+ /* map the next folio */
+ io_ctl_map_folio(io_ctl, 1);
return 0;
}
@@ -610,24 +610,24 @@ static int io_ctl_add_bitmap(struct btrfs_io_ctl *io_ctl, void *bitmap)
return -ENOSPC;
/*
- * If we aren't at the start of the current page, unmap this one and
+ * If we aren't at the start of the current folio, unmap this one and
* map the next one if there is any left.
*/
if (io_ctl->cur != io_ctl->orig) {
io_ctl_set_crc(io_ctl, io_ctl->index - 1);
if (io_ctl->index >= io_ctl->num_folios)
return -ENOSPC;
- io_ctl_map_page(io_ctl, 0);
+ io_ctl_map_folio(io_ctl, 0);
}
copy_page(io_ctl->cur, bitmap);
io_ctl_set_crc(io_ctl, io_ctl->index - 1);
if (io_ctl->index < io_ctl->num_folios)
- io_ctl_map_page(io_ctl, 0);
+ io_ctl_map_folio(io_ctl, 0);
return 0;
}
-static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
+static void io_ctl_zero_remaining_folios(struct btrfs_io_ctl *io_ctl)
{
/*
* If we're not on the boundary we know we've modified the page and we
@@ -636,10 +636,10 @@ static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
if (io_ctl->cur != io_ctl->orig)
io_ctl_set_crc(io_ctl, io_ctl->index - 1);
else
- io_ctl_unmap_page(io_ctl);
+ io_ctl_unmap_folio(io_ctl);
while (io_ctl->index < io_ctl->num_folios) {
- io_ctl_map_page(io_ctl, 1);
+ io_ctl_map_folio(io_ctl, 1);
io_ctl_set_crc(io_ctl, io_ctl->index - 1);
}
}
@@ -666,7 +666,7 @@ static int io_ctl_read_entry(struct btrfs_io_ctl *io_ctl,
if (io_ctl->size >= sizeof(struct btrfs_free_space_entry))
return 0;
- io_ctl_unmap_page(io_ctl);
+ io_ctl_unmap_folio(io_ctl);
return 0;
}
@@ -681,7 +681,7 @@ static int io_ctl_read_bitmap(struct btrfs_io_ctl *io_ctl,
return ret;
copy_page(entry->bitmap, io_ctl->cur);
- io_ctl_unmap_page(io_ctl);
+ io_ctl_unmap_folio(io_ctl);
return 0;
}
@@ -797,7 +797,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
readahead_cache(inode);
- ret = io_ctl_prepare_pages(&io_ctl, true);
+ ret = io_ctl_prepare_folios(&io_ctl, true);
if (ret)
goto out;
@@ -869,7 +869,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
num_entries--;
}
- io_ctl_unmap_page(&io_ctl);
+ io_ctl_unmap_folio(&io_ctl);
/*
* We add the bitmaps at the end of the entries in order that
@@ -882,13 +882,13 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
goto free_cache;
}
- io_ctl_drop_pages(&io_ctl);
+ io_ctl_drop_folios(&io_ctl);
ret = 1;
out:
io_ctl_free(&io_ctl);
return ret;
free_cache:
- io_ctl_drop_pages(&io_ctl);
+ io_ctl_drop_folios(&io_ctl);
spin_lock(&ctl->tree_lock);
__btrfs_remove_free_space_cache(ctl);
@@ -1280,7 +1280,7 @@ cleanup_write_cache_enospc(struct inode *inode,
struct btrfs_io_ctl *io_ctl,
struct extent_state **cached_state)
{
- io_ctl_drop_pages(io_ctl);
+ io_ctl_drop_folios(io_ctl);
btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
cached_state);
}
@@ -1297,7 +1297,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
if (!inode)
return 0;
- /* Flush the dirty pages in the cache file. */
+ /* Flush the dirty folios in the cache file. */
ret = flush_dirty_cache(inode);
if (ret)
goto out;
@@ -1402,8 +1402,8 @@ static int __btrfs_write_out_cache(struct inode *inode,
spin_unlock(&block_group->lock);
}
- /* Lock all pages first so we can lock the extent safely. */
- ret = io_ctl_prepare_pages(io_ctl, false);
+ /* Lock all folios first so we can lock the extent safely. */
+ ret = io_ctl_prepare_folios(io_ctl, false);
if (ret)
goto out_unlock;
@@ -1443,10 +1443,10 @@ static int __btrfs_write_out_cache(struct inode *inode,
if (ret)
goto out_nospc;
- /* Zero out the rest of the pages just to make sure */
- io_ctl_zero_remaining_pages(io_ctl);
+ /* Zero out the rest of the folios just to make sure */
+ io_ctl_zero_remaining_folios(io_ctl);
- /* Everything is written out, now we dirty the pages in the file. */
+ /* Everything is written out, now we dirty the folios in the file. */
i_size = i_size_read(inode);
for (int i = 0; i < round_up(i_size, PAGE_SIZE) / PAGE_SIZE; i++) {
u64 dirty_start = i * PAGE_SIZE;
@@ -1461,17 +1461,17 @@ static int __btrfs_write_out_cache(struct inode *inode,
if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
up_write(&block_group->data_rwsem);
/*
- * Release the pages and unlock the extent, we will flush
+ * Release the folios and unlock the extent, we will flush
* them out later
*/
- io_ctl_drop_pages(io_ctl);
+ io_ctl_drop_folios(io_ctl);
io_ctl_free(io_ctl);
btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
&cached_state);
/*
- * at this point the pages are under IO and we're happy,
+ * at this point the folios are under IO and we're happy,
* The caller is responsible for waiting on them and updating
* the cache and the inode
*/
--
2.39.5
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 10/10] btrfs: rename io_ctl page helpers to folio helpers
2026-09-06 22:29 ` [PATCH 10/10] btrfs: rename io_ctl page helpers to folio helpers Tal Zussman
@ 2026-09-06 23:12 ` Qu Wenruo
2026-09-06 23:20 ` Tal Zussman
0 siblings, 1 reply; 23+ messages in thread
From: Qu Wenruo @ 2026-09-06 23:12 UTC (permalink / raw)
To: Tal Zussman, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
在 2026/9/7 07:59, Tal Zussman 写道:
> These functions now operate on folios. Rename them and update comments
> accordingly.
Again, v1 space cache is fully disabled since commit 545e560a5b0f
("btrfs: disable v1 space cache"), it would make more sense to remove
those functions other than doing a rename for codes that we're going to
remove anyway.
>
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
> ---
> fs/btrfs/free-space-cache.c | 78 ++++++++++++++++++++++-----------------------
> 1 file changed, 39 insertions(+), 39 deletions(-)
>
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index ab933ee6f19c..73cfc1d1a5c1 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -406,7 +406,7 @@ static void io_ctl_free(struct btrfs_io_ctl *io_ctl)
> io_ctl->folios = NULL;
> }
>
> -static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
> +static void io_ctl_unmap_folio(struct btrfs_io_ctl *io_ctl)
> {
> if (io_ctl->cur) {
> io_ctl->cur = NULL;
> @@ -414,7 +414,7 @@ static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
> }
> }
>
> -static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
> +static void io_ctl_map_folio(struct btrfs_io_ctl *io_ctl, int clear)
> {
> ASSERT(io_ctl->index < io_ctl->num_folios);
> io_ctl->folio = io_ctl->folios[io_ctl->index++];
> @@ -425,11 +425,11 @@ static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
> clear_page(io_ctl->cur);
> }
>
> -static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
> +static void io_ctl_drop_folios(struct btrfs_io_ctl *io_ctl)
> {
> int i;
>
> - io_ctl_unmap_page(io_ctl);
> + io_ctl_unmap_folio(io_ctl);
>
> for (i = 0; i < io_ctl->num_folios; i++) {
> if (io_ctl->folios[i]) {
> @@ -439,7 +439,7 @@ static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
> }
> }
>
> -static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
> +static int io_ctl_prepare_folios(struct btrfs_io_ctl *io_ctl, bool uptodate)
> {
> struct folio *folio;
> struct inode *inode = io_ctl->inode;
> @@ -453,7 +453,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
> FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
> mask);
> if (IS_ERR(folio)) {
> - io_ctl_drop_pages(io_ctl);
> + io_ctl_drop_folios(io_ctl);
> return PTR_ERR(folio);
> }
>
> @@ -461,7 +461,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
> if (ret < 0) {
> folio_unlock(folio);
> folio_put(folio);
> - io_ctl_drop_pages(io_ctl);
> + io_ctl_drop_folios(io_ctl);
> return ret;
> }
>
> @@ -472,13 +472,13 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
> if (folio->mapping != inode->i_mapping) {
> btrfs_err(BTRFS_I(inode)->root->fs_info,
> "free space cache page truncated");
> - io_ctl_drop_pages(io_ctl);
> + io_ctl_drop_folios(io_ctl);
> return -EIO;
> }
> if (!folio_test_uptodate(folio)) {
> btrfs_err(BTRFS_I(inode)->root->fs_info,
> "error reading free space cache");
> - io_ctl_drop_pages(io_ctl);
> + io_ctl_drop_folios(io_ctl);
> return -EIO;
> }
> }
> @@ -492,7 +492,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>
> static void io_ctl_set_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
> {
> - io_ctl_map_page(io_ctl, 1);
> + io_ctl_map_folio(io_ctl, 1);
>
> /*
> * Skip the csum areas. If we don't check crcs then we just have a
> @@ -521,7 +521,7 @@ static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
> btrfs_err_rl(io_ctl->fs_info,
> "space cache generation (%llu) does not match inode (%llu)",
> cache_gen, generation);
> - io_ctl_unmap_page(io_ctl);
> + io_ctl_unmap_folio(io_ctl);
> return -EIO;
> }
> io_ctl->cur += sizeof(u64);
> @@ -539,7 +539,7 @@ static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index)
>
> crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
> btrfs_crc32c_final(crc, (u8 *)&crc);
> - io_ctl_unmap_page(io_ctl);
> + io_ctl_unmap_folio(io_ctl);
> tmp = folio_address(io_ctl->folios[0]);
> tmp += index;
> *tmp = crc;
> @@ -561,13 +561,13 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index)
> tmp += index;
> val = *tmp;
>
> - io_ctl_map_page(io_ctl, 0);
> + io_ctl_map_folio(io_ctl, 0);
> crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
> btrfs_crc32c_final(crc, (u8 *)&crc);
> if (val != crc) {
> btrfs_err_rl(io_ctl->fs_info,
> "csum mismatch on free space cache");
> - io_ctl_unmap_page(io_ctl);
> + io_ctl_unmap_folio(io_ctl);
> return -EIO;
> }
>
> @@ -595,12 +595,12 @@ static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes,
>
> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>
> - /* No more pages to map */
> + /* No more folios to map */
> if (io_ctl->index >= io_ctl->num_folios)
> return 0;
>
> - /* map the next page */
> - io_ctl_map_page(io_ctl, 1);
> + /* map the next folio */
> + io_ctl_map_folio(io_ctl, 1);
> return 0;
> }
>
> @@ -610,24 +610,24 @@ static int io_ctl_add_bitmap(struct btrfs_io_ctl *io_ctl, void *bitmap)
> return -ENOSPC;
>
> /*
> - * If we aren't at the start of the current page, unmap this one and
> + * If we aren't at the start of the current folio, unmap this one and
> * map the next one if there is any left.
> */
> if (io_ctl->cur != io_ctl->orig) {
> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
> if (io_ctl->index >= io_ctl->num_folios)
> return -ENOSPC;
> - io_ctl_map_page(io_ctl, 0);
> + io_ctl_map_folio(io_ctl, 0);
> }
>
> copy_page(io_ctl->cur, bitmap);
> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
> if (io_ctl->index < io_ctl->num_folios)
> - io_ctl_map_page(io_ctl, 0);
> + io_ctl_map_folio(io_ctl, 0);
> return 0;
> }
>
> -static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
> +static void io_ctl_zero_remaining_folios(struct btrfs_io_ctl *io_ctl)
> {
> /*
> * If we're not on the boundary we know we've modified the page and we
> @@ -636,10 +636,10 @@ static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
> if (io_ctl->cur != io_ctl->orig)
> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
> else
> - io_ctl_unmap_page(io_ctl);
> + io_ctl_unmap_folio(io_ctl);
>
> while (io_ctl->index < io_ctl->num_folios) {
> - io_ctl_map_page(io_ctl, 1);
> + io_ctl_map_folio(io_ctl, 1);
> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
> }
> }
> @@ -666,7 +666,7 @@ static int io_ctl_read_entry(struct btrfs_io_ctl *io_ctl,
> if (io_ctl->size >= sizeof(struct btrfs_free_space_entry))
> return 0;
>
> - io_ctl_unmap_page(io_ctl);
> + io_ctl_unmap_folio(io_ctl);
>
> return 0;
> }
> @@ -681,7 +681,7 @@ static int io_ctl_read_bitmap(struct btrfs_io_ctl *io_ctl,
> return ret;
>
> copy_page(entry->bitmap, io_ctl->cur);
> - io_ctl_unmap_page(io_ctl);
> + io_ctl_unmap_folio(io_ctl);
>
> return 0;
> }
> @@ -797,7 +797,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
>
> readahead_cache(inode);
>
> - ret = io_ctl_prepare_pages(&io_ctl, true);
> + ret = io_ctl_prepare_folios(&io_ctl, true);
> if (ret)
> goto out;
>
> @@ -869,7 +869,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
> num_entries--;
> }
>
> - io_ctl_unmap_page(&io_ctl);
> + io_ctl_unmap_folio(&io_ctl);
>
> /*
> * We add the bitmaps at the end of the entries in order that
> @@ -882,13 +882,13 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
> goto free_cache;
> }
>
> - io_ctl_drop_pages(&io_ctl);
> + io_ctl_drop_folios(&io_ctl);
> ret = 1;
> out:
> io_ctl_free(&io_ctl);
> return ret;
> free_cache:
> - io_ctl_drop_pages(&io_ctl);
> + io_ctl_drop_folios(&io_ctl);
>
> spin_lock(&ctl->tree_lock);
> __btrfs_remove_free_space_cache(ctl);
> @@ -1280,7 +1280,7 @@ cleanup_write_cache_enospc(struct inode *inode,
> struct btrfs_io_ctl *io_ctl,
> struct extent_state **cached_state)
> {
> - io_ctl_drop_pages(io_ctl);
> + io_ctl_drop_folios(io_ctl);
> btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
> cached_state);
> }
> @@ -1297,7 +1297,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
> if (!inode)
> return 0;
>
> - /* Flush the dirty pages in the cache file. */
> + /* Flush the dirty folios in the cache file. */
> ret = flush_dirty_cache(inode);
> if (ret)
> goto out;
> @@ -1402,8 +1402,8 @@ static int __btrfs_write_out_cache(struct inode *inode,
> spin_unlock(&block_group->lock);
> }
>
> - /* Lock all pages first so we can lock the extent safely. */
> - ret = io_ctl_prepare_pages(io_ctl, false);
> + /* Lock all folios first so we can lock the extent safely. */
> + ret = io_ctl_prepare_folios(io_ctl, false);
> if (ret)
> goto out_unlock;
>
> @@ -1443,10 +1443,10 @@ static int __btrfs_write_out_cache(struct inode *inode,
> if (ret)
> goto out_nospc;
>
> - /* Zero out the rest of the pages just to make sure */
> - io_ctl_zero_remaining_pages(io_ctl);
> + /* Zero out the rest of the folios just to make sure */
> + io_ctl_zero_remaining_folios(io_ctl);
>
> - /* Everything is written out, now we dirty the pages in the file. */
> + /* Everything is written out, now we dirty the folios in the file. */
> i_size = i_size_read(inode);
> for (int i = 0; i < round_up(i_size, PAGE_SIZE) / PAGE_SIZE; i++) {
> u64 dirty_start = i * PAGE_SIZE;
> @@ -1461,17 +1461,17 @@ static int __btrfs_write_out_cache(struct inode *inode,
> if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
> up_write(&block_group->data_rwsem);
> /*
> - * Release the pages and unlock the extent, we will flush
> + * Release the folios and unlock the extent, we will flush
> * them out later
> */
> - io_ctl_drop_pages(io_ctl);
> + io_ctl_drop_folios(io_ctl);
> io_ctl_free(io_ctl);
>
> btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
> &cached_state);
>
> /*
> - * at this point the pages are under IO and we're happy,
> + * at this point the folios are under IO and we're happy,
> * The caller is responsible for waiting on them and updating
> * the cache and the inode
> */
>
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 10/10] btrfs: rename io_ctl page helpers to folio helpers
2026-09-06 23:12 ` Qu Wenruo
@ 2026-09-06 23:20 ` Tal Zussman
2026-09-07 0:23 ` Qu Wenruo
0 siblings, 1 reply; 23+ messages in thread
From: Tal Zussman @ 2026-09-06 23:20 UTC (permalink / raw)
To: Qu Wenruo, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
On 9/7/26 2:12 AM, Qu Wenruo wrote:
> 在 2026/9/7 07:59, Tal Zussman 写道:
>> These functions now operate on folios. Rename them and update comments
>> accordingly.
>
> Again, v1 space cache is fully disabled since commit 545e560a5b0f
> ("btrfs: disable v1 space cache"), it would make more sense to remove
> those functions other than doing a rename for codes that we're going to
> remove anyway.
>
No problem, I can drop this and patch 8. I wasn't sure what the removal
timeline looked like and wanted to keep things consistent.
>>
>> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
>> ---
>> fs/btrfs/free-space-cache.c | 78 ++++++++++++++++++++++-----------------------
>> 1 file changed, 39 insertions(+), 39 deletions(-)
>>
>> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
>> index ab933ee6f19c..73cfc1d1a5c1 100644
>> --- a/fs/btrfs/free-space-cache.c
>> +++ b/fs/btrfs/free-space-cache.c
>> @@ -406,7 +406,7 @@ static void io_ctl_free(struct btrfs_io_ctl *io_ctl)
>> io_ctl->folios = NULL;
>> }
>>
>> -static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
>> +static void io_ctl_unmap_folio(struct btrfs_io_ctl *io_ctl)
>> {
>> if (io_ctl->cur) {
>> io_ctl->cur = NULL;
>> @@ -414,7 +414,7 @@ static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
>> }
>> }
>>
>> -static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
>> +static void io_ctl_map_folio(struct btrfs_io_ctl *io_ctl, int clear)
>> {
>> ASSERT(io_ctl->index < io_ctl->num_folios);
>> io_ctl->folio = io_ctl->folios[io_ctl->index++];
>> @@ -425,11 +425,11 @@ static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
>> clear_page(io_ctl->cur);
>> }
>>
>> -static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
>> +static void io_ctl_drop_folios(struct btrfs_io_ctl *io_ctl)
>> {
>> int i;
>>
>> - io_ctl_unmap_page(io_ctl);
>> + io_ctl_unmap_folio(io_ctl);
>>
>> for (i = 0; i < io_ctl->num_folios; i++) {
>> if (io_ctl->folios[i]) {
>> @@ -439,7 +439,7 @@ static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
>> }
>> }
>>
>> -static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>> +static int io_ctl_prepare_folios(struct btrfs_io_ctl *io_ctl, bool uptodate)
>> {
>> struct folio *folio;
>> struct inode *inode = io_ctl->inode;
>> @@ -453,7 +453,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>> FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
>> mask);
>> if (IS_ERR(folio)) {
>> - io_ctl_drop_pages(io_ctl);
>> + io_ctl_drop_folios(io_ctl);
>> return PTR_ERR(folio);
>> }
>>
>> @@ -461,7 +461,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>> if (ret < 0) {
>> folio_unlock(folio);
>> folio_put(folio);
>> - io_ctl_drop_pages(io_ctl);
>> + io_ctl_drop_folios(io_ctl);
>> return ret;
>> }
>>
>> @@ -472,13 +472,13 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>> if (folio->mapping != inode->i_mapping) {
>> btrfs_err(BTRFS_I(inode)->root->fs_info,
>> "free space cache page truncated");
>> - io_ctl_drop_pages(io_ctl);
>> + io_ctl_drop_folios(io_ctl);
>> return -EIO;
>> }
>> if (!folio_test_uptodate(folio)) {
>> btrfs_err(BTRFS_I(inode)->root->fs_info,
>> "error reading free space cache");
>> - io_ctl_drop_pages(io_ctl);
>> + io_ctl_drop_folios(io_ctl);
>> return -EIO;
>> }
>> }
>> @@ -492,7 +492,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>
>> static void io_ctl_set_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
>> {
>> - io_ctl_map_page(io_ctl, 1);
>> + io_ctl_map_folio(io_ctl, 1);
>>
>> /*
>> * Skip the csum areas. If we don't check crcs then we just have a
>> @@ -521,7 +521,7 @@ static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
>> btrfs_err_rl(io_ctl->fs_info,
>> "space cache generation (%llu) does not match inode (%llu)",
>> cache_gen, generation);
>> - io_ctl_unmap_page(io_ctl);
>> + io_ctl_unmap_folio(io_ctl);
>> return -EIO;
>> }
>> io_ctl->cur += sizeof(u64);
>> @@ -539,7 +539,7 @@ static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index)
>>
>> crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
>> btrfs_crc32c_final(crc, (u8 *)&crc);
>> - io_ctl_unmap_page(io_ctl);
>> + io_ctl_unmap_folio(io_ctl);
>> tmp = folio_address(io_ctl->folios[0]);
>> tmp += index;
>> *tmp = crc;
>> @@ -561,13 +561,13 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index)
>> tmp += index;
>> val = *tmp;
>>
>> - io_ctl_map_page(io_ctl, 0);
>> + io_ctl_map_folio(io_ctl, 0);
>> crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
>> btrfs_crc32c_final(crc, (u8 *)&crc);
>> if (val != crc) {
>> btrfs_err_rl(io_ctl->fs_info,
>> "csum mismatch on free space cache");
>> - io_ctl_unmap_page(io_ctl);
>> + io_ctl_unmap_folio(io_ctl);
>> return -EIO;
>> }
>>
>> @@ -595,12 +595,12 @@ static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes,
>>
>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>
>> - /* No more pages to map */
>> + /* No more folios to map */
>> if (io_ctl->index >= io_ctl->num_folios)
>> return 0;
>>
>> - /* map the next page */
>> - io_ctl_map_page(io_ctl, 1);
>> + /* map the next folio */
>> + io_ctl_map_folio(io_ctl, 1);
>> return 0;
>> }
>>
>> @@ -610,24 +610,24 @@ static int io_ctl_add_bitmap(struct btrfs_io_ctl *io_ctl, void *bitmap)
>> return -ENOSPC;
>>
>> /*
>> - * If we aren't at the start of the current page, unmap this one and
>> + * If we aren't at the start of the current folio, unmap this one and
>> * map the next one if there is any left.
>> */
>> if (io_ctl->cur != io_ctl->orig) {
>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>> if (io_ctl->index >= io_ctl->num_folios)
>> return -ENOSPC;
>> - io_ctl_map_page(io_ctl, 0);
>> + io_ctl_map_folio(io_ctl, 0);
>> }
>>
>> copy_page(io_ctl->cur, bitmap);
>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>> if (io_ctl->index < io_ctl->num_folios)
>> - io_ctl_map_page(io_ctl, 0);
>> + io_ctl_map_folio(io_ctl, 0);
>> return 0;
>> }
>>
>> -static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
>> +static void io_ctl_zero_remaining_folios(struct btrfs_io_ctl *io_ctl)
>> {
>> /*
>> * If we're not on the boundary we know we've modified the page and we
>> @@ -636,10 +636,10 @@ static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
>> if (io_ctl->cur != io_ctl->orig)
>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>> else
>> - io_ctl_unmap_page(io_ctl);
>> + io_ctl_unmap_folio(io_ctl);
>>
>> while (io_ctl->index < io_ctl->num_folios) {
>> - io_ctl_map_page(io_ctl, 1);
>> + io_ctl_map_folio(io_ctl, 1);
>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>> }
>> }
>> @@ -666,7 +666,7 @@ static int io_ctl_read_entry(struct btrfs_io_ctl *io_ctl,
>> if (io_ctl->size >= sizeof(struct btrfs_free_space_entry))
>> return 0;
>>
>> - io_ctl_unmap_page(io_ctl);
>> + io_ctl_unmap_folio(io_ctl);
>>
>> return 0;
>> }
>> @@ -681,7 +681,7 @@ static int io_ctl_read_bitmap(struct btrfs_io_ctl *io_ctl,
>> return ret;
>>
>> copy_page(entry->bitmap, io_ctl->cur);
>> - io_ctl_unmap_page(io_ctl);
>> + io_ctl_unmap_folio(io_ctl);
>>
>> return 0;
>> }
>> @@ -797,7 +797,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
>>
>> readahead_cache(inode);
>>
>> - ret = io_ctl_prepare_pages(&io_ctl, true);
>> + ret = io_ctl_prepare_folios(&io_ctl, true);
>> if (ret)
>> goto out;
>>
>> @@ -869,7 +869,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
>> num_entries--;
>> }
>>
>> - io_ctl_unmap_page(&io_ctl);
>> + io_ctl_unmap_folio(&io_ctl);
>>
>> /*
>> * We add the bitmaps at the end of the entries in order that
>> @@ -882,13 +882,13 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
>> goto free_cache;
>> }
>>
>> - io_ctl_drop_pages(&io_ctl);
>> + io_ctl_drop_folios(&io_ctl);
>> ret = 1;
>> out:
>> io_ctl_free(&io_ctl);
>> return ret;
>> free_cache:
>> - io_ctl_drop_pages(&io_ctl);
>> + io_ctl_drop_folios(&io_ctl);
>>
>> spin_lock(&ctl->tree_lock);
>> __btrfs_remove_free_space_cache(ctl);
>> @@ -1280,7 +1280,7 @@ cleanup_write_cache_enospc(struct inode *inode,
>> struct btrfs_io_ctl *io_ctl,
>> struct extent_state **cached_state)
>> {
>> - io_ctl_drop_pages(io_ctl);
>> + io_ctl_drop_folios(io_ctl);
>> btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
>> cached_state);
>> }
>> @@ -1297,7 +1297,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
>> if (!inode)
>> return 0;
>>
>> - /* Flush the dirty pages in the cache file. */
>> + /* Flush the dirty folios in the cache file. */
>> ret = flush_dirty_cache(inode);
>> if (ret)
>> goto out;
>> @@ -1402,8 +1402,8 @@ static int __btrfs_write_out_cache(struct inode *inode,
>> spin_unlock(&block_group->lock);
>> }
>>
>> - /* Lock all pages first so we can lock the extent safely. */
>> - ret = io_ctl_prepare_pages(io_ctl, false);
>> + /* Lock all folios first so we can lock the extent safely. */
>> + ret = io_ctl_prepare_folios(io_ctl, false);
>> if (ret)
>> goto out_unlock;
>>
>> @@ -1443,10 +1443,10 @@ static int __btrfs_write_out_cache(struct inode *inode,
>> if (ret)
>> goto out_nospc;
>>
>> - /* Zero out the rest of the pages just to make sure */
>> - io_ctl_zero_remaining_pages(io_ctl);
>> + /* Zero out the rest of the folios just to make sure */
>> + io_ctl_zero_remaining_folios(io_ctl);
>>
>> - /* Everything is written out, now we dirty the pages in the file. */
>> + /* Everything is written out, now we dirty the folios in the file. */
>> i_size = i_size_read(inode);
>> for (int i = 0; i < round_up(i_size, PAGE_SIZE) / PAGE_SIZE; i++) {
>> u64 dirty_start = i * PAGE_SIZE;
>> @@ -1461,17 +1461,17 @@ static int __btrfs_write_out_cache(struct inode *inode,
>> if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
>> up_write(&block_group->data_rwsem);
>> /*
>> - * Release the pages and unlock the extent, we will flush
>> + * Release the folios and unlock the extent, we will flush
>> * them out later
>> */
>> - io_ctl_drop_pages(io_ctl);
>> + io_ctl_drop_folios(io_ctl);
>> io_ctl_free(io_ctl);
>>
>> btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
>> &cached_state);
>>
>> /*
>> - * at this point the pages are under IO and we're happy,
>> + * at this point the folios are under IO and we're happy,
>> * The caller is responsible for waiting on them and updating
>> * the cache and the inode
>> */
>>
>
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 10/10] btrfs: rename io_ctl page helpers to folio helpers
2026-09-06 23:20 ` Tal Zussman
@ 2026-09-07 0:23 ` Qu Wenruo
2026-09-07 0:58 ` Tal Zussman
0 siblings, 1 reply; 23+ messages in thread
From: Qu Wenruo @ 2026-09-07 0:23 UTC (permalink / raw)
To: Tal Zussman, Qu Wenruo, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
在 2026/9/7 08:50, Tal Zussman 写道:
> On 9/7/26 2:12 AM, Qu Wenruo wrote:
>> 在 2026/9/7 07:59, Tal Zussman 写道:
>>> These functions now operate on folios. Rename them and update comments
>>> accordingly.
>>
>> Again, v1 space cache is fully disabled since commit 545e560a5b0f
>> ("btrfs: disable v1 space cache"), it would make more sense to remove
>> those functions other than doing a rename for codes that we're going to
>> remove anyway.
>>
>
> No problem, I can drop this and patch 8. I wasn't sure what the removal
> timeline looked like and wanted to keep things consistent.
Would appreciate a lot if you are also interested in removing those v1
space cache code.
>
>>>
>>> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
>>> ---
>>> fs/btrfs/free-space-cache.c | 78 ++++++++++++++++++++++-----------------------
>>> 1 file changed, 39 insertions(+), 39 deletions(-)
>>>
>>> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
>>> index ab933ee6f19c..73cfc1d1a5c1 100644
>>> --- a/fs/btrfs/free-space-cache.c
>>> +++ b/fs/btrfs/free-space-cache.c
>>> @@ -406,7 +406,7 @@ static void io_ctl_free(struct btrfs_io_ctl *io_ctl)
>>> io_ctl->folios = NULL;
>>> }
>>>
>>> -static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
>>> +static void io_ctl_unmap_folio(struct btrfs_io_ctl *io_ctl)
>>> {
>>> if (io_ctl->cur) {
>>> io_ctl->cur = NULL;
>>> @@ -414,7 +414,7 @@ static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
>>> }
>>> }
>>>
>>> -static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
>>> +static void io_ctl_map_folio(struct btrfs_io_ctl *io_ctl, int clear)
>>> {
>>> ASSERT(io_ctl->index < io_ctl->num_folios);
>>> io_ctl->folio = io_ctl->folios[io_ctl->index++];
>>> @@ -425,11 +425,11 @@ static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
>>> clear_page(io_ctl->cur);
>>> }
>>>
>>> -static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
>>> +static void io_ctl_drop_folios(struct btrfs_io_ctl *io_ctl)
>>> {
>>> int i;
>>>
>>> - io_ctl_unmap_page(io_ctl);
>>> + io_ctl_unmap_folio(io_ctl);
>>>
>>> for (i = 0; i < io_ctl->num_folios; i++) {
>>> if (io_ctl->folios[i]) {
>>> @@ -439,7 +439,7 @@ static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
>>> }
>>> }
>>>
>>> -static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>> +static int io_ctl_prepare_folios(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>> {
>>> struct folio *folio;
>>> struct inode *inode = io_ctl->inode;
>>> @@ -453,7 +453,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>> FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
>>> mask);
>>> if (IS_ERR(folio)) {
>>> - io_ctl_drop_pages(io_ctl);
>>> + io_ctl_drop_folios(io_ctl);
>>> return PTR_ERR(folio);
>>> }
>>>
>>> @@ -461,7 +461,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>> if (ret < 0) {
>>> folio_unlock(folio);
>>> folio_put(folio);
>>> - io_ctl_drop_pages(io_ctl);
>>> + io_ctl_drop_folios(io_ctl);
>>> return ret;
>>> }
>>>
>>> @@ -472,13 +472,13 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>> if (folio->mapping != inode->i_mapping) {
>>> btrfs_err(BTRFS_I(inode)->root->fs_info,
>>> "free space cache page truncated");
>>> - io_ctl_drop_pages(io_ctl);
>>> + io_ctl_drop_folios(io_ctl);
>>> return -EIO;
>>> }
>>> if (!folio_test_uptodate(folio)) {
>>> btrfs_err(BTRFS_I(inode)->root->fs_info,
>>> "error reading free space cache");
>>> - io_ctl_drop_pages(io_ctl);
>>> + io_ctl_drop_folios(io_ctl);
>>> return -EIO;
>>> }
>>> }
>>> @@ -492,7 +492,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>>
>>> static void io_ctl_set_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
>>> {
>>> - io_ctl_map_page(io_ctl, 1);
>>> + io_ctl_map_folio(io_ctl, 1);
>>>
>>> /*
>>> * Skip the csum areas. If we don't check crcs then we just have a
>>> @@ -521,7 +521,7 @@ static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
>>> btrfs_err_rl(io_ctl->fs_info,
>>> "space cache generation (%llu) does not match inode (%llu)",
>>> cache_gen, generation);
>>> - io_ctl_unmap_page(io_ctl);
>>> + io_ctl_unmap_folio(io_ctl);
>>> return -EIO;
>>> }
>>> io_ctl->cur += sizeof(u64);
>>> @@ -539,7 +539,7 @@ static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index)
>>>
>>> crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
>>> btrfs_crc32c_final(crc, (u8 *)&crc);
>>> - io_ctl_unmap_page(io_ctl);
>>> + io_ctl_unmap_folio(io_ctl);
>>> tmp = folio_address(io_ctl->folios[0]);
>>> tmp += index;
>>> *tmp = crc;
>>> @@ -561,13 +561,13 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index)
>>> tmp += index;
>>> val = *tmp;
>>>
>>> - io_ctl_map_page(io_ctl, 0);
>>> + io_ctl_map_folio(io_ctl, 0);
>>> crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
>>> btrfs_crc32c_final(crc, (u8 *)&crc);
>>> if (val != crc) {
>>> btrfs_err_rl(io_ctl->fs_info,
>>> "csum mismatch on free space cache");
>>> - io_ctl_unmap_page(io_ctl);
>>> + io_ctl_unmap_folio(io_ctl);
>>> return -EIO;
>>> }
>>>
>>> @@ -595,12 +595,12 @@ static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes,
>>>
>>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>>
>>> - /* No more pages to map */
>>> + /* No more folios to map */
>>> if (io_ctl->index >= io_ctl->num_folios)
>>> return 0;
>>>
>>> - /* map the next page */
>>> - io_ctl_map_page(io_ctl, 1);
>>> + /* map the next folio */
>>> + io_ctl_map_folio(io_ctl, 1);
>>> return 0;
>>> }
>>>
>>> @@ -610,24 +610,24 @@ static int io_ctl_add_bitmap(struct btrfs_io_ctl *io_ctl, void *bitmap)
>>> return -ENOSPC;
>>>
>>> /*
>>> - * If we aren't at the start of the current page, unmap this one and
>>> + * If we aren't at the start of the current folio, unmap this one and
>>> * map the next one if there is any left.
>>> */
>>> if (io_ctl->cur != io_ctl->orig) {
>>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>> if (io_ctl->index >= io_ctl->num_folios)
>>> return -ENOSPC;
>>> - io_ctl_map_page(io_ctl, 0);
>>> + io_ctl_map_folio(io_ctl, 0);
>>> }
>>>
>>> copy_page(io_ctl->cur, bitmap);
>>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>> if (io_ctl->index < io_ctl->num_folios)
>>> - io_ctl_map_page(io_ctl, 0);
>>> + io_ctl_map_folio(io_ctl, 0);
>>> return 0;
>>> }
>>>
>>> -static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
>>> +static void io_ctl_zero_remaining_folios(struct btrfs_io_ctl *io_ctl)
>>> {
>>> /*
>>> * If we're not on the boundary we know we've modified the page and we
>>> @@ -636,10 +636,10 @@ static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
>>> if (io_ctl->cur != io_ctl->orig)
>>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>> else
>>> - io_ctl_unmap_page(io_ctl);
>>> + io_ctl_unmap_folio(io_ctl);
>>>
>>> while (io_ctl->index < io_ctl->num_folios) {
>>> - io_ctl_map_page(io_ctl, 1);
>>> + io_ctl_map_folio(io_ctl, 1);
>>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>> }
>>> }
>>> @@ -666,7 +666,7 @@ static int io_ctl_read_entry(struct btrfs_io_ctl *io_ctl,
>>> if (io_ctl->size >= sizeof(struct btrfs_free_space_entry))
>>> return 0;
>>>
>>> - io_ctl_unmap_page(io_ctl);
>>> + io_ctl_unmap_folio(io_ctl);
>>>
>>> return 0;
>>> }
>>> @@ -681,7 +681,7 @@ static int io_ctl_read_bitmap(struct btrfs_io_ctl *io_ctl,
>>> return ret;
>>>
>>> copy_page(entry->bitmap, io_ctl->cur);
>>> - io_ctl_unmap_page(io_ctl);
>>> + io_ctl_unmap_folio(io_ctl);
>>>
>>> return 0;
>>> }
>>> @@ -797,7 +797,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
>>>
>>> readahead_cache(inode);
>>>
>>> - ret = io_ctl_prepare_pages(&io_ctl, true);
>>> + ret = io_ctl_prepare_folios(&io_ctl, true);
>>> if (ret)
>>> goto out;
>>>
>>> @@ -869,7 +869,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
>>> num_entries--;
>>> }
>>>
>>> - io_ctl_unmap_page(&io_ctl);
>>> + io_ctl_unmap_folio(&io_ctl);
>>>
>>> /*
>>> * We add the bitmaps at the end of the entries in order that
>>> @@ -882,13 +882,13 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
>>> goto free_cache;
>>> }
>>>
>>> - io_ctl_drop_pages(&io_ctl);
>>> + io_ctl_drop_folios(&io_ctl);
>>> ret = 1;
>>> out:
>>> io_ctl_free(&io_ctl);
>>> return ret;
>>> free_cache:
>>> - io_ctl_drop_pages(&io_ctl);
>>> + io_ctl_drop_folios(&io_ctl);
>>>
>>> spin_lock(&ctl->tree_lock);
>>> __btrfs_remove_free_space_cache(ctl);
>>> @@ -1280,7 +1280,7 @@ cleanup_write_cache_enospc(struct inode *inode,
>>> struct btrfs_io_ctl *io_ctl,
>>> struct extent_state **cached_state)
>>> {
>>> - io_ctl_drop_pages(io_ctl);
>>> + io_ctl_drop_folios(io_ctl);
>>> btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
>>> cached_state);
>>> }
>>> @@ -1297,7 +1297,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
>>> if (!inode)
>>> return 0;
>>>
>>> - /* Flush the dirty pages in the cache file. */
>>> + /* Flush the dirty folios in the cache file. */
>>> ret = flush_dirty_cache(inode);
>>> if (ret)
>>> goto out;
>>> @@ -1402,8 +1402,8 @@ static int __btrfs_write_out_cache(struct inode *inode,
>>> spin_unlock(&block_group->lock);
>>> }
>>>
>>> - /* Lock all pages first so we can lock the extent safely. */
>>> - ret = io_ctl_prepare_pages(io_ctl, false);
>>> + /* Lock all folios first so we can lock the extent safely. */
>>> + ret = io_ctl_prepare_folios(io_ctl, false);
>>> if (ret)
>>> goto out_unlock;
>>>
>>> @@ -1443,10 +1443,10 @@ static int __btrfs_write_out_cache(struct inode *inode,
>>> if (ret)
>>> goto out_nospc;
>>>
>>> - /* Zero out the rest of the pages just to make sure */
>>> - io_ctl_zero_remaining_pages(io_ctl);
>>> + /* Zero out the rest of the folios just to make sure */
>>> + io_ctl_zero_remaining_folios(io_ctl);
>>>
>>> - /* Everything is written out, now we dirty the pages in the file. */
>>> + /* Everything is written out, now we dirty the folios in the file. */
>>> i_size = i_size_read(inode);
>>> for (int i = 0; i < round_up(i_size, PAGE_SIZE) / PAGE_SIZE; i++) {
>>> u64 dirty_start = i * PAGE_SIZE;
>>> @@ -1461,17 +1461,17 @@ static int __btrfs_write_out_cache(struct inode *inode,
>>> if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
>>> up_write(&block_group->data_rwsem);
>>> /*
>>> - * Release the pages and unlock the extent, we will flush
>>> + * Release the folios and unlock the extent, we will flush
>>> * them out later
>>> */
>>> - io_ctl_drop_pages(io_ctl);
>>> + io_ctl_drop_folios(io_ctl);
>>> io_ctl_free(io_ctl);
>>>
>>> btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
>>> &cached_state);
>>>
>>> /*
>>> - * at this point the pages are under IO and we're happy,
>>> + * at this point the folios are under IO and we're happy,
>>> * The caller is responsible for waiting on them and updating
>>> * the cache and the inode
>>> */
>>>
>>
>
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 10/10] btrfs: rename io_ctl page helpers to folio helpers
2026-09-07 0:23 ` Qu Wenruo
@ 2026-09-07 0:58 ` Tal Zussman
0 siblings, 0 replies; 23+ messages in thread
From: Tal Zussman @ 2026-09-07 0:58 UTC (permalink / raw)
To: Qu Wenruo, Qu Wenruo, David Sterba, Chris Mason
Cc: Matthew Wilcox (Oracle), linux-btrfs, linux-kernel
On 9/7/26 3:23 AM, Qu Wenruo wrote:
> 在 2026/9/7 08:50, Tal Zussman 写道:
>> On 9/7/26 2:12 AM, Qu Wenruo wrote:
>>> 在 2026/9/7 07:59, Tal Zussman 写道:
>>>> These functions now operate on folios. Rename them and update comments
>>>> accordingly.
>>>
>>> Again, v1 space cache is fully disabled since commit 545e560a5b0f
>>> ("btrfs: disable v1 space cache"), it would make more sense to remove
>>> those functions other than doing a rename for codes that we're going to
>>> remove anyway.
>>>
>>
>> No problem, I can drop this and patch 8. I wasn't sure what the removal
>> timeline looked like and wanted to keep things consistent.
>
> Would appreciate a lot if you are also interested in removing those v1
> space cache code.
>
Sure, I can do that. So patches 8-10 can be dropped from this series and
I'll send another one removing the v1 space cache support.
>>
>>>>
>>>> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
>>>> ---
>>>> fs/btrfs/free-space-cache.c | 78 ++++++++++++++++++++++-----------------------
>>>> 1 file changed, 39 insertions(+), 39 deletions(-)
>>>>
>>>> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
>>>> index ab933ee6f19c..73cfc1d1a5c1 100644
>>>> --- a/fs/btrfs/free-space-cache.c
>>>> +++ b/fs/btrfs/free-space-cache.c
>>>> @@ -406,7 +406,7 @@ static void io_ctl_free(struct btrfs_io_ctl *io_ctl)
>>>> io_ctl->folios = NULL;
>>>> }
>>>>
>>>> -static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
>>>> +static void io_ctl_unmap_folio(struct btrfs_io_ctl *io_ctl)
>>>> {
>>>> if (io_ctl->cur) {
>>>> io_ctl->cur = NULL;
>>>> @@ -414,7 +414,7 @@ static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
>>>> }
>>>> }
>>>>
>>>> -static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
>>>> +static void io_ctl_map_folio(struct btrfs_io_ctl *io_ctl, int clear)
>>>> {
>>>> ASSERT(io_ctl->index < io_ctl->num_folios);
>>>> io_ctl->folio = io_ctl->folios[io_ctl->index++];
>>>> @@ -425,11 +425,11 @@ static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
>>>> clear_page(io_ctl->cur);
>>>> }
>>>>
>>>> -static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
>>>> +static void io_ctl_drop_folios(struct btrfs_io_ctl *io_ctl)
>>>> {
>>>> int i;
>>>>
>>>> - io_ctl_unmap_page(io_ctl);
>>>> + io_ctl_unmap_folio(io_ctl);
>>>>
>>>> for (i = 0; i < io_ctl->num_folios; i++) {
>>>> if (io_ctl->folios[i]) {
>>>> @@ -439,7 +439,7 @@ static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
>>>> }
>>>> }
>>>>
>>>> -static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>>> +static int io_ctl_prepare_folios(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>>> {
>>>> struct folio *folio;
>>>> struct inode *inode = io_ctl->inode;
>>>> @@ -453,7 +453,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>>> FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
>>>> mask);
>>>> if (IS_ERR(folio)) {
>>>> - io_ctl_drop_pages(io_ctl);
>>>> + io_ctl_drop_folios(io_ctl);
>>>> return PTR_ERR(folio);
>>>> }
>>>>
>>>> @@ -461,7 +461,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>>> if (ret < 0) {
>>>> folio_unlock(folio);
>>>> folio_put(folio);
>>>> - io_ctl_drop_pages(io_ctl);
>>>> + io_ctl_drop_folios(io_ctl);
>>>> return ret;
>>>> }
>>>>
>>>> @@ -472,13 +472,13 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>>> if (folio->mapping != inode->i_mapping) {
>>>> btrfs_err(BTRFS_I(inode)->root->fs_info,
>>>> "free space cache page truncated");
>>>> - io_ctl_drop_pages(io_ctl);
>>>> + io_ctl_drop_folios(io_ctl);
>>>> return -EIO;
>>>> }
>>>> if (!folio_test_uptodate(folio)) {
>>>> btrfs_err(BTRFS_I(inode)->root->fs_info,
>>>> "error reading free space cache");
>>>> - io_ctl_drop_pages(io_ctl);
>>>> + io_ctl_drop_folios(io_ctl);
>>>> return -EIO;
>>>> }
>>>> }
>>>> @@ -492,7 +492,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
>>>>
>>>> static void io_ctl_set_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
>>>> {
>>>> - io_ctl_map_page(io_ctl, 1);
>>>> + io_ctl_map_folio(io_ctl, 1);
>>>>
>>>> /*
>>>> * Skip the csum areas. If we don't check crcs then we just have a
>>>> @@ -521,7 +521,7 @@ static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
>>>> btrfs_err_rl(io_ctl->fs_info,
>>>> "space cache generation (%llu) does not match inode (%llu)",
>>>> cache_gen, generation);
>>>> - io_ctl_unmap_page(io_ctl);
>>>> + io_ctl_unmap_folio(io_ctl);
>>>> return -EIO;
>>>> }
>>>> io_ctl->cur += sizeof(u64);
>>>> @@ -539,7 +539,7 @@ static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index)
>>>>
>>>> crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
>>>> btrfs_crc32c_final(crc, (u8 *)&crc);
>>>> - io_ctl_unmap_page(io_ctl);
>>>> + io_ctl_unmap_folio(io_ctl);
>>>> tmp = folio_address(io_ctl->folios[0]);
>>>> tmp += index;
>>>> *tmp = crc;
>>>> @@ -561,13 +561,13 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index)
>>>> tmp += index;
>>>> val = *tmp;
>>>>
>>>> - io_ctl_map_page(io_ctl, 0);
>>>> + io_ctl_map_folio(io_ctl, 0);
>>>> crc = crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset);
>>>> btrfs_crc32c_final(crc, (u8 *)&crc);
>>>> if (val != crc) {
>>>> btrfs_err_rl(io_ctl->fs_info,
>>>> "csum mismatch on free space cache");
>>>> - io_ctl_unmap_page(io_ctl);
>>>> + io_ctl_unmap_folio(io_ctl);
>>>> return -EIO;
>>>> }
>>>>
>>>> @@ -595,12 +595,12 @@ static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes,
>>>>
>>>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>>>
>>>> - /* No more pages to map */
>>>> + /* No more folios to map */
>>>> if (io_ctl->index >= io_ctl->num_folios)
>>>> return 0;
>>>>
>>>> - /* map the next page */
>>>> - io_ctl_map_page(io_ctl, 1);
>>>> + /* map the next folio */
>>>> + io_ctl_map_folio(io_ctl, 1);
>>>> return 0;
>>>> }
>>>>
>>>> @@ -610,24 +610,24 @@ static int io_ctl_add_bitmap(struct btrfs_io_ctl *io_ctl, void *bitmap)
>>>> return -ENOSPC;
>>>>
>>>> /*
>>>> - * If we aren't at the start of the current page, unmap this one and
>>>> + * If we aren't at the start of the current folio, unmap this one and
>>>> * map the next one if there is any left.
>>>> */
>>>> if (io_ctl->cur != io_ctl->orig) {
>>>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>>> if (io_ctl->index >= io_ctl->num_folios)
>>>> return -ENOSPC;
>>>> - io_ctl_map_page(io_ctl, 0);
>>>> + io_ctl_map_folio(io_ctl, 0);
>>>> }
>>>>
>>>> copy_page(io_ctl->cur, bitmap);
>>>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>>> if (io_ctl->index < io_ctl->num_folios)
>>>> - io_ctl_map_page(io_ctl, 0);
>>>> + io_ctl_map_folio(io_ctl, 0);
>>>> return 0;
>>>> }
>>>>
>>>> -static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
>>>> +static void io_ctl_zero_remaining_folios(struct btrfs_io_ctl *io_ctl)
>>>> {
>>>> /*
>>>> * If we're not on the boundary we know we've modified the page and we
>>>> @@ -636,10 +636,10 @@ static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
>>>> if (io_ctl->cur != io_ctl->orig)
>>>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>>> else
>>>> - io_ctl_unmap_page(io_ctl);
>>>> + io_ctl_unmap_folio(io_ctl);
>>>>
>>>> while (io_ctl->index < io_ctl->num_folios) {
>>>> - io_ctl_map_page(io_ctl, 1);
>>>> + io_ctl_map_folio(io_ctl, 1);
>>>> io_ctl_set_crc(io_ctl, io_ctl->index - 1);
>>>> }
>>>> }
>>>> @@ -666,7 +666,7 @@ static int io_ctl_read_entry(struct btrfs_io_ctl *io_ctl,
>>>> if (io_ctl->size >= sizeof(struct btrfs_free_space_entry))
>>>> return 0;
>>>>
>>>> - io_ctl_unmap_page(io_ctl);
>>>> + io_ctl_unmap_folio(io_ctl);
>>>>
>>>> return 0;
>>>> }
>>>> @@ -681,7 +681,7 @@ static int io_ctl_read_bitmap(struct btrfs_io_ctl *io_ctl,
>>>> return ret;
>>>>
>>>> copy_page(entry->bitmap, io_ctl->cur);
>>>> - io_ctl_unmap_page(io_ctl);
>>>> + io_ctl_unmap_folio(io_ctl);
>>>>
>>>> return 0;
>>>> }
>>>> @@ -797,7 +797,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
>>>>
>>>> readahead_cache(inode);
>>>>
>>>> - ret = io_ctl_prepare_pages(&io_ctl, true);
>>>> + ret = io_ctl_prepare_folios(&io_ctl, true);
>>>> if (ret)
>>>> goto out;
>>>>
>>>> @@ -869,7 +869,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
>>>> num_entries--;
>>>> }
>>>>
>>>> - io_ctl_unmap_page(&io_ctl);
>>>> + io_ctl_unmap_folio(&io_ctl);
>>>>
>>>> /*
>>>> * We add the bitmaps at the end of the entries in order that
>>>> @@ -882,13 +882,13 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
>>>> goto free_cache;
>>>> }
>>>>
>>>> - io_ctl_drop_pages(&io_ctl);
>>>> + io_ctl_drop_folios(&io_ctl);
>>>> ret = 1;
>>>> out:
>>>> io_ctl_free(&io_ctl);
>>>> return ret;
>>>> free_cache:
>>>> - io_ctl_drop_pages(&io_ctl);
>>>> + io_ctl_drop_folios(&io_ctl);
>>>>
>>>> spin_lock(&ctl->tree_lock);
>>>> __btrfs_remove_free_space_cache(ctl);
>>>> @@ -1280,7 +1280,7 @@ cleanup_write_cache_enospc(struct inode *inode,
>>>> struct btrfs_io_ctl *io_ctl,
>>>> struct extent_state **cached_state)
>>>> {
>>>> - io_ctl_drop_pages(io_ctl);
>>>> + io_ctl_drop_folios(io_ctl);
>>>> btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
>>>> cached_state);
>>>> }
>>>> @@ -1297,7 +1297,7 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
>>>> if (!inode)
>>>> return 0;
>>>>
>>>> - /* Flush the dirty pages in the cache file. */
>>>> + /* Flush the dirty folios in the cache file. */
>>>> ret = flush_dirty_cache(inode);
>>>> if (ret)
>>>> goto out;
>>>> @@ -1402,8 +1402,8 @@ static int __btrfs_write_out_cache(struct inode *inode,
>>>> spin_unlock(&block_group->lock);
>>>> }
>>>>
>>>> - /* Lock all pages first so we can lock the extent safely. */
>>>> - ret = io_ctl_prepare_pages(io_ctl, false);
>>>> + /* Lock all folios first so we can lock the extent safely. */
>>>> + ret = io_ctl_prepare_folios(io_ctl, false);
>>>> if (ret)
>>>> goto out_unlock;
>>>>
>>>> @@ -1443,10 +1443,10 @@ static int __btrfs_write_out_cache(struct inode *inode,
>>>> if (ret)
>>>> goto out_nospc;
>>>>
>>>> - /* Zero out the rest of the pages just to make sure */
>>>> - io_ctl_zero_remaining_pages(io_ctl);
>>>> + /* Zero out the rest of the folios just to make sure */
>>>> + io_ctl_zero_remaining_folios(io_ctl);
>>>>
>>>> - /* Everything is written out, now we dirty the pages in the file. */
>>>> + /* Everything is written out, now we dirty the folios in the file. */
>>>> i_size = i_size_read(inode);
>>>> for (int i = 0; i < round_up(i_size, PAGE_SIZE) / PAGE_SIZE; i++) {
>>>> u64 dirty_start = i * PAGE_SIZE;
>>>> @@ -1461,17 +1461,17 @@ static int __btrfs_write_out_cache(struct inode *inode,
>>>> if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
>>>> up_write(&block_group->data_rwsem);
>>>> /*
>>>> - * Release the pages and unlock the extent, we will flush
>>>> + * Release the folios and unlock the extent, we will flush
>>>> * them out later
>>>> */
>>>> - io_ctl_drop_pages(io_ctl);
>>>> + io_ctl_drop_folios(io_ctl);
>>>> io_ctl_free(io_ctl);
>>>>
>>>> btrfs_unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
>>>> &cached_state);
>>>>
>>>> /*
>>>> - * at this point the pages are under IO and we're happy,
>>>> + * at this point the folios are under IO and we're happy,
>>>> * The caller is responsible for waiting on them and updating
>>>> * the cache and the inode
>>>> */
>>>>
>>>
>>
>
^ permalink raw reply [flat|nested] 23+ messages in thread