diff options
| author | bouyer <bouyer@NetBSD.org> | 2011-03-06 17:08:10 +0000 |
|---|---|---|
| committer | bouyer <bouyer@NetBSD.org> | 2011-03-06 17:08:10 +0000 |
| commit | 0367ea04357cc3132acde34301e004c31404e00a (patch) | |
| tree | fbee7a75c9221f005c8e599dca212da52915cbe2 /usr.sbin/makefs | |
| parent | e6c5a781a6101ca215918815f4f048df623ddf85 (diff) | |
merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.
See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
Diffstat (limited to 'usr.sbin/makefs')
| -rw-r--r-- | usr.sbin/makefs/ffs/ffs_alloc.c | 94 |
1 files changed, 2 insertions, 92 deletions
diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c index 3f313f9a8e1..54e7afc1036 100644 --- a/usr.sbin/makefs/ffs/ffs_alloc.c +++ b/usr.sbin/makefs/ffs/ffs_alloc.c @@ -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.18 2011/03/06 17:08:42 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.18 2011/03/06 17:08:42 bouyer Exp $"); #endif /* !__lint */ #include <sys/param.h> @@ -600,93 +600,3 @@ ffs_mapsearch(struct fs *fs, struct cg *cgp, daddr_t bpref, int allocsiz) 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; -} |
