From nobody Tue Apr 4 20:48:24 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 4Prfx94mGKz4497q; Tue, 4 Apr 2023 20:48:29 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta002.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) (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 4Prfx92Mfwz4S9B; Tue, 4 Apr 2023 20:48:29 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Authentication-Results: mx1.freebsd.org; none Received: from shw-obgw-4001a.ext.cloudfilter.net ([10.228.9.142]) by cmsmtp with ESMTP id jiPKpvlL9jvm1jnZspkFXu; Tue, 04 Apr 2023 20:48:28 +0000 Received: from spqr.komquats.com ([70.66.148.124]) by cmsmtp with ESMTPA id jnZppOTVLHFsOjnZqpBEwi; Tue, 04 Apr 2023 20:48:28 +0000 X-Authority-Analysis: v=2.4 cv=XZqaca15 c=1 sm=1 tr=0 ts=642c8d1c a=Cwc3rblV8FOMdVN/wOAqyQ==:117 a=Cwc3rblV8FOMdVN/wOAqyQ==:17 a=8nJEP1OIZ-IA:10 a=dKHAf1wccvYA:10 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=EkcXrb_YAAAA:8 a=C-XD7YCCgZGrATHd4SsA:9 a=wPNLvfGTeEIA:10 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 38ECF4A5; Tue, 4 Apr 2023 13:48:24 -0700 (PDT) Received: by slippy.cwsent.com (Postfix, from userid 1000) id 11505E8; Tue, 4 Apr 2023 13:48:24 -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: Martin Matuska cc: Cy Schubert , Mateusz Guzik , Rick Macklem , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org, Pawel Dawidek Subject: Re: git: 8ee579abe09e - main - zfs: fall back if block_cloning feature is disabled In-reply-to: <88b2e6c2-94d7-81f8-f85d-9d7a6b7b8d11@FreeBSD.org> References: <202304041145.334Bjx6l035872@gitrepo.freebsd.org> <20230404141717.B976D31C@slippy.cwsent.com> <98c71e6f-5b48-79f3-e7b0-95d674949624@FreeBSD.org> <20230404091844.639cb1c1@slippy> <20230404093418.3041ff23@slippy> <20230404181823.0EA79C4@slippy.cwsent.com> <88b2e6c2-94d7-81f8-f85d-9d7a6b7b8d11@FreeBSD.org> Comments: In-reply-to Martin Matuska message dated "Tue, 04 Apr 2023 22:18:25 +0200." 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=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Tue, 04 Apr 2023 13:48:24 -0700 Message-Id: <20230404204824.11505E8@slippy.cwsent.com> X-CMAE-Envelope: MS4xfMo66jI7w4dxkaPy7cAgmcoVPnA8DWERgJL+EZCuwpbpPvn4IWQjBX0nUUnKYfcmyWsIBq4tR0CDhOsFS1z3tC7edMKtI/ornDrgW6U5VRRZmH1JFBlw g0Vkvi2EcpG+eMJNMvVb0teSMUzq3zi9QU7sfY8tg5tLIDNKZ/6eCzmLwQuI3J8JNmWTDgTxrvHcfXcfIy/jlR2O0Z72exLCanCzCh2xpzEdfUMUq9oVQ6N6 gQMmppAaA/Wtnnyi/zaZAHyFAfs9RH4CQXMaoSPKNNp0zxT3jBV6Qy+9F9rpyC098REy+ZmPIDwrN+c/gHfzCiYNkjzBKI6KSpMdyUmk8nCKXcoNmUobNDse 9bt4wAzvphOLFYGNb0vN3yZ3h0XDJchCQWYqBSpbzYL9Mk5vJCy9x1SKZrAT/F+QI4Fd1IXz X-Rspamd-Queue-Id: 4Prfx92Mfwz4S9B X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_RCPT(0.00)[]; ASN(0.00)[asn:16509, ipnet:3.96.0.0/15, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N As requested by rpokala, D39418 and D39419 have been submitted. Again, I am not the author of these. Only the curator. We can continue our discussion there. -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org e^(i*pi)+1=0 In message <88b2e6c2-94d7-81f8-f85d-9d7a6b7b8d11@FreeBSD.org>, Martin Matuska w rites: > I agree that these are three individual fixes. > > 1.) pass ap->a_outcred instead of ap->a_fsizetd->td_ucred to > zfs_clone_range() > I am ok with this, the way the argument is subsequently used it should > be ap->a_outcred which is intended for the write. > > 2.) do a vn_generic_copy_file_range() in case of EXDEV > > The comment vn_generic_copy_file_range() says: > /* >  * Copy a byte range of one file to another.  This function can handle the >  * case where invp and outvp are on different file systems. >  * It can also be called by a VOP_COPY_FILE_RANGE() to do the work, if > there >  * is no better file system specific way to do it. >  */ > > That is actually our case. zfs_clone_range() exits with EXDEV if: > - source and destination are not on the same pool > - the block_cloning feature is not enabled > - input and output files have a different block size > - offset and len are not at block boundaries > - length is not a multiple of block size, with except for the end of file > - we are trying to clone a block created in the current transaction group > - we are cloning encrypted data not in the same dataset > > IMO we can fallback to vn_generic_copy_file_range() in all of these cases. > > As of the locks, we need to run vn_generic_copy_file_range() on unlocked > vnodes, > just look into the function. > In both fuse_vnops.c and nfs_clvnops.c it does not run on locked vnodes. > Even the comment from pjd in zfs_vnops_os.c says: >         /* >          * 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, b > ut > then we >          * need something else than vn_generic_copy_file_range(). >          */ > > So IMO it should be at the end after unlock. > > 3.) By doing the feature check early, we save locking the input vnode > and calling mac_vnode_check_write() and vn_rlimit_fsize() at the cost of > checking for the disabled feature twice. Maybe documented skipping of > the check in zfs_clone_range()? The code of the early check looks ok to me. > > On 4. 4. 2023 20:18, Cy Schubert wrote: > > In message c > > om> > > , Mateusz Guzik writes: > >> can you please post a review > > I could but I didn't write any of it. Rick Macklem and Martin Matuska wrote > > it. My patch was for discussion only. > > > > Martin and Rick, do you mind if I post this as a review. It should probably > > be two, maybe three separate commits, fixing two different problems. > > > >