Date: Mon, 23 Jan 2012 05:05:13 +0200 From: Kostik Belousov <kostikbel@gmail.com> To: Yuri Pankov <yuri.pankov@gmail.com> Cc: freebsd-current@freebsd.org Subject: Re: panic: No NCF_TS Message-ID: <20120123030513.GK31224@deviant.kiev.zoral.com.ua> In-Reply-To: <20120123013642.GB10149@sirius.xvoid.org> References: <20120123013642.GB10149@sirius.xvoid.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--l0X5dEQA+6dqjqIE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 23, 2012 at 05:36:42AM +0400, Yuri Pankov wrote: > Seems to be reproducible here running r230467 as the NFS client and > r230135 as NFS server. NFSv4 not enabled. >=20 > # mount > [...] > sirius:/data/distfiles on /usr/ports/distfiles (nfs) >=20 > # /usr/bin/env /usr/bin/fetch -AFpr -S 4682084 -o /usr/ports/distfiles/sq= lite-src-3071000.zip http://www.sqlite.org/sqlite-src-3071000.zip > /usr/ports/distfiles/sqlite-src-3071000.zip 100% of 4572 kB 379 kBps 0= 0m00s > # rm /usr/ports/distfiles/sqlite-src-3071000.zip >=20 > immediately followed by: >=20 > panic: No NCF_TS > cpuid =3D 2 > KDB: enter: panic > [ thread pid 1603 tid 100494 ] > Stopped at kdb_enter+0x3e: movq $0,kdb_why > db> bt > Tracing pid 1603 tid 100494 td 0xfffffe0089585460 > kdb_enter() at kdb_enter+0x3e > panic() at panic+0x245 > cache_lookup_times() at cache_lookup_times+0x6b5 > nfs_lookup() at nfs_lookup+0x190 > VOP_LOOKUP_APV() at VOP_LOOKUP_APV+0x8b > lookup() at lookup+0x7e9 > namei() at namei+0x74c > kern_statat_vnhook() at kern_statat_vnhook+0x90 > sys_lstat() at sys_lstat+0x30 > amd64_syscall() at amd64_syscall+0x221 > Xfast_syscall() at Xfast_syscall+0xfb > --- syscall (190, FreeBSD ELF64, sys_lstat), rip =3D 0x80093ff3c, rsp =3D= 0x7fffffffd8d8, rbp =3D 0x7fffffffd979 --- >=20 Yes, my bad. I wrote the r230441 with the assumption that filesystems are consistent in their use of cache_enter_time(). And my net-booting test box did not catched this, which is at least interesting. Please try the change below. Actually, it should be enough to only apply the changes for fs/nfsclient (or nfsclient/ if you use old nfs). If this does not help, then please try the whole patch. Even if not needed for correctness, I think vfs_cache.c change could be made useful by adding KASSERT to it. commit 9771eb4739170d014fcebfbad07bfed4076c6d85 Author: Konstantin Belousov <kostik@pooma.home> Date: Mon Jan 23 04:36:08 2012 +0200 Make NCF_TS mismatch not fatal. Consistently use cache_enter_time in nfs clients. diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 2747191..2841647 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -1432,7 +1432,7 @@ nfs_mknodrpc(struct vnode *dvp, struct vnode **vpp, s= truct componentname *cnp, } if (!error) { if ((cnp->cn_flags & MAKEENTRY)) - cache_enter(dvp, newvp, cnp); + cache_enter_time(dvp, newvp, cnp, &vattr.va_ctime); *vpp =3D newvp; } else if (NFS_ISV4(dvp)) { error =3D nfscl_maperr(cnp->cn_thread, error, vap->va_uid, @@ -1591,7 +1591,7 @@ again: } if (!error) { if (cnp->cn_flags & MAKEENTRY) - cache_enter(dvp, newvp, cnp); + cache_enter_time(dvp, newvp, cnp, &vap->va_ctime); *ap->a_vpp =3D newvp; } else if (NFS_ISV4(dvp)) { error =3D nfscl_maperr(cnp->cn_thread, error, vap->va_uid, @@ -1923,6 +1923,7 @@ nfs_link(struct vop_link_args *ap) struct componentname *cnp =3D ap->a_cnp; struct nfsnode *np, *tdnp; struct nfsvattr nfsva, dnfsva; + struct timespec ts; int error =3D 0, attrflag, dattrflag; =20 if (vp->v_mount !=3D tdvp->v_mount) { @@ -1966,8 +1967,10 @@ nfs_link(struct vop_link_args *ap) * must care about lookup caching hit rate, so... */ if (VFSTONFS(vp->v_mount)->nm_negnametimeo !=3D 0 && - (cnp->cn_flags & MAKEENTRY)) - cache_enter(tdvp, vp, cnp); + (cnp->cn_flags & MAKEENTRY)) { + vfs_timestamp(&ts); + cache_enter_time(tdvp, vp, cnp, &ts); + } if (error && NFS_ISV4(vp)) error =3D nfscl_maperr(cnp->cn_thread, error, (uid_t)0, (gid_t)0); @@ -1987,6 +1990,7 @@ nfs_symlink(struct vop_symlink_args *ap) struct nfsfh *nfhp; struct nfsnode *np =3D NULL, *dnp; struct vnode *newvp =3D NULL; + struct timespec ts; int error =3D 0, attrflag, dattrflag, ret; =20 vap->va_type =3D VLNK; @@ -2030,8 +2034,10 @@ nfs_symlink(struct vop_symlink_args *ap) * must care about lookup caching hit rate, so... */ if (VFSTONFS(dvp->v_mount)->nm_negnametimeo !=3D 0 && - (cnp->cn_flags & MAKEENTRY)) - cache_enter(dvp, newvp, cnp); + (cnp->cn_flags & MAKEENTRY)) { + vfs_timestamp(&ts); + cache_enter_time(dvp, newvp, cnp, &ts); + } *ap->a_vpp =3D newvp; } =20 @@ -2063,6 +2069,7 @@ nfs_mkdir(struct vop_mkdir_args *ap) struct vattr vattr; struct nfsfh *nfhp; struct nfsvattr nfsva, dnfsva; + struct timespec ts; int error =3D 0, attrflag, dattrflag, ret; =20 if ((error =3D VOP_GETATTR(dvp, &vattr, cnp->cn_cred)) !=3D 0) @@ -2116,8 +2123,10 @@ nfs_mkdir(struct vop_mkdir_args *ap) * must care about lookup caching hit rate, so... */ if (VFSTONFS(dvp->v_mount)->nm_negnametimeo !=3D 0 && - (cnp->cn_flags & MAKEENTRY)) - cache_enter(dvp, newvp, cnp); + (cnp->cn_flags & MAKEENTRY)) { + vfs_timestamp(&ts); + cache_enter_time(dvp, newvp, cnp, &ts); + } *ap->a_vpp =3D newvp; } return (error); diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index c11f25f..647dcac 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -233,6 +233,24 @@ nc_get_name(struct namecache *ncp) return (ncp_ts->nc_name); } =20 +static void +cache_out_ts(struct namecache *ncp, struct timespec *tsp, int *ticksp) +{ + + if ((ncp->nc_flag & NCF_TS) =3D=3D 0) { + if (tsp !=3D NULL) + bzero(tsp, sizeof(*tsp)); + if (ticksp !=3D NULL) + *ticksp =3D 0; + return; + } + + if (tsp !=3D NULL) + *tsp =3D ((struct namecache_ts *)ncp)->nc_time; + if (ticksp !=3D NULL) + *ticksp =3D ((struct namecache_ts *)ncp)->nc_ticks; +} + static int doingcache =3D 1; /* 1 =3D> enable the cache */ SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0, "VFS namecache enabled"); @@ -506,17 +524,7 @@ retry_wlocked: dvp, cnp->cn_nameptr, *vpp); SDT_PROBE(vfs, namecache, lookup, hit, dvp, "..", *vpp, 0, 0); - if (tsp !=3D NULL) { - KASSERT((ncp->nc_flag & NCF_TS) !=3D 0, - ("No NCF_TS")); - *tsp =3D ((struct namecache_ts *)ncp)->nc_time; - } - if (ticksp !=3D NULL) { - KASSERT((ncp->nc_flag & NCF_TS) !=3D 0, - ("No NCF_TS")); - *ticksp =3D ((struct namecache_ts *)ncp)-> - nc_ticks; - } + cache_out_ts(ncp, tsp, ticksp); goto success; } } @@ -563,14 +571,7 @@ retry_wlocked: dvp, cnp->cn_nameptr, *vpp, ncp); SDT_PROBE(vfs, namecache, lookup, hit, dvp, nc_get_name(ncp), *vpp, 0, 0); - if (tsp !=3D NULL) { - KASSERT((ncp->nc_flag & NCF_TS) !=3D 0, ("No NCF_TS")); - *tsp =3D ((struct namecache_ts *)ncp)->nc_time; - } - if (ticksp !=3D NULL) { - KASSERT((ncp->nc_flag & NCF_TS) !=3D 0, ("No NCF_TS")); - *ticksp =3D ((struct namecache_ts *)ncp)->nc_ticks; - } + cache_out_ts(ncp, tsp, ticksp); goto success; } =20 @@ -602,14 +603,7 @@ negative_success: cnp->cn_flags |=3D ISWHITEOUT; SDT_PROBE(vfs, namecache, lookup, hit_negative, dvp, nc_get_name(ncp), 0, 0, 0); - if (tsp !=3D NULL) { - KASSERT((ncp->nc_flag & NCF_TS) !=3D 0, ("No NCF_TS")); - *tsp =3D ((struct namecache_ts *)ncp)->nc_time; - } - if (ticksp !=3D NULL) { - KASSERT((ncp->nc_flag & NCF_TS) !=3D 0, ("No NCF_TS")); - *ticksp =3D ((struct namecache_ts *)ncp)->nc_ticks; - } + cache_out_ts(ncp, tsp, ticksp); CACHE_WUNLOCK(); return (ENOENT); =20 @@ -797,8 +791,8 @@ cache_enter_time(dvp, vp, cnp, tsp) n2->nc_nlen =3D=3D cnp->cn_namelen && !bcmp(nc_get_name(n2), cnp->cn_nameptr, n2->nc_nlen)) { if (tsp !=3D NULL) { - KASSERT((n2->nc_flag & NCF_TS) !=3D 0, - ("no NCF_TS")); + if ((n2->nc_flag & NCF_TS) =3D=3D 0) + continue; n3 =3D (struct namecache_ts *)n2; n3->nc_time =3D ((struct namecache_ts *)ncp)->nc_time; diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index a39b29b..2fc4d2c 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -1531,7 +1531,7 @@ nfsmout: vput(newvp); } else { if (cnp->cn_flags & MAKEENTRY) - cache_enter(dvp, newvp, cnp); + cache_enter_time(dvp, newvp, cnp, &vap->va_ctime); *vpp =3D newvp; } mtx_lock(&(VTONFS(dvp))->n_mtx); @@ -1671,7 +1671,7 @@ nfsmout: } if (!error) { if (cnp->cn_flags & MAKEENTRY) - cache_enter(dvp, newvp, cnp); + cache_enter_time(dvp, newvp, cnp, &vap->va_ctime); *ap->a_vpp =3D newvp; } mtx_lock(&(VTONFS(dvp))->n_mtx); --l0X5dEQA+6dqjqIE Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk8czmkACgkQC3+MBN1Mb4i9wACeK3lFYdgb08gaax/b/teC9agE 1+AAnisAAjAaYBhCV1QsY8hrhzBPXfgx =ruNM -----END PGP SIGNATURE----- --l0X5dEQA+6dqjqIE--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120123030513.GK31224>