diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2015-11-28 21:52:03 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2015-11-28 21:52:03 +0000 |
commit | e405dde65ba2198dcfea0f634e09795a2e899c28 (patch) | |
tree | 4035f25440bc6f0781b890a3a8550e69f2a06d33 | |
parent | acf349b4efe1192e8a6398f701bb37173312f733 (diff) |
move buffer size adjustment to buf_adjcnt - from Walter Neto
ok mpi@
-rw-r--r-- | sys/kern/vfs_bio.c | 9 | ||||
-rw-r--r-- | sys/sys/buf.h | 3 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 8 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_balloc.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 4 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_subr.c | 4 |
6 files changed, 21 insertions, 13 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 9bf9b362c42..aeb9c4121f4 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_bio.c,v 1.170 2015/07/19 16:21:11 beck Exp $ */ +/* $OpenBSD: vfs_bio.c,v 1.171 2015/11/28 21:52:02 beck Exp $ */ /* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */ /* @@ -1206,6 +1206,13 @@ bcstats_print( } #endif +void +buf_adjcnt(struct buf *bp, long ncount) +{ + KASSERT(ncount <= bp->b_bufsize); + bp->b_bcount = ncount; +} + /* bufcache freelist code below */ /* * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 5d71a5f0b78..0e6fab28eb3 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.h,v 1.99 2015/07/19 16:21:11 beck Exp $ */ +/* $OpenBSD: buf.h,v 1.100 2015/11/28 21:52:02 beck Exp $ */ /* $NetBSD: buf.h,v 1.25 1997/04/09 21:12:17 mycroft Exp $ */ /* @@ -292,6 +292,7 @@ void brelse(struct buf *); void bufinit(void); void buf_dirty(struct buf *); void buf_undirty(struct buf *); +void buf_adjcnt(struct buf *, long); int bwrite(struct buf *); struct buf *getblk(struct vnode *, daddr_t, int, int, int); struct buf *geteblk(int); diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 87840a18699..152b42c9f5d 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.105 2015/09/27 05:25:00 guenther Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.106 2015/11/28 21:52:02 beck Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -218,7 +218,7 @@ ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bpref, int osize, if (bpp != NULL) { if ((error = bread(ITOV(ip), lbprev, fs->fs_bsize, &bp)) != 0) goto error; - bp->b_bcount = osize; + buf_adjcnt(bp, osize); } if ((error = ufs_quota_alloc_blocks(ip, btodb(nsize - osize), cred)) @@ -241,7 +241,7 @@ ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bpref, int osize, if (nsize > bp->b_bufsize) panic("ffs_realloccg: small buf"); #endif - bp->b_bcount = nsize; + buf_adjcnt(bp, nsize); bp->b_flags |= B_DONE; memset(bp->b_data + osize, 0, nsize - osize); *bpp = bp; @@ -313,7 +313,7 @@ ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bpref, int osize, if (nsize > bp->b_bufsize) panic("ffs_realloccg: small buf 2"); #endif - bp->b_bcount = nsize; + buf_adjcnt(bp, nsize); bp->b_flags |= B_DONE; memset(bp->b_data + osize, 0, nsize - osize); *bpp = bp; diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index e4b21cd3179..ca1c80d804b 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.43 2015/03/14 03:38:52 jsg Exp $ */ +/* $OpenBSD: ffs_balloc.c,v 1.44 2015/11/28 21:52:02 beck Exp $ */ /* $NetBSD: ffs_balloc.c,v 1.3 1996/02/09 22:22:21 christos Exp $ */ /* @@ -165,7 +165,7 @@ ffs1_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred, brelse(*bpp); return (error); } - (*bpp)->b_bcount = osize; + buf_adjcnt((*bpp), osize); } return (0); } else { @@ -535,7 +535,7 @@ ffs2_balloc(struct inode *ip, off_t off, int size, struct ucred *cred, brelse(*bpp); return (error); } - (*bpp)->b_bcount = osize; + buf_adjcnt((*bpp), osize); } return (0); diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 670a23e83a4..82c1b87c3e1 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_inode.c,v 1.74 2015/03/14 03:38:52 jsg Exp $ */ +/* $OpenBSD: ffs_inode.c,v 1.75 2015/11/28 21:52:02 beck Exp $ */ /* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */ /* @@ -262,7 +262,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) (void) uvm_vnp_uncache(ovp); if (ovp->v_type != VDIR) memset(bp->b_data + offset, 0, size - offset); - bp->b_bcount = size; + buf_adjcnt(bp, size); if (aflags & B_SYNC) bwrite(bp); else diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index c075f1e633e..3da51515e37 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_subr.c,v 1.29 2013/11/02 00:08:17 krw Exp $ */ +/* $OpenBSD: ffs_subr.c,v 1.30 2015/11/28 21:52:02 beck Exp $ */ /* $NetBSD: ffs_subr.c,v 1.6 1996/03/17 02:16:23 christos Exp $ */ /* @@ -72,7 +72,7 @@ ffs_bufatoff(struct inode *ip, off_t offset, char **res, struct buf **bpp) brelse(bp); return (error); } - bp->b_bcount = bsize; + buf_adjcnt(bp, bsize); if (res) *res = (char *)bp->b_data + blkoff(fs, offset); *bpp = bp; |