Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4081254ybv; Tue, 25 Feb 2020 12:49:35 -0800 (PST) X-Google-Smtp-Source: APXvYqw8k0HUqDdYALtMBmiQQDV6ptZsipOSuPR1UfBmp50bcT3gsFyRhk4FFPN1A51HG+VQV3y8 X-Received: by 2002:a05:6830:1d8b:: with SMTP id y11mr399451oti.4.1582663775128; Tue, 25 Feb 2020 12:49:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582663775; cv=none; d=google.com; s=arc-20160816; b=JTrSNfBYy8Emw3OmfBjQdK591WdTF8fyf5a6JnkgeAtpx6V+MXsMsnJmRWtAQKNRJX rIp5XL+LIhjJY9FrPdrY3UO0tHJtFT/UtSLIeFg9v0Xd7F+OcHm87Un4yEHGlnHbSsJw /Gr/S0ZMzN34UaGJcj3oyqnzbHxmeV86W5ysIJzZ04XbvxXLV2XvNFu2+dMCOKIpJaXI dN5HtE4dwNHVYKigLbdhDub08cg2RzTUUKSCt5lZBcBvueY0YNoPWpySjDeVf8mZQe4h ijWGk+nv1rAYf1OI3+EdxPHT6ONAB0AdLhAFs3LrMXATJ1OvZE/bpEzGGx1od9iTptIS 5Gpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=o/1QFZxzNT826m7JFIAME3+yVzvEsCUL19H0/+ZaGD0=; b=PMBh6Cpflrzsxe45EzVTRphgGfB1ErPHq1zPyjradVpiacTfOawDZAXtvGbYkcXCEE LkOgYtsjXLcyuyJK6+H1Y5cYvHKVIvb7mc4HsAUuCQ4tEi7zSvt3IGZFCDkoUEFYuqds 8400P4RHMCXVn3+Q3rd7MnBUUNIxOK6teTgaJL7A8xxVaLxYpViwoljVTw3WwpIZMXc8 xjVz1ESMFhn5iEvya96tSbeKV3bY0Bh47zS7Gjg5spW5shAzoDWqWc9Gn8Uf6OCKtvEv KzjwHHlAXetbOQ+PNxYnFlkae/63DiF9OWX2Y81LW/EPWpqsIM2BLcRv3jyP07j/BI2Y Ypfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="C27S/EX7"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o23si161475oic.127.2020.02.25.12.49.23; Tue, 25 Feb 2020 12:49:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="C27S/EX7"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729654AbgBYUqg (ORCPT + 99 others); Tue, 25 Feb 2020 15:46:36 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:58062 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729048AbgBYUqg (ORCPT ); Tue, 25 Feb 2020 15:46:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=o/1QFZxzNT826m7JFIAME3+yVzvEsCUL19H0/+ZaGD0=; b=C27S/EX74cPZD/Vexlr8p3tKtQ 728obkNdVPjtjHZvyhB6xDUhJvo4kt/VU30ZNqgzPAqX5gF7l5kxxnqDLlGY+NKKC05zby3lHtz/b YH5brjngTWrhNfaC1aD0vv3E6EeO8OSHzNvkWhfGo+WiKgkEg/wm778jgIjOd8clQ1y1eEFZY3gzJ /AkM/+qjw29NQew9qQ0gELKGnqD2c78UNKJ5/SA5EapGxrdXG0eVurrZNnJdnIdcT3npCToYqVKNp OKqDar1kDgw95WD1AJBYj+ALBetyYNEmKK4gkVmd4y9v2yJiXHdV/XfvU2jwKotN1MUqM/3HWFkQT 4uf8RPaA==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6h68-00036M-Ke; Tue, 25 Feb 2020 20:46:32 +0000 Date: Tue, 25 Feb 2020 12:46:32 -0800 From: Christoph Hellwig To: "Darrick J. Wong" Cc: Qian Cai , elver@google.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] xfs: fix data races in inode->i_*time Message-ID: <20200225204632.GA6191@infradead.org> References: <1582661385-30210-1-git-send-email-cai@lca.pw> <20200225202829.GV6740@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200225202829.GV6740@magnolia> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 25, 2020 at 12:28:29PM -0800, Darrick J. Wong wrote: > > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c > > index 81f2f93caec0..2d5ca13ee9da 100644 > > --- a/fs/xfs/xfs_iops.c > > +++ b/fs/xfs/xfs_iops.c > > @@ -547,9 +547,9 @@ > > stat->uid = inode->i_uid; > > stat->gid = inode->i_gid; > > stat->ino = ip->i_ino; > > - stat->atime = inode->i_atime; > > - stat->mtime = inode->i_mtime; > > - stat->ctime = inode->i_ctime; > > + stat->atime = READ_ONCE(inode->i_atime); > > + stat->mtime = READ_ONCE(inode->i_mtime); > > + stat->ctime = READ_ONCE(inode->i_ctime); > > Seeing as one is supposed to take ILOCK_SHARED before reading inode core > information, why don't we do that here? Is there some huge performance > benefit to be realized from READ_ONCE vs. waiting for the lock that > protects all the writes from each other? Yes, I don't see how READ_ONCE works on a structure. I think you should look into fixing this race in generic_fillattr first, and we then piggy back on that fix in XFS once it has all been sorted out.