Use blkstofrags() and fragstoblks(). Use &(NBBY-1) rather than %NBBY.
Switch off of fs_fragshift rather than fs_frag (generates better jump tables).
This commit is contained in:
parent
0a9b835878
commit
afc5d40400
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs_alloc.c,v 1.53 2001/10/30 01:11:53 lukem Exp $ */
|
||||
/* $NetBSD: ffs_alloc.c,v 1.54 2002/04/10 08:05:11 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.53 2001/10/30 01:11:53 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.54 2002/04/10 08:05:11 mycroft Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ffs.h"
|
||||
|
@ -755,7 +755,7 @@ ffs_dirpref(pip)
|
|||
minifree = avgifree - fs->fs_ipg / 4;
|
||||
if (minifree < 0)
|
||||
minifree = 0;
|
||||
minbfree = avgbfree - fs->fs_fpg / fs->fs_frag / 4;
|
||||
minbfree = avgbfree - fragstoblks(fs, fs->fs_fpg) / 4;
|
||||
if (minbfree < 0)
|
||||
minbfree = 0;
|
||||
cgsize = fs->fs_fsize * fs->fs_fpg;
|
||||
|
@ -1726,14 +1726,14 @@ ffs_mapsearch(fs, cgp, bpref, allocsiz)
|
|||
loc = scanc((u_int)len,
|
||||
(const u_char *)&cg_blksfree(cgp, needswap)[start],
|
||||
(const u_char *)fragtbl[fs->fs_frag],
|
||||
(1 << (allocsiz - 1 + (fs->fs_frag % NBBY))));
|
||||
(1 << (allocsiz - 1 + (fs->fs_frag & (NBBY - 1)))));
|
||||
if (loc == 0) {
|
||||
len = start + 1;
|
||||
start = 0;
|
||||
loc = scanc((u_int)len,
|
||||
(const u_char *)&cg_blksfree(cgp, needswap)[0],
|
||||
(const u_char *)fragtbl[fs->fs_frag],
|
||||
(1 << (allocsiz - 1 + (fs->fs_frag % NBBY))));
|
||||
(1 << (allocsiz - 1 + (fs->fs_frag & (NBBY - 1)))));
|
||||
if (loc == 0) {
|
||||
printf("start = %d, len = %d, fs = %s\n",
|
||||
ostart, olen, fs->fs_fsmnt);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs_subr.c,v 1.21 2002/01/31 19:19:22 tv Exp $ */
|
||||
/* $NetBSD: ffs_subr.c,v 1.22 2002/04/10 08:05:13 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__KERNEL_RCSID)
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.21 2002/01/31 19:19:22 tv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.22 2002/04/10 08:05:13 mycroft Exp $");
|
||||
#endif
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
|
@ -127,7 +127,7 @@ ffs_fragacct(fs, fragmap, fraglist, cnt, needswap)
|
|||
inblk = (int)(fragtbl[fs->fs_frag][fragmap]) << 1;
|
||||
fragmap <<= 1;
|
||||
for (siz = 1; siz < fs->fs_frag; siz++) {
|
||||
if ((inblk & (1 << (siz + (fs->fs_frag % NBBY)))) == 0)
|
||||
if ((inblk & (1 << (siz + (fs->fs_frag & (NBBY - 1))))) == 0)
|
||||
continue;
|
||||
field = around[siz];
|
||||
subfield = inside[siz];
|
||||
|
@ -193,20 +193,21 @@ ffs_isblock(fs, cp, h)
|
|||
{
|
||||
u_char mask;
|
||||
|
||||
switch ((int)fs->fs_frag) {
|
||||
case 8:
|
||||
switch ((int)fs->fs_fragshift) {
|
||||
case 3:
|
||||
return (cp[h] == 0xff);
|
||||
case 4:
|
||||
case 2:
|
||||
mask = 0x0f << ((h & 0x1) << 2);
|
||||
return ((cp[h >> 1] & mask) == mask);
|
||||
case 2:
|
||||
case 1:
|
||||
mask = 0x03 << ((h & 0x3) << 1);
|
||||
return ((cp[h >> 2] & mask) == mask);
|
||||
case 1:
|
||||
case 0:
|
||||
mask = 0x01 << (h & 0x7);
|
||||
return ((cp[h >> 3] & mask) == mask);
|
||||
default:
|
||||
panic("ffs_isblock: unknown fs_frag %d", (int)fs->fs_frag);
|
||||
panic("ffs_isblock: unknown fs_fragshift %d",
|
||||
(int)fs->fs_fragshift);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,17 +221,18 @@ ffs_isfreeblock(fs, cp, h)
|
|||
ufs_daddr_t h;
|
||||
{
|
||||
|
||||
switch ((int)fs->fs_frag) {
|
||||
case 8:
|
||||
switch ((int)fs->fs_fragshift) {
|
||||
case 3:
|
||||
return (cp[h] == 0);
|
||||
case 4:
|
||||
return ((cp[h >> 1] & (0x0f << ((h & 0x1) << 2))) == 0);
|
||||
case 2:
|
||||
return ((cp[h >> 2] & (0x03 << ((h & 0x3) << 1))) == 0);
|
||||
return ((cp[h >> 1] & (0x0f << ((h & 0x1) << 2))) == 0);
|
||||
case 1:
|
||||
return ((cp[h >> 2] & (0x03 << ((h & 0x3) << 1))) == 0);
|
||||
case 0:
|
||||
return ((cp[h >> 3] & (0x01 << (h & 0x7))) == 0);
|
||||
default:
|
||||
panic("ffs_isfreeblock: unknown fs_frag %d", (int)fs->fs_frag);
|
||||
panic("ffs_isfreeblock: unknown fs_fragshift %d",
|
||||
(int)fs->fs_fragshift);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,21 +246,22 @@ ffs_clrblock(fs, cp, h)
|
|||
ufs_daddr_t h;
|
||||
{
|
||||
|
||||
switch ((int)fs->fs_frag) {
|
||||
case 8:
|
||||
switch ((int)fs->fs_fragshift) {
|
||||
case 3:
|
||||
cp[h] = 0;
|
||||
return;
|
||||
case 4:
|
||||
case 2:
|
||||
cp[h >> 1] &= ~(0x0f << ((h & 0x1) << 2));
|
||||
return;
|
||||
case 2:
|
||||
case 1:
|
||||
cp[h >> 2] &= ~(0x03 << ((h & 0x3) << 1));
|
||||
return;
|
||||
case 1:
|
||||
case 0:
|
||||
cp[h >> 3] &= ~(0x01 << (h & 0x7));
|
||||
return;
|
||||
default:
|
||||
panic("ffs_clrblock: unknown fs_frag %d", (int)fs->fs_frag);
|
||||
panic("ffs_clrblock: unknown fs_fragshift %d",
|
||||
(int)fs->fs_fragshift);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,21 +275,21 @@ ffs_setblock(fs, cp, h)
|
|||
ufs_daddr_t h;
|
||||
{
|
||||
|
||||
switch ((int)fs->fs_frag) {
|
||||
|
||||
case 8:
|
||||
switch ((int)fs->fs_fragshift) {
|
||||
case 3:
|
||||
cp[h] = 0xff;
|
||||
return;
|
||||
case 4:
|
||||
case 2:
|
||||
cp[h >> 1] |= (0x0f << ((h & 0x1) << 2));
|
||||
return;
|
||||
case 2:
|
||||
case 1:
|
||||
cp[h >> 2] |= (0x03 << ((h & 0x3) << 1));
|
||||
return;
|
||||
case 1:
|
||||
case 0:
|
||||
cp[h >> 3] |= (0x01 << (h & 0x7));
|
||||
return;
|
||||
default:
|
||||
panic("ffs_setblock: unknown fs_frag %d", (int)fs->fs_frag);
|
||||
panic("ffs_setblock: unknown fs_fragshift %d",
|
||||
(int)fs->fs_fragshift);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs_vfsops.c,v 1.97 2002/04/01 07:51:58 enami Exp $ */
|
||||
/* $NetBSD: ffs_vfsops.c,v 1.98 2002/04/10 08:05:13 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993, 1994
|
||||
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.97 2002/04/01 07:51:58 enami Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.98 2002/04/10 08:05:13 mycroft Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ffs.h"
|
||||
|
@ -987,7 +987,7 @@ ffs_statfs(mp, sbp, p)
|
|||
sbp->f_bsize = fs->fs_fsize;
|
||||
sbp->f_iosize = fs->fs_bsize;
|
||||
sbp->f_blocks = fs->fs_dsize;
|
||||
sbp->f_bfree = fs->fs_cstotal.cs_nbfree * fs->fs_frag +
|
||||
sbp->f_bfree = blkstofrags(fs, fs->fs_cstotal.cs_nbfree) +
|
||||
fs->fs_cstotal.cs_nffree + dbtofsb(fs, fs->fs_pendingblocks);
|
||||
sbp->f_bavail = (long) (((u_int64_t) fs->fs_dsize * (u_int64_t)
|
||||
(100 - fs->fs_minfree) / (u_int64_t) 100) -
|
||||
|
|
Loading…
Reference in New Issue