Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/bouyer-quota2]: src/usr.sbin/makefs/ffs ffs_clusteracct() moved to ffs_s...
details: https://anonhg.NetBSD.org/src/rev/66ed33fc6b30
branches: bouyer-quota2
changeset: 761116:66ed33fc6b30
user: bouyer <bouyer%NetBSD.org@localhost>
date: Tue Feb 08 14:48:05 2011 +0000
description:
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.
diffstat:
usr.sbin/makefs/ffs/ffs_alloc.c | 94 +----------------------------------------
1 files changed, 2 insertions(+), 92 deletions(-)
diffs (112 lines):
diff -r 0fb5bc21c1cd -r 66ed33fc6b30 usr.sbin/makefs/ffs/ffs_alloc.c
--- a/usr.sbin/makefs/ffs/ffs_alloc.c Mon Feb 07 20:31:46 2011 +0000
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c Tue Feb 08 14:48:05 2011 +0000
@@ -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;
-}
Home |
Main Index |
Thread Index |
Old Index