UFS vnodes must have VM objects before they can be truncated. This is
authorMatthew Dillon <dillon@dragonflybsd.org>
Wed, 2 Jan 2008 20:15:48 +0000 (20:15 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Wed, 2 Jan 2008 20:15:48 +0000 (20:15 +0000)
normally guarenteed when the vnode is instantiated but there is a degenerate
case in ufs_inactive() that wasn't handled.

Reported-by: "Sepherosa Ziehau" <sepherosa@gmail.com>
sys/vfs/ufs/ufs_inode.c

index 6b6324d..cce5100 100644 (file)
@@ -37,7 +37,7 @@
  *
  *     @(#)ufs_inode.c 8.9 (Berkeley) 5/14/95
  * $FreeBSD: src/sys/ufs/ufs/ufs_inode.c,v 1.25.2.3 2002/07/05 22:42:31 dillon Exp $
- * $DragonFly: src/sys/vfs/ufs/ufs_inode.c,v 1.22 2007/05/06 19:23:35 dillon Exp $
+ * $DragonFly: src/sys/vfs/ufs/ufs_inode.c,v 1.23 2008/01/02 20:15:48 dillon Exp $
  */
 
 #include "opt_quota.h"
@@ -86,6 +86,9 @@ ufs_inactive(struct vop_inactive_args *ap)
                if (!ufs_getinoquota(ip))
                        (void)ufs_chkiq(ip, -1, NOCRED, FORCE);
 #endif
+               /* Must have a VM object to truncate */
+               if (vp->v_object == NULL)
+                       vinitvmio(vp, 0);
                error = ffs_truncate(vp, (off_t)0, 0, NOCRED);
                ip->i_rdev = 0;
                mode = ip->i_mode;