BSD 4_4_Lite2 release
[unix-history] / usr / src / sys / ufs / ffs / ffs_alloc.c
index 8479ea0..35509e6 100644 (file)
@@ -2,9 +2,35 @@
  * Copyright (c) 1982, 1986, 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
  * Copyright (c) 1982, 1986, 1989, 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.
  *
  *
- *     @(#)ffs_alloc.c 8.18 (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.
+ *
+ *     @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -234,17 +260,8 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp)
        bno = (ufs_daddr_t)ffs_hashalloc(ip, cg, (long)bpref, request,
            (u_int32_t (*)())ffs_alloccg);
        if (bno > 0) {
        bno = (ufs_daddr_t)ffs_hashalloc(ip, cg, (long)bpref, request,
            (u_int32_t (*)())ffs_alloccg);
        if (bno > 0) {
-#ifdef SECSIZE
-               obp = bread(ip->i_dev, fsbtodb(fs, bprev), osize,
-                   fs->fs_dbsize);
-#else SECSIZE
-               count = howmany(osize, CLBYTES);
-               for (i = 0; i < count; i++)
-#ifdef SECSIZE
-                       munhash(ip->i_dev, bn + i * CLBYTES / fs->fs_dbsize);
-#else SECSIZE
-                       munhash(ip->i_dev, bn + i * CLBYTES / DEV_BSIZE);
-#endif SECSIZE
+               bp->b_blkno = fsbtodb(fs, bno);
+               (void) vnode_pager_uncache(ITOV(ip));
                ffs_blkfree(ip, bprev, (long)osize);
                if (nsize < request)
                        ffs_blkfree(ip, bno + numfrags(fs, nsize),
                ffs_blkfree(ip, bprev, (long)osize);
                if (nsize < request)
                        ffs_blkfree(ip, bno + numfrags(fs, nsize),
@@ -753,17 +770,12 @@ ffs_fragextend(ip, cg, bprev, osize, nsize)
                /* cannot extend across a block boundary */
                return (NULL);
        }
                /* cannot extend across a block boundary */
                return (NULL);
        }
-#ifdef SECSIZE
-       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
-           fs->fs_dbsize);
-#else SECSIZE
        error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
                (int)fs->fs_cgsize, NOCRED, &bp);
        if (error) {
                brelse(bp);
                return (NULL);
        }
        error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
                (int)fs->fs_cgsize, NOCRED, &bp);
        if (error) {
                brelse(bp);
                return (NULL);
        }
-#endif SECSIZE
        cgp = (struct cg *)bp->b_data;
        if (!cg_chkmagic(cgp)) {
                brelse(bp);
        cgp = (struct cg *)bp->b_data;
        if (!cg_chkmagic(cgp)) {
                brelse(bp);
@@ -821,17 +833,12 @@ ffs_alloccg(ip, cg, bpref, size)
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
                return (NULL);
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
                return (NULL);
-#ifdef SECSIZE
-       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
-           fs->fs_dbsize);
-#else SECSIZE
        error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
                (int)fs->fs_cgsize, NOCRED, &bp);
        if (error) {
                brelse(bp);
                return (NULL);
        }
        error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
                (int)fs->fs_cgsize, NOCRED, &bp);
        if (error) {
                brelse(bp);
                return (NULL);
        }
-#endif SECSIZE
        cgp = (struct cg *)bp->b_data;
        if (!cg_chkmagic(cgp) ||
            (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
        cgp = (struct cg *)bp->b_data;
        if (!cg_chkmagic(cgp) ||
            (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
@@ -1141,17 +1148,12 @@ ffs_nodealloccg(ip, cg, ipref, mode)
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nifree == 0)
                return (NULL);
        fs = ip->i_fs;
        if (fs->fs_cs(fs, cg).cs_nifree == 0)
                return (NULL);
-#ifdef SECSIZE
-       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
-           fs->fs_dbsize);
-#else SECSIZE
        error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
                (int)fs->fs_cgsize, NOCRED, &bp);
        if (error) {
                brelse(bp);
                return (NULL);
        }
        error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
                (int)fs->fs_cgsize, NOCRED, &bp);
        if (error) {
                brelse(bp);
                return (NULL);
        }
-#endif SECSIZE
        cgp = (struct cg *)bp->b_data;
        if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) {
                brelse(bp);
        cgp = (struct cg *)bp->b_data;
        if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) {
                brelse(bp);
@@ -1234,17 +1236,12 @@ ffs_blkfree(ip, bno, size)
                ffs_fserr(fs, ip->i_uid, "bad block");
                return;
        }
                ffs_fserr(fs, ip->i_uid, "bad block");
                return;
        }
-#ifdef SECSIZE
-       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
-           fs->fs_dbsize);
-#else SECSIZE
        error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
                (int)fs->fs_cgsize, NOCRED, &bp);
        if (error) {
                brelse(bp);
                return;
        }
        error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
                (int)fs->fs_cgsize, NOCRED, &bp);
        if (error) {
                brelse(bp);
                return;
        }
-#endif SECSIZE
        cgp = (struct cg *)bp->b_data;
        if (!cg_chkmagic(cgp)) {
                brelse(bp);
        cgp = (struct cg *)bp->b_data;
        if (!cg_chkmagic(cgp)) {
                brelse(bp);
@@ -1391,17 +1388,12 @@ ffs_vfree(ap)
                panic("ifree: range: dev = 0x%x, ino = %d, fs = %s\n",
                    pip->i_dev, ino, fs->fs_fsmnt);
        cg = ino_to_cg(fs, ino);
                panic("ifree: range: dev = 0x%x, ino = %d, fs = %s\n",
                    pip->i_dev, ino, fs->fs_fsmnt);
        cg = ino_to_cg(fs, ino);
-#ifdef SECSIZE
-       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
-           fs->fs_dbsize);
-#else SECSIZE
        error = bread(pip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
                (int)fs->fs_cgsize, NOCRED, &bp);
        if (error) {
                brelse(bp);
                return (0);
        }
        error = bread(pip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
                (int)fs->fs_cgsize, NOCRED, &bp);
        if (error) {
                brelse(bp);
                return (0);
        }
-#endif SECSIZE
        cgp = (struct cg *)bp->b_data;
        if (!cg_chkmagic(cgp)) {
                brelse(bp);
        cgp = (struct cg *)bp->b_data;
        if (!cg_chkmagic(cgp)) {
                brelse(bp);