VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.
This commit is contained in:
hannken 2011-10-24 11:43:30 +00:00
parent fe16316a27
commit 68660b46b7
2 changed files with 11 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_kq.c,v 1.24 2011/06/12 03:35:59 rmind Exp $ */
/* $NetBSD: nfs_kq.c,v 1.25 2011/10/24 11:43:30 hannken Exp $ */
/*-
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_kq.c,v 1.24 2011/06/12 03:35:59 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_kq.c,v 1.25 2011/10/24 11:43:30 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -138,7 +138,10 @@ nfs_kqpoll(void *arg)
/* save v_size, nfs_getattr() updates it */
osize = ke->vp->v_size;
memset(&attr, 0, sizeof(attr));
vn_lock(ke->vp, LK_SHARED | LK_RETRY);
(void) VOP_GETATTR(ke->vp, &attr, l->l_cred);
VOP_UNLOCK(ke->vp);
/* following is a bit fragile, but about best
* we can get */
@ -318,7 +321,9 @@ nfs_kqfilter(void *v)
* held. This is likely cheap due to attrcache, so do it now.
*/
memset(&attr, 0, sizeof(attr));
vn_lock(vp, LK_SHARED | LK_RETRY);
(void) VOP_GETATTR(vp, &attr, l->l_cred);
VOP_UNLOCK(vp);
mutex_enter(&nfskq_lock);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_vfsops.c,v 1.219 2011/10/07 09:35:06 hannken Exp $ */
/* $NetBSD: nfs_vfsops.c,v 1.220 2011/10/24 11:43:30 hannken Exp $ */
/*
* Copyright (c) 1989, 1993, 1995
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.219 2011/10/07 09:35:06 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.220 2011/10/24 11:43:30 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "opt_nfs.h"
@ -387,7 +387,9 @@ nfs_mountroot(void)
vfs_unbusy(mp, false, NULL);
/* Get root attributes (for the time). */
vn_lock(vp, LK_SHARED | LK_RETRY);
error = VOP_GETATTR(vp, &attr, l->l_cred);
VOP_UNLOCK(vp);
if (error)
panic("nfs_mountroot: getattr for root");
n = attr.va_atime.tv_sec;