From patchwork Fri Nov 17 16:14:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13459118 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="N8WgV35M" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6425EA4 for ; Fri, 17 Nov 2023 08:15:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=8gvR0hfnArLw42hOz7sYaHZFkVWRhDjUXlO4vAmkjQw=; b=N8WgV35M5s0mjyyNderE17Qmxo OJkL8RyC2nLLhMIa4daHxxYStcbBxFBTzYl8S3jkoIz5p6orZfU9FrKQAwvGkN6aTsFtlZxxAmFIA r5Kj/oTZc8CWxZKbqy3Sb+8FKsXEWExbklZZzEUjtK4T3XCuSFEEBxZj8bw7GejebeIHdyD7zU9H5 Haf1YaqvY5uVuZILuYO0OZ7t7EkW32MsGqMrRtxpB1H3vUlDY/grumRFHB7TX6eEMYJcx6uCepG9W YHAitttCXDyAfZcqSAo+d7j5o3vN3ahTw+XTkI9uBaK3xszSQYi2lajCeKpSh+MJjqL6osb9Ob7X6 vrRzipgQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r41Uc-00AKWa-GQ; Fri, 17 Nov 2023 16:14:54 +0000 From: "Matthew Wilcox (Oracle)" To: Naoya Horiguchi , Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/6] memory-failure: Use a folio in me_pagecache_clean() Date: Fri, 17 Nov 2023 16:14:42 +0000 Message-Id: <20231117161447.2461643-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231117161447.2461643-1-willy@infradead.org> References: <20231117161447.2461643-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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) --- 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; }