Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp796585ybl; Sun, 1 Dec 2019 13:06:04 -0800 (PST) X-Google-Smtp-Source: APXvYqwvgBzjocGmrbm0Bl+01LEhKLohmdzFdjCIQNNAvO8LBRn/D2+MroR2GgaPPN+YZHb9yxUU X-Received: by 2002:a50:a9e3:: with SMTP id n90mr58699523edc.52.1575234364806; Sun, 01 Dec 2019 13:06:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575234364; cv=none; d=google.com; s=arc-20160816; b=zhNuqOOxYXoU7IwNnIYGqhKgv2J4RnndImI4vAMdIBLLxlgYkoxdPtXFR8z7/V0VMQ 6BiIrE4RqBknOqzeVpPQJ3H7pTmTFiwS7gjHuA7ZmVJXTjDju3ZzAWGDjKzDF1uvPrFN /p+/ZwDLeSdI+fCqcsuwAu0crlE96pnQrrLj1pVfZL5peeQ92u4MV4Vtd0BPq9zT/4LK 3cEND3sQLCa2p+nbPo80+Iyr5Dy1SqUkI0vSGFLy27revBVbovRE74mcjzSPTeSvexg3 F+oNGjXaacHQrQJIKdARoBI1WQ/zJLpmWw8An1pdgc6BBrB053GwdbscLG55M5cWxjOe ITlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ZAxNYPcmvhHkUKvCGG6PxB1vFHLh5og2MutjK2vKncI=; b=Jj8Yz+l6iu+SahQPLsCus6hSp8m2lrmxQdnNFYl4t4QOHDdLCaOrKewPT8zObeoL8u tQxCsdHPrTEES12l9Nv/4CRAaWZgE+Rf7nX12aM1F70uRlIsGkogS+W3QJak/WbX9DzG iJSGxwKNHr/MBkAjvxAOPoZ5hzw/P7gpC4pfL5qaFTWmc60kg22dfFZZhL/WpoZCj4Rg ZxXpoVmyKr0cbvS3CQ30QsS7CHt3sWJ1hyCBx3nlhXgA2HPNvnajpraRED+UBDjhw5uV kO6oWtgLQn9D76mMeHUIsaTc72YGe05n7VTf5YEoQliZPlafBte3KP59gZJrg/CcFW4d WTvA== 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 cc20si22749639edb.201.2019.12.01.13.05.26; Sun, 01 Dec 2019 13:06:04 -0800 (PST) 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 S1727040AbfLAVFZ (ORCPT + 99 others); Sun, 1 Dec 2019 16:05:25 -0500 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:57952 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726965AbfLAVFZ (ORCPT ); Sun, 1 Dec 2019 16:05:25 -0500 Received: from dread.disaster.area (pa49-179-150-192.pa.nsw.optusnet.com.au [49.179.150.192]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 759FA3A0A97; Mon, 2 Dec 2019 08:05:20 +1100 (AEDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1ibWP9-00056e-SX; Mon, 02 Dec 2019 08:05:19 +1100 Date: Mon, 2 Dec 2019 08:05:19 +1100 From: Dave Chinner To: "Darrick J. Wong" Cc: Trond Myklebust , "linux-fsdevel@vger.kernel.org" , "linux-nfs@vger.kernel.org" Subject: Re: Question about clone_range() metadata stability Message-ID: <20191201210519.GB2418@dread.disaster.area> References: <20191127202136.GV6211@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191127202136.GV6211@magnolia> User-Agent: Mutt/1.10.1 (2018-07-13) X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=LYdCFQXi c=1 sm=1 tr=0 a=ZXpxJgW8/q3NVgupyyvOCQ==:117 a=ZXpxJgW8/q3NVgupyyvOCQ==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=pxVhFHJ0LMsA:10 a=7-415B0cAAAA:8 a=y7B9AfDEBtBswh77-68A:9 a=Sca554UL9fLBSYta:21 a=MLJJ3OMF_MbDVCWc:21 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Nov 27, 2019 at 12:21:36PM -0800, Darrick J. Wong wrote: > On Wed, Nov 27, 2019 at 06:38:46PM +0000, Trond Myklebust wrote: > > Hi all > > > > A quick question about clone_range() and guarantees around metadata > > stability. > > > > Are users required to call fsync/fsync_range() after calling > > clone_range() in order to guarantee that the cloned range metadata is > > persisted? > > Yes. > > > I'm assuming that it is required in order to guarantee that > > data is persisted. > > Data and metadata. XFS and ocfs2's reflink implementations will flush > the page cache before starting the remap, but they both require fsync to > force the log/journal to disk. So we need to call xfs_fs_nfs_commit_metadata() to get that done post vfs_clone_file_range() completion on the server side, yes? > > (AFAICT the same reasoning applies to btrfs, but don't trust my word for > it.) > > > I'm asking because knfsd currently just does a call to > > vfs_clone_file_range() when parsing a NFSv4.2 CLONE operation. It does > > not call fsync()/fsync_range() on the destination file, and since the > > NFSv4.2 protocol does not require you to perform any other operation in > > order to persist data/metadata, I'm worried that we may be corrupting > > the cloned file if the NFS server crashes at the wrong moment after the > > client has been told the clone completed. Yup, that's exactly what server side calls to commit_metadata() are supposed to address. I suspect to be correct, this might require commit_metadata() to be called on both the source and destination inodes, as both of them may have modified metadata as a result of the clone operation. For XFS one of them will be a no-op, but for other filesystems that don't implement ->commit_metadata, we'll need to call sync_inode_metadata() on both inodes... Cheers, Dave. -- Dave Chinner david@fromorbit.com