From owner-freebsd-stable@FreeBSD.ORG Fri Nov 5 21:28:02 2010 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87F20106566C; Fri, 5 Nov 2010 21:28:02 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 19D4B8FC0C; Fri, 5 Nov 2010 21:28:01 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id oA5LRvYF038804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 5 Nov 2010 23:27:57 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id oA5LRvZ4055999; Fri, 5 Nov 2010 23:27:57 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id oA5LRvIm055998; Fri, 5 Nov 2010 23:27:57 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 5 Nov 2010 23:27:57 +0200 From: Kostik Belousov To: Josh Carroll Message-ID: <20101105212757.GG2392@deviant.kiev.zoral.com.ua> References: <1984713101.142889.1288963447940.JavaMail.root@erie.cs.uoguelph.ca> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZdqPkeGXoIZADpbP" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: Rick Macklem , freebsd-stable@freebsd.org, jhb@freebsd.org, avg@freebsd.org Subject: Re: NFS deadlock (unkillable nfsd and no mounts work) X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 21:28:02 -0000 --ZdqPkeGXoIZADpbP Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 05, 2010 at 10:27:09AM -0700, Josh Carroll wrote: > >> I'm having a problem with nfsd hanging and not serving mount points, > >> during which time it can not not be killed. This problem started > >> happening sometime after November 2nd, since kernel from 11/2 sources > >> does not exhibit this problem. > > > > Please try the attached patch, rick >=20 > Thanks! I had to manually patch for some reason, but I can confirmed > that nfsd is now well-behaved with your patch applied. I tested a > couple of different mounts and played two separate files on the > Popcorn Hour (one lower bitrate, the other higher bitrate) and both > played without a hiccup. While those were playing I also was able to > automount my home directory on the macbook and move around my home > directory. >=20 > So it looks like this patch did the trick. Thanks Rick, really > appreciate the fast response. Is there a reason why this doesn't seem > to be getting reported a lot? What is particular in my setup that > broke it? >=20 > > ps: Starting about Monday I won't be able to do commits for about 3 wee= ks > > =9A =9Aso, if this patch works, could someone else please commit it, th= anks, > > =9A =9Arick > > >=20 > If someone can commit this, I'd really appreciate it. I will report > back if I notice any problems, but I imagine this would probably get > fixed in HEAD first, then MFC'd anyway, right? Unless this is already > fixed in HEAD. >=20 > Anyway, thanks again Rick! I appreciate it. >=20 > Regards, > Josh > As far as I can tell, there have been no adverse effects or > regressions with the kernel built with this patch (I had t I agree that the fix a right fix for real issue. It should only affect the filesystems that do support VFS_VGET(). In other words, it is relevant for e.g. UFS exports, but not for ZFS, that is the Andrey case. The change is committed as r214851 with shortest MFC timeout possible. There is further issue with use of VOP_ISLOCKED(). Andrey, can you try this untested change in your settings ? Thanks and sorry. diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index 2b9131f..668b02c 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -3037,6 +3037,7 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct= nfssvc_sock *slp, struct vattr va, at, *vap =3D &va; struct nfs_fattr *fp; int len, nlen, rem, xfer, tsiz, i, error =3D 0, error1, getret =3D 1; + int vp_locked; int siz, cnt, fullsiz, eofflag, rdonly, dirlen, ncookies; u_quad_t off, toff, verf; u_long *cookies =3D NULL, *cookiep; /* needs to be int64_t or off_t */ @@ -3067,10 +3068,12 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, stru= ct nfssvc_sock *slp, fullsiz =3D siz; error =3D nfsrv_fhtovp(fhp, 1, &vp, &vfslocked, nfsd, slp, nam, &rdonly, TRUE); + vp_locked =3D 1; if (!error && vp->v_type !=3D VDIR) { error =3D ENOTDIR; vput(vp); vp =3D NULL; + vp_locked =3D 0; } if (error) { nfsm_reply(NFSX_UNSIGNED); @@ -3090,6 +3093,7 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct= nfssvc_sock *slp, error =3D nfsrv_access(vp, VEXEC, cred, rdonly, 0); if (error) { vput(vp); + vp_locked =3D 0; vp =3D NULL; nfsm_reply(NFSX_V3POSTOPATTR); nfsm_srvpostop_attr(getret, &at); @@ -3097,6 +3101,7 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct= nfssvc_sock *slp, goto nfsmout; } VOP_UNLOCK(vp, 0); + vp_locked =3D 0; rbuf =3D malloc(siz, M_TEMP, M_WAITOK); again: iv.iov_base =3D rbuf; @@ -3110,6 +3115,7 @@ again: io.uio_td =3D NULL; eofflag =3D 0; vn_lock(vp, LK_SHARED | LK_RETRY); + vp_locked =3D 1; if (cookies) { free((caddr_t)cookies, M_TEMP); cookies =3D NULL; @@ -3118,6 +3124,7 @@ again: off =3D (u_quad_t)io.uio_offset; getret =3D VOP_GETATTR(vp, &at, cred); VOP_UNLOCK(vp, 0); + vp_locked =3D 0; if (!cookies && !error) error =3D NFSERR_PERM; if (!error) @@ -3238,8 +3245,10 @@ again: } else { cn.cn_flags &=3D ~ISDOTDOT; } - if (!VOP_ISLOCKED(vp)) + if (!vp_locked) { vn_lock(vp, LK_SHARED | LK_RETRY); + vp_locked =3D 1; + } if ((vp->v_vflag & VV_ROOT) !=3D 0 && (cn.cn_flags & ISDOTDOT) !=3D 0) { vref(vp); @@ -3342,7 +3351,7 @@ invalid: cookiep++; ncookies--; } - if (!usevget && VOP_ISLOCKED(vp)) + if (!usevget && vp_locked) vput(vp); else vrele(vp); --ZdqPkeGXoIZADpbP Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAkzUdtwACgkQC3+MBN1Mb4h7rgCgzrTfMysveofKNTshv4CuxZBM sIoAn0WT9bd1K9Oq1hHiXwUs4gyFAo9t =WGCj -----END PGP SIGNATURE----- --ZdqPkeGXoIZADpbP--