From owner-svn-src-projects@freebsd.org Sun Nov 3 03:16:24 2019 Return-Path: Delivered-To: svn-src-projects@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 D04F81A371A for ; Sun, 3 Nov 2019 03:16:24 +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) server-signature RSA-PSS (4096 bits) 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 475LgD4zbNz4Yk7; Sun, 3 Nov 2019 03:16:24 +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 75B3F58AA; Sun, 3 Nov 2019 03:16:24 +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 xA33GORd018275; Sun, 3 Nov 2019 03:16:24 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA33GOOr018273; Sun, 3 Nov 2019 03:16:24 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201911030316.xA33GOOr018273@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Sun, 3 Nov 2019 03:16:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r354274 - projects/nfsv42/sys/fs/nfsserver X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/nfsv42/sys/fs/nfsserver X-SVN-Commit-Revision: 354274 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Nov 2019 03:16:24 -0000 Author: rmacklem Date: Sun Nov 3 03:16:23 2019 New Revision: 354274 URL: https://svnweb.freebsd.org/changeset/base/354274 Log: Fix vnode locking for the case where Seek is proxied to the DS server. When a Seek is done on a pNFS server, the Seek is proxied to the DS server. This requires that the vnode remain locked until after the proxied Seek is completed. This patch fixes the vnode locking for Seek so that the vnode remains locked until after the proxy call and then unlocks it just before the VOP_IOCTL() call. Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdport.c projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- projects/nfsv42/sys/fs/nfsserver/nfs_nfsdport.c Sun Nov 3 02:52:41 2019 (r354273) +++ projects/nfsv42/sys/fs/nfsserver/nfs_nfsdport.c Sun Nov 3 03:16:23 2019 (r354274) @@ -5871,6 +5871,8 @@ out: /* * Seek vnode op call (actually it is a VOP_IOCTL()). + * This function is called with the vnode locked, but unlocks and vrele()s + * the vp before returning. */ int nfsvno_seek(struct nfsrv_descript *nd, struct vnode *vp, u_long cmd, @@ -5879,21 +5881,24 @@ nfsvno_seek(struct nfsrv_descript *nd, struct vnode *v struct nfsvattr at; int error, ret; - ASSERT_VOP_UNLOCKED(vp, "nfsvno_seek vp"); + ASSERT_VOP_LOCKED(vp, "nfsvno_seek vp"); /* * Attempt to seek on a DS file. A return of ENOENT implies * there is no DS file to seek on. */ error = nfsrv_proxyds(vp, 0, 0, cred, p, NFSPROC_SEEKDS, NULL, NULL, NULL, NULL, NULL, offp, content, eofp); - if (error != ENOENT) + if (error != ENOENT) { + vput(vp); return (error); + } /* * Do the VOP_IOCTL() call. For the case where *offp == file_size, * VOP_IOCTL() will return ENXIO. However, the correct reply for * NFSv4.2 is *eofp == true and error == 0 for this case. */ + NFSVOPUNLOCK(vp, 0); error = VOP_IOCTL(vp, cmd, offp, 0, cred, p); *eofp = false; if (error == ENXIO || (error == 0 && cmd == FIOSEEKHOLE)) { @@ -5906,6 +5911,7 @@ nfsvno_seek(struct nfsrv_descript *nd, struct vnode *v if (ret != 0 && error == 0) error = ret; } + vrele(vp); NFSEXITCODE(error); return (error); } Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Sun Nov 3 02:52:41 2019 (r354273) +++ projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c Sun Nov 3 03:16:23 2019 (r354274) @@ -5472,10 +5472,9 @@ nfsrvd_seek(struct nfsrv_descript *nd, __unused int is if (nd->nd_repstat != 0) goto nfsmout; - NFSVOPUNLOCK(vp, 0); + /* nfsvno_seek() unlocks and vrele()s the vp. */ nd->nd_repstat = nfsvno_seek(nd, vp, cmd, &off, content, &eof, nd->nd_cred, curthread); - vrele(vp); if (nd->nd_repstat == 0 && eof && content == NFSV4CONTENT_DATA && nfsrv_linux42server != 0) nd->nd_repstat = NFSERR_NXIO;