aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-02-15 18:35:09 -0500
committerAlex Elder <aelder@sgi.com>2010-03-01 17:35:37 -0500
commitd7e84f413726876c0ec66bbf90770f69841f7663 (patch)
treebb9b26dfcc82351cefe852def017a6fffdda2fc9 /fs/xfs
parent35a8a72f064105807b091a21e004893b219c9ed2 (diff)
xfs: factor common xfs_trans_bjoin code
Most of xfs_trans_bjoin is duplicated in xfs_trans_get_buf, xfs_trans_getsb and xfs_trans_read_buf. Add a new _xfs_trans_bjoin which can be called by all four functions. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_trans_buf.c216
1 files changed, 66 insertions, 150 deletions
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 5ffd544434e..fb586360d1c 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -46,6 +46,65 @@ STATIC xfs_buf_t *xfs_trans_buf_item_match(xfs_trans_t *, xfs_buftarg_t *,
46STATIC xfs_buf_t *xfs_trans_buf_item_match_all(xfs_trans_t *, xfs_buftarg_t *, 46STATIC xfs_buf_t *xfs_trans_buf_item_match_all(xfs_trans_t *, xfs_buftarg_t *,
47 xfs_daddr_t, int); 47 xfs_daddr_t, int);
48 48
49/*
50 * Add the locked buffer to the transaction.
51 *
52 * The buffer must be locked, and it cannot be associated with any
53 * transaction.
54 *
55 * If the buffer does not yet have a buf log item associated with it,
56 * then allocate one for it. Then add the buf item to the transaction.
57 */
58STATIC void
59_xfs_trans_bjoin(
60 struct xfs_trans *tp,
61 struct xfs_buf *bp,
62 int reset_recur)
63{
64 struct xfs_buf_log_item *bip;
65
66 ASSERT(XFS_BUF_ISBUSY(bp));
67 ASSERT(XFS_BUF_FSPRIVATE2(bp, void *) == NULL);
68
69 /*
70 * The xfs_buf_log_item pointer is stored in b_fsprivate. If
71 * it doesn't have one yet, then allocate one and initialize it.
72 * The checks to see if one is there are in xfs_buf_item_init().
73 */
74 xfs_buf_item_init(bp, tp->t_mountp);
75 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
76 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
77 ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
78 ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
79 if (reset_recur)
80 bip->bli_recur = 0;
81
82 /*
83 * Take a reference for this transaction on the buf item.
84 */
85 atomic_inc(&bip->bli_refcount);
86
87 /*
88 * Get a log_item_desc to point at the new item.
89 */
90 (void) xfs_trans_add_item(tp, (xfs_log_item_t *)bip);
91
92 /*
93 * Initialize b_fsprivate2 so we can find it with incore_match()
94 * in xfs_trans_get_buf() and friends above.
95 */
96 XFS_BUF_SET_FSPRIVATE2(bp, tp);
97
98}
99
100void
101xfs_trans_bjoin(
102 struct xfs_trans *tp,
103 struct xfs_buf *bp)
104{
105 _xfs_trans_bjoin(tp, bp, 0);
106 trace_xfs_trans_bjoin(bp->b_fspriv);
107}
49 108
50/* 109/*
51 * Get and lock the buffer for the caller if it is not already 110 * Get and lock the buffer for the caller if it is not already
@@ -132,40 +191,8 @@ xfs_trans_get_buf(xfs_trans_t *tp,
132 191
133 ASSERT(!XFS_BUF_GETERROR(bp)); 192 ASSERT(!XFS_BUF_GETERROR(bp));
134 193
135 /* 194 _xfs_trans_bjoin(tp, bp, 1);
136 * The xfs_buf_log_item pointer is stored in b_fsprivate. If 195 trace_xfs_trans_get_buf(bp->b_fspriv);
137 * it doesn't have one yet, then allocate one and initialize it.
138 * The checks to see if one is there are in xfs_buf_item_init().
139 */
140 xfs_buf_item_init(bp, tp->t_mountp);
141
142 /*
143 * Set the recursion count for the buffer within this transaction
144 * to 0.
145 */
146 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
147 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
148 ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
149 ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
150 bip->bli_recur = 0;
151
152 /*
153 * Take a reference for this transaction on the buf item.
154 */
155 atomic_inc(&bip->bli_refcount);
156
157 /*
158 * Get a log_item_desc to point at the new item.
159 */
160 (void) xfs_trans_add_item(tp, (xfs_log_item_t*)bip);
161
162 /*
163 * Initialize b_fsprivate2 so we can find it with incore_match()
164 * above.
165 */
166 XFS_BUF_SET_FSPRIVATE2(bp, tp);
167
168 trace_xfs_trans_get_buf(bip);
169 return (bp); 196 return (bp);
170} 197}
171 198
@@ -210,44 +237,11 @@ xfs_trans_getsb(xfs_trans_t *tp,
210 } 237 }
211 238
212 bp = xfs_getsb(mp, flags); 239 bp = xfs_getsb(mp, flags);
213 if (bp == NULL) { 240 if (bp == NULL)
214 return NULL; 241 return NULL;
215 }
216
217 /*
218 * The xfs_buf_log_item pointer is stored in b_fsprivate. If
219 * it doesn't have one yet, then allocate one and initialize it.
220 * The checks to see if one is there are in xfs_buf_item_init().
221 */
222 xfs_buf_item_init(bp, mp);
223
224 /*
225 * Set the recursion count for the buffer within this transaction
226 * to 0.
227 */
228 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
229 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
230 ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
231 ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
232 bip->bli_recur = 0;
233
234 /*
235 * Take a reference for this transaction on the buf item.
236 */
237 atomic_inc(&bip->bli_refcount);
238
239 /*
240 * Get a log_item_desc to point at the new item.
241 */
242 (void) xfs_trans_add_item(tp, (xfs_log_item_t*)bip);
243
244 /*
245 * Initialize b_fsprivate2 so we can find it with incore_match()
246 * above.
247 */
248 XFS_BUF_SET_FSPRIVATE2(bp, tp);
249 242
250 trace_xfs_trans_getsb(bip); 243 _xfs_trans_bjoin(tp, bp, 1);
244 trace_xfs_trans_getsb(bp->b_fspriv);
251 return (bp); 245 return (bp);
252} 246}
253 247
@@ -425,40 +419,9 @@ xfs_trans_read_buf(
425 if (XFS_FORCED_SHUTDOWN(mp)) 419 if (XFS_FORCED_SHUTDOWN(mp))
426 goto shutdown_abort; 420 goto shutdown_abort;
427 421
428 /* 422 _xfs_trans_bjoin(tp, bp, 1);
429 * The xfs_buf_log_item pointer is stored in b_fsprivate. If 423 trace_xfs_trans_read_buf(bp->b_fspriv);
430 * it doesn't have one yet, then allocate one and initialize it.
431 * The checks to see if one is there are in xfs_buf_item_init().
432 */
433 xfs_buf_item_init(bp, tp->t_mountp);
434 424
435 /*
436 * Set the recursion count for the buffer within this transaction
437 * to 0.
438 */
439 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
440 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
441 ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
442 ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
443 bip->bli_recur = 0;
444
445 /*
446 * Take a reference for this transaction on the buf item.
447 */
448 atomic_inc(&bip->bli_refcount);
449
450 /*
451 * Get a log_item_desc to point at the new item.
452 */
453 (void) xfs_trans_add_item(tp, (xfs_log_item_t*)bip);
454
455 /*
456 * Initialize b_fsprivate2 so we can find it with incore_match()
457 * above.
458 */
459 XFS_BUF_SET_FSPRIVATE2(bp, tp);
460
461 trace_xfs_trans_read_buf(bip);
462 *bpp = bp; 425 *bpp = bp;
463 return 0; 426 return 0;
464 427
@@ -623,53 +586,6 @@ xfs_trans_brelse(xfs_trans_t *tp,
623} 586}
624 587
625/* 588/*
626 * Add the locked buffer to the transaction.
627 * The buffer must be locked, and it cannot be associated with any
628 * transaction.
629 *
630 * If the buffer does not yet have a buf log item associated with it,
631 * then allocate one for it. Then add the buf item to the transaction.
632 */
633void
634xfs_trans_bjoin(xfs_trans_t *tp,
635 xfs_buf_t *bp)
636{
637 xfs_buf_log_item_t *bip;
638
639 ASSERT(XFS_BUF_ISBUSY(bp));
640 ASSERT(XFS_BUF_FSPRIVATE2(bp, void *) == NULL);
641
642 /*
643 * The xfs_buf_log_item pointer is stored in b_fsprivate. If
644 * it doesn't have one yet, then allocate one and initialize it.
645 * The checks to see if one is there are in xfs_buf_item_init().
646 */
647 xfs_buf_item_init(bp, tp->t_mountp);
648 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
649 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
650 ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
651 ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
652
653 /*
654 * Take a reference for this transaction on the buf item.
655 */
656 atomic_inc(&bip->bli_refcount);
657
658 /*
659 * Get a log_item_desc to point at the new item.
660 */
661 (void) xfs_trans_add_item(tp, (xfs_log_item_t *)bip);
662
663 /*
664 * Initialize b_fsprivate2 so we can find it with incore_match()
665 * in xfs_trans_get_buf() and friends above.
666 */
667 XFS_BUF_SET_FSPRIVATE2(bp, tp);
668
669 trace_xfs_trans_bjoin(bip);
670}
671
672/*
673 * Mark the buffer as not needing to be unlocked when the buf item's 589 * Mark the buffer as not needing to be unlocked when the buf item's
674 * IOP_UNLOCK() routine is called. The buffer must already be locked 590 * IOP_UNLOCK() routine is called. The buffer must already be locked
675 * and associated with the given transaction. 591 * and associated with the given transaction.