Module Name:    src
Committed By:   bouyer
Date:           Tue Feb  8 14:48:05 UTC 2011

Modified Files:
        src/usr.sbin/makefs/ffs [bouyer-quota2]: ffs_alloc.c

Log Message:
ffs_clusteracct() moved to ffs_subr.c, so remove it from this copy of
ffs_alloc.c (otherwise we have duplicate symbols at link time).
Always use UFS_FSNEEDSWAP(fs) even if !KERNEL; so we can use for makefs too.
other !KERNEL consumers will have UFS_FSNEEDSWAP(fs) == 0 anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.17.30.1 src/usr.sbin/makefs/ffs/ffs_alloc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/ffs_alloc.c
diff -u src/usr.sbin/makefs/ffs/ffs_alloc.c:1.17 src/usr.sbin/makefs/ffs/ffs_alloc.c:1.17.30.1
--- src/usr.sbin/makefs/ffs/ffs_alloc.c:1.17	Mon Dec 18 21:03:29 2006
+++ src/usr.sbin/makefs/ffs/ffs_alloc.c	Tue Feb  8 14:48:05 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.17 2006/12/18 21:03:29 christos Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.17.30.1 2011/02/08 14:48:05 bouyer Exp $	*/
 /* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */
 
 /*
@@ -47,7 +47,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs_alloc.c,v 1.17 2006/12/18 21:03:29 christos Exp $");
+__RCSID("$NetBSD: ffs_alloc.c,v 1.17.30.1 2011/02/08 14:48:05 bouyer Exp $");
 #endif	/* !__lint */
 
 #include <sys/param.h>
@@ -600,93 +600,3 @@
 	errx(1, "ffs_alloccg: block not in map: bno %lld", (long long)bno);
 	return (-1);
 }
-
-/*
- * Update the cluster map because of an allocation or free.
- *
- * Cnt == 1 means free; cnt == -1 means allocating.
- */
-void
-ffs_clusteracct(struct fs *fs, struct cg *cgp, int32_t blkno, int cnt)
-{
-	int32_t *sump;
-	int32_t *lp;
-	u_char *freemapp, *mapp;
-	int i, start, end, forw, back, map, bit;
-	const int needswap = UFS_FSNEEDSWAP(fs);
-
-	if (fs->fs_contigsumsize <= 0)
-		return;
-	freemapp = cg_clustersfree(cgp, needswap);
-	sump = cg_clustersum(cgp, needswap);
-	/*
-	 * Allocate or clear the actual block.
-	 */
-	if (cnt > 0)
-		setbit(freemapp, blkno);
-	else
-		clrbit(freemapp, blkno);
-	/*
-	 * Find the size of the cluster going forward.
-	 */
-	start = blkno + 1;
-	end = start + fs->fs_contigsumsize;
-	if (end >= ufs_rw32(cgp->cg_nclusterblks, needswap))
-		end = ufs_rw32(cgp->cg_nclusterblks, needswap);
-	mapp = &freemapp[start / NBBY];
-	map = *mapp++;
-	bit = 1 << (start % NBBY);
-	for (i = start; i < end; i++) {
-		if ((map & bit) == 0)
-			break;
-		if ((i & (NBBY - 1)) != (NBBY - 1)) {
-			bit <<= 1;
-		} else {
-			map = *mapp++;
-			bit = 1;
-		}
-	}
-	forw = i - start;
-	/*
-	 * Find the size of the cluster going backward.
-	 */
-	start = blkno - 1;
-	end = start - fs->fs_contigsumsize;
-	if (end < 0)
-		end = -1;
-	mapp = &freemapp[start / NBBY];
-	map = *mapp--;
-	bit = 1 << (start % NBBY);
-	for (i = start; i > end; i--) {
-		if ((map & bit) == 0)
-			break;
-		if ((i & (NBBY - 1)) != 0) {
-			bit >>= 1;
-		} else {
-			map = *mapp--;
-			bit = 1 << (NBBY - 1);
-		}
-	}
-	back = start - i;
-	/*
-	 * Account for old cluster and the possibly new forward and
-	 * back clusters.
-	 */
-	i = back + forw + 1;
-	if (i > fs->fs_contigsumsize)
-		i = fs->fs_contigsumsize;
-	ufs_add32(sump[i], cnt, needswap);
-	if (back > 0)
-		ufs_add32(sump[back], -cnt, needswap);
-	if (forw > 0)
-		ufs_add32(sump[forw], -cnt, needswap);
-
-	/*
-	 * Update cluster summary information.
-	 */
-	lp = &sump[fs->fs_contigsumsize];
-	for (i = fs->fs_contigsumsize; i > 0; i--)
-		if (ufs_rw32(*lp--, needswap) > 0)
-			break;
-	fs->fs_maxcluster[ufs_rw32(cgp->cg_cgx, needswap)] = i;
-}

Reply via email to