From nobody Tue Apr 4 15:35:52 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PrX0X6rbKz43l0l; Tue, 4 Apr 2023 15:35:56 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta001.cacentral1.a.cloudfilter.net (omta001.cacentral1.a.cloudfilter.net [3.97.99.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PrX0W6WNlz3lD6; Tue, 4 Apr 2023 15:35:55 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Authentication-Results: mx1.freebsd.org; dkim=none; spf=none (mx1.freebsd.org: domain of cy.schubert@cschubert.com has no SPF policy when checking 3.97.99.32) smtp.mailfrom=cy.schubert@cschubert.com; dmarc=none Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTP id jSdkppVaHuZMSjihPpx7bV; Tue, 04 Apr 2023 15:35:55 +0000 Received: from spqr.komquats.com ([70.66.148.124]) by cmsmtp with ESMTPA id jihNpZnjv3fOSjihOpL8Dk; Tue, 04 Apr 2023 15:35:55 +0000 X-Authority-Analysis: v=2.4 cv=J8G5USrS c=1 sm=1 tr=0 ts=642c43db a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=kj9zAlcOel0A:10 a=dKHAf1wccvYA:10 a=pGLkceISAAAA:8 a=hF2rLc1pAAAA:8 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=EkcXrb_YAAAA:8 a=UYhlscbCs1nmgsX7yaIA:9 a=CjuIK1q_8ugA:10 a=O9OM7dhJW_8Hj9EqqvKN:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTP id 24374B22; Tue, 4 Apr 2023 08:35:53 -0700 (PDT) Received: by slippy.cwsent.com (Postfix, from userid 1000) id F063F27A; Tue, 4 Apr 2023 08:35:52 -0700 (PDT) X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.8+dev Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Rick Macklem cc: Mateusz Guzik , Cy Schubert , Martin Matuska , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 8ee579abe09e - main - zfs: fall back if block_cloning feature is disabled In-reply-to: References: <202304041145.334Bjx6l035872@gitrepo.freebsd.org> <20230404141717.B976D31C@slippy.cwsent.com> Comments: In-reply-to Rick Macklem message dated "Tue, 04 Apr 2023 08:26:02 -0700." List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 04 Apr 2023 08:35:52 -0700 Message-Id: <20230404153552.F063F27A@slippy.cwsent.com> X-CMAE-Envelope: MS4xfE6bN1/urTLU0+Ejo7cm73iSUfxW1cDTRTGW58P363WFmP3/7/voXpnhIbcmfl812QMsFdY75MrPYF7f64fi6N4hAi5qtanQa/+jSuKJEd41DnNUdghZ zehrZSBn3Liw+YB3k8ilC37kHLVuls3ipc2iQ76WvzEiXTUgzXeDE7onw4MMidKK80TZDv+OtsF5XrlcPbVceRAE7ooqodmwB480R5UA2KijSDg6Ls/HzPjS llhr7V4DisstRC/MdBz3fDo63SU5zAHRmPaXGJAFdKPamBg3NvWeWut3eERbxBPAd5ayw3yszdqnJN7Ix3XbfCwji1H3Alp8hzHAGoa49S77RRDpEtsNzUon qRRoWT3Vk3booBJbu1tgRsokG12mc0NyrDvUDqEs9fccUlDWt5Q= X-Spamd-Result: default: False [3.30 / 15.00]; R_BAD_CTE_7BIT(3.50)[7bit]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; AUTH_NA(1.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.998]; NEURAL_HAM_SHORT(-1.00)[-0.998]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_IN_DNSWL_LOW(-0.10)[3.97.99.32:from]; TAGGED_RCPT(0.00)[]; FREEMAIL_CC(0.00)[gmail.com,cschubert.com,freebsd.org]; DMARC_NA(0.00)[cschubert.com: no valid DMARC record]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[3.97.99.32:from]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; R_SPF_NA(0.00)[no SPF record]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; GREYLIST(0.00)[pass,meta]; RCPT_COUNT_SEVEN(0.00)[7]; FREEMAIL_TO(0.00)[gmail.com]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:16509, ipnet:3.96.0.0/15, country:US]; HAS_REPLYTO(0.00)[Cy.Schubert@cschubert.com] X-Rspamd-Queue-Id: 4PrX0W6WNlz3lD6 X-Spamd-Bar: +++ X-ThisMailContainsUnwantedMimeParts: N In message , Rick Macklem writes: > On Tue, Apr 4, 2023 at 7:38=E2=80=AFAM Mateusz Guzik wr= > ote: > > > > CAUTION: This email originated from outside of the University of Guelph. = > Do not click links or open attachments unless you recognize the sender and = > know the content is safe. If in doubt, forward suspicious emails to IThelp@= > uoguelph.ca > > > > > > On 4/4/23, Cy Schubert wrote: > > > In message <202304041145.334Bjx6l035872@gitrepo.freebsd.org>, Martin > > > Matuska wr > > > ites: > > >> The branch main has been updated by mm: > > >> > > >> URL: > > >> https://cgit.FreeBSD.org/src/commit/?id=3D8ee579abe09ec1fe15c588fc9a08= > 370b > > >> 83b81cd6 > > >> > > >> commit 8ee579abe09ec1fe15c588fc9a08370b83b81cd6 > > >> Author: Martin Matuska > > >> AuthorDate: 2023-04-04 11:40:41 +0000 > > >> Commit: Martin Matuska > > >> CommitDate: 2023-04-04 11:43:34 +0000 > > >> > > >> zfs: fall back if block_cloning feature is disabled > > >> > > >> If block_cloning is disabled, or other errors from zfs_clone_range= > () > > >> return an EXDEV we should fall back to vn_generic_copy_file_range(= > ). > > >> > > >> This fixes issues when copying files on the same dataset with > > >> block_cloning disabled. > > >> > > >> Upstreamed as pull request to OpenZFS. > > >> > > >> Reviewed by: Mateusz Guzik > > >> OpenZFS pull request: 14713 > > >> --- > > >> .../openzfs/module/os/freebsd/zfs/zfs_vnops_os.c | 17 > > >> ++++++++++----- > > >> -- > > >> 1 file changed, 10 insertions(+), 7 deletions(-) > > >> > > >> diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c > > >> b/sys/c > > >> ontrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c > > >> index 97429b360a36..2cd1d27e37bc 100644 > > >> --- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c > > >> +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c > > >> @@ -6243,13 +6243,6 @@ zfs_freebsd_copy_file_range(struct > > >> vop_copy_file_range > > >> _args *ap) > > >> int error; > > >> uint64_t len =3D *ap->a_lenp; > > >> > > >> - /* > > >> - * TODO: If offset/length is not aligned to recordsize, use > > >> - * vn_generic_copy_file_range() on this fragment. > > >> - * It would be better to do this after we lock the vnodes, but th= > en we > > >> - * need something else than vn_generic_copy_file_range(). > > >> - */ > > >> - > > >> /* Lock both vnodes, avoiding risk of deadlock. */ > > >> do { > > >> mp =3D NULL; > > >> @@ -6300,6 +6293,16 @@ unlock: > > >> if (mp !=3D NULL) > > >> vn_finished_write(mp); > > >> > > >> + /* > > >> + * Fall back if block_cloning feature is disabled > > >> + * or other EXDEV failures from zfs_vnops.c > > >> + */ > > >> + if (error =3D=3D EXDEV) { > > >> + error =3D vn_generic_copy_file_range(ap->a_invp, ap->a_in= > offp, > > >> + ap->a_outvp, ap->a_outoffp, ap->a_lenp, ap->a= > _flags > > >> , > > >> + ap->a_incred, ap->a_outcred, ap->a_fsizetd); > > >> + } > > >> + > > >> return (error); > > >> } > > >> > > >> > > > > > > This is too late to fall back. On Rick's suggestion the following makes= > the > > > > > > determination at > > > zfs_freebsd_copy_file_range() entry much earlier. > > > > > > > It's not too late, but I agree it is faster to bail out early. > > > > The proposed patch adds a condition which *differs* from the one in > > zfs_clone_range: > > if (dmu_objset_spa(inos) !=3D dmu_objset_spa(outos)) { > > zfs_exit_two(inzfsvfs, outzfsvfs, FTAG); > > return (SET_ERROR(EXDEV)); > > } > > > > ... meaning with the proposed patch the routine can still fail with > > EXDEV, making zfs_freebsd_copy_file_range also do it, which must not > > happen. > Since VOP_COPY_FILE_RANGE() is only called when invp and outvp > are on the same mount point, I don't think this can happen now. > However, there is a TO DO comment that suggests a call with invp and > outvp on different mount points may be in the future. > > As such, leaving Martin's patch in so that it calls vn_generic_copy_file_ra= > nge() > when zfs_clone_range() returns EXDEV seems like a good idea to me. It would need to be a few lines earlier, within the locked block. [...] -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org e^(i*pi)+1=0