From df70316e3fc1514c4621cf5ac818b6e139defc21 Mon Sep 17 00:00:00 2001 From: hannken Date: Thu, 18 Oct 2007 17:39:04 +0000 Subject: [PATCH] Ffs_blkfree() and ffs_freefile() take a devvp that may be a regular file whencalled from snapshot creation. Be sure to use the right mount. Ok: Andrew Doran --- sys/ufs/ffs/ffs_alloc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 3d10c6b0cafa..e7ced719578c 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_alloc.c,v 1.102 2007/10/10 20:42:33 ad Exp $ */ +/* $NetBSD: ffs_alloc.c,v 1.103 2007/10/18 17:39:04 hannken Exp $ */ /* * Copyright (c) 2002 Networks Associates Technology, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.102 2007/10/10 20:42:33 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.103 2007/10/18 17:39:04 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1585,14 +1585,15 @@ ffs_blkfree(struct fs *fs, struct vnode *devvp, daddr_t bno, long size, dev_t dev; const int needswap = UFS_FSNEEDSWAP(fs); - ump = VFSTOUFS(devvp->v_specmountpoint); cg = dtog(fs, bno); if (devvp->v_type != VBLK) { /* devvp is a snapshot */ dev = VTOI(devvp)->i_devvp->v_rdev; + ump = VFSTOUFS(devvp->v_mount); cgblkno = fragstoblks(fs, cgtod(fs, cg)); } else { dev = devvp->v_rdev; + ump = VFSTOUFS(devvp->v_specmountpoint); cgblkno = fsbtodb(fs, cgtod(fs, cg)); if (ffs_snapblkfree(fs, devvp, bno, size, inum)) return; @@ -1800,13 +1801,14 @@ ffs_freefile(struct fs *fs, struct vnode *devvp, ino_t ino, int mode) #endif cg = ino_to_cg(fs, ino); - ump = VFSTOUFS(devvp->v_specmountpoint); if (devvp->v_type != VBLK) { /* devvp is a snapshot */ dev = VTOI(devvp)->i_devvp->v_rdev; + ump = VFSTOUFS(devvp->v_mount); cgbno = fragstoblks(fs, cgtod(fs, cg)); } else { dev = devvp->v_rdev; + ump = VFSTOUFS(devvp->v_specmountpoint); cgbno = fsbtodb(fs, cgtod(fs, cg)); } if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg)