aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_trans_buf.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:34 -0400
commite98c414f9a3134fe7efc56ef8f1d394b54bfd40e (patch)
treeb3d4696cfb4875af39041f9ddcd642bd1cd90a29 /fs/xfs/xfs_trans_buf.c
parent3400777ff03a3cd4fdbc6cb15676fc7e7ceefc00 (diff)
xfs: simplify log item descriptor tracking
Currently we track log item descriptor belonging to a transaction using a complex opencoded chunk allocator. This code has been there since day one and seems to work around the lack of an efficient slab allocator. This patch replaces it with dynamically allocated log item descriptors from a dedicated slab pool, linked to the transaction by a linked list. This allows to greatly simplify the log item descriptor tracking to the point where it's just a couple hundred lines in xfs_trans.c instead of a separate file. The external API has also been simplified while we're at it - the xfs_trans_add_item and xfs_trans_del_item functions to add/ delete items from a transaction have been simplified to the bare minium, and the xfs_trans_find_item function is replaced with a direct dereference of the li_desc field. All debug code walking the list of log items in a transaction is down to a simple list_for_each_entry. Note that we could easily use a singly linked list here instead of the double linked list from list.h as the fastpath only does deletion from sequential traversal. But given that we don't have one available as a library function yet I use the list.h functions for simplicity. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_trans_buf.c')
-rw-r--r--fs/xfs/xfs_trans_buf.c64
1 files changed, 15 insertions, 49 deletions
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index d1d08aa404b5..74a1c33e4098 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -47,36 +47,17 @@ xfs_trans_buf_item_match(
47 xfs_daddr_t blkno, 47 xfs_daddr_t blkno,
48 int len) 48 int len)
49{ 49{
50 xfs_log_item_chunk_t *licp; 50 struct xfs_log_item_desc *lidp;
51 xfs_log_item_desc_t *lidp; 51 struct xfs_buf_log_item *blip;
52 xfs_buf_log_item_t *blip;
53 int i;
54 52
55 len = BBTOB(len); 53 len = BBTOB(len);
56 for (licp = &tp->t_items; licp != NULL; licp = licp->lic_next) { 54 list_for_each_entry(lidp, &tp->t_items, lid_trans) {
57 if (xfs_lic_are_all_free(licp)) { 55 blip = (struct xfs_buf_log_item *)lidp->lid_item;
58 ASSERT(licp == &tp->t_items); 56 if (blip->bli_item.li_type == XFS_LI_BUF &&
59 ASSERT(licp->lic_next == NULL); 57 XFS_BUF_TARGET(blip->bli_buf) == target &&
60 return NULL; 58 XFS_BUF_ADDR(blip->bli_buf) == blkno &&
61 } 59 XFS_BUF_COUNT(blip->bli_buf) == len)
62 60 return blip->bli_buf;
63 for (i = 0; i < licp->lic_unused; i++) {
64 /*
65 * Skip unoccupied slots.
66 */
67 if (xfs_lic_isfree(licp, i))
68 continue;
69
70 lidp = xfs_lic_slot(licp, i);
71 blip = (xfs_buf_log_item_t *)lidp->lid_item;
72 if (blip->bli_item.li_type != XFS_LI_BUF)
73 continue;
74
75 if (XFS_BUF_TARGET(blip->bli_buf) == target &&
76 XFS_BUF_ADDR(blip->bli_buf) == blkno &&
77 XFS_BUF_COUNT(blip->bli_buf) == len)
78 return blip->bli_buf;
79 }
80 } 61 }
81 62
82 return NULL; 63 return NULL;
@@ -123,7 +104,7 @@ _xfs_trans_bjoin(
123 /* 104 /*
124 * Get a log_item_desc to point at the new item. 105 * Get a log_item_desc to point at the new item.
125 */ 106 */
126 (void) xfs_trans_add_item(tp, (xfs_log_item_t *)bip); 107 xfs_trans_add_item(tp, &bip->bli_item);
127 108
128 /* 109 /*
129 * Initialize b_fsprivate2 so we can find it with incore_match() 110 * Initialize b_fsprivate2 so we can find it with incore_match()
@@ -479,7 +460,6 @@ xfs_trans_brelse(xfs_trans_t *tp,
479{ 460{
480 xfs_buf_log_item_t *bip; 461 xfs_buf_log_item_t *bip;
481 xfs_log_item_t *lip; 462 xfs_log_item_t *lip;
482 xfs_log_item_desc_t *lidp;
483 463
484 /* 464 /*
485 * Default to a normal brelse() call if the tp is NULL. 465 * Default to a normal brelse() call if the tp is NULL.
@@ -510,13 +490,6 @@ xfs_trans_brelse(xfs_trans_t *tp,
510 ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_CANCEL)); 490 ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_CANCEL));
511 ASSERT(atomic_read(&bip->bli_refcount) > 0); 491 ASSERT(atomic_read(&bip->bli_refcount) > 0);
512 492
513 /*
514 * Find the item descriptor pointing to this buffer's
515 * log item. It must be there.
516 */
517 lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)bip);
518 ASSERT(lidp != NULL);
519
520 trace_xfs_trans_brelse(bip); 493 trace_xfs_trans_brelse(bip);
521 494
522 /* 495 /*
@@ -532,7 +505,7 @@ xfs_trans_brelse(xfs_trans_t *tp,
532 * If the buffer is dirty within this transaction, we can't 505 * If the buffer is dirty within this transaction, we can't
533 * release it until we commit. 506 * release it until we commit.
534 */ 507 */
535 if (lidp->lid_flags & XFS_LID_DIRTY) 508 if (bip->bli_item.li_desc->lid_flags & XFS_LID_DIRTY)
536 return; 509 return;
537 510
538 /* 511 /*
@@ -549,7 +522,7 @@ xfs_trans_brelse(xfs_trans_t *tp,
549 /* 522 /*
550 * Free up the log item descriptor tracking the released item. 523 * Free up the log item descriptor tracking the released item.
551 */ 524 */
552 xfs_trans_free_item(tp, lidp); 525 xfs_trans_del_item(&bip->bli_item);
553 526
554 /* 527 /*
555 * Clear the hold flag in the buf log item if it is set. 528 * Clear the hold flag in the buf log item if it is set.
@@ -661,7 +634,6 @@ xfs_trans_log_buf(xfs_trans_t *tp,
661 uint last) 634 uint last)
662{ 635{
663 xfs_buf_log_item_t *bip; 636 xfs_buf_log_item_t *bip;
664 xfs_log_item_desc_t *lidp;
665 637
666 ASSERT(XFS_BUF_ISBUSY(bp)); 638 ASSERT(XFS_BUF_ISBUSY(bp));
667 ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); 639 ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp);
@@ -703,11 +675,8 @@ xfs_trans_log_buf(xfs_trans_t *tp,
703 bip->bli_format.blf_flags &= ~XFS_BLF_CANCEL; 675 bip->bli_format.blf_flags &= ~XFS_BLF_CANCEL;
704 } 676 }
705 677
706 lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)bip);
707 ASSERT(lidp != NULL);
708
709 tp->t_flags |= XFS_TRANS_DIRTY; 678 tp->t_flags |= XFS_TRANS_DIRTY;
710 lidp->lid_flags |= XFS_LID_DIRTY; 679 bip->bli_item.li_desc->lid_flags |= XFS_LID_DIRTY;
711 bip->bli_flags |= XFS_BLI_LOGGED; 680 bip->bli_flags |= XFS_BLI_LOGGED;
712 xfs_buf_item_log(bip, first, last); 681 xfs_buf_item_log(bip, first, last);
713} 682}
@@ -736,7 +705,6 @@ xfs_trans_binval(
736 xfs_trans_t *tp, 705 xfs_trans_t *tp,
737 xfs_buf_t *bp) 706 xfs_buf_t *bp)
738{ 707{
739 xfs_log_item_desc_t *lidp;
740 xfs_buf_log_item_t *bip; 708 xfs_buf_log_item_t *bip;
741 709
742 ASSERT(XFS_BUF_ISBUSY(bp)); 710 ASSERT(XFS_BUF_ISBUSY(bp));
@@ -744,8 +712,6 @@ xfs_trans_binval(
744 ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); 712 ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
745 713
746 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *); 714 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
747 lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)bip);
748 ASSERT(lidp != NULL);
749 ASSERT(atomic_read(&bip->bli_refcount) > 0); 715 ASSERT(atomic_read(&bip->bli_refcount) > 0);
750 716
751 trace_xfs_trans_binval(bip); 717 trace_xfs_trans_binval(bip);
@@ -760,7 +726,7 @@ xfs_trans_binval(
760 ASSERT(!(bip->bli_flags & (XFS_BLI_LOGGED | XFS_BLI_DIRTY))); 726 ASSERT(!(bip->bli_flags & (XFS_BLI_LOGGED | XFS_BLI_DIRTY)));
761 ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_INODE_BUF)); 727 ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_INODE_BUF));
762 ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL); 728 ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL);
763 ASSERT(lidp->lid_flags & XFS_LID_DIRTY); 729 ASSERT(bip->bli_item.li_desc->lid_flags & XFS_LID_DIRTY);
764 ASSERT(tp->t_flags & XFS_TRANS_DIRTY); 730 ASSERT(tp->t_flags & XFS_TRANS_DIRTY);
765 return; 731 return;
766 } 732 }
@@ -793,7 +759,7 @@ xfs_trans_binval(
793 bip->bli_format.blf_flags |= XFS_BLF_CANCEL; 759 bip->bli_format.blf_flags |= XFS_BLF_CANCEL;
794 memset((char *)(bip->bli_format.blf_data_map), 0, 760 memset((char *)(bip->bli_format.blf_data_map), 0,
795 (bip->bli_format.blf_map_size * sizeof(uint))); 761 (bip->bli_format.blf_map_size * sizeof(uint)));
796 lidp->lid_flags |= XFS_LID_DIRTY; 762 bip->bli_item.li_desc->lid_flags |= XFS_LID_DIRTY;
797 tp->t_flags |= XFS_TRANS_DIRTY; 763 tp->t_flags |= XFS_TRANS_DIRTY;
798} 764}
799 765