Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp501843ybk; Fri, 15 May 2020 06:22:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmZeqLT7Xf8DyqEyp1FwCaHHyfELmO0wK4xf0pk3N+YEizZL5uGq6t4MKYSlaG0kX/Kha0 X-Received: by 2002:a17:906:5795:: with SMTP id k21mr2721978ejq.374.1589548968146; Fri, 15 May 2020 06:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589548968; cv=none; d=google.com; s=arc-20160816; b=EOfwuf/ebv2DvUlh640EB2as8Upin5nMZocX/iK/QoiGvrr3mnlT2cthAMo+A8ecMX 7EBML3V/oSn02yCXz/BJ/v3tU+oH9OHjjqJG6N8gGbwzKFNvPil99iH+0W9w8lp0UOpO yaa/uzOpqG8Avm72/o6pJZZGrZvx8zjim5R7Evjl9PbW37rsV4uB3ZOSWYCp7wR35Mle I3WlOVWds/X9NjrNkaHm0rf83xXS+KliGIBX/RxildnAfTfdjnpBhtDtUZvgJ2p/vO8n 5bjoUGBzeCSZBYaPaysX2LO/QUjdf7/LT0ilIiJQw71CJadtLmvYfWdWHxa7p4c1cY0K FpOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aYJkiZGtapS3EI3nSaAZcijPUCj2H7jj4UUNli9ipQA=; b=nSgkyzdFYbmY/SvWUhityR7O2c4699f+cYMw91sXWEf6TJHVyx24+kkPfIg7hWGMgX b68UvtZ3pP5Swihzaz6qlHiChPAlxIMvBzUGcmUYla7p6nNVMERaAZXwnjw9YE/91xxS e8jF7JLypW9LxUYVzb7w2m9OzwzI5Nwr/GoU5OIH/Uedn1reCTHAuYDr7cihhtWtxXC1 o40fciRV1GwR6BWVyr9pdNUsKktseGNx1qyuUIuxd6CWbgbTo8uVa+VsX7OAJhQUs8vn PZt0A0wiEn2BQ77Y2Uv6Xac5PIKQTymGzZmkqtL8yHCZij0AqexAWgLAaudLQVq16kml E0Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=o4xNijdi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si1285299edc.413.2020.05.15.06.22.20; Fri, 15 May 2020 06:22:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=o4xNijdi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727837AbgEONSI (ORCPT + 99 others); Fri, 15 May 2020 09:18:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726585AbgEONRD (ORCPT ); Fri, 15 May 2020 09:17:03 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94DC3C05BD19; Fri, 15 May 2020 06:17:02 -0700 (PDT) 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: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 int 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 original + * We need to bail out if page->mapping is no longer equal to the original * mapping. This happens a) when the VM reclaimed the page while we waited on * its lock, b) when a concurrent invalidate_mapping_pages got there first 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 = PageTransHuge(page) ? HPAGE_PMD_NR : 1; + unsigned int nr = hpage_nr_pages(page); unmap_mapping_pages(mapping, page->index, nr, false); } if (page_has_private(page)) - do_invalidatepage(page, 0, PAGE_SIZE); + do_invalidatepage(page, 0, thp_size(page)); /* * Some filesystems seem to re-dirty the page even after -- 2.26.2