Subject: kern/18977: LFS panic "getblk: block size invariant failed"
To: None <gnats-bugs@gnats.netbsd.org>
From: None <yamt@mwd.biglobe.ne.jp>
List: netbsd-bugs
Date: 11/09/2002 01:41:38
>Number:         18977
>Category:       kern
>Synopsis:       LFS panic "getblk: block size invariant failed"
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 08 08:55:09 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
>Release:        NetBSD 1.6K
>Organization:

>Environment:
	
	
System: NetBSD kaeru 1.6K NetBSD 1.6K (build.kaeru) #170: Sat Nov 9 00:41:22 JST 2002 takashi@kaeru:/usr/home/takashi/work/kernel/build.kaeru i386
Architecture: i386
Machine: i386
>Description:
	lfs abuses blksize() macro for indirect blocks and
	getblk with wrong sizes.
>How-To-Repeat:
	
>Fix:

Index: lfs_syscalls.c
===================================================================
RCS file: /cvs/NetBSD/syssrc/sys/ufs/lfs/lfs_syscalls.c,v
retrieving revision 1.71
diff -u -p -r1.71 lfs_syscalls.c
--- lfs_syscalls.c	2002/08/03 00:12:49	1.71
+++ lfs_syscalls.c	2002/11/08 16:37:24
@@ -455,7 +455,10 @@ lfs_markv(struct proc *p, fsid_t *fsidp,
 		 * disk, so they should have the same size as their on-disk
 		 * counterparts.
 		 */
-		obsize = blksize(fs, ip, blkp->bi_lbn);
+		if (blkp->bi_lbn >= 0)
+			obsize = blksize(fs, ip, blkp->bi_lbn);
+		else
+			obsize = fs->lfs_bsize;
 		/* Check for fragment size change */
 		if (blkp->bi_lbn >= 0 && blkp->bi_lbn < NDADDR) {
 			obsize = ip->i_lfs_fragsize[blkp->bi_lbn];
@@ -484,6 +487,9 @@ lfs_markv(struct proc *p, fsid_t *fsidp,
 			bp->b_blkno = fsbtodb(fs, blkp->bi_daddr);
 		} else {
 			/* Indirect block */
+			if (blkp->bi_size != fs->lfs_bsize)
+				panic("lfs_markv: partial indirect block?"
+				    " size=%d\n", blkp->bi_size);
 			bp = getblk(vp, blkp->bi_lbn, blkp->bi_size, 0, 0);
 			if (!(bp->b_flags & (B_DONE|B_DELWRI))) { /* B_CACHE */
 				/*
@@ -836,7 +842,10 @@ lfs_bmapv(struct proc *p, fsid_t *fsidp,
 			}
 			blkp->bi_daddr = dbtofsb(fs, blkp->bi_daddr);
 			/* Fill in the block size, too */
-			blkp->bi_size = blksize(fs, ip, blkp->bi_lbn);
+			if (blkp->bi_lbn >= 0)
+				blkp->bi_size = blksize(fs, ip, blkp->bi_lbn);
+			else
+				blkp->bi_size = fs->lfs_bsize;
 		}
 	}
 	
>Release-Note:
>Audit-Trail:
>Unformatted: