* [PATCH 0/6] Convert aops->error_remove_page to ->error_remove_folio
@ 2023-11-17 16:14 Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 1/6] memory-failure: Use a folio in me_pagecache_clean() Matthew Wilcox (Oracle)
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2023-11-17 16:14 UTC (permalink / raw)
To: Naoya Horiguchi, Andrew Morton
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm
While this affects every filesystem, it's generally in a trivial way,
so I haven't cc'd the maintainers as it won't affect them. Really,
this is a memory-failure patch series which converts a lot of uses of
page APIs into folio APIs with the usual benefits.
It is only compile tested. Nothing here should change any user-visible
behaviour.
Matthew Wilcox (Oracle) (6):
memory-failure: Use a folio in me_pagecache_clean()
memory-failure: Use a folio in me_pagecache_dirty()
memory-failure: Convert delete_from_lru_cache() to take a folio
memory-failure: Use a folio in me_huge_page()
memory-failure: Convert truncate_error_page to truncate_error_folio
fs: Convert error_remove_page to error_remove_folio
Documentation/filesystems/locking.rst | 4 +-
Documentation/filesystems/vfs.rst | 6 +--
block/fops.c | 2 +-
fs/afs/write.c | 2 +-
fs/bcachefs/fs.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ceph/addr.c | 4 +-
fs/ext2/inode.c | 2 +-
fs/ext4/inode.c | 6 +--
fs/f2fs/compress.c | 2 +-
fs/f2fs/inode.c | 2 +-
fs/gfs2/aops.c | 4 +-
fs/hugetlbfs/inode.c | 6 +--
fs/nfs/file.c | 2 +-
fs/ntfs/aops.c | 6 +--
fs/ocfs2/aops.c | 2 +-
fs/xfs/xfs_aops.c | 2 +-
fs/zonefs/file.c | 2 +-
include/linux/fs.h | 2 +-
include/linux/mm.h | 3 +-
mm/memory-failure.c | 63 +++++++++++++--------------
mm/shmem.c | 6 +--
mm/truncate.c | 9 ++--
virt/kvm/guest_memfd.c | 9 ++--
24 files changed, 75 insertions(+), 75 deletions(-)
--
2.42.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/6] memory-failure: Use a folio in me_pagecache_clean()
2023-11-17 16:14 [PATCH 0/6] Convert aops->error_remove_page to ->error_remove_folio Matthew Wilcox (Oracle)
@ 2023-11-17 16:14 ` Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 2/6] memory-failure: Use a folio in me_pagecache_dirty() Matthew Wilcox (Oracle)
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2023-11-17 16:14 UTC (permalink / raw)
To: Naoya Horiguchi, Andrew Morton
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm
Replaces three hidden calls to compound_head() with one visible one.
Fix up a few comments while I'm modifying this function.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/memory-failure.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index b601f59ed062..496e8ecd8496 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1014,6 +1014,7 @@ static int me_unknown(struct page_state *ps, struct page *p)
*/
static int me_pagecache_clean(struct page_state *ps, struct page *p)
{
+ struct folio *folio = page_folio(p);
int ret;
struct address_space *mapping;
bool extra_pins;
@@ -1021,10 +1022,10 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p)
delete_from_lru_cache(p);
/*
- * For anonymous pages we're done the only reference left
+ * For anonymous folios the only reference left
* should be the one m_f() holds.
*/
- if (PageAnon(p)) {
+ if (folio_test_anon(folio)) {
ret = MF_RECOVERED;
goto out;
}
@@ -1036,11 +1037,9 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p)
* has a reference, because it could be file system metadata
* and that's not safe to truncate.
*/
- mapping = page_mapping(p);
+ mapping = folio_mapping(folio);
if (!mapping) {
- /*
- * Page has been teared down in the meanwhile
- */
+ /* Folio has been torn down in the meantime */
ret = MF_FAILED;
goto out;
}
@@ -1061,7 +1060,7 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p)
ret = MF_FAILED;
out:
- unlock_page(p);
+ folio_unlock(folio);
return ret;
}
--
2.42.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/6] memory-failure: Use a folio in me_pagecache_dirty()
2023-11-17 16:14 [PATCH 0/6] Convert aops->error_remove_page to ->error_remove_folio Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 1/6] memory-failure: Use a folio in me_pagecache_clean() Matthew Wilcox (Oracle)
@ 2023-11-17 16:14 ` Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 3/6] memory-failure: Convert delete_from_lru_cache() to take a folio Matthew Wilcox (Oracle)
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2023-11-17 16:14 UTC (permalink / raw)
To: Naoya Horiguchi, Andrew Morton
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm
Replaces three hidden calls to compound_head() with one visible one.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/memory-failure.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 496e8ecd8496..d2764fd3e448 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1138,15 +1138,16 @@ static int me_pagecache_dirty(struct page_state *ps, struct page *p)
*/
static int me_swapcache_dirty(struct page_state *ps, struct page *p)
{
+ struct folio *folio = page_folio(p);
int ret;
bool extra_pins = false;
- ClearPageDirty(p);
+ folio_clear_dirty(folio);
/* Trigger EIO in shmem: */
- ClearPageUptodate(p);
+ folio_clear_uptodate(folio);
ret = delete_from_lru_cache(p) ? MF_FAILED : MF_DELAYED;
- unlock_page(p);
+ folio_unlock(folio);
if (ret == MF_DELAYED)
extra_pins = true;
--
2.42.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/6] memory-failure: Convert delete_from_lru_cache() to take a folio
2023-11-17 16:14 [PATCH 0/6] Convert aops->error_remove_page to ->error_remove_folio Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 1/6] memory-failure: Use a folio in me_pagecache_clean() Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 2/6] memory-failure: Use a folio in me_pagecache_dirty() Matthew Wilcox (Oracle)
@ 2023-11-17 16:14 ` Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 4/6] memory-failure: Use a folio in me_huge_page() Matthew Wilcox (Oracle)
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2023-11-17 16:14 UTC (permalink / raw)
To: Naoya Horiguchi, Andrew Morton
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm
All three callers now have a folio; pass it in instead of the page.
Saves five calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/memory-failure.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index d2764fd3e448..e73f2047ffcb 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -902,26 +902,26 @@ static const char * const action_page_types[] = {
* The page count will stop it from being freed by unpoison.
* Stress tests should be aware of this memory leak problem.
*/
-static int delete_from_lru_cache(struct page *p)
+static int delete_from_lru_cache(struct folio *folio)
{
- if (isolate_lru_page(p)) {
+ if (folio_isolate_lru(folio)) {
/*
* Clear sensible page flags, so that the buddy system won't
- * complain when the page is unpoison-and-freed.
+ * complain when the folio is unpoison-and-freed.
*/
- ClearPageActive(p);
- ClearPageUnevictable(p);
+ folio_clear_active(folio);
+ folio_clear_unevictable(folio);
/*
* Poisoned page might never drop its ref count to 0 so we have
* to uncharge it manually from its memcg.
*/
- mem_cgroup_uncharge(page_folio(p));
+ mem_cgroup_uncharge(folio);
/*
- * drop the page count elevated by isolate_lru_page()
+ * drop the refcount elevated by folio_isolate_lru()
*/
- put_page(p);
+ folio_put(folio);
return 0;
}
return -EIO;
@@ -1019,7 +1019,7 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p)
struct address_space *mapping;
bool extra_pins;
- delete_from_lru_cache(p);
+ delete_from_lru_cache(folio);
/*
* For anonymous folios the only reference left
@@ -1146,7 +1146,7 @@ static int me_swapcache_dirty(struct page_state *ps, struct page *p)
/* Trigger EIO in shmem: */
folio_clear_uptodate(folio);
- ret = delete_from_lru_cache(p) ? MF_FAILED : MF_DELAYED;
+ ret = delete_from_lru_cache(folio) ? MF_FAILED : MF_DELAYED;
folio_unlock(folio);
if (ret == MF_DELAYED)
@@ -1165,7 +1165,7 @@ static int me_swapcache_clean(struct page_state *ps, struct page *p)
delete_from_swap_cache(folio);
- ret = delete_from_lru_cache(p) ? MF_FAILED : MF_RECOVERED;
+ ret = delete_from_lru_cache(folio) ? MF_FAILED : MF_RECOVERED;
folio_unlock(folio);
if (has_extra_refcount(ps, p, false))
--
2.42.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/6] memory-failure: Use a folio in me_huge_page()
2023-11-17 16:14 [PATCH 0/6] Convert aops->error_remove_page to ->error_remove_folio Matthew Wilcox (Oracle)
` (2 preceding siblings ...)
2023-11-17 16:14 ` [PATCH 3/6] memory-failure: Convert delete_from_lru_cache() to take a folio Matthew Wilcox (Oracle)
@ 2023-11-17 16:14 ` Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 5/6] memory-failure: Convert truncate_error_page to truncate_error_folio Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 6/6] fs: Convert error_remove_page to error_remove_folio Matthew Wilcox (Oracle)
5 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2023-11-17 16:14 UTC (permalink / raw)
To: Naoya Horiguchi, Andrew Morton
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm
This function was already explicitly calling compound_head();
unfortunately the compiler can't know that and elide the redundant
calls to compound_head() buried in page_mapping(), unlock_page(), etc.
Switch to using a folio, which does let us elide these calls.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/memory-failure.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index e73f2047ffcb..d97d247c0224 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1182,25 +1182,25 @@ static int me_swapcache_clean(struct page_state *ps, struct page *p)
*/
static int me_huge_page(struct page_state *ps, struct page *p)
{
+ struct folio *folio = page_folio(p);
int res;
- struct page *hpage = compound_head(p);
struct address_space *mapping;
bool extra_pins = false;
- mapping = page_mapping(hpage);
+ mapping = folio_mapping(folio);
if (mapping) {
- res = truncate_error_page(hpage, page_to_pfn(p), mapping);
+ res = truncate_error_page(&folio->page, page_to_pfn(p), mapping);
/* The page is kept in page cache. */
extra_pins = true;
- unlock_page(hpage);
+ folio_unlock(folio);
} else {
- unlock_page(hpage);
+ folio_unlock(folio);
/*
* migration entry prevents later access on error hugepage,
* so we can free and dissolve it into buddy to save healthy
* subpages.
*/
- put_page(hpage);
+ folio_put(folio);
if (__page_handle_poison(p) >= 0) {
page_ref_inc(p);
res = MF_RECOVERED;
--
2.42.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/6] memory-failure: Convert truncate_error_page to truncate_error_folio
2023-11-17 16:14 [PATCH 0/6] Convert aops->error_remove_page to ->error_remove_folio Matthew Wilcox (Oracle)
` (3 preceding siblings ...)
2023-11-17 16:14 ` [PATCH 4/6] memory-failure: Use a folio in me_huge_page() Matthew Wilcox (Oracle)
@ 2023-11-17 16:14 ` Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 6/6] fs: Convert error_remove_page to error_remove_folio Matthew Wilcox (Oracle)
5 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2023-11-17 16:14 UTC (permalink / raw)
To: Naoya Horiguchi, Andrew Morton
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm
Both callers now have a folio, so pass it in. Nothing downstream was
expecting a tail page; that's asserted in generic_error_remove_page(),
for example.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/memory-failure.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index d97d247c0224..6aec94821fda 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -927,14 +927,13 @@ static int delete_from_lru_cache(struct folio *folio)
return -EIO;
}
-static int truncate_error_page(struct page *p, unsigned long pfn,
+static int truncate_error_page(struct folio *folio, unsigned long pfn,
struct address_space *mapping)
{
- struct folio *folio = page_folio(p);
int ret = MF_FAILED;
if (mapping->a_ops->error_remove_page) {
- int err = mapping->a_ops->error_remove_page(mapping, p);
+ int err = mapping->a_ops->error_remove_page(mapping, &folio->page);
if (err != 0)
pr_info("%#lx: Failed to punch page: %d\n", pfn, err);
@@ -1055,7 +1054,7 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p)
*
* Open: to take i_rwsem or not for this? Right now we don't.
*/
- ret = truncate_error_page(p, page_to_pfn(p), mapping);
+ ret = truncate_error_page(folio, page_to_pfn(p), mapping);
if (has_extra_refcount(ps, p, extra_pins))
ret = MF_FAILED;
@@ -1189,7 +1188,7 @@ static int me_huge_page(struct page_state *ps, struct page *p)
mapping = folio_mapping(folio);
if (mapping) {
- res = truncate_error_page(&folio->page, page_to_pfn(p), mapping);
+ res = truncate_error_page(folio, page_to_pfn(p), mapping);
/* The page is kept in page cache. */
extra_pins = true;
folio_unlock(folio);
--
2.42.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/6] fs: Convert error_remove_page to error_remove_folio
2023-11-17 16:14 [PATCH 0/6] Convert aops->error_remove_page to ->error_remove_folio Matthew Wilcox (Oracle)
` (4 preceding siblings ...)
2023-11-17 16:14 ` [PATCH 5/6] memory-failure: Convert truncate_error_page to truncate_error_folio Matthew Wilcox (Oracle)
@ 2023-11-17 16:14 ` Matthew Wilcox (Oracle)
2023-11-17 17:28 ` Andrew Morton
5 siblings, 1 reply; 10+ messages in thread
From: Matthew Wilcox (Oracle) @ 2023-11-17 16:14 UTC (permalink / raw)
To: Naoya Horiguchi, Andrew Morton
Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-mm
There were already assertions that we were not passing a tail page
to error_remove_page(), so make the compiler enforce that by converting
everything to pass and use a folio.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
Documentation/filesystems/locking.rst | 4 ++--
Documentation/filesystems/vfs.rst | 6 +++---
block/fops.c | 2 +-
fs/afs/write.c | 2 +-
fs/bcachefs/fs.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ceph/addr.c | 4 ++--
fs/ext2/inode.c | 2 +-
fs/ext4/inode.c | 6 +++---
fs/f2fs/compress.c | 2 +-
fs/f2fs/inode.c | 2 +-
fs/gfs2/aops.c | 4 ++--
fs/hugetlbfs/inode.c | 6 +++---
fs/nfs/file.c | 2 +-
fs/ntfs/aops.c | 6 +++---
fs/ocfs2/aops.c | 2 +-
fs/xfs/xfs_aops.c | 2 +-
fs/zonefs/file.c | 2 +-
include/linux/fs.h | 2 +-
include/linux/mm.h | 3 ++-
mm/memory-failure.c | 10 +++++-----
mm/shmem.c | 6 +++---
mm/truncate.c | 9 ++++-----
virt/kvm/guest_memfd.c | 9 +++++----
24 files changed, 49 insertions(+), 48 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 7be2900806c8..421daf837940 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -261,7 +261,7 @@ prototypes::
struct folio *src, enum migrate_mode);
int (*launder_folio)(struct folio *);
bool (*is_partially_uptodate)(struct folio *, size_t from, size_t count);
- int (*error_remove_page)(struct address_space *, struct page *);
+ int (*error_remove_folio)(struct address_space *, struct folio *);
int (*swap_activate)(struct swap_info_struct *sis, struct file *f, sector_t *span)
int (*swap_deactivate)(struct file *);
int (*swap_rw)(struct kiocb *iocb, struct iov_iter *iter);
@@ -287,7 +287,7 @@ direct_IO:
migrate_folio: yes (both)
launder_folio: yes
is_partially_uptodate: yes
-error_remove_page: yes
+error_remove_folio: yes
swap_activate: no
swap_deactivate: no
swap_rw: yes, unlocks
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index 99acc2e98673..dd99ce5912d8 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -823,7 +823,7 @@ cache in your filesystem. The following members are defined:
bool (*is_partially_uptodate) (struct folio *, size_t from,
size_t count);
void (*is_dirty_writeback)(struct folio *, bool *, bool *);
- int (*error_remove_page) (struct mapping *mapping, struct page *page);
+ int (*error_remove_folio)(struct mapping *mapping, struct folio *);
int (*swap_activate)(struct swap_info_struct *sis, struct file *f, sector_t *span)
int (*swap_deactivate)(struct file *);
int (*swap_rw)(struct kiocb *iocb, struct iov_iter *iter);
@@ -1034,8 +1034,8 @@ cache in your filesystem. The following members are defined:
VM if a folio should be treated as dirty or writeback for the
purposes of stalling.
-``error_remove_page``
- normally set to generic_error_remove_page if truncation is ok
+``error_remove_folio``
+ normally set to generic_error_remove_folio if truncation is ok
for this address space. Used for memory failure handling.
Setting this implies you deal with pages going away under you,
unless you have them locked or reference counts increased.
diff --git a/block/fops.c b/block/fops.c
index 0abaac705daf..0bdad1e8d514 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -500,7 +500,7 @@ const struct address_space_operations def_blk_aops = {
.readahead = blkdev_readahead,
.writepages = blkdev_writepages,
.is_partially_uptodate = iomap_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
.migrate_folio = filemap_migrate_folio,
};
#endif /* CONFIG_BUFFER_HEAD */
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 57d05d67f0c2..e87b52b1f34c 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -242,7 +242,7 @@ static void afs_kill_pages(struct address_space *mapping,
folio_clear_uptodate(folio);
folio_end_writeback(folio);
folio_lock(folio);
- generic_error_remove_page(mapping, &folio->page);
+ generic_error_remove_folio(mapping, folio);
folio_unlock(folio);
folio_put(folio);
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index 74cdd3d85c8a..dc3f6e75703a 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -1103,7 +1103,7 @@ static const struct address_space_operations bch_address_space_operations = {
#ifdef CONFIG_MIGRATION
.migrate_folio = filemap_migrate_folio,
#endif
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
};
struct bcachefs_fid {
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 9f5a9894f88f..ff7b4efca24f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -10930,7 +10930,7 @@ static const struct address_space_operations btrfs_aops = {
.release_folio = btrfs_release_folio,
.migrate_folio = btrfs_migrate_folio,
.dirty_folio = filemap_dirty_folio,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
.swap_activate = btrfs_swap_activate,
.swap_deactivate = btrfs_swap_deactivate,
};
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 85be3bf18cdf..13af429ab030 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -907,8 +907,8 @@ static void writepages_finish(struct ceph_osd_request *req)
doutc(cl, "unlocking %p\n", page);
if (remove_page)
- generic_error_remove_page(inode->i_mapping,
- page);
+ generic_error_remove_folio(inode->i_mapping,
+ page_folio(page));
unlock_page(page);
}
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 464faf6c217e..5a4272b2c6b0 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -969,7 +969,7 @@ const struct address_space_operations ext2_aops = {
.writepages = ext2_writepages,
.migrate_folio = buffer_migrate_folio,
.is_partially_uptodate = block_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
};
static const struct address_space_operations ext2_dax_aops = {
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 61277f7f8722..d7729b17a66b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3564,7 +3564,7 @@ static const struct address_space_operations ext4_aops = {
.direct_IO = noop_direct_IO,
.migrate_folio = buffer_migrate_folio,
.is_partially_uptodate = block_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
.swap_activate = ext4_iomap_swap_activate,
};
@@ -3581,7 +3581,7 @@ static const struct address_space_operations ext4_journalled_aops = {
.direct_IO = noop_direct_IO,
.migrate_folio = buffer_migrate_folio_norefs,
.is_partially_uptodate = block_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
.swap_activate = ext4_iomap_swap_activate,
};
@@ -3598,7 +3598,7 @@ static const struct address_space_operations ext4_da_aops = {
.direct_IO = noop_direct_IO,
.migrate_folio = buffer_migrate_folio,
.is_partially_uptodate = block_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
.swap_activate = ext4_iomap_swap_activate,
};
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 36e5dab6baae..6b2af514660d 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -1944,7 +1944,7 @@ void f2fs_invalidate_compress_pages(struct f2fs_sb_info *sbi, nid_t ino)
continue;
}
- generic_error_remove_page(mapping, &folio->page);
+ generic_error_remove_folio(mapping, folio);
folio_unlock(folio);
}
folio_batch_release(&fbatch);
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 560bfcad1af2..a9eb3891f417 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -600,7 +600,7 @@ struct inode *f2fs_iget(struct super_block *sb, unsigned long ino)
#ifdef CONFIG_F2FS_FS_COMPRESSION
inode->i_mapping->a_ops = &f2fs_compress_aops;
/*
- * generic_error_remove_page only truncates pages of regular
+ * generic_error_remove_folio only truncates pages of regular
* inode
*/
inode->i_mode |= S_IFREG;
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index ba8742dc91f8..5cffb079b87c 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -745,7 +745,7 @@ static const struct address_space_operations gfs2_aops = {
.bmap = gfs2_bmap,
.migrate_folio = filemap_migrate_folio,
.is_partially_uptodate = iomap_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
};
static const struct address_space_operations gfs2_jdata_aops = {
@@ -758,7 +758,7 @@ static const struct address_space_operations gfs2_jdata_aops = {
.invalidate_folio = gfs2_invalidate_folio,
.release_folio = gfs2_release_folio,
.is_partially_uptodate = block_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
};
void gfs2_set_aops(struct inode *inode)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index f757d4f7ad98..36132c9125f9 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1129,8 +1129,8 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping,
#define hugetlbfs_migrate_folio NULL
#endif
-static int hugetlbfs_error_remove_page(struct address_space *mapping,
- struct page *page)
+static int hugetlbfs_error_remove_folio(struct address_space *mapping,
+ struct folio *folio)
{
return 0;
}
@@ -1277,7 +1277,7 @@ static const struct address_space_operations hugetlbfs_aops = {
.write_end = hugetlbfs_write_end,
.dirty_folio = noop_dirty_folio,
.migrate_folio = hugetlbfs_migrate_folio,
- .error_remove_page = hugetlbfs_error_remove_page,
+ .error_remove_folio = hugetlbfs_error_remove_folio,
};
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 3f9768810427..e8cccb94b927 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -567,7 +567,7 @@ const struct address_space_operations nfs_file_aops = {
.migrate_folio = nfs_migrate_folio,
.launder_folio = nfs_launder_folio,
.is_dirty_writeback = nfs_check_dirty_writeback,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
.swap_activate = nfs_swap_activate,
.swap_deactivate = nfs_swap_deactivate,
.swap_rw = nfs_swap_rw,
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 71e31e789b29..70479ce915e8 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -1644,7 +1644,7 @@ const struct address_space_operations ntfs_normal_aops = {
.bmap = ntfs_bmap,
.migrate_folio = buffer_migrate_folio,
.is_partially_uptodate = block_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
};
/*
@@ -1658,7 +1658,7 @@ const struct address_space_operations ntfs_compressed_aops = {
#endif /* NTFS_RW */
.migrate_folio = buffer_migrate_folio,
.is_partially_uptodate = block_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
};
/*
@@ -1673,7 +1673,7 @@ const struct address_space_operations ntfs_mst_aops = {
#endif /* NTFS_RW */
.migrate_folio = buffer_migrate_folio,
.is_partially_uptodate = block_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
};
#ifdef NTFS_RW
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index ba790219d528..795997806326 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -2480,5 +2480,5 @@ const struct address_space_operations ocfs2_aops = {
.release_folio = ocfs2_release_folio,
.migrate_folio = buffer_migrate_folio,
.is_partially_uptodate = block_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
};
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 465d7630bb21..813f85156b0c 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -584,7 +584,7 @@ const struct address_space_operations xfs_address_space_operations = {
.bmap = xfs_vm_bmap,
.migrate_folio = filemap_migrate_folio,
.is_partially_uptodate = iomap_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
.swap_activate = xfs_iomap_swapfile_activate,
};
diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c
index b2c9b35df8f7..6ab2318a9c8e 100644
--- a/fs/zonefs/file.c
+++ b/fs/zonefs/file.c
@@ -180,7 +180,7 @@ const struct address_space_operations zonefs_file_aops = {
.invalidate_folio = iomap_invalidate_folio,
.migrate_folio = filemap_migrate_folio,
.is_partially_uptodate = iomap_is_partially_uptodate,
- .error_remove_page = generic_error_remove_page,
+ .error_remove_folio = generic_error_remove_folio,
.swap_activate = zonefs_swap_activate,
};
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b2a3f1c61c19..0f26cf2fbac8 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -434,7 +434,7 @@ struct address_space_operations {
bool (*is_partially_uptodate) (struct folio *, size_t from,
size_t count);
void (*is_dirty_writeback) (struct folio *, bool *dirty, bool *wb);
- int (*error_remove_page)(struct address_space *, struct page *);
+ int (*error_remove_folio)(struct address_space *, struct folio *);
/* swapfile support */
int (*swap_activate)(struct swap_info_struct *sis, struct file *file,
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 64cd1ee4aacc..13a090271716 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2384,7 +2384,8 @@ extern void truncate_pagecache(struct inode *inode, loff_t new);
extern void truncate_setsize(struct inode *inode, loff_t newsize);
void pagecache_isize_extended(struct inode *inode, loff_t from, loff_t to);
void truncate_pagecache_range(struct inode *inode, loff_t offset, loff_t end);
-int generic_error_remove_page(struct address_space *mapping, struct page *page);
+int generic_error_remove_folio(struct address_space *mapping,
+ struct folio *folio);
struct vm_area_struct *lock_mm_and_find_vma(struct mm_struct *mm,
unsigned long address, struct pt_regs *regs);
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 6aec94821fda..d8c853b35dbb 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -927,13 +927,13 @@ static int delete_from_lru_cache(struct folio *folio)
return -EIO;
}
-static int truncate_error_page(struct folio *folio, unsigned long pfn,
+static int truncate_error_folio(struct folio *folio, unsigned long pfn,
struct address_space *mapping)
{
int ret = MF_FAILED;
- if (mapping->a_ops->error_remove_page) {
- int err = mapping->a_ops->error_remove_page(mapping, &folio->page);
+ if (mapping->a_ops->error_remove_folio) {
+ int err = mapping->a_ops->error_remove_folio(mapping, folio);
if (err != 0)
pr_info("%#lx: Failed to punch page: %d\n", pfn, err);
@@ -1054,7 +1054,7 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p)
*
* Open: to take i_rwsem or not for this? Right now we don't.
*/
- ret = truncate_error_page(folio, page_to_pfn(p), mapping);
+ ret = truncate_error_folio(folio, page_to_pfn(p), mapping);
if (has_extra_refcount(ps, p, extra_pins))
ret = MF_FAILED;
@@ -1188,7 +1188,7 @@ static int me_huge_page(struct page_state *ps, struct page *p)
mapping = folio_mapping(folio);
if (mapping) {
- res = truncate_error_page(folio, page_to_pfn(p), mapping);
+ res = truncate_error_folio(folio, page_to_pfn(p), mapping);
/* The page is kept in page cache. */
extra_pins = true;
folio_unlock(folio);
diff --git a/mm/shmem.c b/mm/shmem.c
index 0d1ce70bce38..c62f904ba1ca 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -4462,8 +4462,8 @@ static void __init shmem_destroy_inodecache(void)
}
/* Keep the page in page cache instead of truncating it */
-static int shmem_error_remove_page(struct address_space *mapping,
- struct page *page)
+static int shmem_error_remove_folio(struct address_space *mapping,
+ struct folio *folio)
{
return 0;
}
@@ -4478,7 +4478,7 @@ const struct address_space_operations shmem_aops = {
#ifdef CONFIG_MIGRATION
.migrate_folio = migrate_folio,
#endif
- .error_remove_page = shmem_error_remove_page,
+ .error_remove_folio = shmem_error_remove_folio,
};
EXPORT_SYMBOL(shmem_aops);
diff --git a/mm/truncate.c b/mm/truncate.c
index 52e3a703e7b2..725b150e47ac 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -250,10 +250,9 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end)
/*
* Used to get rid of pages on hardware memory corruption.
*/
-int generic_error_remove_page(struct address_space *mapping, struct page *page)
+int generic_error_remove_folio(struct address_space *mapping,
+ struct folio *folio)
{
- VM_BUG_ON_PAGE(PageTail(page), page);
-
if (!mapping)
return -EINVAL;
/*
@@ -262,9 +261,9 @@ int generic_error_remove_page(struct address_space *mapping, struct page *page)
*/
if (!S_ISREG(mapping->host->i_mode))
return -EIO;
- return truncate_inode_folio(mapping, page_folio(page));
+ return truncate_inode_folio(mapping, folio);
}
-EXPORT_SYMBOL(generic_error_remove_page);
+EXPORT_SYMBOL(generic_error_remove_folio);
/**
* mapping_evict_folio() - Remove an unused folio from the page-cache.
diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
index b99272396119..451435123fe7 100644
--- a/virt/kvm/guest_memfd.c
+++ b/virt/kvm/guest_memfd.c
@@ -267,7 +267,8 @@ static int kvm_gmem_migrate_folio(struct address_space *mapping,
return -EINVAL;
}
-static int kvm_gmem_error_page(struct address_space *mapping, struct page *page)
+static int kvm_gmem_error_folio(struct address_space *mapping,
+ struct folio *folio)
{
struct list_head *gmem_list = &mapping->private_list;
struct kvm_gmem *gmem;
@@ -275,8 +276,8 @@ static int kvm_gmem_error_page(struct address_space *mapping, struct page *page)
filemap_invalidate_lock_shared(mapping);
- start = page->index;
- end = start + thp_nr_pages(page);
+ start = folio->index;
+ end = start + folio_nr_pages(folio);
list_for_each_entry(gmem, gmem_list, entry)
kvm_gmem_invalidate_begin(gmem, start, end);
@@ -303,7 +304,7 @@ static const struct address_space_operations kvm_gmem_aops = {
#ifdef CONFIG_MIGRATION
.migrate_folio = kvm_gmem_migrate_folio,
#endif
- .error_remove_page = kvm_gmem_error_page,
+ .error_remove_folio = kvm_gmem_error_folio,
};
static int kvm_gmem_getattr(struct mnt_idmap *idmap, const struct path *path,
--
2.42.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 6/6] fs: Convert error_remove_page to error_remove_folio
2023-11-17 16:14 ` [PATCH 6/6] fs: Convert error_remove_page to error_remove_folio Matthew Wilcox (Oracle)
@ 2023-11-17 17:28 ` Andrew Morton
2023-11-17 18:14 ` Matthew Wilcox
2023-11-20 0:33 ` Stephen Rothwell
0 siblings, 2 replies; 10+ messages in thread
From: Andrew Morton @ 2023-11-17 17:28 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Naoya Horiguchi, linux-fsdevel, linux-mm, Paolo Bonzini,
Stephen Rothwell
On Fri, 17 Nov 2023 16:14:47 +0000 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote:
> There were already assertions that we were not passing a tail page
> to error_remove_page(), so make the compiler enforce that by converting
> everything to pass and use a folio.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> Documentation/filesystems/locking.rst | 4 ++--
> Documentation/filesystems/vfs.rst | 6 +++---
> block/fops.c | 2 +-
> fs/afs/write.c | 2 +-
> fs/bcachefs/fs.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/addr.c | 4 ++--
> fs/ext2/inode.c | 2 +-
> fs/ext4/inode.c | 6 +++---
> fs/f2fs/compress.c | 2 +-
> fs/f2fs/inode.c | 2 +-
> fs/gfs2/aops.c | 4 ++--
> fs/hugetlbfs/inode.c | 6 +++---
> fs/nfs/file.c | 2 +-
> fs/ntfs/aops.c | 6 +++---
> fs/ocfs2/aops.c | 2 +-
> fs/xfs/xfs_aops.c | 2 +-
> fs/zonefs/file.c | 2 +-
> include/linux/fs.h | 2 +-
> include/linux/mm.h | 3 ++-
> mm/memory-failure.c | 10 +++++-----
> mm/shmem.c | 6 +++---
> mm/truncate.c | 9 ++++-----
> virt/kvm/guest_memfd.c | 9 +++++----
virt/kvm/guest_memfd.c exists only in the KVM tree (and hence
linux-next). So I assume Stephen will use the change from this patch
when doing his resolution.
This:
--- a/virt/kvm/guest_memfd.c
+++ b/virt/kvm/guest_memfd.c
@@ -267,7 +267,8 @@ static int kvm_gmem_migrate_folio(struct address_space *mapping,
return -EINVAL;
}
-static int kvm_gmem_error_page(struct address_space *mapping, struct page *page)
+static int kvm_gmem_error_folio(struct address_space *mapping,
+ struct folio *folio)
{
struct list_head *gmem_list = &mapping->private_list;
struct kvm_gmem *gmem;
@@ -275,8 +276,8 @@ static int kvm_gmem_error_page(struct address_space *mapping, struct page *page)
filemap_invalidate_lock_shared(mapping);
- start = page->index;
- end = start + thp_nr_pages(page);
+ start = folio->index;
+ end = start + folio_nr_pages(folio);
list_for_each_entry(gmem, gmem_list, entry)
kvm_gmem_invalidate_begin(gmem, start, end);
@@ -303,7 +304,7 @@ static const struct address_space_operations kvm_gmem_aops = {
#ifdef CONFIG_MIGRATION
.migrate_folio = kvm_gmem_migrate_folio,
#endif
- .error_remove_page = kvm_gmem_error_page,
+ .error_remove_folio = kvm_gmem_error_folio,
};
static int kvm_gmem_getattr(struct mnt_idmap *idmap, const struct path *path,
--
2.42.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 6/6] fs: Convert error_remove_page to error_remove_folio
2023-11-17 17:28 ` Andrew Morton
@ 2023-11-17 18:14 ` Matthew Wilcox
2023-11-20 0:33 ` Stephen Rothwell
1 sibling, 0 replies; 10+ messages in thread
From: Matthew Wilcox @ 2023-11-17 18:14 UTC (permalink / raw)
To: Andrew Morton
Cc: Naoya Horiguchi, linux-fsdevel, linux-mm, Paolo Bonzini,
Stephen Rothwell
On Fri, Nov 17, 2023 at 09:28:33AM -0800, Andrew Morton wrote:
> > virt/kvm/guest_memfd.c | 9 +++++----
>
> virt/kvm/guest_memfd.c exists only in the KVM tree (and hence
> linux-next). So I assume Stephen will use the change from this patch
> when doing his resolution.
Guilty of developing against linux-next ;-) Sorry, I didn't notice it
depended on something else; thanks for alerting Stephen.
> This:
>
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@ -267,7 +267,8 @@ static int kvm_gmem_migrate_folio(struct address_space *mapping,
> return -EINVAL;
> }
>
> -static int kvm_gmem_error_page(struct address_space *mapping, struct page *page)
> +static int kvm_gmem_error_folio(struct address_space *mapping,
> + struct folio *folio)
> {
> struct list_head *gmem_list = &mapping->private_list;
> struct kvm_gmem *gmem;
> @@ -275,8 +276,8 @@ static int kvm_gmem_error_page(struct address_space *mapping, struct page *page)
>
> filemap_invalidate_lock_shared(mapping);
>
> - start = page->index;
> - end = start + thp_nr_pages(page);
> + start = folio->index;
> + end = start + folio_nr_pages(folio);
>
> list_for_each_entry(gmem, gmem_list, entry)
> kvm_gmem_invalidate_begin(gmem, start, end);
> @@ -303,7 +304,7 @@ static const struct address_space_operations kvm_gmem_aops = {
> #ifdef CONFIG_MIGRATION
> .migrate_folio = kvm_gmem_migrate_folio,
> #endif
> - .error_remove_page = kvm_gmem_error_page,
> + .error_remove_folio = kvm_gmem_error_folio,
> };
>
> static int kvm_gmem_getattr(struct mnt_idmap *idmap, const struct path *path,
> --
> 2.42.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 6/6] fs: Convert error_remove_page to error_remove_folio
2023-11-17 17:28 ` Andrew Morton
2023-11-17 18:14 ` Matthew Wilcox
@ 2023-11-20 0:33 ` Stephen Rothwell
1 sibling, 0 replies; 10+ messages in thread
From: Stephen Rothwell @ 2023-11-20 0:33 UTC (permalink / raw)
To: Andrew Morton
Cc: Matthew Wilcox (Oracle), Naoya Horiguchi, linux-fsdevel, linux-mm,
Paolo Bonzini
[-- Attachment #1: Type: text/plain, Size: 349 bytes --]
Hi Andrew,
On Fri, 17 Nov 2023 09:28:33 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:
>
> virt/kvm/guest_memfd.c exists only in the KVM tree (and hence
> linux-next). So I assume Stephen will use the change from this patch
> when doing his resolution.
Thanks for the heads up and the resolution.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-11-20 0:33 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-17 16:14 [PATCH 0/6] Convert aops->error_remove_page to ->error_remove_folio Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 1/6] memory-failure: Use a folio in me_pagecache_clean() Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 2/6] memory-failure: Use a folio in me_pagecache_dirty() Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 3/6] memory-failure: Convert delete_from_lru_cache() to take a folio Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 4/6] memory-failure: Use a folio in me_huge_page() Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 5/6] memory-failure: Convert truncate_error_page to truncate_error_folio Matthew Wilcox (Oracle)
2023-11-17 16:14 ` [PATCH 6/6] fs: Convert error_remove_page to error_remove_folio Matthew Wilcox (Oracle)
2023-11-17 17:28 ` Andrew Morton
2023-11-17 18:14 ` Matthew Wilcox
2023-11-20 0:33 ` Stephen Rothwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).