Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2385437pxb; Mon, 20 Sep 2021 20:59:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymZADHVBCb5zLNSC1f6vHHCXDO1haaf+hZzYUutg+vPRLsTMA1Qe7CpPSnjTwN83r8+dVT X-Received: by 2002:a17:906:1c99:: with SMTP id g25mr31876462ejh.521.1632196759238; Mon, 20 Sep 2021 20:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632196759; cv=none; d=google.com; s=arc-20160816; b=PnzZJsFlnymgAbNnHq7s1nE6uSRcuZX6/vJf3i/3UqjhqDMG/juwgH7drrAwVRTdQh Z+b54huZg1klMN+ojYK5VpedcqfoRSeFBa+Zi15/+Yax7V7VXZICi/kz4SVUISvcLjCK LJ0TH6hdc/fjn1RQ2Exd5FxUD3AIUbVzTX/HPy8VF4bLNBmN01kXtwhAOCdpZDtOhr40 fiyuXzotKZa6FkCfInVM5krZpoiGzxYJsM6irjBj6FhRF3d/cnwcD8WmxhbXxvLy3/oI 76cCLz5KtwoXLyJMhqUvGX00FvWjXq06k7axpbrExL+XJW3ZF3FFdqPBmqlImuNMJ6dL Xb5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=et0MvhdhrmyngXfH1Tl0dRGqqe2AQSXkxnodtir63lE=; b=C5NPJ5UwF0ir5a5XcaxHGT+aguU1uQ58cVapNPU8QRxsdHVV/RBjlwsyg0/sBarbrt k7X9mYMvx+FrFtg19ynvaTRfH/lHRE9H5eazEVjvcXBkyq9mIs49bf1SFz7aB2la13fV +AresFGHQvXf+kOCkSqR7rroX1Wj4czxDUdymK10cmVCw0JN2re2V1oTiqn6g10nqSYD Nc7TLK5PvEsjJUMrU898e+cuG1hsh13wtJ3tHYGt9bdmYWx+f8qklxxHKYh6yuQA7goz tjoC9FrNXW+x2wwidbfdWEKXYUDA7NycEtknAS8Wmfs5l5xacAGbDe/tYKJYW47+QWpA fKKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KHowFi1h; 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 bd8si17137632edb.521.2021.09.20.20.58.55; Mon, 20 Sep 2021 20:59:19 -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=pass header.i=@infradead.org header.s=casper.20170209 header.b=KHowFi1h; 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 S242847AbhIUCF1 (ORCPT + 99 others); Mon, 20 Sep 2021 22:05:27 -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-kernel@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.