Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1808799pxj; Wed, 19 May 2021 14:35:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8J/TZA7RGljm/wD1XRfotGl6tv5c9WAW/zXxHR1ahun/SNH+g47RORd+BgV9ViFaJLEhR X-Received: by 2002:a05:6e02:e41:: with SMTP id l1mr1261886ilk.141.1621460145028; Wed, 19 May 2021 14:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621460145; cv=none; d=google.com; s=arc-20160816; b=Ul3XjUjlZ1k1o896w3e7GxWQJs/5OMp7kMiQx6uj3yGlad8xyyG5MU4niZxOshw9gd fqXn8HaT3zCRJakzcureY1J2Bpqx6PIyhBN3M4fLq0DPEPtZ2hK8yTQbG8+K+E3fCkJV avWPyy93PwgYd+IJpTmbdA4mfmHYdw6ym0aMxkgB3D5NXARDIqfjdyG5zvnO99bw8hXf OQRHNbcx+8NCzZp5hJAaxT6jGHrEsyRTZ/eaZIITpHG+olVFMAyV/WljG4FeBsrowBNH Yhk7Cjsm4r+/7FlN2DppDcxiKzrme0Putm9G0deby8QXRmU8OV/Yn60iypGucZYc1oCR 2T/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:from:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date :dkim-signature:dkim-filter; bh=HWbzhv9i3P37jhkoG6H7SO5nBlTADmZQFZ9qbtWGzwI=; b=tjOao+n/PIfYW5YvEpTlL7fPvW/vD8J1KoLUUYw0ZytaN1mubq8g0vuOQYxjmC60Fn 9P6mkjUPF1rd7raPhBUvZM+rnGTtooPidw/p8iLqhDzxd9T8tBtaQYG+luAu6apLQYgv Q9KuhhoqorGZCKni3o7ZWFqAeyTvhI54WYunmn/HKFHwnPCwXUKAo7ctfpDa4EjFFveN 6MRbvtBJm+aBtzCYwju3fpz6pPPepHVVSfro1XGHF+CiIC82ud7pTofCvtvFVCI6UJEj nRTY+MXny2Tk2pfbdEJsUVQVJyOtI+xI7Z6uQl3CIb+dbO1ZKiMojBtxnZHMaMPOP9j9 X0Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=SvMjojGn; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 y10si520699jan.19.2021.05.19.14.35.20; Wed, 19 May 2021 14:35:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@fieldses.org header.s=default header.b=SvMjojGn; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229597AbhESVd5 (ORCPT + 99 others); Wed, 19 May 2021 17:33:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbhESVd5 (ORCPT ); Wed, 19 May 2021 17:33:57 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91A33C06175F for ; Wed, 19 May 2021 14:32:37 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 29C9464E8; Wed, 19 May 2021 17:32:36 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 29C9464E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1621459956; bh=HWbzhv9i3P37jhkoG6H7SO5nBlTADmZQFZ9qbtWGzwI=; h=Date:To:Cc:Subject:References:In-Reply-To:From:From; b=SvMjojGnqaqJqXPqXFc1ocnAiNuJm2vfJ7Uh2qWYhVSoxjcOxfHmnsiRgIuCC5ffO zpZUGZmsEiBpsrTExdh4rpeN/Xt3DLFK6JZI6Gf6rlX7QQH61A0rtWbmupU6w54J6j IrohqDHJR9Yta2z1zZN8QSb/ztMJ6v4bfk1GIjKk= Date: Wed, 19 May 2021 17:32:36 -0400 To: Olga Kornievskaia Cc: bfields@redhat.com, chuck.lever@oracle.com, linux-nfs@vger.kernel.org Subject: Re: [PATCH v2 1/1] NFSD add vfs_fsync after async copy is done Message-ID: <20210519213236.GD19450@fieldses.org> References: <20210519184827.5460-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210519184827.5460-1-olga.kornievskaia@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) From: bfields@fieldses.org (J. Bruce Fields) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, May 19, 2021 at 02:48:27PM -0400, Olga Kornievskaia wrote: > From: Olga Kornievskaia > > Currently, the server does all copies as NFS_UNSTABLE. For synchronous > copies linux client will append a COMMIT to the COPY compound but for > async copies it does not (because COMMIT needs to be done after all > bytes are copied and not as a reply to the COPY operation). > > However, in order to save the client doing a COMMIT as a separate > rpc, the server can reply back with NFS_FILE_SYNC copy. This patch > proposed to add vfs_fsync() call at the end of the async copy. > > --- v2: moved the committed argument into the nfsd4_copy structure Makes sense to me, thanks. Applying if nobody sees an objection.--b. > > Signed-off-by: Olga Kornievskaia > --- > fs/nfsd/nfs4proc.c | 14 +++++++++++++- > fs/nfsd/xdr4.h | 1 + > 2 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > index f4ce93d7f26e..dc7ac4b39eff 100644 > --- a/fs/nfsd/nfs4proc.c > +++ b/fs/nfsd/nfs4proc.c > @@ -1375,7 +1375,8 @@ static const struct nfsd4_callback_ops nfsd4_cb_offload_ops = { > > static void nfsd4_init_copy_res(struct nfsd4_copy *copy, bool sync) > { > - copy->cp_res.wr_stable_how = NFS_UNSTABLE; > + copy->cp_res.wr_stable_how = > + copy->committed ? NFS_FILE_SYNC : NFS_UNSTABLE; > copy->cp_synchronous = sync; > gen_boot_verifier(©->cp_res.wr_verifier, copy->cp_clp->net); > } > @@ -1386,6 +1387,7 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy) > u64 bytes_total = copy->cp_count; > u64 src_pos = copy->cp_src_pos; > u64 dst_pos = copy->cp_dst_pos; > + __be32 status; > > /* See RFC 7862 p.67: */ > if (bytes_total == 0) > @@ -1403,6 +1405,16 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy) > src_pos += bytes_copied; > dst_pos += bytes_copied; > } while (bytes_total > 0 && !copy->cp_synchronous); > + /* for a non-zero asynchronous copy do a commit of data */ > + if (!copy->cp_synchronous && copy->cp_res.wr_bytes_written > 0) { > + down_write(©->nf_dst->nf_rwsem); > + status = vfs_fsync_range(copy->nf_dst->nf_file, > + copy->cp_dst_pos, > + copy->cp_res.wr_bytes_written, 0); > + up_write(©->nf_dst->nf_rwsem); > + if (!status) > + copy->committed = true; > + } > return bytes_copied; > } > > diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h > index a7c425254fee..3e4052e3bd50 100644 > --- a/fs/nfsd/xdr4.h > +++ b/fs/nfsd/xdr4.h > @@ -567,6 +567,7 @@ struct nfsd4_copy { > struct vfsmount *ss_mnt; > struct nfs_fh c_fh; > nfs4_stateid stateid; > + bool committed; > }; > > struct nfsd4_seek { > -- > 2.27.0