Subject: bin/19133: lfs coalescing doesn't work properly
To: None <gnats-bugs@gnats.netbsd.org>
From: None <yamt@mwd.biglobe.ne.jp>
List: netbsd-bugs
Date: 11/22/2002 22:25:40
>Number:         19133
>Category:       bin
>Synopsis:       lfs coalescing doesn't work properly
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 22 08:37:00 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) #216: Fri Nov 22 14:43:30 JST 2002 takashi@kaeru:/usr/home/takashi/work/kernel/build.kaeru i386
Architecture: i386
Machine: i386
>Description:
	there're calculation bugs that prevent lfs coalescing work.
>How-To-Repeat:
	
>Fix:
	see following.

Index: coalesce.c
===================================================================
RCS file: /cvs/NetBSD/basesrc/libexec/lfs_cleanerd/coalesce.c,v
retrieving revision 1.3
diff -u -p -r1.3 coalesce.c
--- coalesce.c	2002/06/14 05:21:21	1.3
+++ coalesce.c	2002/11/22 13:21:54
@@ -135,7 +135,7 @@ int clean_inode(struct fs_info *fsp, ino
 		return COALESCE_NOINODE;
 
 	/* Compute file block size, set up for lfs_bmapv */
-	onb = nb = btofsb(lfsp, dip->di_size);
+	onb = nb = lblkno(lfsp, dip->di_size);
 
 	/* XXX for now, don't do any file small enough to have fragments */
 	if (nb < NDADDR)
@@ -174,9 +174,10 @@ int clean_inode(struct fs_info *fsp, ino
 	}
 	noff = toff = 0;
 	for (i = 1; i < nb; i++) {
-		if (bip[i].bi_daddr != bip[i - 1].bi_daddr + 1)
+		if (bip[i].bi_daddr != bip[i - 1].bi_daddr + lfsp->lfs_frag)
 			++noff;
-		toff += abs(bip[i].bi_daddr - bip[i - 1].bi_daddr - 1);
+		toff += abs(bip[i].bi_daddr - bip[i - 1].bi_daddr
+		    - lfsp->lfs_frag) >> lfsp->lfs_fbshift;
 	}
 
 	/*
>Release-Note:
>Audit-Trail:
>Unformatted: