Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/ufs only call ufs_getlbns() for blocks which involve...



details:   https://anonhg.NetBSD.org/src/rev/92422018d00d
branches:  trunk
changeset: 517168:92422018d00d
user:      chs <chs%NetBSD.org@localhost>
date:      Thu Nov 08 05:00:51 2001 +0000

description:
only call ufs_getlbns() for blocks which involve indirects, and assert
that this is so.  use a shift instead of a multiply in one place.

diffstat:

 sys/ufs/ufs/ufs_bmap.c |  27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diffs (69 lines):

diff -r fac1e52469d0 -r 92422018d00d sys/ufs/ufs/ufs_bmap.c
--- a/sys/ufs/ufs/ufs_bmap.c    Thu Nov 08 04:51:05 2001 +0000
+++ b/sys/ufs/ufs/ufs_bmap.c    Thu Nov 08 05:00:51 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_bmap.c,v 1.13 2001/11/08 02:39:15 lukem Exp $      */
+/*     $NetBSD: ufs_bmap.c,v 1.14 2001/11/08 05:00:51 chs Exp $        */
 
 /*
  * Copyright (c) 1989, 1991, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.13 2001/11/08 02:39:15 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.14 2001/11/08 05:00:51 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -139,14 +139,7 @@
                maxrun = MAXBSIZE / mp->mnt_stat.f_iosize - 1;
        }
 
-       xap = ap == NULL ? a : ap;
-       if (!nump)
-               nump = &num;
-       if ((error = ufs_getlbns(vp, bn, xap, nump)) != 0)
-               return (error);
-
-       num = *nump;
-       if (num == 0) {
+       if (bn < NDADDR) {
                *bnp = blkptrtodb(ump, ufs_rw32(ip->i_ffs_db[bn],
                    UFS_MPNEEDSWAP(vp->v_mount)));
                if (*bnp == 0)
@@ -162,6 +155,13 @@
                return (0);
        }
 
+       xap = ap == NULL ? a : ap;
+       if (!nump)
+               nump = &num;
+       if ((error = ufs_getlbns(vp, bn, xap, nump)) != 0)
+               return (error);
+
+       num = *nump;
 
        /* Get disk address out of indirect block array */
        daddr = ufs_rw32(ip->i_ffs_ib[xap->in_off],
@@ -256,10 +256,7 @@
        realbn = bn;
        if ((long)bn < 0)
                bn = -(long)bn;
-
-       /* The first NDADDR blocks are direct blocks. */
-       if (bn < NDADDR)
-               return (0);
+       KASSERT(bn >= NDADDR);
 
        /* 
         * Determine the number of levels of indirection.  After this loop
@@ -311,7 +308,7 @@
                ap->in_exists = 0;
                ++ap;
 
-               metalbn -= -1 + off * blockcnt;
+               metalbn -= -1 + (off << lbc);
        }
        if (nump)
                *nump = numlevels;



Home | Main Index | Thread Index | Old Index