Bug 13314

Summary: can't compile when softupdates + debug.
Product: Base System Reporter: spam <spam>
Component: kernAssignee: Sheldon Hearn <sheldonh>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description spam 1999-08-22 04:20:01 UTC
system acting funny.. so tried to define DEBUG to see why its rebooting by itself....

If your config file has 

options SOFTUPDATES 
options "DEBUG=1"

you'll get an error in reallockblk of ffs_alloc.c that ffs_checkblk is nto defined.

it seems that the prototype for the function is #ifdef DIAGNOSTIC, yet in the reallocblk, there is a #ifdef DEBUG..#endif block that uses the ffs_checkblk() function.

in other words, it is defined under the DIAGNOSTIC condition but used in both DIAGNOSTIC and DEBUG.

Fix: 

include options "DIAGNOSTIC=1" to config file so that the function, ffs_checkblk is defined so that the #ifdef DEBUG..endif block that contains the call to the function as the prototype is surrounded by an $ifdef DIAGNOSTIC .. endif block
How-To-Repeat: add those two lines above in your options for config'ing a kernel, but exclude  options "DIAGNOSTIC=1"
Comment 1 Sheldon Hearn 1999-08-23 16:07:37 UTC
It looks like the problem was introduced in rev 1.28 of ffs_alloc.c .
I think the patch below is the correct fix to this problem. Please try
it with

	options		DIAGNOSTIC

instead of

	options		DEBUG

in your kernel config file.

Your feedback would be greatly appreciated.

Thanks,
Sheldon.

Index: ffs_alloc.c
===================================================================
RCS file: /home/ncvs/src/sys/ufs/ffs/ffs_alloc.c,v
retrieving revision 1.58
diff -u -d -r1.58 ffs_alloc.c
--- ffs_alloc.c	1999/05/12 22:32:07	1.58
+++ ffs_alloc.c	1999/08/23 14:58:03
@@ -343,7 +343,7 @@
 static int doreallocblks = 1;
 SYSCTL_INT(_vfs_ffs, FFS_REALLOCBLKS, doreallocblks, CTLFLAG_RW, &doreallocblks, 0, "");
 
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 static volatile int prtrealloc = 0;
 #endif
 
@@ -447,7 +447,7 @@
 	 * block pointers in the inode and indirect blocks associated
 	 * with the file.
 	 */
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if (prtrealloc)
 		printf("realloc: ino %d, lbns %d-%d\n\told:", ip->i_number,
 		    start_lbn, end_lbn);
@@ -465,7 +465,7 @@
 		if (dbtofsb(fs, buflist->bs_children[i]->b_blkno) != *bap)
 			panic("ffs_reallocblks: alloc mismatch");
 #endif
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 		if (prtrealloc)
 			printf(" %d,", *bap);
 #endif
@@ -514,7 +514,7 @@
 	/*
 	 * Last, free the old blocks and assign the new blocks to the buffers.
 	 */
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if (prtrealloc)
 		printf("\n\tnew:");
 #endif
@@ -524,7 +524,7 @@
 			    dbtofsb(fs, buflist->bs_children[i]->b_blkno),
 			    fs->fs_bsize);
 		buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 		if (!ffs_checkblk(ip,
 		   dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
 			panic("ffs_reallocblks: unallocated block 3");
@@ -532,7 +532,7 @@
 			printf(" %d,", blkno);
 #endif
 	}
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 	if (prtrealloc) {
 		prtrealloc--;
 		printf("\n");
Comment 2 Sheldon Hearn freebsd_committer freebsd_triage 1999-08-23 16:07:59 UTC
Responsible Changed
From-To: freebsd-bugs->sheldonh

I'll take this one. If it gets hairy, I'll back off. :-) 

Comment 3 Sheldon Hearn 1999-08-23 16:14:56 UTC
On Mon, 23 Aug 1999 17:07:37 +0200, Sheldon Hearn wrote:

> 	options		DIAGNOSTIC
> 
> instead of
> 
> 	options		DEBUG

Sorry, got muddled. You can have both in your kernel config if you want.

Ciao,
Sheldon.
Comment 4 sporty 1999-08-23 16:15:49 UTC
or some odd combination of the two.  thanx for the prompt reply.

On Mon, 23 Aug 1999, Sheldon Hearn wrote:

> 
> It looks like the problem was introduced in rev 1.28 of ffs_alloc.c .
> I think the patch below is the correct fix to this problem. Please try
> it with
> 
> 	options		DIAGNOSTIC
> 
> instead of
> 
> 	options		DEBUG
> 
> in your kernel config file.
> 
> Your feedback would be greatly appreciated.
> 
> Thanks,
> Sheldon.
> 
> Index: ffs_alloc.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/ufs/ffs/ffs_alloc.c,v
> retrieving revision 1.58
> diff -u -d -r1.58 ffs_alloc.c
> --- ffs_alloc.c	1999/05/12 22:32:07	1.58
> +++ ffs_alloc.c	1999/08/23 14:58:03
> @@ -343,7 +343,7 @@
>  static int doreallocblks = 1;
>  SYSCTL_INT(_vfs_ffs, FFS_REALLOCBLKS, doreallocblks, CTLFLAG_RW, &doreallocblks, 0, "");
>  
> -#ifdef DEBUG
> +#ifdef DIAGNOSTIC
>  static volatile int prtrealloc = 0;
>  #endif
>  
> @@ -447,7 +447,7 @@
>  	 * block pointers in the inode and indirect blocks associated
>  	 * with the file.
>  	 */
> -#ifdef DEBUG
> +#ifdef DIAGNOSTIC
>  	if (prtrealloc)
>  		printf("realloc: ino %d, lbns %d-%d\n\told:", ip->i_number,
>  		    start_lbn, end_lbn);
> @@ -465,7 +465,7 @@
>  		if (dbtofsb(fs, buflist->bs_children[i]->b_blkno) != *bap)
>  			panic("ffs_reallocblks: alloc mismatch");
>  #endif
> -#ifdef DEBUG
> +#ifdef DIAGNOSTIC
>  		if (prtrealloc)
>  			printf(" %d,", *bap);
>  #endif
> @@ -514,7 +514,7 @@
>  	/*
>  	 * Last, free the old blocks and assign the new blocks to the buffers.
>  	 */
> -#ifdef DEBUG
> +#ifdef DIAGNOSTIC
>  	if (prtrealloc)
>  		printf("\n\tnew:");
>  #endif
> @@ -524,7 +524,7 @@
>  			    dbtofsb(fs, buflist->bs_children[i]->b_blkno),
>  			    fs->fs_bsize);
>  		buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno);
> -#ifdef DEBUG
> +#ifdef DIAGNOSTIC
>  		if (!ffs_checkblk(ip,
>  		   dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
>  			panic("ffs_reallocblks: unallocated block 3");
> @@ -532,7 +532,7 @@
>  			printf(" %d,", blkno);
>  #endif
>  	}
> -#ifdef DEBUG
> +#ifdef DIAGNOSTIC
>  	if (prtrealloc) {
>  		prtrealloc--;
>  		printf("\n");
>
Comment 5 Sheldon Hearn 1999-08-23 16:53:31 UTC
On Tue, 24 Aug 1999 01:46:06 +1000, Bruce Evans wrote:

> No, prtrealloc is for debugging, not for diagnostics.

I assumed too much. It's recurring theme that becomes less funny each
time it comes around.

> The ifdefs fo ffs_chkblk() are wrong.

*nod* Once you pointed out the need for prtrealloc to be conditional on
DEBUG, the rest kinda became obvious.

Ciao,
Sheldon.

Index: ffs_alloc.c
===================================================================
RCS file: /home/ncvs/src/sys/ufs/ffs/ffs_alloc.c,v
retrieving revision 1.58
diff -u -d -r1.58 ffs_alloc.c
--- ffs_alloc.c	1999/05/12 22:32:07	1.58
+++ ffs_alloc.c	1999/08/23 15:50:54
@@ -524,10 +524,12 @@
 			    dbtofsb(fs, buflist->bs_children[i]->b_blkno),
 			    fs->fs_bsize);
 		buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno);
-#ifdef DEBUG
+#ifdef DIAGNOSTIC
 		if (!ffs_checkblk(ip,
 		   dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
 			panic("ffs_reallocblks: unallocated block 3");
+#endif
+#ifdef DEBUG
 		if (prtrealloc)
 			printf(" %d,", blkno);
 #endif
Comment 6 Sheldon Hearn freebsd_committer freebsd_triage 1999-08-24 09:43:57 UTC
State Changed
From-To: open->analyzed

Fixed in CURRENT in rev 1.60 .  MFC to follow. 
Comment 7 Sheldon Hearn freebsd_committer freebsd_triage 1999-10-01 13:19:55 UTC
State Changed
From-To: analyzed->suspended

I'm told that suspended is the correct state for issues awaiting an 
MFC. 
Comment 8 Sheldon Hearn freebsd_committer freebsd_triage 1999-12-15 14:29:54 UTC
State Changed
From-To: suspended->closed

Merged from CURRENT in rev 1.56.2.2.