From patchwork Wed Dec 8 04:22:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12663731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACF3CC433EF for ; Wed, 8 Dec 2021 06:30:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 466D66B0071; Wed, 8 Dec 2021 01:23:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EF6C6B0073; Wed, 8 Dec 2021 01:23:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28F506B0075; Wed, 8 Dec 2021 01:23:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay025.a.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 141116B0071 for ; Wed, 8 Dec 2021 01:23:40 -0500 (EST) Received: by unirelay01.hostedemail.com (Postfix, from userid 108) id 46EFF6059B; Wed, 8 Dec 2021 05:38:47 +0000 (UTC) Received: by unirelay01.hostedemail.com (Postfix, from userid 108) id 32BF3604C3; Wed, 8 Dec 2021 05:32:07 +0000 (UTC) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7E74560A10 for ; Wed, 8 Dec 2021 04:23:17 +0000 (UTC) X-FDA: 78893332434.25.7CA8A67 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 26482400208A for ; Wed, 8 Dec 2021 04:23:17 +0000 (UTC) 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=rsEJxdywVEoM0ervtUyhDSP7KMwK7lVPrAeU8/731OE=; b=qz7qSp9TRh7ufJAZHOEWtvrC1s +otedc/SjuvSkhoNGBamGLmEk6/Nqh1nBjaa3f4ZIfkFVTGWbrZA4uz+VmGndZ/S1WDXB+Qs7pYqy YrOx1isibEPxZqb+X8j1xW74iFmIGSY95jRod+875T3k8ZuiZpsa0H7Us1B7vmtyeSsH/NKl0MOer Dv0rPgXENpRCozTrexfXAn+QHK6vE1pZrQ1keQNYqLTv1roMHTVFson/JAASxTQLnkenlldv6ePVh MXsyLRBp19oDd7+4MaJdGCl3lBIvmH/5qXM2pPbUs/RAyz8g66JG5gS4qCLXIRfxcosuHedgsB8Xo O+p6ERYg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1muoU6-0084ax-5i; Wed, 08 Dec 2021 04:23:14 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 34/48] shmem: Convert part of shmem_undo_range() to use a folio Date: Wed, 8 Dec 2021 04:22:42 +0000 Message-Id: <20211208042256.1923824-35-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211208042256.1923824-1-willy@infradead.org> References: <20211208042256.1923824-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=qz7qSp9T; dmarc=none; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 26482400208A X-Stat-Signature: hsowd6y43dr443wbfzirtzasuu84cx6z X-HE-Tag: 1638937397-72670 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: find_lock_entries() never returns tail pages. We cannot use page_folio() here as the pagevec may also contain swap entries, so simply cast. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- mm/shmem.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 18f93c2d68f1..40da9075374b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -936,22 +936,22 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, while (index < end && find_lock_entries(mapping, index, end - 1, &pvec, indices)) { for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i]; + struct folio *folio = (struct folio *)pvec.pages[i]; index = indices[i]; - if (xa_is_value(page)) { + if (xa_is_value(folio)) { if (unfalloc) continue; nr_swaps_freed += !shmem_free_swap(mapping, - index, page); + index, folio); continue; } - index += thp_nr_pages(page) - 1; + index += folio_nr_pages(folio) - 1; - if (!unfalloc || !PageUptodate(page)) - truncate_inode_page(mapping, page); - unlock_page(page); + if (!unfalloc || !folio_test_uptodate(folio)) + truncate_inode_page(mapping, &folio->page); + folio_unlock(folio); } pagevec_remove_exceptionals(&pvec); pagevec_release(&pvec);