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.6 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 99873C433DF for ; Fri, 15 May 2020 13:40:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5309020657 for ; Fri, 15 May 2020 13:40:20 +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="o4xNijdi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5309020657 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 B962F80056; Fri, 15 May 2020 09:40:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4A6E80054; Fri, 15 May 2020 09:40:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3BAA80056; Fri, 15 May 2020 09:40:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 8746280054 for ; Fri, 15 May 2020 09:40:18 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4A239181AC553 for ; Fri, 15 May 2020 13:40:18 +0000 (UTC) X-FDA: 76819062516.26.drug10_2a18bf5e1e32 X-HE-Tag: drug10_2a18bf5e1e32 X-Filterd-Recvd-Size: 3167 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 May 2020 13:40:17 +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=o4xNijdiMl41kDuFLB3H7T+TfA ACNPaBxZh46ndjsZiHyYF3dDxXndNhMFBUhJqvCMnfBteuYm+BEfeAJIul5qFc+AS9zwJZ4YAHjty rmoD9yQE518yqJBXyMG6+M5mUj0txhwYqPBT1hDhK49s3rYGZiltF9giu+fLqchQRh/sAXz2jBwMt 1AbQEcqW+lcCKGgkMN5+s9hOs0DQxMWqO/AhiBHQb78C+oZKlwKCCHSRQ4Zz9WJC0Ug21UmeG0KOZ cmcpY9zzaFhYhTguPZAZrROFHS2QEkgoyg17db6hydV0l/96HS1CC6q00yEjQkxoNJ9oAGtH2Jylt etBt+Y4g==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jZaD0-0005kq-B3; Fri, 15 May 2020 13:17:02 +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 v4 27/36] mm: Fix truncation for pages of arbitrary size Date: Fri, 15 May 2020 06:16:47 -0700 Message-Id: <20200515131656.12890-28-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200515131656.12890-1-willy@infradead.org> References: <20200515131656.12890-1-willy@infradead.org> MIME-Version: 1.0 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