Skip to content

Commit

Permalink
memory-failure: use a folio in me_pagecache_clean()
Browse files Browse the repository at this point in the history
Patch series "Convert aops->error_remove_page to ->error_remove_folio".

This is a memory-failure patch series which converts a lot of uses of page
APIs into folio APIs with the usual benefits.  


This patch (of 6):

Replaces three hidden calls to compound_head() with one visible one.
Fix up a few comments while I'm modifying this function.

Link: https://lkml.kernel.org/r/20231117161447.2461643-1-willy@infradead.org
Link: https://lkml.kernel.org/r/20231117161447.2461643-2-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Matthew Wilcox (Oracle) authored and Andrew Morton committed Dec 11, 2023
1 parent 2e16898 commit 3d47e31
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,17 +1014,18 @@ 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;

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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 3d47e31

Please sign in to comment.