Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/ffs Use blkstofrags() and fragstoblks(). Use &(NBBY...



details:   https://anonhg.NetBSD.org/src/rev/a13941635096
branches:  trunk
changeset: 525345:a13941635096
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Wed Apr 10 08:05:11 2002 +0000

description:
Use blkstofrags() and fragstoblks().  Use &(NBBY-1) rather than %NBBY.
Switch off of fs_fragshift rather than fs_frag (generates better jump tables).

diffstat:

 sys/ufs/ffs/ffs_alloc.c  |  10 ++++----
 sys/ufs/ffs/ffs_subr.c   |  59 +++++++++++++++++++++++++----------------------
 sys/ufs/ffs/ffs_vfsops.c |   6 ++--
 3 files changed, 39 insertions(+), 36 deletions(-)

diffs (209 lines):

diff -r 2843787ae93e -r a13941635096 sys/ufs/ffs/ffs_alloc.c
--- a/sys/ufs/ffs/ffs_alloc.c   Wed Apr 10 07:46:10 2002 +0000
+++ b/sys/ufs/ffs/ffs_alloc.c   Wed Apr 10 08:05:11 2002 +0000
@@ -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 @@
        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 @@
        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);
diff -r 2843787ae93e -r a13941635096 sys/ufs/ffs/ffs_subr.c
--- a/sys/ufs/ffs/ffs_subr.c    Wed Apr 10 07:46:10 2002 +0000
+++ b/sys/ufs/ffs/ffs_subr.c    Wed Apr 10 08:05:11 2002 +0000
@@ -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 @@
        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 @@
 {
        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 @@
        ufs_daddr_t h;
 {
 
-       switch ((int)fs->fs_frag) {
-       case 8:
+       switch ((int)fs->fs_fragshift) {
+       case 3:
                return (cp[h] == 0);
-       case 4:
+       case 2:
                return ((cp[h >> 1] & (0x0f << ((h & 0x1) << 2))) == 0);
-       case 2:
+       case 1:
                return ((cp[h >> 2] & (0x03 << ((h & 0x3) << 1))) == 0);
-       case 1:
+       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 @@
        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 @@
        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);
        }
 }
diff -r 2843787ae93e -r a13941635096 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c  Wed Apr 10 07:46:10 2002 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c  Wed Apr 10 08:05:11 2002 +0000
@@ -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 @@
        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) -



Home | Main Index | Thread Index | Old Index