summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs/inode.c
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2013-02-24 06:44:29 +0000
committermckusick <mckusick@FreeBSD.org>2013-02-24 06:44:29 +0000
commitf51be3d42991b018fce27dc15fe8b9cfc9d4cfd3 (patch)
treea155aaefa3f14e813888f202776df11239e2e87a /sbin/fsck_ffs/inode.c
parent61f5e2d8e639c7305ace277d84812e884a545366 (diff)
downloadFreeBSD-src-f51be3d42991b018fce27dc15fe8b9cfc9d4cfd3.zip
FreeBSD-src-f51be3d42991b018fce27dc15fe8b9cfc9d4cfd3.tar.gz
When running with the -d option, instrument fsck_ffs to track the number,
data type, and running time of its I/O operations. No functional changes.
Diffstat (limited to 'sbin/fsck_ffs/inode.c')
-rw-r--r--sbin/fsck_ffs/inode.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index 389150a..fd98575 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$");
static ino_t startinum;
-static int iblock(struct inodesc *, long ilevel, off_t isize);
+static int iblock(struct inodesc *, long ilevel, off_t isize, int type);
int
ckinode(union dinode *dp, struct inodesc *idesc)
@@ -121,7 +121,7 @@ ckinode(union dinode *dp, struct inodesc *idesc)
sizepb *= NINDIR(&sblock);
if (DIP(&dino, di_ib[i])) {
idesc->id_blkno = DIP(&dino, di_ib[i]);
- ret = iblock(idesc, i + 1, remsize);
+ ret = iblock(idesc, i + 1, remsize, BT_LEVEL1 + i);
if (ret & STOP)
return (ret);
} else {
@@ -151,7 +151,7 @@ ckinode(union dinode *dp, struct inodesc *idesc)
}
static int
-iblock(struct inodesc *idesc, long ilevel, off_t isize)
+iblock(struct inodesc *idesc, long ilevel, off_t isize, int type)
{
struct bufarea *bp;
int i, n, (*func)(struct inodesc *), nif;
@@ -168,7 +168,7 @@ iblock(struct inodesc *idesc, long ilevel, off_t isize)
func = dirscan;
if (chkrange(idesc->id_blkno, idesc->id_numfrags))
return (SKIP);
- bp = getdatablk(idesc->id_blkno, sblock.fs_bsize);
+ bp = getdatablk(idesc->id_blkno, sblock.fs_bsize, type);
ilevel--;
for (sizepb = sblock.fs_bsize, i = 0; i < ilevel; i++)
sizepb *= NINDIR(&sblock);
@@ -199,7 +199,7 @@ iblock(struct inodesc *idesc, long ilevel, off_t isize)
if (ilevel == 0)
n = (*func)(idesc);
else
- n = iblock(idesc, ilevel, isize);
+ n = iblock(idesc, ilevel, isize, type);
if (n & STOP) {
bp->b_flags &= ~B_INUSE;
return (n);
@@ -292,7 +292,7 @@ ginode(ino_t inumber)
iblk = ino_to_fsba(&sblock, inumber);
if (pbp != 0)
pbp->b_flags &= ~B_INUSE;
- pbp = getdatablk(iblk, sblock.fs_bsize);
+ pbp = getdatablk(iblk, sblock.fs_bsize, BT_INODES);
startinum = (inumber / INOPB(&sblock)) * INOPB(&sblock);
}
if (sblock.fs_magic == FS_UFS1_MAGIC)
@@ -306,8 +306,8 @@ ginode(ino_t inumber)
* over all the inodes in numerical order.
*/
static ino_t nextino, lastinum, lastvalidinum;
-static long readcnt, readpercg, fullcnt, inobufsize, partialcnt, partialsize;
-static caddr_t inodebuf;
+static long readcount, readpercg, fullcnt, inobufsize, partialcnt, partialsize;
+static struct bufarea inobuf;
union dinode *
getnextinode(ino_t inumber, int rebuildcg)
@@ -315,7 +315,7 @@ getnextinode(ino_t inumber, int rebuildcg)
int j;
long size;
mode_t mode;
- ufs2_daddr_t ndb, dblk;
+ ufs2_daddr_t ndb, blk;
union dinode *dp;
static caddr_t nextinop;
@@ -323,9 +323,9 @@ getnextinode(ino_t inumber, int rebuildcg)
errx(EEXIT, "bad inode number %ju to nextinode",
(uintmax_t)inumber);
if (inumber >= lastinum) {
- readcnt++;
- dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum));
- if (readcnt % readpercg == 0) {
+ readcount++;
+ blk = ino_to_fsba(&sblock, lastinum);
+ if (readcount % readpercg == 0) {
size = partialsize;
lastinum += partialcnt;
} else {
@@ -333,14 +333,14 @@ getnextinode(ino_t inumber, int rebuildcg)
lastinum += fullcnt;
}
/*
- * If blread returns an error, it will already have zeroed
+ * If getblk encounters an error, it will already have zeroed
* out the buffer, so we do not need to do so here.
*/
- (void)blread(fsreadfd, inodebuf, dblk, size);
- nextinop = inodebuf;
+ getblk(&inobuf, blk, size);
+ nextinop = inobuf.b_un.b_buf;
}
dp = (union dinode *)nextinop;
- if (rebuildcg && nextinop == inodebuf) {
+ if (rebuildcg && nextinop == inobuf.b_un.b_buf) {
/*
* Try to determine if we have reached the end of the
* allocated inodes.
@@ -406,8 +406,8 @@ setinodebuf(ino_t inum)
startinum = 0;
nextino = inum;
lastinum = inum;
- readcnt = 0;
- if (inodebuf != NULL)
+ readcount = 0;
+ if (inobuf.b_un.b_buf != NULL)
return;
inobufsize = blkroundup(&sblock, INOBUFSIZE);
fullcnt = inobufsize / ((sblock.fs_magic == FS_UFS1_MAGIC) ?
@@ -422,7 +422,8 @@ setinodebuf(ino_t inum)
partialcnt = fullcnt;
partialsize = inobufsize;
}
- if ((inodebuf = malloc((unsigned)inobufsize)) == NULL)
+ initbarea(&inobuf, BT_INODES);
+ if ((inobuf.b_un.b_buf = malloc((unsigned)inobufsize)) == NULL)
errx(EEXIT, "cannot allocate space for inode buffer");
}
@@ -430,9 +431,9 @@ void
freeinodebuf(void)
{
- if (inodebuf != NULL)
- free((char *)inodebuf);
- inodebuf = NULL;
+ if (inobuf.b_un.b_buf != NULL)
+ free((char *)inobuf.b_un.b_buf);
+ inobuf.b_un.b_buf = NULL;
}
/*
OpenPOWER on IntegriCloud