aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-08-23 04:28:06 -0400
committerAlex Elder <aelder@sgi.com>2011-10-11 22:14:59 -0400
commit61551f1ee536289084a4a8f1c4f187e2f371c440 (patch)
treeb160fd8779bafb6ec8e99f928bcb3e222a91817e
parent5a8ee6bafdd0ab8555adceac8b2cec539a552a1f (diff)
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Alex Elder <aelder@sgi.com>
-rw-r--r--fs/xfs/xfs_attr.c2
-rw-r--r--fs/xfs/xfs_buf.c21
-rw-r--r--fs/xfs/xfs_buf.h8
-rw-r--r--fs/xfs/xfs_buf_item.c4
-rw-r--r--fs/xfs/xfs_dquot.c6
-rw-r--r--fs/xfs/xfs_inode.c6
-rw-r--r--fs/xfs/xfs_log_recover.c9
-rw-r--r--fs/xfs/xfs_mount.c2
-rw-r--r--fs/xfs/xfs_qm.c3
-rw-r--r--fs/xfs/xfs_rw.c2
-rw-r--r--fs/xfs/xfs_trace.h1
-rw-r--r--fs/xfs/xfs_trans_buf.c5
12 files changed, 30 insertions, 39 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 160bcdc34a6e..b097fd5a2b3f 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -2189,7 +2189,7 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
2189 bp = xfs_incore(mp->m_ddev_targp, dblkno, blkcnt, XBF_TRYLOCK); 2189 bp = xfs_incore(mp->m_ddev_targp, dblkno, blkcnt, XBF_TRYLOCK);
2190 if (bp) { 2190 if (bp) {
2191 XFS_BUF_STALE(bp); 2191 XFS_BUF_STALE(bp);
2192 XFS_BUF_UNDELAYWRITE(bp); 2192 xfs_buf_delwri_dequeue(bp);
2193 xfs_buf_relse(bp); 2193 xfs_buf_relse(bp);
2194 bp = NULL; 2194 bp = NULL;
2195 } 2195 }
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 86c0945053c9..309eca75fad4 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -43,7 +43,6 @@
43 43
44static kmem_zone_t *xfs_buf_zone; 44static kmem_zone_t *xfs_buf_zone;
45STATIC int xfsbufd(void *); 45STATIC int xfsbufd(void *);
46STATIC void xfs_buf_delwri_queue(xfs_buf_t *);
47 46
48static struct workqueue_struct *xfslogd_workqueue; 47static struct workqueue_struct *xfslogd_workqueue;
49struct workqueue_struct *xfsdatad_workqueue; 48struct workqueue_struct *xfsdatad_workqueue;
@@ -937,9 +936,6 @@ void
937xfs_buf_unlock( 936xfs_buf_unlock(
938 struct xfs_buf *bp) 937 struct xfs_buf *bp)
939{ 938{
940 if ((bp->b_flags & (XBF_DELWRI|_XBF_DELWRI_Q)) == XBF_DELWRI)
941 xfs_buf_delwri_queue(bp);
942
943 XB_CLEAR_OWNER(bp); 939 XB_CLEAR_OWNER(bp);
944 up(&bp->b_sema); 940 up(&bp->b_sema);
945 941
@@ -1036,17 +1032,6 @@ xfs_bwrite(
1036 return error; 1032 return error;
1037} 1033}
1038 1034
1039void
1040xfs_bdwrite(
1041 void *mp,
1042 struct xfs_buf *bp)
1043{
1044 trace_xfs_buf_bdwrite(bp, _RET_IP_);
1045
1046 xfs_buf_delwri_queue(bp);
1047 xfs_buf_relse(bp);
1048}
1049
1050/* 1035/*
1051 * Called when we want to stop a buffer from getting written or read. 1036 * Called when we want to stop a buffer from getting written or read.
1052 * We attach the EIO error, muck with its flags, and call xfs_buf_ioend 1037 * We attach the EIO error, muck with its flags, and call xfs_buf_ioend
@@ -1069,7 +1054,7 @@ xfs_bioerror(
1069 * We're calling xfs_buf_ioend, so delete XBF_DONE flag. 1054 * We're calling xfs_buf_ioend, so delete XBF_DONE flag.
1070 */ 1055 */
1071 XFS_BUF_UNREAD(bp); 1056 XFS_BUF_UNREAD(bp);
1072 XFS_BUF_UNDELAYWRITE(bp); 1057 xfs_buf_delwri_dequeue(bp);
1073 XFS_BUF_UNDONE(bp); 1058 XFS_BUF_UNDONE(bp);
1074 XFS_BUF_STALE(bp); 1059 XFS_BUF_STALE(bp);
1075 1060
@@ -1098,7 +1083,7 @@ xfs_bioerror_relse(
1098 * change that interface. 1083 * change that interface.
1099 */ 1084 */
1100 XFS_BUF_UNREAD(bp); 1085 XFS_BUF_UNREAD(bp);
1101 XFS_BUF_UNDELAYWRITE(bp); 1086 xfs_buf_delwri_dequeue(bp);
1102 XFS_BUF_DONE(bp); 1087 XFS_BUF_DONE(bp);
1103 XFS_BUF_STALE(bp); 1088 XFS_BUF_STALE(bp);
1104 bp->b_iodone = NULL; 1089 bp->b_iodone = NULL;
@@ -1555,7 +1540,7 @@ error:
1555/* 1540/*
1556 * Delayed write buffer handling 1541 * Delayed write buffer handling
1557 */ 1542 */
1558STATIC void 1543void
1559xfs_buf_delwri_queue( 1544xfs_buf_delwri_queue(
1560 xfs_buf_t *bp) 1545 xfs_buf_t *bp)
1561{ 1546{
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 620972b8094d..f1a8933becb6 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -198,7 +198,6 @@ extern void xfs_buf_unlock(xfs_buf_t *);
198 198
199/* Buffer Read and Write Routines */ 199/* Buffer Read and Write Routines */
200extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp); 200extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp);
201extern void xfs_bdwrite(void *mp, xfs_buf_t *bp);
202 201
203extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *); 202extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
204extern int xfs_bdstrat_cb(struct xfs_buf *); 203extern int xfs_bdstrat_cb(struct xfs_buf *);
@@ -221,8 +220,9 @@ static inline int xfs_buf_geterror(xfs_buf_t *bp)
221extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t); 220extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t);
222 221
223/* Delayed Write Buffer Routines */ 222/* Delayed Write Buffer Routines */
224extern void xfs_buf_delwri_dequeue(xfs_buf_t *); 223extern void xfs_buf_delwri_queue(struct xfs_buf *);
225extern void xfs_buf_delwri_promote(xfs_buf_t *); 224extern void xfs_buf_delwri_dequeue(struct xfs_buf *);
225extern void xfs_buf_delwri_promote(struct xfs_buf *);
226 226
227/* Buffer Daemon Setup Routines */ 227/* Buffer Daemon Setup Routines */
228extern int xfs_buf_init(void); 228extern int xfs_buf_init(void);
@@ -251,8 +251,6 @@ void xfs_buf_stale(struct xfs_buf *bp);
251 XFS_BUF_DONE(bp); \ 251 XFS_BUF_DONE(bp); \
252 } while (0) 252 } while (0)
253 253
254#define XFS_BUF_DELAYWRITE(bp) ((bp)->b_flags |= XBF_DELWRI)
255#define XFS_BUF_UNDELAYWRITE(bp) xfs_buf_delwri_dequeue(bp)
256#define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI) 254#define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI)
257 255
258#define XFS_BUF_DONE(bp) ((bp)->b_flags |= XBF_DONE) 256#define XFS_BUF_DONE(bp) ((bp)->b_flags |= XBF_DONE)
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index cac2ecfa6746..3243083d8693 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -992,7 +992,7 @@ xfs_buf_iodone_callbacks(
992 xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */ 992 xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */
993 993
994 if (!XFS_BUF_ISSTALE(bp)) { 994 if (!XFS_BUF_ISSTALE(bp)) {
995 XFS_BUF_DELAYWRITE(bp); 995 xfs_buf_delwri_queue(bp);
996 XFS_BUF_DONE(bp); 996 XFS_BUF_DONE(bp);
997 } 997 }
998 ASSERT(bp->b_iodone != NULL); 998 ASSERT(bp->b_iodone != NULL);
@@ -1007,7 +1007,7 @@ xfs_buf_iodone_callbacks(
1007 */ 1007 */
1008 XFS_BUF_STALE(bp); 1008 XFS_BUF_STALE(bp);
1009 XFS_BUF_DONE(bp); 1009 XFS_BUF_DONE(bp);
1010 XFS_BUF_UNDELAYWRITE(bp); 1010 xfs_buf_delwri_dequeue(bp);
1011 1011
1012 trace_xfs_buf_error_relse(bp, _RET_IP_); 1012 trace_xfs_buf_error_relse(bp, _RET_IP_);
1013 1013
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index db62959bed13..0f78dd46415c 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -1243,8 +1243,10 @@ xfs_qm_dqflush(
1243 1243
1244 if (flags & SYNC_WAIT) 1244 if (flags & SYNC_WAIT)
1245 error = xfs_bwrite(mp, bp); 1245 error = xfs_bwrite(mp, bp);
1246 else 1246 else {
1247 xfs_bdwrite(mp, bp); 1247 xfs_buf_delwri_queue(bp);
1248 xfs_buf_relse(bp);
1249 }
1248 1250
1249 trace_xfs_dqflush_done(dqp); 1251 trace_xfs_dqflush_done(dqp);
1250 1252
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 0239a7c7c886..f8fe1c66d420 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2598,8 +2598,10 @@ xfs_iflush(
2598 2598
2599 if (flags & SYNC_WAIT) 2599 if (flags & SYNC_WAIT)
2600 error = xfs_bwrite(mp, bp); 2600 error = xfs_bwrite(mp, bp);
2601 else 2601 else {
2602 xfs_bdwrite(mp, bp); 2602 xfs_buf_delwri_queue(bp);
2603 xfs_buf_relse(bp);
2604 }
2603 return error; 2605 return error;
2604 2606
2605corrupt_out: 2607corrupt_out:
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index a199dbcee7d8..22946949bf5e 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2176,7 +2176,8 @@ xlog_recover_buffer_pass2(
2176 } else { 2176 } else {
2177 ASSERT(bp->b_target->bt_mount == mp); 2177 ASSERT(bp->b_target->bt_mount == mp);
2178 bp->b_iodone = xlog_recover_iodone; 2178 bp->b_iodone = xlog_recover_iodone;
2179 xfs_bdwrite(mp, bp); 2179 xfs_buf_delwri_queue(bp);
2180 xfs_buf_relse(bp);
2180 } 2181 }
2181 2182
2182 return (error); 2183 return (error);
@@ -2439,7 +2440,8 @@ xlog_recover_inode_pass2(
2439write_inode_buffer: 2440write_inode_buffer:
2440 ASSERT(bp->b_target->bt_mount == mp); 2441 ASSERT(bp->b_target->bt_mount == mp);
2441 bp->b_iodone = xlog_recover_iodone; 2442 bp->b_iodone = xlog_recover_iodone;
2442 xfs_bdwrite(mp, bp); 2443 xfs_buf_delwri_queue(bp);
2444 xfs_buf_relse(bp);
2443error: 2445error:
2444 if (need_free) 2446 if (need_free)
2445 kmem_free(in_f); 2447 kmem_free(in_f);
@@ -2561,7 +2563,8 @@ xlog_recover_dquot_pass2(
2561 ASSERT(dq_f->qlf_size == 2); 2563 ASSERT(dq_f->qlf_size == 2);
2562 ASSERT(bp->b_target->bt_mount == mp); 2564 ASSERT(bp->b_target->bt_mount == mp);
2563 bp->b_iodone = xlog_recover_iodone; 2565 bp->b_iodone = xlog_recover_iodone;
2564 xfs_bdwrite(mp, bp); 2566 xfs_buf_delwri_queue(bp);
2567 xfs_buf_relse(bp);
2565 2568
2566 return (0); 2569 return (0);
2567} 2570}
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 0081657ad985..a957e437bee1 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1612,7 +1612,7 @@ xfs_unmountfs_writesb(xfs_mount_t *mp)
1612 1612
1613 XFS_BUF_UNDONE(sbp); 1613 XFS_BUF_UNDONE(sbp);
1614 XFS_BUF_UNREAD(sbp); 1614 XFS_BUF_UNREAD(sbp);
1615 XFS_BUF_UNDELAYWRITE(sbp); 1615 xfs_buf_delwri_dequeue(sbp);
1616 XFS_BUF_WRITE(sbp); 1616 XFS_BUF_WRITE(sbp);
1617 XFS_BUF_UNASYNC(sbp); 1617 XFS_BUF_UNASYNC(sbp);
1618 ASSERT(sbp->b_target == mp->m_ddev_targp); 1618 ASSERT(sbp->b_target == mp->m_ddev_targp);
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 9a0aa76facdf..f51bef885e6d 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -1296,7 +1296,8 @@ xfs_qm_dqiter_bufs(
1296 break; 1296 break;
1297 1297
1298 xfs_qm_reset_dqcounts(mp, bp, firstid, type); 1298 xfs_qm_reset_dqcounts(mp, bp, firstid, type);
1299 xfs_bdwrite(mp, bp); 1299 xfs_buf_delwri_queue(bp);
1300 xfs_buf_relse(bp);
1300 /* 1301 /*
1301 * goto the next block. 1302 * goto the next block.
1302 */ 1303 */
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c
index c96a8a05ac03..99823c3b9aca 100644
--- a/fs/xfs/xfs_rw.c
+++ b/fs/xfs/xfs_rw.c
@@ -149,7 +149,7 @@ xfs_read_buf(
149 } 149 }
150 if (bp) { 150 if (bp) {
151 XFS_BUF_UNDONE(bp); 151 XFS_BUF_UNDONE(bp);
152 XFS_BUF_UNDELAYWRITE(bp); 152 xfs_buf_delwri_dequeue(bp);
153 XFS_BUF_STALE(bp); 153 XFS_BUF_STALE(bp);
154 /* 154 /*
155 * brelse clears B_ERROR and b_error 155 * brelse clears B_ERROR and b_error
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 690fc7a7bd72..bb5e660e0fab 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -320,7 +320,6 @@ DEFINE_BUF_EVENT(xfs_buf_rele);
320DEFINE_BUF_EVENT(xfs_buf_iodone); 320DEFINE_BUF_EVENT(xfs_buf_iodone);
321DEFINE_BUF_EVENT(xfs_buf_iorequest); 321DEFINE_BUF_EVENT(xfs_buf_iorequest);
322DEFINE_BUF_EVENT(xfs_buf_bawrite); 322DEFINE_BUF_EVENT(xfs_buf_bawrite);
323DEFINE_BUF_EVENT(xfs_buf_bdwrite);
324DEFINE_BUF_EVENT(xfs_buf_lock); 323DEFINE_BUF_EVENT(xfs_buf_lock);
325DEFINE_BUF_EVENT(xfs_buf_lock_done); 324DEFINE_BUF_EVENT(xfs_buf_lock_done);
326DEFINE_BUF_EVENT(xfs_buf_trylock); 325DEFINE_BUF_EVENT(xfs_buf_trylock);
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 137e2b9e2948..5e5196a269dd 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -643,13 +643,14 @@ xfs_trans_log_buf(xfs_trans_t *tp,
643 * inside the b_bdstrat callback so that this won't get written to 643 * inside the b_bdstrat callback so that this won't get written to
644 * disk. 644 * disk.
645 */ 645 */
646 XFS_BUF_DELAYWRITE(bp);
647 XFS_BUF_DONE(bp); 646 XFS_BUF_DONE(bp);
648 647
649 ASSERT(atomic_read(&bip->bli_refcount) > 0); 648 ASSERT(atomic_read(&bip->bli_refcount) > 0);
650 bp->b_iodone = xfs_buf_iodone_callbacks; 649 bp->b_iodone = xfs_buf_iodone_callbacks;
651 bip->bli_item.li_cb = xfs_buf_iodone; 650 bip->bli_item.li_cb = xfs_buf_iodone;
652 651
652 xfs_buf_delwri_queue(bp);
653
653 trace_xfs_trans_log_buf(bip); 654 trace_xfs_trans_log_buf(bip);
654 655
655 /* 656 /*
@@ -738,7 +739,7 @@ xfs_trans_binval(
738 * We set the stale bit in the buffer as well since we're getting 739 * We set the stale bit in the buffer as well since we're getting
739 * rid of it. 740 * rid of it.
740 */ 741 */
741 XFS_BUF_UNDELAYWRITE(bp); 742 xfs_buf_delwri_dequeue(bp);
742 XFS_BUF_STALE(bp); 743 XFS_BUF_STALE(bp);
743 bip->bli_flags |= XFS_BLI_STALE; 744 bip->bli_flags |= XFS_BLI_STALE;
744 bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY); 745 bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY);