Duhh.. my bad walter. it's early.. as of yet undercaffinated.
On Thu, Nov 26, 2015 at 10:58 AM, Walter Neto <wsouz...@gmail.com> wrote: > On Thu, Nov 26, 2015 at 10:30:23AM -0700, Bob Beck wrote: >> walter the ideom of: >> >> bp->b_count = foo >> buf_adjcnt(bp, foo) >> >> where buf_adjcnt then does internally the same >> bp->b_count = foo >> >> is silly.. remove the duplicate assignments above the buf_adjcnt, and >> let buf_adjcnt do it. > > Hi Bob, sorry but I could not identify where I'm using duplicated. > I think my diff is removing the duplications. > > comments on the diff >> >> Do that and I'll commit it for you :) >> >> >> On Thu, Nov 26, 2015 at 8:36 AM, Walter Neto <wsouz...@gmail.com> wrote: >> > Sorry guys, my bad. >> > >> > It will not compile, there is a warning. >> > >> > Here is the correct diff. >> > >> > -- >> > Walter Neto >> > >> > >> > diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c >> > index 2ce876a..63bd7ca 100644 >> > --- a/sys/kern/vfs_bio.c >> > +++ b/sys/kern/vfs_bio.c >> > @@ -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 <t...@openbsd.org> >> > diff --git a/sys/sys/buf.h b/sys/sys/buf.h >> > index ce1d35c..c47f3f9 100644 >> > --- a/sys/sys/buf.h >> > +++ b/sys/sys/buf.h >> > @@ -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 da4ff2a..08961b9 100644 >> > --- a/sys/ufs/ffs/ffs_alloc.c >> > +++ b/sys/ufs/ffs/ffs_alloc.c >> > @@ -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); >> > } > > like here, I'm deleting the "bp->b_bcount = osize;" line. > >> > >> > 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 16f9b6f..ef9f6d4 100644 >> > --- a/sys/ufs/ffs/ffs_balloc.c >> > +++ b/sys/ufs/ffs/ffs_balloc.c >> > @@ -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 1eaa8b5..25c5fd5 100644 >> > --- a/sys/ufs/ffs/ffs_inode.c >> > +++ b/sys/ufs/ffs/ffs_inode.c >> > @@ -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 938af62..4282779 100644 >> > --- a/sys/ufs/ffs/ffs_subr.c >> > +++ b/sys/ufs/ffs/ffs_subr.c >> > @@ -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; >> >