zero-out dinode is not a proper way to 'clear' an lfs inode.

This commit is contained in:
yamt 2004-07-18 20:51:30 +00:00
parent 32c9e25b89
commit 17d264b6df
3 changed files with 40 additions and 23 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsck.h,v 1.12 2004/03/20 22:31:13 perseant Exp $ */
/* $NetBSD: fsck.h,v 1.13 2004/07/18 20:51:30 yamt Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -190,7 +190,6 @@ struct inoinfo {
/* XXX ondisk32 */
int32_t i_blks[1]; /* actually longer */
} **inphead, **inpsort;
#define clearinode(dp) (*(dp) = zino)
#ifndef VERBOSE_BLOCKMAP
#define setbmap(blkno) setbit(blockmap, blkno)
@ -213,5 +212,6 @@ int ino_to_fsba(struct lfs *, ino_t);
struct ufs1_dinode *ginode(ino_t);
struct inoinfo *getinoinfo(ino_t);
daddr_t lfs_ino_daddr(ino_t);
void clearinode(ino_t);
#include "fsck_vars.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: inode.c,v 1.23 2004/03/20 22:31:13 perseant Exp $ */
/* $NetBSD: inode.c,v 1.24 2004/07/18 20:51:30 yamt Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -432,8 +432,6 @@ inodirty(struct inode *ip)
void
clri(struct inodesc * idesc, char *type, int flag)
{
struct ubuf *bp;
IFILE *ifp;
struct uvnode *vp;
vp = vget(fs, idesc->id_number);
@ -447,18 +445,39 @@ clri(struct inodesc * idesc, char *type, int flag)
printf(" (CLEARED)\n");
n_files--;
(void) ckinode(VTOD(vp), idesc);
clearinode(VTOD(vp));
clearinode(idesc->id_number);
statemap[idesc->id_number] = USTATE;
inodirty(VTOI(vp));
vnode_destroy(vp);
}
}
/* Send cleared inode to the free list */
void
clearinode(ino_t inumber)
{
struct ubuf *bp;
IFILE *ifp;
daddr_t daddr;
LFS_IENTRY(ifp, fs, idesc->id_number, bp);
ifp->if_daddr = LFS_UNUSED_DADDR;
ifp->if_nextfree = fs->lfs_freehd;
fs->lfs_freehd = idesc->id_number;
sbdirty();
VOP_BWRITE(bp);
/* Send cleared inode to the free list */
LFS_IENTRY(ifp, fs, inumber, bp);
daddr = ifp->if_daddr;
ifp->if_daddr = LFS_UNUSED_DADDR;
ifp->if_nextfree = fs->lfs_freehd;
fs->lfs_freehd = inumber;
sbdirty();
VOP_BWRITE(bp);
/*
* update segment usage.
*/
if (daddr != LFS_UNUSED_DADDR) {
SEGUSE *sup;
u_int32_t oldsn = dtosn(fs, daddr);
LFS_SEGENTRY(sup, fs, oldsn, bp);
sup->su_nbytes -= DINODE1_SIZE;
LFS_WRITESEGENTRY(sup, fs, oldsn, bp); /* Ifile */
}
}
@ -607,9 +626,9 @@ freeino(ino_t ino)
idesc.id_number = ino;
vp = vget(fs, ino);
(void) ckinode(VTOD(vp), &idesc);
clearinode(VTOI(vp)->i_din.ffs1_din);
inodirty(VTOI(vp));
clearinode(ino);
statemap[ino] = USTATE;
vnode_destroy(vp);
n_files--;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pass1.c,v 1.17 2003/08/07 10:04:23 agc Exp $ */
/* $NetBSD: pass1.c,v 1.18 2004/07/18 20:51:30 yamt Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -197,9 +197,8 @@ checkinode(ino_t inumber, struct inodesc * idesc)
pfatal("PARTIALLY ALLOCATED INODE I=%u", inumber);
if (reply("CLEAR") == 1) {
vp = vget(fs, inumber);
dp = VTOD(vp);
clearinode(dp);
inodirty(VTOI(vp));
clearinode(inumber);
vnode_destroy(vp);
}
}
statemap[inumber] = USTATE;
@ -304,9 +303,8 @@ unknown:
if (reply("CLEAR") == 1) {
statemap[inumber] = USTATE;
vp = vget(fs, inumber);
dp = VTOD(vp);
clearinode(dp);
inodirty(VTOI(vp));
clearinode(inumber);
vnode_destroy(vp);
}
}