Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4754937ybi; Tue, 28 May 2019 01:54:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqycm0amoFzdHtn2Ol4HSpYdDZHJyHrzhTSdg9FyOZDhsGG1PXo43e6LTK7apZVgXHsBwPF9 X-Received: by 2002:a63:eb03:: with SMTP id t3mr31513783pgh.315.1559033650332; Tue, 28 May 2019 01:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559033650; cv=none; d=google.com; s=arc-20160816; b=WqtzRQTid1NbWI9mLNYJ7IrZKV6TqJTo0zilOctPt1d8GX77MJPuLuJLnssW8H2/Cu rlDrL1qyNeVb4uXHjLqfgcQUNtOfUVD7B9CITmQodzp/GN4M/nB59DeaId2/EExzBQLs 0V0K+iwzJRy/41uH/rHfyq86D4HURvxThT+cTwlxoZKijMB2T9cd6oJC6/S6Cjnac176 hMqo//NTaOWswKByGUkkaMQkMZ56haDLcM8TlppoiLR1ohfivQho2yzUKKI9YGri/Exg tj2BMN6k3bfW34pHZ6m6SipyxpwQuAnke5pBaPmY8470hMKa3CtlcoTDkglauVgYXH+e Qn5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to:date :references:subject:cc:to:from; bh=Mu16YqA3D3A84TYtnDEXOhM2DzZHmcz+lxMMOFKwpRk=; b=XCPuSKsbjKsyF/3kysPvMMraLbiwhk78RcB+4G4Fp4WvMWf9Z1D0KTUGapRD4jtv4U QuISyPoRhKmrr+7sc7qzbBdSttKdprZ/yitjthKLlY2Mqtw9BdRdXDZhe2qvGf8bnUP9 J1WKbwc49bbqFkNaNPvA9OzHCnD0db1IeEWFNO1YHLrNLQGE5CbYytNRfzbDRnawwsGI wJuwShXWTkvkZgXbeCnAw06p2ekLWvoGBlYRlnYRhToc0Q3+rABkLPySDTWeRi0ua1KS EpTCzzBb+L5wHiLczgfFV1yg8KSY3ZPOvmBoNyZ/bBB+W5cLPCxoZK9RQ/2u8lVNNaec /2hg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-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 i12si2407450pjk.55.2019.05.28.01.53.40; Tue, 28 May 2019 01:54:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726668AbfE1IxY (ORCPT + 99 others); Tue, 28 May 2019 04:53:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:42388 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726649AbfE1IxY (ORCPT ); Tue, 28 May 2019 04:53:24 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3CFCCAF1C; Tue, 28 May 2019 08:53:22 +0000 (UTC) From: Luis Henriques To: Dave Chinner Cc: Amir Goldstein , "Darrick J . Wong" , Christoph Hellwig , Olga Kornievskaia , Al Viro , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, linux-api@vger.kernel.org, Dave Chinner Subject: Re: [PATCH v2 6/8] vfs: copy_file_range should update file timestamps References: <20190526061100.21761-1-amir73il@gmail.com> <20190526061100.21761-7-amir73il@gmail.com> <20190527143539.GA14980@hermes.olymp> <20190527220513.GB29573@dread.disaster.area> Date: Tue, 28 May 2019 09:53:20 +0100 In-Reply-To: <20190527220513.GB29573@dread.disaster.area> (Dave Chinner's message of "Tue, 28 May 2019 08:05:13 +1000") Message-ID: <875zpvrmdb.fsf@suse.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Dave Chinner writes: > On Mon, May 27, 2019 at 03:35:39PM +0100, Luis Henriques wrote: >> On Sun, May 26, 2019 at 09:10:57AM +0300, Amir Goldstein wrote: >> > From: Dave Chinner >> > >> > Timestamps are not updated right now, so programs looking for >> > timestamp updates for file modifications (like rsync) will not >> > detect that files have changed. We are also accessing the source >> > data when doing a copy (but not when cloning) so we need to update >> > atime on the source file as well. >> > >> > Signed-off-by: Dave Chinner >> > Signed-off-by: Amir Goldstein >> > --- >> > fs/read_write.c | 10 ++++++++++ >> > 1 file changed, 10 insertions(+) >> > >> > diff --git a/fs/read_write.c b/fs/read_write.c >> > index e16bcafc0da2..4b23a86aacd9 100644 >> > --- a/fs/read_write.c >> > +++ b/fs/read_write.c >> > @@ -1576,6 +1576,16 @@ int generic_copy_file_range_prep(struct file *file_in, struct file *file_out) >> > >> > WARN_ON_ONCE(!inode_is_locked(file_inode(file_out))); >> > >> > + /* Update source timestamps, because we are accessing file data */ >> > + file_accessed(file_in); >> > + >> > + /* Update destination timestamps, since we can alter file contents. */ >> > + if (!(file_out->f_mode & FMODE_NOCMTIME)) { >> > + ret = file_update_time(file_out); >> > + if (ret) >> > + return ret; >> > + } >> > + >> >> Is this the right place for updating the timestamps? I see that in same >> cases we may be updating the timestamp even if there was an error and no >> copy was performed. For example, if file_remove_privs fails. > > It's the same place we do it for read - file_accessed() is called > before we do the IO - and the same place for write - > file_update_time() is called before we copy data into the pagecache > or do direct IO. As such, it really doesn't matter if it is before > or after file_remove_privs() - the IO can still fail for many > reasons after we've updated the timestamps and in some of the > failure cases (e.g. we failed the sync at the end of an O_DSYNC > buffered write) we still want the timestamps to be modified because > the data and/or user visible metadata /may/ have been changed. > > cfr operates under the same constraints as read() and write(), so we > need to update the timestamps up front regardless of whether the > copy ends up succeeding or not.... Great, thanks for explaining it. It now makes sense, even for consistency, to have this operation here. Cheers, -- Luis