BSD 4_4 release
[unix-history] / usr / src / sys / ufs / ufs / ufs_bmap.c
index ed48b4d..16b675d 100644 (file)
@@ -1,10 +1,36 @@
 /*
 /*
- * Copyright (c) 1989, 1991 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1989, 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)ufs_bmap.c  7.1 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)ufs_bmap.c  8.1 (Berkeley) 6/11/93
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -100,8 +126,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp)
                 * can handle.
                 */
                *runp = 0;
                 * can handle.
                 */
                *runp = 0;
-               maxrun = MAXBSIZE / mp->mnt_stat.f_iosize -
-                   (MAXBSIZE < 64 * 1024 ? 1 : 2);
+               maxrun = MAXBSIZE / mp->mnt_stat.f_iosize - 1;
        }
 
        xap = ap == NULL ? a : ap;
        }
 
        xap = ap == NULL ? a : ap;
@@ -115,12 +140,10 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp)
                *bnp = blkptrtodb(ump, ip->i_db[bn]);
                if (*bnp == 0)
                        *bnp = -1;
                *bnp = blkptrtodb(ump, ip->i_db[bn]);
                if (*bnp == 0)
                        *bnp = -1;
-               else if (runp) {
+               else if (runp)
                        for (++bn; bn < NDADDR && *runp < maxrun &&
                            is_sequential(ump, ip->i_db[bn - 1], ip->i_db[bn]);
                            ++bn, ++*runp);
                        for (++bn; bn < NDADDR && *runp < maxrun &&
                            is_sequential(ump, ip->i_db[bn - 1], ip->i_db[bn]);
                            ++bn, ++*runp);
-                       printf ("ufs_bmaparray: runlength = %d\n", *runp);
-               }
                return (0);
        }
 
                return (0);
        }
 
@@ -149,7 +172,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp)
                        brelse(bp);
 
                xap->in_exists = 1;
                        brelse(bp);
 
                xap->in_exists = 1;
-               bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize);
+               bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0);
                if (bp->b_flags & (B_DONE | B_DELWRI)) {
                        trace(TR_BREADHIT, pack(vp, size), metalbn);
                }
                if (bp->b_flags & (B_DONE | B_DELWRI)) {
                        trace(TR_BREADHIT, pack(vp, size), metalbn);
                }
@@ -170,14 +193,12 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp)
                }
 
                daddr = bp->b_un.b_daddr[xap->in_off];
                }
 
                daddr = bp->b_un.b_daddr[xap->in_off];
-               if (num == 1 && daddr && runp) {
+               if (num == 1 && daddr && runp)
                        for (bn = xap->in_off + 1;
                            bn < MNINDIR(ump) && *runp < maxrun &&
                            is_sequential(ump, bp->b_un.b_daddr[bn - 1],
                            bp->b_un.b_daddr[bn]);
                            ++bn, ++*runp);
                        for (bn = xap->in_off + 1;
                            bn < MNINDIR(ump) && *runp < maxrun &&
                            is_sequential(ump, bp->b_un.b_daddr[bn - 1],
                            bp->b_un.b_daddr[bn]);
                            ++bn, ++*runp);
-                       printf ("ufs_bmaparray: runlength = %d\n", *runp);
-               }
        }
        if (bp)
                brelse(bp);
        }
        if (bp)
                brelse(bp);