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=-5.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 9DD8DC433EF for ; Tue, 21 Sep 2021 02:18:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85D43611ED for ; Tue, 21 Sep 2021 02:18:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347005AbhIUCTY (ORCPT ); Mon, 20 Sep 2021 22:19:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236246AbhIUBt5 (ORCPT ); Mon, 20 Sep 2021 21:49:57 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E653C0A0E12; Mon, 20 Sep 2021 14:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=et0MvhdhrmyngXfH1Tl0dRGqqe2AQSXkxnodtir63lE=; b=KHowFi1hYx9+25v21zaYvXfc9F Ba5gKPkLatl6F/9QVuf0aG9yLx8MRLHha+g85sD1HNUMMrLzCaquMLgQaywwi3K++u0QUld4AXn1C TDc5y0sUw+Tvhisa9wwA22jkxntuDLQcPux0BKJWNsATr5iNiGdOGJn89M3+l2XKBZQ0pTwy6QnUv LCwQmMNVCJ3+OegsxGPjN8ItWMCd0uGq3zN+1YXtk36K7cUfKad9CRVBFBGzAyC78FSVCuLm4wqPo bfch3wYh8ko6sWzghaKMKmS80jtaiGAYb9CRV31XLNDv+dLs0KYYZPUi9boqtUzlwORVHtg717a8P zWTwti6A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSRBD-003Htc-8W; Mon, 20 Sep 2021 21:50:34 +0000 Date: Mon, 20 Sep 2021 22:50:27 +0100 From: Matthew Wilcox To: Yang Shi Cc: Hugh Dickins , cfijalkovich@google.com, song@kernel.org, Andrew Morton , Hao Sun , Linux MM , Linux FS-devel Mailing List , Linux Kernel Mailing List , Song Liu Subject: Re: [PATCH] fs: buffer: check huge page size instead of single page for invalidatepage Message-ID: References: <20210917205731.262693-1-shy828301@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, Sep 20, 2021 at 02:23:41PM -0700, Yang Shi wrote: > On Sun, Sep 19, 2021 at 7:41 AM Matthew Wilcox wrote: > > > > On Fri, Sep 17, 2021 at 05:07:03PM -0700, Yang Shi wrote: > > > > The debugging showed the page passed to invalidatepage is a huge page > > > > and the length is the size of huge page instead of single page due to > > > > read only FS THP support. But block_invalidatepage() would throw BUG if > > > > the size is greater than single page. > > > > Things have already gone wrong before we get to this point. See > > do_dentry_open(). You aren't supposed to be able to get a writable file > > descriptor on a file which has had huge pages added to the page cache > > without the filesystem's knowledge. That's the problem that needs to > > be fixed. > > I don't quite understand your point here. Do you mean do_dentry_open() > should fail for such cases instead of truncating the page cache? No, do_dentry_open() should have truncated the page cache when it was called and found that there were THPs in the cache. Then khugepaged should see that someone has the file open for write and decline to create new THPs. So it shouldn't be possible to get here with THPs in the cache.