geteblk => malloc for copy of indirect pointers
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Mon, 22 Jun 1987 06:46:00 +0000 (22:46 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Mon, 22 Jun 1987 06:46:00 +0000 (22:46 -0800)
SCCS-vsn: sys/ufs/ffs/ffs_inode.c 7.5
SCCS-vsn: sys/ufs/ffs/ufs_inode.c 7.5
SCCS-vsn: sys/ufs/lfs/lfs_inode.c 7.5
SCCS-vsn: sys/ufs/ufs/ufs_inode.c 7.5

usr/src/sys/ufs/ffs/ffs_inode.c
usr/src/sys/ufs/ffs/ufs_inode.c
usr/src/sys/ufs/lfs/lfs_inode.c
usr/src/sys/ufs/ufs/ufs_inode.c

index 3599b82..a47728f 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_inode.c 7.4 (Berkeley) %G%
+ *     @(#)ffs_inode.c 7.5 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -19,6 +19,7 @@
 #include "quota.h"
 #endif
 #include "kernel.h"
 #include "quota.h"
 #endif
 #include "kernel.h"
+#include "malloc.h"
 
 #define        INOHSZ  512
 #if    ((INOHSZ&(INOHSZ-1)) == 0)
 
 #define        INOHSZ  512
 #if    ((INOHSZ&(INOHSZ-1)) == 0)
@@ -571,10 +572,10 @@ indirtrunc(ip, bn, lastbn, level)
        int level;
 {
        register int i;
        int level;
 {
        register int i;
-       struct buf *bp, *copy;
-       register daddr_t *bap;
+       struct buf *bp;
        register struct fs *fs = ip->i_fs;
        register struct fs *fs = ip->i_fs;
-       daddr_t nb, last;
+       register daddr_t *bap;
+       daddr_t *copy, nb, last;
        long factor;
        int blocksreleased = 0, nblocks;
 
        long factor;
        int blocksreleased = 0, nblocks;
 
@@ -595,7 +596,6 @@ indirtrunc(ip, bn, lastbn, level)
         * entries corresponding to blocks to be free'd,
         * and update on disk copy first.
         */
         * entries corresponding to blocks to be free'd,
         * and update on disk copy first.
         */
-       copy = geteblk((int)fs->fs_bsize);
 #ifdef SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
            fs->fs_dbsize);
 #ifdef SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
            fs->fs_dbsize);
@@ -603,16 +603,16 @@ indirtrunc(ip, bn, lastbn, level)
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
 #endif SECSIZE
        if (bp->b_flags&B_ERROR) {
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
 #endif SECSIZE
        if (bp->b_flags&B_ERROR) {
-               brelse(copy);
                brelse(bp);
                return (0);
        }
        bap = bp->b_un.b_daddr;
                brelse(bp);
                return (0);
        }
        bap = bp->b_un.b_daddr;
-       bcopy((caddr_t)bap, (caddr_t)copy->b_un.b_daddr, (u_int)fs->fs_bsize);
+       MALLOC(copy, daddr_t *, fs->fs_bsize, M_TEMP, M_WAITOK);
+       bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->fs_bsize);
        bzero((caddr_t)&bap[last + 1],
          (u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
        bwrite(bp);
        bzero((caddr_t)&bap[last + 1],
          (u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
        bwrite(bp);
-       bp = copy, bap = bp->b_un.b_daddr;
+       bap = copy;
 
        /*
         * Recursively free totally unused blocks.
 
        /*
         * Recursively free totally unused blocks.
@@ -637,7 +637,7 @@ indirtrunc(ip, bn, lastbn, level)
                if (nb != 0)
                        blocksreleased += indirtrunc(ip, nb, last, level - 1);
        }
                if (nb != 0)
                        blocksreleased += indirtrunc(ip, nb, last, level - 1);
        }
-       brelse(bp);
+       FREE(copy, M_TEMP);
        return (blocksreleased);
 }
 
        return (blocksreleased);
 }
 
index 45d977f..7f3ea4f 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.
  *
- *     @(#)ufs_inode.c 7.4 (Berkeley) %G%
+ *     @(#)ufs_inode.c 7.5 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -19,6 +19,7 @@
 #include "quota.h"
 #endif
 #include "kernel.h"
 #include "quota.h"
 #endif
 #include "kernel.h"
+#include "malloc.h"
 
 #define        INOHSZ  512
 #if    ((INOHSZ&(INOHSZ-1)) == 0)
 
 #define        INOHSZ  512
 #if    ((INOHSZ&(INOHSZ-1)) == 0)
@@ -571,10 +572,10 @@ indirtrunc(ip, bn, lastbn, level)
        int level;
 {
        register int i;
        int level;
 {
        register int i;
-       struct buf *bp, *copy;
-       register daddr_t *bap;
+       struct buf *bp;
        register struct fs *fs = ip->i_fs;
        register struct fs *fs = ip->i_fs;
-       daddr_t nb, last;
+       register daddr_t *bap;
+       daddr_t *copy, nb, last;
        long factor;
        int blocksreleased = 0, nblocks;
 
        long factor;
        int blocksreleased = 0, nblocks;
 
@@ -595,7 +596,6 @@ indirtrunc(ip, bn, lastbn, level)
         * entries corresponding to blocks to be free'd,
         * and update on disk copy first.
         */
         * entries corresponding to blocks to be free'd,
         * and update on disk copy first.
         */
-       copy = geteblk((int)fs->fs_bsize);
 #ifdef SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
            fs->fs_dbsize);
 #ifdef SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
            fs->fs_dbsize);
@@ -603,16 +603,16 @@ indirtrunc(ip, bn, lastbn, level)
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
 #endif SECSIZE
        if (bp->b_flags&B_ERROR) {
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
 #endif SECSIZE
        if (bp->b_flags&B_ERROR) {
-               brelse(copy);
                brelse(bp);
                return (0);
        }
        bap = bp->b_un.b_daddr;
                brelse(bp);
                return (0);
        }
        bap = bp->b_un.b_daddr;
-       bcopy((caddr_t)bap, (caddr_t)copy->b_un.b_daddr, (u_int)fs->fs_bsize);
+       MALLOC(copy, daddr_t *, fs->fs_bsize, M_TEMP, M_WAITOK);
+       bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->fs_bsize);
        bzero((caddr_t)&bap[last + 1],
          (u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
        bwrite(bp);
        bzero((caddr_t)&bap[last + 1],
          (u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
        bwrite(bp);
-       bp = copy, bap = bp->b_un.b_daddr;
+       bap = copy;
 
        /*
         * Recursively free totally unused blocks.
 
        /*
         * Recursively free totally unused blocks.
@@ -637,7 +637,7 @@ indirtrunc(ip, bn, lastbn, level)
                if (nb != 0)
                        blocksreleased += indirtrunc(ip, nb, last, level - 1);
        }
                if (nb != 0)
                        blocksreleased += indirtrunc(ip, nb, last, level - 1);
        }
-       brelse(bp);
+       FREE(copy, M_TEMP);
        return (blocksreleased);
 }
 
        return (blocksreleased);
 }
 
index b7ba1b1..5d81a96 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.
  *
- *     @(#)lfs_inode.c 7.4 (Berkeley) %G%
+ *     @(#)lfs_inode.c 7.5 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -19,6 +19,7 @@
 #include "quota.h"
 #endif
 #include "kernel.h"
 #include "quota.h"
 #endif
 #include "kernel.h"
+#include "malloc.h"
 
 #define        INOHSZ  512
 #if    ((INOHSZ&(INOHSZ-1)) == 0)
 
 #define        INOHSZ  512
 #if    ((INOHSZ&(INOHSZ-1)) == 0)
@@ -571,10 +572,10 @@ indirtrunc(ip, bn, lastbn, level)
        int level;
 {
        register int i;
        int level;
 {
        register int i;
-       struct buf *bp, *copy;
-       register daddr_t *bap;
+       struct buf *bp;
        register struct fs *fs = ip->i_fs;
        register struct fs *fs = ip->i_fs;
-       daddr_t nb, last;
+       register daddr_t *bap;
+       daddr_t *copy, nb, last;
        long factor;
        int blocksreleased = 0, nblocks;
 
        long factor;
        int blocksreleased = 0, nblocks;
 
@@ -595,7 +596,6 @@ indirtrunc(ip, bn, lastbn, level)
         * entries corresponding to blocks to be free'd,
         * and update on disk copy first.
         */
         * entries corresponding to blocks to be free'd,
         * and update on disk copy first.
         */
-       copy = geteblk((int)fs->fs_bsize);
 #ifdef SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
            fs->fs_dbsize);
 #ifdef SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
            fs->fs_dbsize);
@@ -603,16 +603,16 @@ indirtrunc(ip, bn, lastbn, level)
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
 #endif SECSIZE
        if (bp->b_flags&B_ERROR) {
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
 #endif SECSIZE
        if (bp->b_flags&B_ERROR) {
-               brelse(copy);
                brelse(bp);
                return (0);
        }
        bap = bp->b_un.b_daddr;
                brelse(bp);
                return (0);
        }
        bap = bp->b_un.b_daddr;
-       bcopy((caddr_t)bap, (caddr_t)copy->b_un.b_daddr, (u_int)fs->fs_bsize);
+       MALLOC(copy, daddr_t *, fs->fs_bsize, M_TEMP, M_WAITOK);
+       bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->fs_bsize);
        bzero((caddr_t)&bap[last + 1],
          (u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
        bwrite(bp);
        bzero((caddr_t)&bap[last + 1],
          (u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
        bwrite(bp);
-       bp = copy, bap = bp->b_un.b_daddr;
+       bap = copy;
 
        /*
         * Recursively free totally unused blocks.
 
        /*
         * Recursively free totally unused blocks.
@@ -637,7 +637,7 @@ indirtrunc(ip, bn, lastbn, level)
                if (nb != 0)
                        blocksreleased += indirtrunc(ip, nb, last, level - 1);
        }
                if (nb != 0)
                        blocksreleased += indirtrunc(ip, nb, last, level - 1);
        }
-       brelse(bp);
+       FREE(copy, M_TEMP);
        return (blocksreleased);
 }
 
        return (blocksreleased);
 }
 
index 45d977f..7f3ea4f 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.
  *
- *     @(#)ufs_inode.c 7.4 (Berkeley) %G%
+ *     @(#)ufs_inode.c 7.5 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -19,6 +19,7 @@
 #include "quota.h"
 #endif
 #include "kernel.h"
 #include "quota.h"
 #endif
 #include "kernel.h"
+#include "malloc.h"
 
 #define        INOHSZ  512
 #if    ((INOHSZ&(INOHSZ-1)) == 0)
 
 #define        INOHSZ  512
 #if    ((INOHSZ&(INOHSZ-1)) == 0)
@@ -571,10 +572,10 @@ indirtrunc(ip, bn, lastbn, level)
        int level;
 {
        register int i;
        int level;
 {
        register int i;
-       struct buf *bp, *copy;
-       register daddr_t *bap;
+       struct buf *bp;
        register struct fs *fs = ip->i_fs;
        register struct fs *fs = ip->i_fs;
-       daddr_t nb, last;
+       register daddr_t *bap;
+       daddr_t *copy, nb, last;
        long factor;
        int blocksreleased = 0, nblocks;
 
        long factor;
        int blocksreleased = 0, nblocks;
 
@@ -595,7 +596,6 @@ indirtrunc(ip, bn, lastbn, level)
         * entries corresponding to blocks to be free'd,
         * and update on disk copy first.
         */
         * entries corresponding to blocks to be free'd,
         * and update on disk copy first.
         */
-       copy = geteblk((int)fs->fs_bsize);
 #ifdef SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
            fs->fs_dbsize);
 #ifdef SECSIZE
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize,
            fs->fs_dbsize);
@@ -603,16 +603,16 @@ indirtrunc(ip, bn, lastbn, level)
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
 #endif SECSIZE
        if (bp->b_flags&B_ERROR) {
        bp = bread(ip->i_dev, fsbtodb(fs, bn), (int)fs->fs_bsize);
 #endif SECSIZE
        if (bp->b_flags&B_ERROR) {
-               brelse(copy);
                brelse(bp);
                return (0);
        }
        bap = bp->b_un.b_daddr;
                brelse(bp);
                return (0);
        }
        bap = bp->b_un.b_daddr;
-       bcopy((caddr_t)bap, (caddr_t)copy->b_un.b_daddr, (u_int)fs->fs_bsize);
+       MALLOC(copy, daddr_t *, fs->fs_bsize, M_TEMP, M_WAITOK);
+       bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->fs_bsize);
        bzero((caddr_t)&bap[last + 1],
          (u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
        bwrite(bp);
        bzero((caddr_t)&bap[last + 1],
          (u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
        bwrite(bp);
-       bp = copy, bap = bp->b_un.b_daddr;
+       bap = copy;
 
        /*
         * Recursively free totally unused blocks.
 
        /*
         * Recursively free totally unused blocks.
@@ -637,7 +637,7 @@ indirtrunc(ip, bn, lastbn, level)
                if (nb != 0)
                        blocksreleased += indirtrunc(ip, nb, last, level - 1);
        }
                if (nb != 0)
                        blocksreleased += indirtrunc(ip, nb, last, level - 1);
        }
-       brelse(bp);
+       FREE(copy, M_TEMP);
        return (blocksreleased);
 }
 
        return (blocksreleased);
 }