提交 61551f1e 编写于 作者: C Christoph Hellwig 提交者: Alex Elder

xfs: call xfs_buf_delwri_queue directly

Unify the ways we add buffers to the delwri queue by always calling
xfs_buf_delwri_queue directly.  The xfs_bdwrite functions is removed and
opencoded in its callers, and the two places setting XBF_DELWRI while a
buffer is locked and expecting xfs_buf_unlock to pick it up are converted
to call xfs_buf_delwri_queue directly, too.  Also replace the
XFS_BUF_UNDELAYWRITE macro with direct calls to xfs_buf_delwri_dequeue
to make the explicit queuing/dequeuing more obvious.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDave Chinner <dchinner@redhat.com>
Signed-off-by: NAlex Elder <aelder@sgi.com>
上级 5a8ee6ba
...@@ -2189,7 +2189,7 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args) ...@@ -2189,7 +2189,7 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
bp = xfs_incore(mp->m_ddev_targp, dblkno, blkcnt, XBF_TRYLOCK); bp = xfs_incore(mp->m_ddev_targp, dblkno, blkcnt, XBF_TRYLOCK);
if (bp) { if (bp) {
XFS_BUF_STALE(bp); XFS_BUF_STALE(bp);
XFS_BUF_UNDELAYWRITE(bp); xfs_buf_delwri_dequeue(bp);
xfs_buf_relse(bp); xfs_buf_relse(bp);
bp = NULL; bp = NULL;
} }
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
static kmem_zone_t *xfs_buf_zone; static kmem_zone_t *xfs_buf_zone;
STATIC int xfsbufd(void *); STATIC int xfsbufd(void *);
STATIC void xfs_buf_delwri_queue(xfs_buf_t *);
static struct workqueue_struct *xfslogd_workqueue; static struct workqueue_struct *xfslogd_workqueue;
struct workqueue_struct *xfsdatad_workqueue; struct workqueue_struct *xfsdatad_workqueue;
...@@ -937,9 +936,6 @@ void ...@@ -937,9 +936,6 @@ void
xfs_buf_unlock( xfs_buf_unlock(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
if ((bp->b_flags & (XBF_DELWRI|_XBF_DELWRI_Q)) == XBF_DELWRI)
xfs_buf_delwri_queue(bp);
XB_CLEAR_OWNER(bp); XB_CLEAR_OWNER(bp);
up(&bp->b_sema); up(&bp->b_sema);
...@@ -1036,17 +1032,6 @@ xfs_bwrite( ...@@ -1036,17 +1032,6 @@ xfs_bwrite(
return error; return error;
} }
void
xfs_bdwrite(
void *mp,
struct xfs_buf *bp)
{
trace_xfs_buf_bdwrite(bp, _RET_IP_);
xfs_buf_delwri_queue(bp);
xfs_buf_relse(bp);
}
/* /*
* Called when we want to stop a buffer from getting written or read. * Called when we want to stop a buffer from getting written or read.
* We attach the EIO error, muck with its flags, and call xfs_buf_ioend * We attach the EIO error, muck with its flags, and call xfs_buf_ioend
...@@ -1069,7 +1054,7 @@ xfs_bioerror( ...@@ -1069,7 +1054,7 @@ xfs_bioerror(
* We're calling xfs_buf_ioend, so delete XBF_DONE flag. * We're calling xfs_buf_ioend, so delete XBF_DONE flag.
*/ */
XFS_BUF_UNREAD(bp); XFS_BUF_UNREAD(bp);
XFS_BUF_UNDELAYWRITE(bp); xfs_buf_delwri_dequeue(bp);
XFS_BUF_UNDONE(bp); XFS_BUF_UNDONE(bp);
XFS_BUF_STALE(bp); XFS_BUF_STALE(bp);
...@@ -1098,7 +1083,7 @@ xfs_bioerror_relse( ...@@ -1098,7 +1083,7 @@ xfs_bioerror_relse(
* change that interface. * change that interface.
*/ */
XFS_BUF_UNREAD(bp); XFS_BUF_UNREAD(bp);
XFS_BUF_UNDELAYWRITE(bp); xfs_buf_delwri_dequeue(bp);
XFS_BUF_DONE(bp); XFS_BUF_DONE(bp);
XFS_BUF_STALE(bp); XFS_BUF_STALE(bp);
bp->b_iodone = NULL; bp->b_iodone = NULL;
...@@ -1555,7 +1540,7 @@ xfs_alloc_buftarg( ...@@ -1555,7 +1540,7 @@ xfs_alloc_buftarg(
/* /*
* Delayed write buffer handling * Delayed write buffer handling
*/ */
STATIC void void
xfs_buf_delwri_queue( xfs_buf_delwri_queue(
xfs_buf_t *bp) xfs_buf_t *bp)
{ {
......
...@@ -198,7 +198,6 @@ extern void xfs_buf_unlock(xfs_buf_t *); ...@@ -198,7 +198,6 @@ extern void xfs_buf_unlock(xfs_buf_t *);
/* Buffer Read and Write Routines */ /* Buffer Read and Write Routines */
extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp); extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp);
extern void xfs_bdwrite(void *mp, xfs_buf_t *bp);
extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *); extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
extern int xfs_bdstrat_cb(struct xfs_buf *); extern int xfs_bdstrat_cb(struct xfs_buf *);
...@@ -221,8 +220,9 @@ static inline int xfs_buf_geterror(xfs_buf_t *bp) ...@@ -221,8 +220,9 @@ static inline int xfs_buf_geterror(xfs_buf_t *bp)
extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t); extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t);
/* Delayed Write Buffer Routines */ /* Delayed Write Buffer Routines */
extern void xfs_buf_delwri_dequeue(xfs_buf_t *); extern void xfs_buf_delwri_queue(struct xfs_buf *);
extern void xfs_buf_delwri_promote(xfs_buf_t *); extern void xfs_buf_delwri_dequeue(struct xfs_buf *);
extern void xfs_buf_delwri_promote(struct xfs_buf *);
/* Buffer Daemon Setup Routines */ /* Buffer Daemon Setup Routines */
extern int xfs_buf_init(void); extern int xfs_buf_init(void);
...@@ -251,8 +251,6 @@ void xfs_buf_stale(struct xfs_buf *bp); ...@@ -251,8 +251,6 @@ void xfs_buf_stale(struct xfs_buf *bp);
XFS_BUF_DONE(bp); \ XFS_BUF_DONE(bp); \
} while (0) } while (0)
#define XFS_BUF_DELAYWRITE(bp) ((bp)->b_flags |= XBF_DELWRI)
#define XFS_BUF_UNDELAYWRITE(bp) xfs_buf_delwri_dequeue(bp)
#define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI) #define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI)
#define XFS_BUF_DONE(bp) ((bp)->b_flags |= XBF_DONE) #define XFS_BUF_DONE(bp) ((bp)->b_flags |= XBF_DONE)
......
...@@ -992,7 +992,7 @@ xfs_buf_iodone_callbacks( ...@@ -992,7 +992,7 @@ xfs_buf_iodone_callbacks(
xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */ xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */
if (!XFS_BUF_ISSTALE(bp)) { if (!XFS_BUF_ISSTALE(bp)) {
XFS_BUF_DELAYWRITE(bp); xfs_buf_delwri_queue(bp);
XFS_BUF_DONE(bp); XFS_BUF_DONE(bp);
} }
ASSERT(bp->b_iodone != NULL); ASSERT(bp->b_iodone != NULL);
...@@ -1007,7 +1007,7 @@ xfs_buf_iodone_callbacks( ...@@ -1007,7 +1007,7 @@ xfs_buf_iodone_callbacks(
*/ */
XFS_BUF_STALE(bp); XFS_BUF_STALE(bp);
XFS_BUF_DONE(bp); XFS_BUF_DONE(bp);
XFS_BUF_UNDELAYWRITE(bp); xfs_buf_delwri_dequeue(bp);
trace_xfs_buf_error_relse(bp, _RET_IP_); trace_xfs_buf_error_relse(bp, _RET_IP_);
......
...@@ -1243,8 +1243,10 @@ xfs_qm_dqflush( ...@@ -1243,8 +1243,10 @@ xfs_qm_dqflush(
if (flags & SYNC_WAIT) if (flags & SYNC_WAIT)
error = xfs_bwrite(mp, bp); error = xfs_bwrite(mp, bp);
else else {
xfs_bdwrite(mp, bp); xfs_buf_delwri_queue(bp);
xfs_buf_relse(bp);
}
trace_xfs_dqflush_done(dqp); trace_xfs_dqflush_done(dqp);
......
...@@ -2598,8 +2598,10 @@ xfs_iflush( ...@@ -2598,8 +2598,10 @@ xfs_iflush(
if (flags & SYNC_WAIT) if (flags & SYNC_WAIT)
error = xfs_bwrite(mp, bp); error = xfs_bwrite(mp, bp);
else else {
xfs_bdwrite(mp, bp); xfs_buf_delwri_queue(bp);
xfs_buf_relse(bp);
}
return error; return error;
corrupt_out: corrupt_out:
......
...@@ -2176,7 +2176,8 @@ xlog_recover_buffer_pass2( ...@@ -2176,7 +2176,8 @@ xlog_recover_buffer_pass2(
} else { } else {
ASSERT(bp->b_target->bt_mount == mp); ASSERT(bp->b_target->bt_mount == mp);
bp->b_iodone = xlog_recover_iodone; bp->b_iodone = xlog_recover_iodone;
xfs_bdwrite(mp, bp); xfs_buf_delwri_queue(bp);
xfs_buf_relse(bp);
} }
return (error); return (error);
...@@ -2439,7 +2440,8 @@ xlog_recover_inode_pass2( ...@@ -2439,7 +2440,8 @@ xlog_recover_inode_pass2(
write_inode_buffer: write_inode_buffer:
ASSERT(bp->b_target->bt_mount == mp); ASSERT(bp->b_target->bt_mount == mp);
bp->b_iodone = xlog_recover_iodone; bp->b_iodone = xlog_recover_iodone;
xfs_bdwrite(mp, bp); xfs_buf_delwri_queue(bp);
xfs_buf_relse(bp);
error: error:
if (need_free) if (need_free)
kmem_free(in_f); kmem_free(in_f);
...@@ -2561,7 +2563,8 @@ xlog_recover_dquot_pass2( ...@@ -2561,7 +2563,8 @@ xlog_recover_dquot_pass2(
ASSERT(dq_f->qlf_size == 2); ASSERT(dq_f->qlf_size == 2);
ASSERT(bp->b_target->bt_mount == mp); ASSERT(bp->b_target->bt_mount == mp);
bp->b_iodone = xlog_recover_iodone; bp->b_iodone = xlog_recover_iodone;
xfs_bdwrite(mp, bp); xfs_buf_delwri_queue(bp);
xfs_buf_relse(bp);
return (0); return (0);
} }
......
...@@ -1612,7 +1612,7 @@ xfs_unmountfs_writesb(xfs_mount_t *mp) ...@@ -1612,7 +1612,7 @@ xfs_unmountfs_writesb(xfs_mount_t *mp)
XFS_BUF_UNDONE(sbp); XFS_BUF_UNDONE(sbp);
XFS_BUF_UNREAD(sbp); XFS_BUF_UNREAD(sbp);
XFS_BUF_UNDELAYWRITE(sbp); xfs_buf_delwri_dequeue(sbp);
XFS_BUF_WRITE(sbp); XFS_BUF_WRITE(sbp);
XFS_BUF_UNASYNC(sbp); XFS_BUF_UNASYNC(sbp);
ASSERT(sbp->b_target == mp->m_ddev_targp); ASSERT(sbp->b_target == mp->m_ddev_targp);
......
...@@ -1296,7 +1296,8 @@ xfs_qm_dqiter_bufs( ...@@ -1296,7 +1296,8 @@ xfs_qm_dqiter_bufs(
break; break;
xfs_qm_reset_dqcounts(mp, bp, firstid, type); xfs_qm_reset_dqcounts(mp, bp, firstid, type);
xfs_bdwrite(mp, bp); xfs_buf_delwri_queue(bp);
xfs_buf_relse(bp);
/* /*
* goto the next block. * goto the next block.
*/ */
......
...@@ -149,7 +149,7 @@ xfs_read_buf( ...@@ -149,7 +149,7 @@ xfs_read_buf(
} }
if (bp) { if (bp) {
XFS_BUF_UNDONE(bp); XFS_BUF_UNDONE(bp);
XFS_BUF_UNDELAYWRITE(bp); xfs_buf_delwri_dequeue(bp);
XFS_BUF_STALE(bp); XFS_BUF_STALE(bp);
/* /*
* brelse clears B_ERROR and b_error * brelse clears B_ERROR and b_error
......
...@@ -320,7 +320,6 @@ DEFINE_BUF_EVENT(xfs_buf_rele); ...@@ -320,7 +320,6 @@ DEFINE_BUF_EVENT(xfs_buf_rele);
DEFINE_BUF_EVENT(xfs_buf_iodone); DEFINE_BUF_EVENT(xfs_buf_iodone);
DEFINE_BUF_EVENT(xfs_buf_iorequest); DEFINE_BUF_EVENT(xfs_buf_iorequest);
DEFINE_BUF_EVENT(xfs_buf_bawrite); DEFINE_BUF_EVENT(xfs_buf_bawrite);
DEFINE_BUF_EVENT(xfs_buf_bdwrite);
DEFINE_BUF_EVENT(xfs_buf_lock); DEFINE_BUF_EVENT(xfs_buf_lock);
DEFINE_BUF_EVENT(xfs_buf_lock_done); DEFINE_BUF_EVENT(xfs_buf_lock_done);
DEFINE_BUF_EVENT(xfs_buf_trylock); DEFINE_BUF_EVENT(xfs_buf_trylock);
......
...@@ -643,13 +643,14 @@ xfs_trans_log_buf(xfs_trans_t *tp, ...@@ -643,13 +643,14 @@ xfs_trans_log_buf(xfs_trans_t *tp,
* inside the b_bdstrat callback so that this won't get written to * inside the b_bdstrat callback so that this won't get written to
* disk. * disk.
*/ */
XFS_BUF_DELAYWRITE(bp);
XFS_BUF_DONE(bp); XFS_BUF_DONE(bp);
ASSERT(atomic_read(&bip->bli_refcount) > 0); ASSERT(atomic_read(&bip->bli_refcount) > 0);
bp->b_iodone = xfs_buf_iodone_callbacks; bp->b_iodone = xfs_buf_iodone_callbacks;
bip->bli_item.li_cb = xfs_buf_iodone; bip->bli_item.li_cb = xfs_buf_iodone;
xfs_buf_delwri_queue(bp);
trace_xfs_trans_log_buf(bip); trace_xfs_trans_log_buf(bip);
/* /*
...@@ -738,7 +739,7 @@ xfs_trans_binval( ...@@ -738,7 +739,7 @@ xfs_trans_binval(
* We set the stale bit in the buffer as well since we're getting * We set the stale bit in the buffer as well since we're getting
* rid of it. * rid of it.
*/ */
XFS_BUF_UNDELAYWRITE(bp); xfs_buf_delwri_dequeue(bp);
XFS_BUF_STALE(bp); XFS_BUF_STALE(bp);
bip->bli_flags |= XFS_BLI_STALE; bip->bli_flags |= XFS_BLI_STALE;
bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY); bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册