From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 852B4C433E1 for ; Fri, 29 May 2020 02:58:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4A33020814 for ; Fri, 29 May 2020 02:58:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="nJnZNf8t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A33020814 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 50153800C9; Thu, 28 May 2020 22:58:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7711800C6; Thu, 28 May 2020 22:58:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CC39800BF; Thu, 28 May 2020 22:58:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0222.hostedemail.com [216.40.44.222]) by kanga.kvack.org (Postfix) with ESMTP id 530E9800BA for ; Thu, 28 May 2020 22:58:29 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1B14F8245578 for ; Fri, 29 May 2020 02:58:29 +0000 (UTC) X-FDA: 76868248338.29.drink42_fd55f9cc3004 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id F01F418086CD8 for ; Fri, 29 May 2020 02:58:28 +0000 (UTC) X-HE-Tag: drink42_fd55f9cc3004 X-Filterd-Recvd-Size: 3167 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Fri, 29 May 2020 02:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=aYJkiZGtapS3EI3nSaAZcijPUCj2H7jj4UUNli9ipQA=; b=nJnZNf8tfVg7EFBrZJqumiyTyY Bje0odEdqWl6kWDiQ3bhdocJf9hVFl1YRGRVwlAtnb/NrM9vo5WaZ8EeOulUxA+7cP824PW/HXH4h VLGSQi83MRWRPJg69L7H2pQK3LaR+1ndt7dBtTSabgP2onMW/OgfLIU2PQ3pOcOh2yzd4uTd7KIBa 4L6TCMaf7tWnFazU2f9tp3M+gmIoa3JnVbc1mH4OMEo4uwO7WlTBiGwsgKhqcA20ICcoiYbc4hSqZ U8k2slRo0DGsU5b6SQgcO7QjcXO7gVauUUcwOJdAPrz3QMP63orhBtXR5uEQAhWFAPqen9oCmXGyH b6rmnyCw==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jeVE3-0008Sv-MU; Fri, 29 May 2020 02:58:27 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 29/39] mm: Fix truncation for pages of arbitrary size Date: Thu, 28 May 2020 19:58:14 -0700 Message-Id: <20200529025824.32296-30-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200529025824.32296-1-willy@infradead.org> References: <20200529025824.32296-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: F01F418086CD8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 Content-Transfer-Encoding: quoted-printable 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: From: "Matthew Wilcox (Oracle)" Remove the assumption that a compound page is HPAGE_PMD_SIZE, and the assumption that any page is PAGE_SIZE. Signed-off-by: Matthew Wilcox (Oracle) --- mm/truncate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/truncate.c b/mm/truncate.c index dd9ebc1da356..dad384a4dc6d 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -168,7 +168,7 @@ void do_invalidatepage(struct page *page, unsigned in= t offset, * becomes orphaned. It will be left on the LRU and may even be mapped = into * user pagetables if we're racing with filemap_fault(). * - * We need to bale out if page->mapping is no longer equal to the origin= al + * We need to bail out if page->mapping is no longer equal to the origin= al * mapping. This happens a) when the VM reclaimed the page while we wai= ted on * its lock, b) when a concurrent invalidate_mapping_pages got there fir= st and * c) when tmpfs swizzles a page between a tmpfs inode and swapper_space= . @@ -177,12 +177,12 @@ static void truncate_cleanup_page(struct address_space *mapping, struct page *page) { if (page_mapped(page)) { - pgoff_t nr =3D PageTransHuge(page) ? HPAGE_PMD_NR : 1; + unsigned int nr =3D hpage_nr_pages(page); unmap_mapping_pages(mapping, page->index, nr, false); } =20 if (page_has_private(page)) - do_invalidatepage(page, 0, PAGE_SIZE); + do_invalidatepage(page, 0, thp_size(page)); =20 /* * Some filesystems seem to re-dirty the page even after --=20 2.26.2