From nobody Thu Dec 02 02:31:52 2021 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 5A46418AC0A7; Thu, 2 Dec 2021 02:31:53 +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 4J4Kj43GBgz4nZq; Thu, 2 Dec 2021 02:31:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 49F5D1588C; Thu, 2 Dec 2021 02:31:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B22VqE0073898; Thu, 2 Dec 2021 02:31:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B22VqY2073897; Thu, 2 Dec 2021 02:31:52 GMT (envelope-from git) Date: Thu, 2 Dec 2021 02:31:52 GMT Message-Id: <202112020231.1B22VqY2073897@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 4b2caeec43ea - stable/13 - swapon: extend the region where the swap vnode is locked 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 4b2caeec43eabdb6331352ca9249abd5175f4838 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638412312; 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=y95LN2XzDYYie4w2rFxa9B1Vmi6/8RylTAfTz3XpapU=; b=k3EIPlQ4wuitMvf+ZO7ez55JZ1aS3fjgElagw0fvWGwzV0Aemj13dTUTexxOToOxUwHIZa wz84iJEA8gGh2E+QIAH99KJgHz6AKexOkj6DUoFPvFlC6HYYWONQ7TWamOBbC04gwakbu2 SrCGNRgY0Dgq/V6w5WlqvDfzTR3NzQxTc/PakvR5eS6qBYro69Y34WQehkd914UB6j+ALS W+K6INPu1R7pDcn5b7ICLOqNz63kDGRXWgF/6SIweog/ncLCeT5ReKVuI7nwZvsy1VguzU eEUTWnHAFBvXJN0eq/o/kAIZP5cH3TUP6kL212h6c7VP6ZsVuReF9J08ItUM4w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638412312; a=rsa-sha256; cv=none; b=VqrO3hQG1n/SFRAEY5kxNeh2zdTVHQaopKrFjfUDqd0gp+Xv45Iqvjgwb+rAe+A2YyTTWW YtwlRBnuyU1D8hCSREL0nApguiyzhZuDWSEy8E+VFiZewoT64mb5BoyLoS2JifQdxzfTGK oNhWqgA/fzo11jFtBuqYMwClEpntLkVi0N22DiHjym9rV/ufJxOlju6Qo8oSDGskvZipsJ WJ8TfeGk3CLF1tackkitEM9ak3YPm/pOQJjOJVJdIwAVDmyyeGb+Kg7/I5AgHzhk4LdKl9 FCzB/nDitzxalxWOOXFaqyBJcYleMJvACWeB2jo99dG78+NxRFi+8oZWwAYQvw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4b2caeec43eabdb6331352ca9249abd5175f4838 commit 4b2caeec43eabdb6331352ca9249abd5175f4838 Author: Konstantin Belousov AuthorDate: 2021-11-24 03:06:02 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-02 02:21:14 +0000 swapon: extend the region where the swap vnode is locked (cherry picked from commit 6ddf41faa6f54738db9b3f313086974b6403d680) --- sys/vm/swap_pager.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 38c225db51ee..8363dce52683 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -2360,8 +2360,8 @@ sys_swapon(struct thread *td, struct swapon_args *uap) goto done; } - NDINIT(&nd, LOOKUP, ISOPEN | FOLLOW | AUDITVNODE1, UIO_USERSPACE, - uap->name, td); + NDINIT(&nd, LOOKUP, ISOPEN | FOLLOW | LOCKLEAF | AUDITVNODE1, + UIO_USERSPACE, uap->name, td); error = namei(&nd); if (error) goto done; @@ -2381,8 +2381,10 @@ sys_swapon(struct thread *td, struct swapon_args *uap) error = swaponvp(td, vp, attr.va_size / DEV_BSIZE); } - if (error) - vrele(vp); + if (error != 0) + vput(vp); + else + VOP_UNLOCK(vp); done: sx_xunlock(&swdev_syscall_lock); return (error); @@ -3005,7 +3007,7 @@ swapongeom(struct vnode *vp) { int error; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + ASSERT_VOP_ELOCKED(vp, "swapongeom"); if (vp->v_type != VCHR || VN_IS_DOOMED(vp)) { error = ENOENT; } else { @@ -3013,7 +3015,6 @@ swapongeom(struct vnode *vp) error = swapongeom_locked(vp->v_rdev, vp); g_topology_unlock(); } - VOP_UNLOCK(vp); return (error); } @@ -3064,6 +3065,7 @@ swaponvp(struct thread *td, struct vnode *vp, u_long nblks) struct swdevt *sp; int error; + ASSERT_VOP_ELOCKED(vp, "swaponvp"); if (nblks == 0) return (ENXIO); mtx_lock(&sw_dev_mtx); @@ -3075,14 +3077,12 @@ swaponvp(struct thread *td, struct vnode *vp, u_long nblks) } mtx_unlock(&sw_dev_mtx); - (void) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); #ifdef MAC error = mac_system_check_swapon(td->td_ucred, vp); if (error == 0) #endif error = VOP_OPEN(vp, FREAD | FWRITE, td->td_ucred, td, NULL); - (void) VOP_UNLOCK(vp); - if (error) + if (error != 0) return (error); swaponsomething(vp, vp, nblks, swapdev_strategy, swapdev_close,