Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 07 Jul 2002 12:27:31 +0100
From:      Ian Dowse <iedowse@maths.tcd.ie>
To:        Don Lewis <dl-freebsd@catspoiler.org>
Cc:        Georg.Koltermann@mscsoftware.com, obrien@FreeBSD.ORG, current@FreeBSD.ORG, mckusick@mckusick.com
Subject:   Re: dump(8) is hosed 
Message-ID:   <200207071227.aa27815@salmon.maths.tcd.ie>
In-Reply-To: Your message of "Sat, 06 Jul 2002 21:57:24 PDT." <200207070458.g674wI0M021931@gw.catspoiler.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <200207070458.g674wI0M021931@gw.catspoiler.org>, Don Lewis writes:
>
>I was finally finally able to reproduce this by creating a large file
>before doing the dump.  Dump(8) is *very* hosed.  The UFS2 import broke
>it's ability to follow multiple levels of indirect blocks.

Thanks for tracking this down! One thing is that the code was using
the static pointers to avoid having to malloc and free blocks every
time. Keeping an array of NIADDR pointers and using `ind_level' as
the index is an alternative (patch below) - I doubt the performance
difference is noticable but it avoids having to remember the free()
before each return.

I'll commit your printf format changes first anyway - thanks!

Ian

Index: traverse.c
===================================================================
RCS file: /dump/FreeBSD-CVS/src/sbin/dump/traverse.c,v
retrieving revision 1.19
diff -u -r1.19 traverse.c
--- traverse.c	21 Jun 2002 06:17:57 -0000	1.19
+++ traverse.c	7 Jul 2002 10:44:55 -0000
@@ -275,10 +275,13 @@
 {
 	int ret = 0;
 	int i;
-	static caddr_t idblk;
+	static caddr_t idblks[NIADDR];
+	caddr_t idblk;
 
-	if (idblk == NULL && (idblk = malloc(sblock->fs_bsize)) == NULL)
+	if (idblks[ind_level] == NULL &&
+	    (idblks[ind_level] = malloc(sblock->fs_bsize)) == NULL)
 		quit("dirindir: cannot allocate indirect memory.\n");
+	idblk = idblks[ind_level];
 	bread(fsbtodb(sblock, blkno), idblk, (int)sblock->fs_bsize);
 	if (ind_level <= 0) {
 		for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
@@ -501,10 +505,13 @@
 dmpindir(ino_t ino, ufs2_daddr_t blk, int ind_level, off_t *size)
 {
 	int i, cnt;
-	static caddr_t idblk;
+	static caddr_t idblks[NIADDR];
+	caddr_t idblk;
 
-	if (idblk == NULL && (idblk = malloc(sblock->fs_bsize)) == NULL)
+	if (idblks[ind_level] == NULL &&
+	    (idblks[ind_level] = malloc(sblock->fs_bsize)) == NULL)
 		quit("dmpindir: cannot allocate indirect memory.\n");
+	idblk = idblks[ind_level];
 	if (blk != 0)
 		bread(fsbtodb(sblock, blk), idblk, (int) sblock->fs_bsize);
 	else



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi? <200207071227.aa27815>