From 5816dad45e0e5e9b10bc8563cb54dc9b8125cb0d Mon Sep 17 00:00:00 2001 From: hannken Date: Sun, 29 Aug 2004 10:13:48 +0000 Subject: [PATCH] While creating a snapshot inodes must be freed from the snapshot, not from the file system. ffs_freefile() needs explicit "fs" and "devvp" arguments. --- sys/ufs/ffs/ffs_alloc.c | 37 ++++++++++++++++++------------------- sys/ufs/ffs/ffs_extern.h | 4 ++-- sys/ufs/ffs/ffs_snapshot.c | 12 ++++-------- sys/ufs/ffs/ffs_softdep.c | 19 ++++--------------- 4 files changed, 28 insertions(+), 44 deletions(-) diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 6e2739b9fa22..9e6e95903926 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.77 2004/05/26 20:33:10 hannken Exp $ */ +/* $NetBSD: ffs_alloc.c,v 1.78 2004/08/29 10:13:48 hannken Exp $ */ /* * Copyright (c) 2002 Networks Associates Technology, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.77 2004/05/26 20:33:10 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.78 2004/08/29 10:13:48 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1752,7 +1752,8 @@ ffs_vfree(v) softdep_freefile(ap); return (0); } - return (ffs_freefile(ap)); + return (ffs_freefile(VTOI(ap->a_pvp)->i_fs, VTOI(ap->a_pvp)->i_devvp, + ap->a_ino, ap->a_mode)); } /* @@ -1760,37 +1761,35 @@ ffs_vfree(v) * The specified inode is placed back in the free map. */ int -ffs_freefile(v) - void *v; +ffs_freefile(fs, devvp, ino, mode) + struct fs *fs; + struct vnode *devvp; + ino_t ino; + int mode; { - struct vop_vfree_args /* { - struct vnode *a_pvp; - ino_t a_ino; - int a_mode; - } */ *ap = v; struct cg *cgp; - struct inode *pip = VTOI(ap->a_pvp); - struct fs *fs = pip->i_fs; - ino_t ino = ap->a_ino; struct buf *bp; int error, cg; daddr_t cgbno; u_int8_t *inosused; + dev_t dev; #ifdef FFS_EI const int needswap = UFS_FSNEEDSWAP(fs); #endif cg = ino_to_cg(fs, ino); - if (pip->i_devvp->v_type != VBLK) { - /* pip->i_devvp is a snapshot */ + if (devvp->v_type != VBLK) { + /* devvp is a snapshot */ + dev = VTOI(devvp)->i_devvp->v_rdev; cgbno = fragstoblks(fs, cgtod(fs, cg)); } else { + dev = devvp->v_rdev; cgbno = fsbtodb(fs, cgtod(fs, cg)); } if ((u_int)ino >= fs->fs_ipg * fs->fs_ncg) panic("ifree: range: dev = 0x%x, ino = %d, fs = %s", - pip->i_dev, ino, fs->fs_fsmnt); - error = bread(pip->i_devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp); + dev, ino, fs->fs_fsmnt); + error = bread(devvp, cgbno, (int)fs->fs_cgsize, NOCRED, &bp); if (error) { brelse(bp); return (error); @@ -1808,7 +1807,7 @@ ffs_freefile(v) ino %= fs->fs_ipg; if (isclr(inosused, ino)) { printf("dev = 0x%x, ino = %d, fs = %s\n", - pip->i_dev, ino, fs->fs_fsmnt); + dev, ino, fs->fs_fsmnt); if (fs->fs_ronly == 0) panic("ifree: freeing free inode"); } @@ -1818,7 +1817,7 @@ ffs_freefile(v) ufs_add32(cgp->cg_cs.cs_nifree, 1, needswap); fs->fs_cstotal.cs_nifree++; fs->fs_cs(fs, cg).cs_nifree++; - if ((ap->a_mode & IFMT) == IFDIR) { + if ((mode & IFMT) == IFDIR) { ufs_add32(cgp->cg_cs.cs_ndir, -1, needswap); fs->fs_cstotal.cs_ndir--; fs->fs_cs(fs, cg).cs_ndir--; diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h index ee03ca77f38d..1c88f35865cf 100644 --- a/sys/ufs/ffs/ffs_extern.h +++ b/sys/ufs/ffs/ffs_extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_extern.h,v 1.40 2004/06/04 07:43:56 he Exp $ */ +/* $NetBSD: ffs_extern.h,v 1.41 2004/08/29 10:13:48 hannken Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -110,7 +110,7 @@ int ffs_truncate __P((void *)); /* ffs_subr.c */ void ffs_load_inode __P((struct buf *, struct inode *, struct fs *, ino_t)); int ffs_blkatoff __P((void *)); -int ffs_freefile __P((void *)); +int ffs_freefile __P((struct fs *, struct vnode *, ino_t, int)); void ffs_fragacct __P((struct fs *, int, int32_t[], int, int)); #ifdef DIAGNOSTIC void ffs_checkoverlap __P((struct buf *, struct inode *)); diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 0b6bba221a32..c2ac4304d28f 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.5 2004/06/30 18:42:17 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.6 2004/08/29 10:13:48 hannken Exp $"); #include #include @@ -147,7 +147,6 @@ ffs_snapshot(mp, vp, ctime) struct buf *bp, *ibp; struct vattr vat; struct vnode *xvp, *nvp, *devvp; - struct vop_vfree_args args; ns = UFS_FSNEEDSWAP(fs); /* @@ -405,12 +404,9 @@ loop: BLK_NOCOPY); if (blkno) db_assign(xp, loc, blkno); - if (!error) { - args.a_pvp = vp; - args.a_ino = xp->i_number; - args.a_mode = xp->i_mode; - error = ffs_freefile(&args); - } + if (!error) + error = ffs_freefile(copy_fs, vp, xp->i_number, + xp->i_mode); VOP_UNLOCK(xvp, 0); if (error) { free(copy_fs->fs_csp, M_UFSMNT); diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index bf5c9c34c867..228f4de7299c 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_softdep.c,v 1.59 2004/05/25 14:54:59 hannken Exp $ */ +/* $NetBSD: ffs_softdep.c,v 1.60 2004/08/29 10:13:48 hannken Exp $ */ /* * Copyright 1998 Marshall Kirk McKusick. All Rights Reserved. @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_softdep.c,v 1.59 2004/05/25 14:54:59 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_softdep.c,v 1.60 2004/08/29 10:13:48 hannken Exp $"); #include #include @@ -3362,12 +3362,9 @@ static void handle_workitem_freefile(freefile) struct freefile *freefile; { - struct vnode vp; - struct inode tip; #ifdef DEBUG struct inodedep *idp; #endif - struct vop_vfree_args args; int error; #ifdef DEBUG @@ -3376,17 +3373,9 @@ handle_workitem_freefile(freefile) panic("handle_workitem_freefile: inodedep survived"); FREE_LOCK(&lk); #endif - tip.i_devvp = freefile->fx_devvp; - tip.i_dev = freefile->fx_devvp->v_rdev; - tip.i_fs = freefile->fx_fs; freefile->fx_fs->fs_pendinginodes -= 1; - vp.v_data = &tip; - vp.v_mount = freefile->fx_devvp->v_specmountpoint; - tip.i_vnode = &vp; - args.a_pvp = &vp; - args.a_ino = freefile->fx_oldinum; - args.a_mode = freefile->fx_mode; - if ((error = ffs_freefile(&args)) != 0) + if ((error = ffs_freefile(freefile->fx_fs, freefile->fx_devvp, + freefile->fx_oldinum, freefile->fx_mode)) != 0) softdep_error("handle_workitem_freefile", error); WORKITEM_FREE(freefile, D_FREEFILE); }