From owner-svn-src-head@freebsd.org Thu Oct 1 00:47:36 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A359943441D; Thu, 1 Oct 2020 00:47:36 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C1vbr3tD6z40t2; Thu, 1 Oct 2020 00:47:36 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 684678461; Thu, 1 Oct 2020 00:47:36 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0910lau4035812; Thu, 1 Oct 2020 00:47:36 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0910la56035811; Thu, 1 Oct 2020 00:47:36 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <202010010047.0910la56035811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Thu, 1 Oct 2020 00:47:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366303 - head/sys/fs/nfsclient X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/sys/fs/nfsclient X-SVN-Commit-Revision: 366303 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Oct 2020 00:47:36 -0000 Author: rmacklem Date: Thu Oct 1 00:47:35 2020 New Revision: 366303 URL: https://svnweb.freebsd.org/changeset/base/366303 Log: Modify the NFSv4.2 VOP_COPY_FILE_RANGE() client call to return after one successful RPC. Without this patch, the NFSv4.2 VOP_COPY_FILE_RANGE() client call would loop until the copy "len" was completed. The problem with doing this is that it might take a considerable time to complete for a large "len". By returning after a single successful Copy RPC that copied some of the data, the application that did the copy_file_range(2) syscall will be more responsive to signal delivery for large "len" copies. Modified: head/sys/fs/nfsclient/nfs_clvnops.c Modified: head/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clvnops.c Thu Oct 1 00:33:44 2020 (r366302) +++ head/sys/fs/nfsclient/nfs_clvnops.c Thu Oct 1 00:47:35 2020 (r366303) @@ -3638,7 +3638,7 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a struct vattr *vap; struct uio io; struct nfsmount *nmp; - size_t len, len2, copiedlen; + size_t len, len2; int error, inattrflag, outattrflag, ret, ret2; off_t inoff, outoff; bool consecutive, must_commit, tryoutcred; @@ -3731,7 +3731,11 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a } else error = 0; } - copiedlen = 0; + + /* + * len will be set to 0 upon a successful Copy RPC. + * As such, this only loops when the Copy RPC needs to be retried. + */ while (len > 0 && error == 0) { inattrflag = outattrflag = 0; len2 = len; @@ -3761,18 +3765,9 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a } else error = NFSERR_OFFLOADNOREQS; } - /* - * If the Copy returns a length == 0, it hit the - * EOF on the input file. - */ - if (len2 == 0) { - *ap->a_lenp = copiedlen; - len = 0; - } else { - len -= len2; - copiedlen += len2; - } - if (len == 0 && must_commit && error == 0) + *ap->a_lenp = len2; + len = 0; + if (len2 > 0 && must_commit && error == 0) error = ncl_commit(outvp, outoff, *ap->a_lenp, ap->a_outcred, curthread); if (error == 0 && ret != 0) @@ -3783,6 +3778,9 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a /* * Try consecutive == false, which is ok only if all * bytes are copied. + * If only some bytes were copied when consecutive + * is false, there is no way to know which bytes + * still need to be written. */ consecutive = false; error = 0;