memory-failure: use a folio in me_pagecache_clean()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 17 Nov 2023 16:14:42 +0000 (16:14 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 11 Dec 2023 00:51:41 +0000 (16:51 -0800)
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>
mm/memory-failure.c

index b601f59..496e8ec 100644 (file)
@@ -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;
 }