From 3fc1786cedde198884d9d028d45db9d7bd948165 Mon Sep 17 00:00:00 2001 From: Francois Tigeot Date: Sun, 29 Jan 2012 09:42:38 +0100 Subject: [PATCH] kernel - properly initialize vnode->v_pfsmp * add and rewrite comments to document it better --- sys/kern/vfs_lock.c | 1 + sys/kern/vfs_vopops.c | 3 +++ sys/sys/vnode.h | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_lock.c b/sys/kern/vfs_lock.c index 52a9a997e7..85006df4d9 100644 --- a/sys/kern/vfs_lock.c +++ b/sys/kern/vfs_lock.c @@ -949,6 +949,7 @@ allocvnode(int lktimeout, int lkflags) vp->v_tag = 0; vp->v_ops = NULL; vp->v_data = NULL; + vp->v_pfsmp = NULL; KKASSERT(vp->v_mount == NULL); return (vp); diff --git a/sys/kern/vfs_vopops.c b/sys/kern/vfs_vopops.c index e016f4bf9a..f6c893e52d 100644 --- a/sys/kern/vfs_vopops.c +++ b/sys/kern/vfs_vopops.c @@ -438,9 +438,12 @@ vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag, DO_OPS(ops, error, &ap, vop_write); if ((error == 0) && do_accounting) { size_after = vp->v_filesize; + /* does this vnode belong to a pfs/nullfs mount ? */ if (vp->v_pfsmp != NULL) { + /* yes, use a copy of the real mp */ mp = vp->v_pfsmp; } else { + /* no, we can use vp->v_mount directly */ mp = vp->v_mount; } VFS_ACCOUNT(mp, va.va_uid, va.va_gid, size_after - size_before); diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index cadce2b969..6b4cb67ba3 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -198,7 +198,7 @@ struct vnode { } v_pollinfo; struct vmresident *v_resident; /* optional vmresident */ struct ccms_dataspace v_ccms; /* cache coherency */ - struct mount *v_pfsmp; /* XXX: hack for PFS accounting */ + struct mount *v_pfsmp; /* real mount point for pfs/nullfs mounts */ #ifdef DEBUG_LOCKS const char *filename; /* Source file doing locking */ int line; /* Line number doing locking */ -- 2.41.0