summaryrefslogtreecommitdiff
path: root/sys/ufs
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-11-13 00:10:57 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-11-13 00:10:57 +0000
commit30783811e022a9235a839fbe208d799cf9299cd2 (patch)
tree6d7833e8a7051f1a0dfacb74af08c55074198934 /sys/ufs
parent4ec594334e5c968ad0fec157a2bb0f22becf57d8 (diff)
Allow the bpp arguemnt on ffs_realloccg to be NULL, don't return the
buffer in that case. Also add a new argument - blknop, which can be used to return the allocated blkno.
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_alloc.c48
-rw-r--r--sys/ufs/ffs/ffs_balloc.c18
-rw-r--r--sys/ufs/ffs/ffs_extern.h4
3 files changed, 42 insertions, 28 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index f3035539de3..2346d24d16b 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_alloc.c,v 1.32 2001/11/06 19:53:21 miod Exp $ */
+/* $OpenBSD: ffs_alloc.c,v 1.33 2001/11/13 00:10:56 art Exp $ */
/* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */
/*
@@ -162,13 +162,14 @@ nospace:
* invoked to get an appropriate block.
*/
int
-ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp)
+ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp, blknop)
register struct inode *ip;
daddr_t lbprev;
daddr_t bpref;
int osize, nsize;
struct ucred *cred;
struct buf **bpp;
+ ufs_daddr_t *blknop;
{
register struct fs *fs;
struct buf *bp;
@@ -198,13 +199,16 @@ 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)) != 0) {
+ if (bpp != NULL &&
+ (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)) != 0) {
- brelse(bp);
+ if (bpp != NULL) {
+ brelse(bp);
+ }
return (error);
}
#endif
@@ -213,14 +217,19 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp)
*/
cg = dtog(fs, bprev);
if ((bno = ffs_fragextend(ip, cg, (long)bprev, osize, nsize)) != 0) {
- if (bp->b_blkno != fsbtodb(fs, bno))
- panic("ffs_realloccg: bad blockno");
ip->i_ffs_blocks += btodb(nsize - osize);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
- allocbuf(bp, nsize);
- bp->b_flags |= B_DONE;
- bzero((char *)bp->b_data + osize, (u_int)nsize - osize);
- *bpp = bp;
+ if (bpp != NULL) {
+ if (bp->b_blkno != fsbtodb(fs, bno))
+ panic("ffs_realloccg: bad blockno");
+ allocbuf(bp, nsize);
+ bp->b_flags |= B_DONE;
+ bzero((char *)bp->b_data + osize, (u_int)nsize - osize);
+ *bpp = bp;
+ }
+ if (blknop != NULL) {
+ *blknop = bno;
+ }
return (0);
}
/*
@@ -274,7 +283,6 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp)
bno = (daddr_t)ffs_hashalloc(ip, cg, (long)bpref, request,
ffs_alloccg);
if (bno > 0) {
- bp->b_blkno = fsbtodb(fs, bno);
(void) uvm_vnp_uncache(ITOV(ip));
if (!DOINGSOFTDEP(ITOV(ip)))
ffs_blkfree(ip, bprev, (long)osize);
@@ -283,10 +291,16 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp)
(long)(request - nsize));
ip->i_ffs_blocks += btodb(nsize - osize);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
- allocbuf(bp, nsize);
- bp->b_flags |= B_DONE;
- bzero((char *)bp->b_data + osize, (u_int)nsize - osize);
- *bpp = bp;
+ if (bpp != NULL) {
+ bp->b_blkno = fsbtodb(fs, bno);
+ allocbuf(bp, nsize);
+ bp->b_flags |= B_DONE;
+ bzero((char *)bp->b_data + osize, (u_int)nsize - osize);
+ *bpp = bp;
+ }
+ if (blknop != NULL) {
+ *blknop = bno;
+ }
return (0);
}
#ifdef QUOTA
@@ -295,7 +309,9 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp)
*/
(void) chkdq(ip, (long)-btodb(nsize - osize), cred, FORCE);
#endif
- brelse(bp);
+ if (bpp != NULL) {
+ brelse(bp);
+ }
nospace:
/*
* no space available
diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c
index 87554518aa5..735d5d3fbba 100644
--- a/sys/ufs/ffs/ffs_balloc.c
+++ b/sys/ufs/ffs/ffs_balloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_balloc.c,v 1.15 2001/11/06 19:53:21 miod Exp $ */
+/* $OpenBSD: ffs_balloc.c,v 1.16 2001/11/13 00:10:56 art Exp $ */
/* $NetBSD: ffs_balloc.c,v 1.3 1996/02/09 22:22:21 christos Exp $ */
/*
@@ -93,18 +93,17 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred,
osize = blksize(fs, ip, nb);
if (osize < fs->fs_bsize && osize > 0) {
error = ffs_realloccg(ip, nb,
- ffs_blkpref(ip, nb, (int)nb, &ip->i_ffs_db[0]),
- osize, (int)fs->fs_bsize, cred, &bp);
+ ffs_blkpref(ip, nb, (int)nb, &ip->i_ffs_db[0]),
+ osize, (int)fs->fs_bsize, cred, &bp, &newb);
if (error)
return (error);
if (DOINGSOFTDEP(vp))
- softdep_setup_allocdirect(ip, nb,
- dbtofsb(fs, bp->b_blkno), ip->i_ffs_db[nb],
- fs->fs_bsize, osize, bp);
+ softdep_setup_allocdirect(ip, nb, newb,
+ ip->i_ffs_db[nb], fs->fs_bsize, osize, bp);
ip->i_ffs_size = lblktosize(fs, nb + 1);
uvm_vnp_setsize(vp, ip->i_ffs_size);
- ip->i_ffs_db[nb] = dbtofsb(fs, bp->b_blkno);
+ ip->i_ffs_db[nb] = newb;
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (flags & B_SYNC)
bwrite(bp);
@@ -142,13 +141,12 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred,
error = ffs_realloccg(ip, lbn,
ffs_blkpref(ip, lbn, (int)lbn,
&ip->i_ffs_db[0]),
- osize, nsize, cred, &bp);
+ osize, nsize, cred, &bp, &newb);
if (error)
return (error);
if (DOINGSOFTDEP(vp))
softdep_setup_allocdirect(ip, lbn,
- dbtofsb(fs, bp->b_blkno), nb,
- nsize, osize, bp);
+ newb, nb, nsize, osize, bp);
}
} else {
if (ip->i_ffs_size < lblktosize(fs, lbn + 1))
diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h
index 40f61d068b4..eeeba209c69 100644
--- a/sys/ufs/ffs/ffs_extern.h
+++ b/sys/ufs/ffs/ffs_extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_extern.h,v 1.13 2001/06/23 02:07:53 csapuntz Exp $ */
+/* $OpenBSD: ffs_extern.h,v 1.14 2001/11/13 00:10:56 art Exp $ */
/* $NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $ */
/*-
@@ -75,7 +75,7 @@ __BEGIN_DECLS
int ffs_alloc __P((struct inode *, daddr_t, daddr_t , int, struct ucred *,
daddr_t *));
int ffs_realloccg __P((struct inode *, daddr_t, daddr_t, int, int ,
- struct ucred *, struct buf **));
+ struct ucred *, struct buf **, daddr_t *));
int ffs_reallocblks __P((void *));
int ffs_inode_alloc(struct inode *, int, struct ucred *, struct vnode **);
int ffs_inode_free(struct inode *, ino_t, int);