aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_buf_item.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-06-23 04:11:15 -0400
committerAlex Elder <aelder@sgi.com>2010-07-26 14:16:35 -0400
commit7bfa31d8e0f90b65ff23be94fca65ce261b43fc8 (patch)
treedbf7bfd8ce06baca8fd23aeac3c99fa73c07a8bb /fs/xfs/xfs_buf_item.c
parent9412e3181c0ef82efc3d8e88d73e583ec10c34e9 (diff)
xfs: give xfs_item_ops methods the correct prototypes
Stop the function pointer casting madness and give all the xfs_item_ops the correct prototypes. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_buf_item.c')
-rw-r--r--fs/xfs/xfs_buf_item.c129
1 files changed, 66 insertions, 63 deletions
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 93899953c603..992d6be101cb 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -33,6 +33,12 @@
33 33
34kmem_zone_t *xfs_buf_item_zone; 34kmem_zone_t *xfs_buf_item_zone;
35 35
36static inline struct xfs_buf_log_item *BUF_ITEM(struct xfs_log_item *lip)
37{
38 return container_of(lip, struct xfs_buf_log_item, bli_item);
39}
40
41
36#ifdef XFS_TRANS_DEBUG 42#ifdef XFS_TRANS_DEBUG
37/* 43/*
38 * This function uses an alternate strategy for tracking the bytes 44 * This function uses an alternate strategy for tracking the bytes
@@ -150,12 +156,13 @@ STATIC void xfs_buf_do_callbacks(xfs_buf_t *bp, xfs_log_item_t *lip);
150 */ 156 */
151STATIC uint 157STATIC uint
152xfs_buf_item_size( 158xfs_buf_item_size(
153 xfs_buf_log_item_t *bip) 159 struct xfs_log_item *lip)
154{ 160{
155 uint nvecs; 161 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
156 int next_bit; 162 struct xfs_buf *bp = bip->bli_buf;
157 int last_bit; 163 uint nvecs;
158 xfs_buf_t *bp; 164 int next_bit;
165 int last_bit;
159 166
160 ASSERT(atomic_read(&bip->bli_refcount) > 0); 167 ASSERT(atomic_read(&bip->bli_refcount) > 0);
161 if (bip->bli_flags & XFS_BLI_STALE) { 168 if (bip->bli_flags & XFS_BLI_STALE) {
@@ -169,7 +176,6 @@ xfs_buf_item_size(
169 return 1; 176 return 1;
170 } 177 }
171 178
172 bp = bip->bli_buf;
173 ASSERT(bip->bli_flags & XFS_BLI_LOGGED); 179 ASSERT(bip->bli_flags & XFS_BLI_LOGGED);
174 nvecs = 1; 180 nvecs = 1;
175 last_bit = xfs_next_bit(bip->bli_format.blf_data_map, 181 last_bit = xfs_next_bit(bip->bli_format.blf_data_map,
@@ -218,13 +224,13 @@ xfs_buf_item_size(
218 */ 224 */
219STATIC void 225STATIC void
220xfs_buf_item_format( 226xfs_buf_item_format(
221 xfs_buf_log_item_t *bip, 227 struct xfs_log_item *lip,
222 xfs_log_iovec_t *log_vector) 228 struct xfs_log_iovec *vecp)
223{ 229{
230 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
231 struct xfs_buf *bp = bip->bli_buf;
224 uint base_size; 232 uint base_size;
225 uint nvecs; 233 uint nvecs;
226 xfs_log_iovec_t *vecp;
227 xfs_buf_t *bp;
228 int first_bit; 234 int first_bit;
229 int last_bit; 235 int last_bit;
230 int next_bit; 236 int next_bit;
@@ -234,8 +240,6 @@ xfs_buf_item_format(
234 ASSERT(atomic_read(&bip->bli_refcount) > 0); 240 ASSERT(atomic_read(&bip->bli_refcount) > 0);
235 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || 241 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
236 (bip->bli_flags & XFS_BLI_STALE)); 242 (bip->bli_flags & XFS_BLI_STALE));
237 bp = bip->bli_buf;
238 vecp = log_vector;
239 243
240 /* 244 /*
241 * The size of the base structure is the size of the 245 * The size of the base structure is the size of the
@@ -262,7 +266,7 @@ xfs_buf_item_format(
262 */ 266 */
263 if (bip->bli_flags & XFS_BLI_INODE_BUF) { 267 if (bip->bli_flags & XFS_BLI_INODE_BUF) {
264 if (!((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && 268 if (!((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) &&
265 xfs_log_item_in_current_chkpt(&bip->bli_item))) 269 xfs_log_item_in_current_chkpt(lip)))
266 bip->bli_format.blf_flags |= XFS_BLF_INODE_BUF; 270 bip->bli_format.blf_flags |= XFS_BLF_INODE_BUF;
267 bip->bli_flags &= ~XFS_BLI_INODE_BUF; 271 bip->bli_flags &= ~XFS_BLI_INODE_BUF;
268 } 272 }
@@ -365,21 +369,20 @@ xfs_buf_item_format(
365 369
366STATIC void 370STATIC void
367xfs_buf_item_pin( 371xfs_buf_item_pin(
368 xfs_buf_log_item_t *bip) 372 struct xfs_log_item *lip)
369{ 373{
370 xfs_buf_t *bp; 374 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
371 375
372 bp = bip->bli_buf; 376 ASSERT(XFS_BUF_ISBUSY(bip->bli_buf));
373 ASSERT(XFS_BUF_ISBUSY(bp));
374 ASSERT(atomic_read(&bip->bli_refcount) > 0); 377 ASSERT(atomic_read(&bip->bli_refcount) > 0);
375 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || 378 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
376 (bip->bli_flags & XFS_BLI_STALE)); 379 (bip->bli_flags & XFS_BLI_STALE));
380
377 atomic_inc(&bip->bli_refcount); 381 atomic_inc(&bip->bli_refcount);
378 trace_xfs_buf_item_pin(bip); 382 trace_xfs_buf_item_pin(bip);
379 xfs_bpin(bp); 383 xfs_bpin(bip->bli_buf);
380} 384}
381 385
382
383/* 386/*
384 * This is called to unpin the buffer associated with the buf log 387 * This is called to unpin the buffer associated with the buf log
385 * item which was previously pinned with a call to xfs_buf_item_pin(). 388 * item which was previously pinned with a call to xfs_buf_item_pin().
@@ -396,13 +399,14 @@ xfs_buf_item_pin(
396 */ 399 */
397STATIC void 400STATIC void
398xfs_buf_item_unpin( 401xfs_buf_item_unpin(
399 xfs_buf_log_item_t *bip, 402 struct xfs_log_item *lip,
400 int remove) 403 int remove)
401{ 404{
402 struct xfs_ail *ailp; 405 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
403 xfs_buf_t *bp = bip->bli_buf; 406 xfs_buf_t *bp = bip->bli_buf;
404 int freed; 407 struct xfs_ail *ailp = lip->li_ailp;
405 int stale = bip->bli_flags & XFS_BLI_STALE; 408 int stale = bip->bli_flags & XFS_BLI_STALE;
409 int freed;
406 410
407 ASSERT(XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *) == bip); 411 ASSERT(XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *) == bip);
408 ASSERT(atomic_read(&bip->bli_refcount) > 0); 412 ASSERT(atomic_read(&bip->bli_refcount) > 0);
@@ -410,8 +414,8 @@ xfs_buf_item_unpin(
410 trace_xfs_buf_item_unpin(bip); 414 trace_xfs_buf_item_unpin(bip);
411 415
412 freed = atomic_dec_and_test(&bip->bli_refcount); 416 freed = atomic_dec_and_test(&bip->bli_refcount);
413 ailp = bip->bli_item.li_ailp;
414 xfs_bunpin(bp); 417 xfs_bunpin(bp);
418
415 if (freed && stale) { 419 if (freed && stale) {
416 ASSERT(bip->bli_flags & XFS_BLI_STALE); 420 ASSERT(bip->bli_flags & XFS_BLI_STALE);
417 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); 421 ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
@@ -429,7 +433,7 @@ xfs_buf_item_unpin(
429 * in xfs_trans_uncommit() will ry to reference the 433 * in xfs_trans_uncommit() will ry to reference the
430 * buffer which we no longer have a hold on. 434 * buffer which we no longer have a hold on.
431 */ 435 */
432 xfs_trans_del_item(&bip->bli_item); 436 xfs_trans_del_item(lip);
433 437
434 /* 438 /*
435 * Since the transaction no longer refers to the buffer, 439 * Since the transaction no longer refers to the buffer,
@@ -468,11 +472,11 @@ xfs_buf_item_unpin(
468 */ 472 */
469STATIC uint 473STATIC uint
470xfs_buf_item_trylock( 474xfs_buf_item_trylock(
471 xfs_buf_log_item_t *bip) 475 struct xfs_log_item *lip)
472{ 476{
473 xfs_buf_t *bp; 477 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
478 struct xfs_buf *bp = bip->bli_buf;
474 479
475 bp = bip->bli_buf;
476 if (XFS_BUF_ISPINNED(bp)) 480 if (XFS_BUF_ISPINNED(bp))
477 return XFS_ITEM_PINNED; 481 return XFS_ITEM_PINNED;
478 if (!XFS_BUF_CPSEMA(bp)) 482 if (!XFS_BUF_CPSEMA(bp))
@@ -509,13 +513,12 @@ xfs_buf_item_trylock(
509 */ 513 */
510STATIC void 514STATIC void
511xfs_buf_item_unlock( 515xfs_buf_item_unlock(
512 xfs_buf_log_item_t *bip) 516 struct xfs_log_item *lip)
513{ 517{
514 int aborted; 518 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
515 xfs_buf_t *bp; 519 struct xfs_buf *bp = bip->bli_buf;
516 uint hold; 520 int aborted;
517 521 uint hold;
518 bp = bip->bli_buf;
519 522
520 /* Clear the buffer's association with this transaction. */ 523 /* Clear the buffer's association with this transaction. */
521 XFS_BUF_SET_FSPRIVATE2(bp, NULL); 524 XFS_BUF_SET_FSPRIVATE2(bp, NULL);
@@ -526,7 +529,7 @@ xfs_buf_item_unlock(
526 * (cancelled) buffers at unpin time, but we'll never go through the 529 * (cancelled) buffers at unpin time, but we'll never go through the
527 * pin/unpin cycle if we abort inside commit. 530 * pin/unpin cycle if we abort inside commit.
528 */ 531 */
529 aborted = (bip->bli_item.li_flags & XFS_LI_ABORTED) != 0; 532 aborted = (lip->li_flags & XFS_LI_ABORTED) != 0;
530 533
531 /* 534 /*
532 * Before possibly freeing the buf item, determine if we should 535 * Before possibly freeing the buf item, determine if we should
@@ -587,16 +590,16 @@ xfs_buf_item_unlock(
587 */ 590 */
588STATIC xfs_lsn_t 591STATIC xfs_lsn_t
589xfs_buf_item_committed( 592xfs_buf_item_committed(
590 xfs_buf_log_item_t *bip, 593 struct xfs_log_item *lip,
591 xfs_lsn_t lsn) 594 xfs_lsn_t lsn)
592{ 595{
596 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
597
593 trace_xfs_buf_item_committed(bip); 598 trace_xfs_buf_item_committed(bip);
594 599
595 if ((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && 600 if ((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && lip->li_lsn != 0)
596 (bip->bli_item.li_lsn != 0)) { 601 return lip->li_lsn;
597 return bip->bli_item.li_lsn; 602 return lsn;
598 }
599 return (lsn);
600} 603}
601 604
602/* 605/*
@@ -606,15 +609,16 @@ xfs_buf_item_committed(
606 */ 609 */
607STATIC void 610STATIC void
608xfs_buf_item_push( 611xfs_buf_item_push(
609 xfs_buf_log_item_t *bip) 612 struct xfs_log_item *lip)
610{ 613{
611 xfs_buf_t *bp; 614 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
615 struct xfs_buf *bp = bip->bli_buf;
612 616
613 ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); 617 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
618 ASSERT(!XFS_BUF_ISDELAYWRITE(bp));
619
614 trace_xfs_buf_item_push(bip); 620 trace_xfs_buf_item_push(bip);
615 621
616 bp = bip->bli_buf;
617 ASSERT(!XFS_BUF_ISDELAYWRITE(bp));
618 xfs_buf_relse(bp); 622 xfs_buf_relse(bp);
619} 623}
620 624
@@ -626,22 +630,24 @@ xfs_buf_item_push(
626 */ 630 */
627STATIC void 631STATIC void
628xfs_buf_item_pushbuf( 632xfs_buf_item_pushbuf(
629 xfs_buf_log_item_t *bip) 633 struct xfs_log_item *lip)
630{ 634{
631 xfs_buf_t *bp; 635 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
636 struct xfs_buf *bp = bip->bli_buf;
632 637
633 ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); 638 ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
639 ASSERT(XFS_BUF_ISDELAYWRITE(bp));
640
634 trace_xfs_buf_item_pushbuf(bip); 641 trace_xfs_buf_item_pushbuf(bip);
635 642
636 bp = bip->bli_buf;
637 ASSERT(XFS_BUF_ISDELAYWRITE(bp));
638 xfs_buf_delwri_promote(bp); 643 xfs_buf_delwri_promote(bp);
639 xfs_buf_relse(bp); 644 xfs_buf_relse(bp);
640} 645}
641 646
642/* ARGSUSED */
643STATIC void 647STATIC void
644xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn) 648xfs_buf_item_committing(
649 struct xfs_log_item *lip,
650 xfs_lsn_t commit_lsn)
645{ 651{
646} 652}
647 653
@@ -649,19 +655,16 @@ xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn)
649 * This is the ops vector shared by all buf log items. 655 * This is the ops vector shared by all buf log items.
650 */ 656 */
651static struct xfs_item_ops xfs_buf_item_ops = { 657static struct xfs_item_ops xfs_buf_item_ops = {
652 .iop_size = (uint(*)(xfs_log_item_t*))xfs_buf_item_size, 658 .iop_size = xfs_buf_item_size,
653 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 659 .iop_format = xfs_buf_item_format,
654 xfs_buf_item_format, 660 .iop_pin = xfs_buf_item_pin,
655 .iop_pin = (void(*)(xfs_log_item_t*))xfs_buf_item_pin, 661 .iop_unpin = xfs_buf_item_unpin,
656 .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_buf_item_unpin, 662 .iop_trylock = xfs_buf_item_trylock,
657 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_buf_item_trylock, 663 .iop_unlock = xfs_buf_item_unlock,
658 .iop_unlock = (void(*)(xfs_log_item_t*))xfs_buf_item_unlock, 664 .iop_committed = xfs_buf_item_committed,
659 .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) 665 .iop_push = xfs_buf_item_push,
660 xfs_buf_item_committed, 666 .iop_pushbuf = xfs_buf_item_pushbuf,
661 .iop_push = (void(*)(xfs_log_item_t*))xfs_buf_item_push, 667 .iop_committing = xfs_buf_item_committing
662 .iop_pushbuf = (void(*)(xfs_log_item_t*))xfs_buf_item_pushbuf,
663 .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t))
664 xfs_buf_item_committing
665}; 668};
666 669
667 670