From nobody Mon Nov 13 22:28:02 2023 X-Original-To: dev-commits-src-all@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 4STkb71qBSz50xK7; Mon, 13 Nov 2023 22:28:03 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4STkb71FvZz3ZCT; Mon, 13 Nov 2023 22:28:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699914483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OiE5sZKNOFhDzLhvnhFepbrvYoMQ1LFDYnDiU3DbRR4=; b=Jk2GcC8+sUsVb1cNoeytFr5fWrHWoZBEA14nRmnA2IIY8A8vzy+gJwN228ZyFiY96QE2yO nbJg10OOPafaE3HUdFyXr9V6vrBXszn82IqeWh6PND1NRJ8TxUGqLCo1uGnSoGzSWdQqH7 iqntIk3pZvnUTeAjJG4OyqTKPGK+0vW6FuEwBTw6D4wA/ytFAcFq6f7F55KF4C6zUxzQYl pZXMHpLEZx4eK9KInESNIcAOuFLClP7ujklmmEw8WFOY2NeAelKaIrhaFuLR/9BGs96NtB zk7s8vJB50jQZoqdDkzm1h2u8vYiIvi+34MoYg1E//L0MTSp84qzXtjTU3L3ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699914483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OiE5sZKNOFhDzLhvnhFepbrvYoMQ1LFDYnDiU3DbRR4=; b=TgTATdcu8CFeJc9bu+dZSJ0Y3z4ONjN/6n39tH1acL83EZaUhVyB4O9iDzr7LICvlXq0qN xdQvUJxvBYvkhZyr+vWG69hoqfsVcuugSSsi5bZ/BHGswp8nEoLiX/BJ34WBzMNcS9iTBF 0MgGAmTxaOEsypfSWdEyIucWqhtgurFWPWWS12Z2afVTlRQGzeofZGkDhQPpC+R7y7h9US V3OrZw0O8ngUj7nMbP8uwFqQWahFLCChUzoJtbd5lpmfsT4JWXit9ycEWoGOZ3nybhmPTX eOYs1AhFFAdCajBIloRBrLQadeoXrjHdo5RBznS5LwkVpN54GpLEmqoZ+3NaLw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699914483; a=rsa-sha256; cv=none; b=ntnZt++hQCTfOMIERa45sy9moO1VMeIrwP/ZJ3VnJmqUvSd4XLB+5LVzSZMk5SOELWoSNA xqz/XCOok0w1S4Ebg+FhnQ/r+h4xHOPLcZQn9XkHOW79URhX3wh/Y5kWZmbVmgliKtn5qO SYhnHi5crazaHKz+RdZMZ0H/wP0hOGTYeHS55KYxI2Ow6osHnl8OGsg4fCCrctYN3Tugx0 58nCELj0fdkJ5pxNIqjWKOfaoZRli1dx53b3XXHRZyGxXuZQfY4eWtz2EBj2XzmcDH0k3j Oz0J1aw/sn7kGg9sQLpdgRBHYzmwPKbc1GM0B9F+0HY4E5+q132OpQt23LNtfw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4STkb70Hywz8Pn; Mon, 13 Nov 2023 22:28:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3ADMS2NM063818; Mon, 13 Nov 2023 22:28:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3ADMS2k6063815; Mon, 13 Nov 2023 22:28:02 GMT (envelope-from git) Date: Mon, 13 Nov 2023 22:28:02 GMT Message-Id: <202311132228.3ADMS2k6063815@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 23210f538a00 - main - vn_copy_file_range(): busy both in and out mp around call to VOP_COPY_FILE_RANGE() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 23210f538a008788b2e16b9eddafa4f598a21663 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=23210f538a008788b2e16b9eddafa4f598a21663 commit 23210f538a008788b2e16b9eddafa4f598a21663 Author: Konstantin Belousov AuthorDate: 2023-11-12 18:37:29 +0000 Commit: Konstantin Belousov CommitDate: 2023-11-13 22:26:34 +0000 vn_copy_file_range(): busy both in and out mp around call to VOP_COPY_FILE_RANGE() This is required e.g. for nullfs to ensure liveness of the lower mount points. Reviewed by: jah, rmacklem, Olivier Certner Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42554 --- sys/kern/vfs_vnops.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index e2227537dde1..27ce5401f15f 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -3078,6 +3078,29 @@ vn_copy_file_range(struct vnode *invp, off_t *inoffp, struct vnode *outvp, inmp = invp->v_mount; outmp = outvp->v_mount; + if (inmp == NULL || outmp == NULL) { + error = EBADF; + goto out; + } + + for (;;) { + error = vfs_busy(inmp, 0); + if (error != 0) + goto out; + if (inmp == outmp) + break; + error = vfs_busy(outmp, MBF_NOWAIT); + if (error != 0) { + vfs_unbusy(inmp); + error = vfs_busy(outmp, 0); + if (error == 0) { + vfs_unbusy(outmp); + continue; + } + goto out; + } + break; + } /* * If the two vnodes are for the same file system type, call @@ -3092,6 +3115,9 @@ vn_copy_file_range(struct vnode *invp, off_t *inoffp, struct vnode *outvp, else error = vn_generic_copy_file_range(invp, inoffp, outvp, outoffp, lenp, flags, incred, outcred, fsize_td); + vfs_unbusy(outmp); + if (inmp != outmp) + vfs_unbusy(inmp); out: return (error); }