diff options
Diffstat (limited to 'sys/ufs/ffs/ffs_alloc.c')
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 4b99b553415..8386bd839d1 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1,4 +1,5 @@ -/* $NetBSD: ffs_alloc.c,v 1.8 1995/07/19 15:47:36 cgd Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.2 1996/02/27 07:27:34 niklas Exp $ */ +/* $NetBSD: ffs_alloc.c,v 1.9 1996/02/09 22:22:18 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -48,6 +49,7 @@ #include <ufs/ufs/quota.h> #include <ufs/ufs/inode.h> +#include <ufs/ufs/ufs_extern.h> #include <ufs/ffs/fs.h> #include <ufs/ffs/ffs_extern.h> @@ -60,9 +62,10 @@ static daddr_t ffs_clusteralloc __P((struct inode *, int, daddr_t, int)); static ino_t ffs_dirpref __P((struct fs *)); static daddr_t ffs_fragextend __P((struct inode *, int, long, int, int)); static void ffs_fserr __P((struct fs *, u_int, char *)); -static u_long ffs_hashalloc - __P((struct inode *, int, long, int, u_int32_t (*)())); -static ino_t ffs_nodealloccg __P((struct inode *, int, daddr_t, int)); +static u_long ffs_hashalloc __P((struct inode *, int, long, int, + daddr_t (*)(struct inode *, int, daddr_t, + int))); +static daddr_t ffs_nodealloccg __P((struct inode *, int, daddr_t, int)); static daddr_t ffs_mapsearch __P((struct fs *, struct cg *, daddr_t, int)); /* @@ -84,6 +87,7 @@ static daddr_t ffs_mapsearch __P((struct fs *, struct cg *, daddr_t, int)); * 2) quadradically rehash into other cylinder groups, until an * available block is located. */ +int ffs_alloc(ip, lbn, bpref, size, cred, bnp) register struct inode *ip; daddr_t lbn, bpref; @@ -93,7 +97,10 @@ ffs_alloc(ip, lbn, bpref, size, cred, bnp) { register struct fs *fs; daddr_t bno; - int cg, error; + int cg; +#ifdef QUOTA + int error; +#endif *bnp = 0; fs = ip->i_fs; @@ -111,7 +118,7 @@ ffs_alloc(ip, lbn, bpref, size, cred, bnp) if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0) goto nospace; #ifdef QUOTA - if (error = chkdq(ip, (long)btodb(size), cred, 0)) + if ((error = chkdq(ip, (long)btodb(size), cred, 0)) != 0) return (error); #endif if (bpref >= fs->fs_size) @@ -121,7 +128,7 @@ ffs_alloc(ip, lbn, bpref, size, cred, bnp) else cg = dtog(fs, bpref); bno = (daddr_t)ffs_hashalloc(ip, cg, (long)bpref, size, - (u_int32_t (*)())ffs_alloccg); + ffs_alloccg); if (bno > 0) { ip->i_blocks += btodb(size); ip->i_flag |= IN_CHANGE | IN_UPDATE; @@ -148,6 +155,7 @@ nospace: * the original block. Failing that, the regular block allocator is * invoked to get an appropriate block. */ +int ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) register struct inode *ip; daddr_t lbprev; @@ -184,12 +192,12 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) /* * Allocate the extra space in the buffer. */ - if (error = bread(ITOV(ip), lbprev, osize, NOCRED, &bp)) { + if ((error = bread(ITOV(ip), lbprev, osize, NOCRED, &bp)) != 0) { brelse(bp); return (error); } #ifdef QUOTA - if (error = chkdq(ip, (long)btodb(nsize - osize), cred, 0)) { + if ((error = chkdq(ip, (long)btodb(nsize - osize), cred, 0)) != 0) { brelse(bp); return (error); } @@ -198,7 +206,7 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) * Check for extension in the existing location. */ cg = dtog(fs, bprev); - if (bno = ffs_fragextend(ip, cg, (long)bprev, osize, nsize)) { + if ((bno = ffs_fragextend(ip, cg, (long)bprev, osize, nsize)) != 0) { if (bp->b_blkno != fsbtodb(fs, bno)) panic("bad blockno"); ip->i_blocks += btodb(nsize - osize); @@ -258,7 +266,7 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) /* NOTREACHED */ } bno = (daddr_t)ffs_hashalloc(ip, cg, (long)bpref, request, - (u_int32_t (*)())ffs_alloccg); + ffs_alloccg); if (bno > 0) { bp->b_blkno = fsbtodb(fs, bno); (void) vnode_pager_uncache(ITOV(ip)); @@ -315,19 +323,20 @@ struct ctldebug debug15 = { "prtrealloc", &prtrealloc }; #endif int -ffs_reallocblks(ap) +ffs_reallocblks(v) + void *v; +{ struct vop_reallocblks_args /* { struct vnode *a_vp; struct cluster_save *a_buflist; - } */ *ap; -{ + } */ *ap = v; struct fs *fs; struct inode *ip; struct vnode *vp; struct buf *sbp, *ebp; - daddr_t *bap, *sbap, *ebap; + daddr_t *bap, *sbap, *ebap = NULL; struct cluster_save *buflist; - daddr_t start_lbn, end_lbn, soff, eoff, newblk, blkno; + daddr_t start_lbn, end_lbn, soff, newblk, blkno; struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp; int i, len, start_lvl, end_lvl, pref, ssize; @@ -394,7 +403,7 @@ ffs_reallocblks(ap) * Search the block map looking for an allocation of the desired size. */ if ((newblk = (daddr_t)ffs_hashalloc(ip, dtog(fs, pref), (long)pref, - len, (u_int32_t (*)())ffs_clusteralloc)) == 0) + len, ffs_clusteralloc)) == 0) goto fail; /* * We have found a new contiguous block. @@ -499,14 +508,16 @@ fail: * 2) quadradically rehash into other cylinder groups, until an * available inode is located. */ -ffs_valloc(ap) +int +ffs_valloc(v) + void *v; +{ struct vop_valloc_args /* { struct vnode *a_pvp; int a_mode; struct ucred *a_cred; struct vnode **a_vpp; - } */ *ap; -{ + } */ *ap = v; register struct vnode *pvp = ap->a_pvp; register struct inode *pip; register struct fs *fs; @@ -690,7 +701,7 @@ ffs_hashalloc(ip, cg, pref, size, allocator) int cg; long pref; int size; /* size for data blocks, mode for inodes */ - u_int32_t (*allocator)(); + daddr_t (*allocator) __P((struct inode *, int, daddr_t, int)); { register struct fs *fs; long result; @@ -1118,7 +1129,7 @@ fail: * 2) allocate the next available inode after the requested * inode in the specified cylinder group. */ -static ino_t +static daddr_t ffs_nodealloccg(ip, cg, ipref, mode) struct inode *ip; int cg; @@ -1198,6 +1209,7 @@ gotit: * free map. If a fragment is deallocated, a possible * block reassembly is checked. */ +void ffs_blkfree(ip, bno, size) register struct inode *ip; daddr_t bno; @@ -1303,13 +1315,14 @@ ffs_blkfree(ip, bno, size) * The specified inode is placed back in the free map. */ int -ffs_vfree(ap) +ffs_vfree(v) + void *v; +{ struct vop_vfree_args /* { struct vnode *a_pvp; ino_t a_ino; int a_mode; - } */ *ap; -{ + } */ *ap = v; register struct fs *fs; register struct cg *cgp; register struct inode *pip; @@ -1428,6 +1441,7 @@ ffs_mapsearch(fs, cgp, bpref, allocsiz) * * Cnt == 1 means free; cnt == -1 means allocating. */ +void ffs_clusteracct(fs, cgp, blkno, cnt) struct fs *fs; struct cg *cgp; |