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=-7.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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 30510C433E2 for ; Sat, 5 Sep 2020 15:37:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 990C7206B8 for ; Sat, 5 Sep 2020 15:37:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="A9z6nKTE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 990C7206B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A5BF56B0003; Sat, 5 Sep 2020 11:37:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A0D696B0037; Sat, 5 Sep 2020 11:37:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D5546B0055; Sat, 5 Sep 2020 11:37:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id 6E3636B0003 for ; Sat, 5 Sep 2020 11:37:17 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 315573624 for ; Sat, 5 Sep 2020 15:37:17 +0000 (UTC) X-FDA: 77229411714.02.blade92_1e03757270bc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id F2363100994D8 for ; Sat, 5 Sep 2020 15:37:16 +0000 (UTC) X-HE-Tag: blade92_1e03757270bc X-Filterd-Recvd-Size: 6908 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Sat, 5 Sep 2020 15:37:16 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 085FUIW0097218; Sat, 5 Sep 2020 15:37:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=vD/AOAr0WrELqvXdX96uBWr/OfEgaHB8gYfku2p5lG8=; b=A9z6nKTE2U3JnSRnGJ5GAezCjU18vJCB6Cqj8K0YYYwtA5Od/ljur95RwdJBgLrpP8PG wq7LYBbu90KRTr30uy7kvz457HEszYv5bPvquGTVDSuWtxAb+Ggy+PTLNrJVWNHvERBi KQt59h6ECpthJ23tXtlNFEC19keLSUL9DDvdEayeDtOaW7sVUnjcVWf3ChIlcwE1Rwu4 lVVHUcdSuc4KMeZ+DgnVlBpvsxf+iF6kfDJ2iuK/BMWclr/sodLrVMGZ/k9+jUvZVnHi Be+9lPsx0JAsLWlVgi/lrxlLUypVKbHi0BnNB4X1/yyP39DEXntu/iCeMkO6UfU6gQ2L dg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 33c2mkhd8t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 05 Sep 2020 15:37:07 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 085FYoVF123563; Sat, 5 Sep 2020 15:37:06 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 33c2g0p3dv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 05 Sep 2020 15:37:06 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 085Fas0R013808; Sat, 5 Sep 2020 15:36:54 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 05 Sep 2020 08:36:54 -0700 Date: Sat, 5 Sep 2020 08:36:52 -0700 From: "Darrick J. Wong" To: Mikulas Patocka Cc: Linus Torvalds , Jan Kara , Dave Chinner , Jann Horn , Christoph Hellwig , Oleg Nesterov , Kirill Shutemov , "Theodore Ts'o" , Andrea Arcangeli , Matthew Wilcox , Andrew Morton , Dan Williams , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org Subject: Re: [PATCH 2/2] xfs: don't update mtime on COW faults Message-ID: <20200905153652.GA7955@magnolia> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9735 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009050151 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9735 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 priorityscore=1501 phishscore=0 adultscore=0 bulkscore=0 clxscore=1011 mlxlogscore=999 malwarescore=0 suspectscore=1 lowpriorityscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009050150 X-Rspamd-Queue-Id: F2363100994D8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: On Sat, Sep 05, 2020 at 08:13:02AM -0400, Mikulas Patocka wrote: > When running in a dax mode, if the user maps a page with MAP_PRIVATE and > PROT_WRITE, the xfs filesystem would incorrectly update ctime and mtime > when the user hits a COW fault. > > This breaks building of the Linux kernel. > How to reproduce: > 1. extract the Linux kernel tree on dax-mounted xfs filesystem > 2. run make clean > 3. run make -j12 > 4. run make -j12 > - at step 4, make would incorrectly rebuild the whole kernel (although it > was already built in step 3). > > The reason for the breakage is that almost all object files depend on > objtool. When we run objtool, it takes COW page fault on its .data > section, and these faults will incorrectly update the timestamp of the > objtool binary. The updated timestamp causes make to rebuild the whole > tree. > > Signed-off-by: Mikulas Patocka > Cc: stable@vger.kernel.org > > --- > fs/xfs/xfs_file.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > Index: linux-2.6/fs/xfs/xfs_file.c > =================================================================== > --- linux-2.6.orig/fs/xfs/xfs_file.c 2020-09-05 10:01:42.000000000 +0200 > +++ linux-2.6/fs/xfs/xfs_file.c 2020-09-05 13:59:12.000000000 +0200 > @@ -1223,6 +1223,13 @@ __xfs_filemap_fault( > return ret; > } > > +static bool > +xfs_is_write_fault( Call this xfs_is_shared_dax_write_fault, and throw in the IS_DAX() test? You might as well make it a static inline. > + struct vm_fault *vmf) > +{ > + return vmf->flags & FAULT_FLAG_WRITE && vmf->vma->vm_flags & VM_SHARED; Also, is "shortcutting the normal fault path" the reason for ext2 and xfs both being broken? /me puzzles over why write_fault is always true for page_mkwrite and pfn_mkwrite, but not for fault and huge_fault... Also: Can you please turn this (checking for timestamp update behavior wrt shared and private mapping write faults) into an fstest so we don't mess this up again? --D > +} > + > static vm_fault_t > xfs_filemap_fault( > struct vm_fault *vmf) > @@ -1230,7 +1237,7 @@ xfs_filemap_fault( > /* DAX can shortcut the normal fault path on write faults! */ > return __xfs_filemap_fault(vmf, PE_SIZE_PTE, > IS_DAX(file_inode(vmf->vma->vm_file)) && > - (vmf->flags & FAULT_FLAG_WRITE)); > + xfs_is_write_fault(vmf)); > } > > static vm_fault_t > @@ -1243,7 +1250,7 @@ xfs_filemap_huge_fault( > > /* DAX can shortcut the normal fault path on write faults! */ > return __xfs_filemap_fault(vmf, pe_size, > - (vmf->flags & FAULT_FLAG_WRITE)); > + xfs_is_write_fault(vmf)); > } > > static vm_fault_t >