add ifdefs for dev_bsize (almost working)
[unix-history] / usr / src / sys / ufs / ffs / ffs_alloc.c
index 72eb9a9..0dd37ef 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ffs_alloc.c 7.1 (Berkeley) %G%
+ *     @(#)ffs_alloc.c 7.1.1.1 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -86,7 +86,11 @@ alloc(ip, bpref, size)
                goto nospace;
        ip->i_blocks += btodb(size);
        ip->i_flag |= IUPD|ICHG;
                goto nospace;
        ip->i_blocks += btodb(size);
        ip->i_flag |= IUPD|ICHG;
+#ifdef SECSIZE
+       bp = getblk(ip->i_dev, fsbtodb(fs, bno), size, fs->fs_dbsize);
+#else SECSIZE
        bp = getblk(ip->i_dev, fsbtodb(fs, bno), size);
        bp = getblk(ip->i_dev, fsbtodb(fs, bno), size);
+#endif SECSIZE
        clrbuf(bp);
        return (bp);
 nospace:
        clrbuf(bp);
        return (bp);
 nospace:
@@ -140,7 +144,12 @@ realloccg(ip, bprev, bpref, osize, nsize)
        bno = fragextend(ip, cg, (long)bprev, osize, nsize);
        if (bno != 0) {
                do {
        bno = fragextend(ip, cg, (long)bprev, osize, nsize);
        if (bno != 0) {
                do {
+#ifdef SECSIZE
+                       bp = bread(ip->i_dev, fsbtodb(fs, bno), osize,
+                           fs->fs_dbsize);
+#else SECSIZE
                        bp = bread(ip->i_dev, fsbtodb(fs, bno), osize);
                        bp = bread(ip->i_dev, fsbtodb(fs, bno), osize);
+#endif SECSIZE
                        if (bp->b_flags & B_ERROR) {
                                brelse(bp);
                                return (NULL);
                        if (bp->b_flags & B_ERROR) {
                                brelse(bp);
                                return (NULL);
@@ -200,20 +209,30 @@ realloccg(ip, bprev, bpref, osize, nsize)
        bno = (daddr_t)hashalloc(ip, cg, (long)bpref, request,
                (u_long (*)())alloccg);
        if (bno > 0) {
        bno = (daddr_t)hashalloc(ip, cg, (long)bpref, request,
                (u_long (*)())alloccg);
        if (bno > 0) {
+#ifdef SECSIZE
+               obp = bread(ip->i_dev, fsbtodb(fs, bprev), osize,
+                   fs->fs_dbsize);
+#else SECSIZE
                obp = bread(ip->i_dev, fsbtodb(fs, bprev), osize);
                obp = bread(ip->i_dev, fsbtodb(fs, bprev), osize);
+#endif SECSIZE
                if (obp->b_flags & B_ERROR) {
                        brelse(obp);
                        return (NULL);
                }
                bn = fsbtodb(fs, bno);
                if (obp->b_flags & B_ERROR) {
                        brelse(obp);
                        return (NULL);
                }
                bn = fsbtodb(fs, bno);
+#ifdef SECSIZE
+               bp = getblk(ip->i_dev, bn, nsize, fs->fs_dbsize);
+#else SECSIZE
                bp = getblk(ip->i_dev, bn, nsize);
                bp = getblk(ip->i_dev, bn, nsize);
+#endif SECSIZE
                bcopy(obp->b_un.b_addr, bp->b_un.b_addr, (u_int)osize);
                bcopy(obp->b_un.b_addr, bp->b_un.b_addr, (u_int)osize);
-               count = howmany(osize, DEV_BSIZE);
-               s = splimp();
-               for (i = 0; i < count; i += CLBYTES / DEV_BSIZE)
-                       if (mfind(ip->i_dev, bn + i))
-                               munhash(ip->i_dev, bn + i);
-               splx(s);
+               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
                bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize);
                if (obp->b_flags & B_DELWRI) {
                        obp->b_flags &= ~B_DELWRI;
                bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize);
                if (obp->b_flags & B_DELWRI) {
                        obp->b_flags &= ~B_DELWRI;
@@ -497,10 +516,15 @@ fragextend(ip, cg, bprev, osize, nsize)
        frags = numfrags(fs, nsize);
        bbase = fragnum(fs, bprev);
        if (bbase > fragnum(fs, (bprev + frags - 1))) {
        frags = numfrags(fs, nsize);
        bbase = fragnum(fs, bprev);
        if (bbase > fragnum(fs, (bprev + frags - 1))) {
-               /* cannot extend across a block boundry */
+               /* cannot extend across a block boundary */
                return (NULL);
        }
                return (NULL);
        }
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
@@ -559,7 +583,12 @@ 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
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
@@ -754,7 +783,12 @@ ialloccg(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
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            cgp->cg_cs.cs_nifree == 0) {
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC ||
            cgp->cg_cs.cs_nifree == 0) {
@@ -837,7 +871,12 @@ free(ip, bno, size)
                printf("bad block %d, ino %d\n", bno, ip->i_number);
                return;
        }
                printf("bad block %d, ino %d\n", bno, ip->i_number);
                return;
        }
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
@@ -926,7 +965,12 @@ ifree(ip, ino, mode)
                panic("ifree: range");
        }
        cg = itog(fs, ino);
                panic("ifree: range");
        }
        cg = itog(fs, ino);
+#ifdef SECSIZE
+       bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+           fs->fs_dbsize);
+#else SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
        bp = bread(ip->i_dev, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize);
+#endif SECSIZE
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);
        cgp = bp->b_un.b_cg;
        if (bp->b_flags & B_ERROR || cgp->cg_magic != CG_MAGIC) {
                brelse(bp);