Properly vector all bwrite() and BUF_WRITE() calls through the same path
and s/BUF_WRITE()/bwrite()/ since it now does the same as bwrite().
This commit is contained in:
parent
2b348f7429
commit
4d453ef101
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=126853
@ -900,7 +900,7 @@ ext2_direnter(ip, dvp, cnp)
|
||||
ep = (struct ext2_dir_entry_2 *)((char *)ep + dsize);
|
||||
}
|
||||
bcopy((caddr_t)&newdir, (caddr_t)ep, (u_int)newentrysize);
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
if (!error && dp->i_endoff && dp->i_endoff < dp->i_size)
|
||||
error = ext2_truncate(dvp, (off_t)dp->i_endoff, IO_SYNC,
|
||||
@ -940,7 +940,7 @@ ext2_dirremove(dvp, cnp)
|
||||
&bp)) != 0)
|
||||
return (error);
|
||||
ep->inode = 0;
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
return (error);
|
||||
}
|
||||
@ -951,7 +951,7 @@ ext2_dirremove(dvp, cnp)
|
||||
(char **)&ep, &bp)) != 0)
|
||||
return (error);
|
||||
ep->rec_len += dp->i_reclen;
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
return (error);
|
||||
}
|
||||
@ -980,7 +980,7 @@ ext2_dirrewrite(dp, ip, cnp)
|
||||
ep->file_type = DTTOFT(IFTODT(ip->i_mode));
|
||||
else
|
||||
ep->file_type = EXT2_FT_UNKNOWN;
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
return (error);
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ ext2_direnter(ip, dvp, cnp)
|
||||
ep = (struct ext2_dir_entry_2 *)((char *)ep + dsize);
|
||||
}
|
||||
bcopy((caddr_t)&newdir, (caddr_t)ep, (u_int)newentrysize);
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
if (!error && dp->i_endoff && dp->i_endoff < dp->i_size)
|
||||
error = ext2_truncate(dvp, (off_t)dp->i_endoff, IO_SYNC,
|
||||
@ -940,7 +940,7 @@ ext2_dirremove(dvp, cnp)
|
||||
&bp)) != 0)
|
||||
return (error);
|
||||
ep->inode = 0;
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
return (error);
|
||||
}
|
||||
@ -951,7 +951,7 @@ ext2_dirremove(dvp, cnp)
|
||||
(char **)&ep, &bp)) != 0)
|
||||
return (error);
|
||||
ep->rec_len += dp->i_reclen;
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
return (error);
|
||||
}
|
||||
@ -980,7 +980,7 @@ ext2_dirrewrite(dp, ip, cnp)
|
||||
ep->file_type = DTTOFT(IFTODT(ip->i_mode));
|
||||
else
|
||||
ep->file_type = EXT2_FT_UNKNOWN;
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
return (error);
|
||||
}
|
||||
|
@ -61,9 +61,11 @@ static MALLOC_DEFINE(M_BIOBUF, "BIO buffer", "BIO buffer");
|
||||
|
||||
struct bio_ops bioops; /* I/O operation notification */
|
||||
|
||||
static int ibwrite(struct buf *);
|
||||
|
||||
struct buf_ops buf_ops_bio = {
|
||||
"buf_ops_bio",
|
||||
bwrite
|
||||
ibwrite
|
||||
};
|
||||
|
||||
/*
|
||||
@ -760,9 +762,17 @@ breadn(struct vnode * vp, daddr_t blkno, int size,
|
||||
* or in biodone() since the I/O is synchronous. We put it
|
||||
* here.
|
||||
*/
|
||||
|
||||
int
|
||||
bwrite(struct buf * bp)
|
||||
{
|
||||
|
||||
KASSERT(bp->b_op != NULL && bp->b_op->bop_write != NULL,
|
||||
("Martian buffer %p in bwrite: nobody to write it.", bp));
|
||||
return (bp->b_op->bop_write(bp));
|
||||
}
|
||||
|
||||
static int
|
||||
ibwrite(struct buf * bp)
|
||||
{
|
||||
int oldflags, s;
|
||||
struct buf *newbp;
|
||||
@ -775,7 +785,7 @@ bwrite(struct buf * bp)
|
||||
oldflags = bp->b_flags;
|
||||
|
||||
if (BUF_REFCNT(bp) == 0)
|
||||
panic("bwrite: buffer is not busy???");
|
||||
panic("ibwrite: buffer is not busy???");
|
||||
s = splbio();
|
||||
/*
|
||||
* If a background write is already in progress, delay
|
||||
@ -793,7 +803,7 @@ bwrite(struct buf * bp)
|
||||
bp->b_vflags |= BV_BKGRDWAIT;
|
||||
msleep(&bp->b_xflags, VI_MTX(bp->b_vp), PRIBIO, "bwrbg", 0);
|
||||
if (bp->b_vflags & BV_BKGRDINPROG)
|
||||
panic("bwrite: still writing");
|
||||
panic("ibwrite: still writing");
|
||||
}
|
||||
VI_UNLOCK(bp->b_vp);
|
||||
|
||||
@ -814,7 +824,7 @@ bwrite(struct buf * bp)
|
||||
!buf_dirty_count_severe()) {
|
||||
if (bp->b_iodone != NULL) {
|
||||
printf("bp->b_iodone = %p\n", bp->b_iodone);
|
||||
panic("bwrite: need chained iodone");
|
||||
panic("ibwrite: need chained iodone");
|
||||
}
|
||||
|
||||
/* get a new block */
|
||||
@ -1147,7 +1157,7 @@ void
|
||||
bawrite(struct buf * bp)
|
||||
{
|
||||
bp->b_flags |= B_ASYNC;
|
||||
(void) BUF_WRITE(bp);
|
||||
(void) bwrite(bp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1710,7 +1720,7 @@ vfs_bio_awrite(struct buf * bp)
|
||||
* XXX returns b_bufsize instead of b_bcount for nwritten?
|
||||
*/
|
||||
nwritten = bp->b_bufsize;
|
||||
(void) BUF_WRITE(bp);
|
||||
(void) bwrite(bp);
|
||||
|
||||
return nwritten;
|
||||
}
|
||||
@ -2382,7 +2392,7 @@ vfs_setdirty(struct buf *bp)
|
||||
* case it is returned with B_INVAL clear and B_CACHE set based on the
|
||||
* backing VM.
|
||||
*
|
||||
* getblk() also forces a BUF_WRITE() for any B_DELWRI buffer whos
|
||||
* getblk() also forces a bwrite() for any B_DELWRI buffer whos
|
||||
* B_CACHE bit is clear.
|
||||
*
|
||||
* What this means, basically, is that the caller should use B_CACHE to
|
||||
@ -2474,7 +2484,7 @@ getblk(struct vnode * vp, daddr_t blkno, int size, int slpflag, int slptimeo,
|
||||
(size > bp->b_kvasize)) {
|
||||
if (bp->b_flags & B_DELWRI) {
|
||||
bp->b_flags |= B_NOCACHE;
|
||||
BUF_WRITE(bp);
|
||||
bwrite(bp);
|
||||
} else {
|
||||
if ((bp->b_flags & B_VMIO) &&
|
||||
(LIST_FIRST(&bp->b_dep) == NULL)) {
|
||||
@ -2482,7 +2492,7 @@ getblk(struct vnode * vp, daddr_t blkno, int size, int slpflag, int slptimeo,
|
||||
brelse(bp);
|
||||
} else {
|
||||
bp->b_flags |= B_NOCACHE;
|
||||
BUF_WRITE(bp);
|
||||
bwrite(bp);
|
||||
}
|
||||
}
|
||||
goto loop;
|
||||
@ -2531,7 +2541,7 @@ getblk(struct vnode * vp, daddr_t blkno, int size, int slpflag, int slptimeo,
|
||||
|
||||
if ((bp->b_flags & (B_CACHE|B_DELWRI)) == B_DELWRI) {
|
||||
bp->b_flags |= B_NOCACHE;
|
||||
BUF_WRITE(bp);
|
||||
bwrite(bp);
|
||||
goto loop;
|
||||
}
|
||||
|
||||
|
@ -1028,7 +1028,7 @@ flushbuflist(blist, flags, vp, slpflag, slptimeo, errorp)
|
||||
* believe there is a slight chance that a delayed
|
||||
* write will occur while sleeping just above, so
|
||||
* check for it. Note that vfs_bio_awrite expects
|
||||
* buffers to reside on a queue, while BUF_WRITE and
|
||||
* buffers to reside on a queue, while bwrite and
|
||||
* brelse do not.
|
||||
*/
|
||||
if (((bp->b_flags & (B_DELWRI | B_INVAL)) == B_DELWRI) &&
|
||||
@ -1040,11 +1040,11 @@ flushbuflist(blist, flags, vp, slpflag, slptimeo, errorp)
|
||||
} else {
|
||||
bremfree(bp);
|
||||
bp->b_flags |= B_ASYNC;
|
||||
BUF_WRITE(bp);
|
||||
bwrite(bp);
|
||||
}
|
||||
} else {
|
||||
bremfree(bp);
|
||||
(void) BUF_WRITE(bp);
|
||||
(void) bwrite(bp);
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
@ -2858,7 +2858,7 @@ nfs4_flush(struct vnode *vp, struct ucred *cred, int waitfor, struct thread *td,
|
||||
else
|
||||
bp->b_flags |= B_ASYNC | B_WRITEINPROG;
|
||||
splx(s);
|
||||
BUF_WRITE(bp);
|
||||
bwrite(bp);
|
||||
goto loop;
|
||||
}
|
||||
splx(s);
|
||||
|
@ -967,7 +967,7 @@ nfs_write(struct vop_write_args *ap)
|
||||
|
||||
if (bp->b_dirtyend > 0 &&
|
||||
(on > bp->b_dirtyend || (on + n) < bp->b_dirtyoff)) {
|
||||
if (BUF_WRITE(bp) == EINTR) {
|
||||
if (bwrite(bp) == EINTR) {
|
||||
error = EINTR;
|
||||
break;
|
||||
}
|
||||
@ -1014,7 +1014,7 @@ nfs_write(struct vop_write_args *ap)
|
||||
if ((ioflag & IO_SYNC)) {
|
||||
if (ioflag & IO_INVAL)
|
||||
bp->b_flags |= B_NOCACHE;
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
if (error)
|
||||
break;
|
||||
} else if ((n + on) == biosize) {
|
||||
|
@ -2849,7 +2849,7 @@ nfs_flush(struct vnode *vp, struct ucred *cred, int waitfor, struct thread *td,
|
||||
else
|
||||
bp->b_flags |= B_ASYNC | B_WRITEINPROG;
|
||||
splx(s);
|
||||
BUF_WRITE(bp);
|
||||
bwrite(bp);
|
||||
goto loop;
|
||||
}
|
||||
splx(s);
|
||||
|
@ -3719,7 +3719,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
B_DELWRI) {
|
||||
bremfree(bp);
|
||||
bp->b_flags &= ~B_ASYNC;
|
||||
BUF_WRITE(bp);
|
||||
bwrite(bp);
|
||||
++nfs_commit_miss;
|
||||
} else
|
||||
BUF_UNLOCK(bp);
|
||||
|
@ -403,8 +403,6 @@ struct cluster_save {
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#define BUF_WRITE(bp) \
|
||||
(bp)->b_op->bop_write(bp)
|
||||
|
||||
static __inline void
|
||||
buf_start(struct buf *bp)
|
||||
|
@ -4705,7 +4705,7 @@ softdep_update_inodeblock(ip, bp, waitfor)
|
||||
ibp = inodedep->id_buf;
|
||||
ibp = getdirtybuf(&ibp, NULL, MNT_WAIT);
|
||||
FREE_LOCK(&lk);
|
||||
if (ibp && (error = BUF_WRITE(ibp)) != 0)
|
||||
if (ibp && (error = bwrite(ibp)) != 0)
|
||||
softdep_error("softdep_update_inodeblock: bwrite", error);
|
||||
if ((inodedep->id_state & DEPCOMPLETE) == 0)
|
||||
panic("softdep_update_inodeblock: update failed");
|
||||
@ -4862,7 +4862,7 @@ softdep_fsync(vp)
|
||||
error = bread(pvp, lbn, blksize(fs, VTOI(pvp), lbn), td->td_ucred,
|
||||
&bp);
|
||||
if (error == 0)
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
else
|
||||
brelse(bp);
|
||||
vput(pvp);
|
||||
@ -5026,7 +5026,7 @@ softdep_sync_metadata(ap)
|
||||
FREE_LOCK(&lk);
|
||||
if (waitfor == MNT_NOWAIT) {
|
||||
bawrite(nbp);
|
||||
} else if ((error = BUF_WRITE(nbp)) != 0) {
|
||||
} else if ((error = bwrite(nbp)) != 0) {
|
||||
break;
|
||||
}
|
||||
ACQUIRE_LOCK(&lk);
|
||||
@ -5043,7 +5043,7 @@ softdep_sync_metadata(ap)
|
||||
FREE_LOCK(&lk);
|
||||
if (waitfor == MNT_NOWAIT) {
|
||||
bawrite(nbp);
|
||||
} else if ((error = BUF_WRITE(nbp)) != 0) {
|
||||
} else if ((error = bwrite(nbp)) != 0) {
|
||||
break;
|
||||
}
|
||||
ACQUIRE_LOCK(&lk);
|
||||
@ -5060,7 +5060,7 @@ softdep_sync_metadata(ap)
|
||||
if (nbp == NULL)
|
||||
goto restart;
|
||||
FREE_LOCK(&lk);
|
||||
if ((error = BUF_WRITE(nbp)) != 0) {
|
||||
if ((error = bwrite(nbp)) != 0) {
|
||||
break;
|
||||
}
|
||||
ACQUIRE_LOCK(&lk);
|
||||
@ -5112,7 +5112,7 @@ softdep_sync_metadata(ap)
|
||||
FREE_LOCK(&lk);
|
||||
if (waitfor == MNT_NOWAIT) {
|
||||
bawrite(nbp);
|
||||
} else if ((error = BUF_WRITE(nbp)) != 0) {
|
||||
} else if ((error = bwrite(nbp)) != 0) {
|
||||
break;
|
||||
}
|
||||
ACQUIRE_LOCK(&lk);
|
||||
@ -5133,7 +5133,7 @@ softdep_sync_metadata(ap)
|
||||
FREE_LOCK(&lk);
|
||||
if (waitfor == MNT_NOWAIT) {
|
||||
bawrite(nbp);
|
||||
} else if ((error = BUF_WRITE(nbp)) != 0) {
|
||||
} else if ((error = bwrite(nbp)) != 0) {
|
||||
break;
|
||||
}
|
||||
ACQUIRE_LOCK(&lk);
|
||||
@ -5286,7 +5286,7 @@ flush_deplist(listhead, waitfor, errorp)
|
||||
FREE_LOCK(&lk);
|
||||
if (waitfor == MNT_NOWAIT) {
|
||||
bawrite(bp);
|
||||
} else if ((*errorp = BUF_WRITE(bp)) != 0) {
|
||||
} else if ((*errorp = bwrite(bp)) != 0) {
|
||||
ACQUIRE_LOCK(&lk);
|
||||
return (1);
|
||||
}
|
||||
@ -5395,7 +5395,7 @@ flush_pagedep_deps(pvp, mp, diraddhdp)
|
||||
bp = inodedep->id_buf;
|
||||
bp = getdirtybuf(&bp, NULL, MNT_WAIT);
|
||||
FREE_LOCK(&lk);
|
||||
if (bp && (error = BUF_WRITE(bp)) != 0)
|
||||
if (bp && (error = bwrite(bp)) != 0)
|
||||
break;
|
||||
ACQUIRE_LOCK(&lk);
|
||||
if (dap != LIST_FIRST(diraddhdp))
|
||||
@ -5412,7 +5412,7 @@ flush_pagedep_deps(pvp, mp, diraddhdp)
|
||||
brelse(bp);
|
||||
break;
|
||||
}
|
||||
if ((error = BUF_WRITE(bp)) != 0)
|
||||
if ((error = bwrite(bp)) != 0)
|
||||
break;
|
||||
ACQUIRE_LOCK(&lk);
|
||||
/*
|
||||
|
@ -805,7 +805,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp)
|
||||
* can lead to deadlock if we also hold a lock on
|
||||
* the newly entered node.
|
||||
*/
|
||||
if ((error = BUF_WRITE(bp)))
|
||||
if ((error = bwrite(bp)))
|
||||
return (error);
|
||||
if (tvp != NULL)
|
||||
VOP_UNLOCK(tvp, 0, td);
|
||||
@ -818,7 +818,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp)
|
||||
bdwrite(bp);
|
||||
return (UFS_UPDATE(dvp, 0));
|
||||
}
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
ret = UFS_UPDATE(dvp, 1);
|
||||
if (error == 0)
|
||||
return (ret);
|
||||
@ -945,7 +945,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp)
|
||||
bdwrite(bp);
|
||||
error = 0;
|
||||
} else {
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
}
|
||||
}
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
@ -1046,7 +1046,7 @@ ufs_dirremove(dvp, ip, flags, isrmdir)
|
||||
softdep_setup_remove(bp, dp, ip, isrmdir);
|
||||
}
|
||||
if (softdep_slowdown(dvp)) {
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
} else {
|
||||
bdwrite(bp);
|
||||
error = 0;
|
||||
@ -1059,12 +1059,12 @@ ufs_dirremove(dvp, ip, flags, isrmdir)
|
||||
ip->i_flag |= IN_CHANGE;
|
||||
}
|
||||
if (flags & DOWHITEOUT)
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
else if (DOINGASYNC(dvp) && dp->i_count != 0) {
|
||||
bdwrite(bp);
|
||||
error = 0;
|
||||
} else
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
}
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
/*
|
||||
@ -1115,7 +1115,7 @@ ufs_dirrewrite(dp, oip, newinum, newtype, isrmdir)
|
||||
bdwrite(bp);
|
||||
error = 0;
|
||||
} else {
|
||||
error = BUF_WRITE(bp);
|
||||
error = bwrite(bp);
|
||||
}
|
||||
}
|
||||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
|
@ -1601,7 +1601,7 @@ ufs_mkdir(ap)
|
||||
}
|
||||
if ((error = UFS_UPDATE(tvp, !(DOINGSOFTDEP(tvp) |
|
||||
DOINGASYNC(tvp)))) != 0) {
|
||||
(void)BUF_WRITE(bp);
|
||||
(void)bwrite(bp);
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
@ -1617,7 +1617,7 @@ ufs_mkdir(ap)
|
||||
*/
|
||||
if (DOINGASYNC(dvp))
|
||||
bdwrite(bp);
|
||||
else if (!DOINGSOFTDEP(dvp) && ((error = BUF_WRITE(bp))))
|
||||
else if (!DOINGSOFTDEP(dvp) && ((error = bwrite(bp))))
|
||||
goto bad;
|
||||
ufs_makedirentry(ip, cnp, &newdir);
|
||||
error = ufs_direnter(dvp, tvp, &newdir, cnp, bp);
|
||||
|
Loading…
Reference in New Issue
Block a user