aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-12-01 17:06:23 -0500
committerAlex Elder <aelder@sgi.com>2010-12-16 17:05:26 -0500
commitd0450948641b2090b5d467ba638bbebd40b20b21 (patch)
treec91ea11d5c6e95901ba5c87e02abf44c8fd2a225 /fs/xfs
parentd5689eaa0ac5588cf459ee32f86d5700dd7d6403 (diff)
xfs: refactor xlog_recover_commit_trans
Merge the call to xlog_recover_reorder_trans and the loop over the recovery items from xlog_recover_do_trans into xlog_recover_commit_trans, and keep the switch statement over the log item types as a separate helper. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_log_recover.c117
1 files changed, 53 insertions, 64 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 960afd41315e..26e18052a648 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2674,71 +2674,13 @@ xlog_recover_do_efd_trans(
2674} 2674}
2675 2675
2676/* 2676/*
2677 * Perform the transaction
2678 *
2679 * If the transaction modifies a buffer or inode, do it now. Otherwise,
2680 * EFIs and EFDs get queued up by adding entries into the AIL for them.
2681 */
2682STATIC int
2683xlog_recover_do_trans(
2684 xlog_t *log,
2685 xlog_recover_t *trans,
2686 int pass)
2687{
2688 int error = 0;
2689 xlog_recover_item_t *item;
2690
2691 error = xlog_recover_reorder_trans(log, trans, pass);
2692 if (error)
2693 return error;
2694
2695 list_for_each_entry(item, &trans->r_itemq, ri_list) {
2696 trace_xfs_log_recover_item_recover(log, trans, item, pass);
2697 switch (ITEM_TYPE(item)) {
2698 case XFS_LI_BUF:
2699 error = xlog_recover_do_buffer_trans(log, item, pass);
2700 break;
2701 case XFS_LI_INODE:
2702 error = xlog_recover_do_inode_trans(log, item, pass);
2703 break;
2704 case XFS_LI_EFI:
2705 error = xlog_recover_do_efi_trans(log, item,
2706 trans->r_lsn, pass);
2707 break;
2708 case XFS_LI_EFD:
2709 xlog_recover_do_efd_trans(log, item, pass);
2710 error = 0;
2711 break;
2712 case XFS_LI_DQUOT:
2713 error = xlog_recover_do_dquot_trans(log, item, pass);
2714 break;
2715 case XFS_LI_QUOTAOFF:
2716 error = xlog_recover_do_quotaoff_trans(log, item,
2717 pass);
2718 break;
2719 default:
2720 xlog_warn(
2721 "XFS: invalid item type (%d) xlog_recover_do_trans", ITEM_TYPE(item));
2722 ASSERT(0);
2723 error = XFS_ERROR(EIO);
2724 break;
2725 }
2726
2727 if (error)
2728 return error;
2729 }
2730
2731 return 0;
2732}
2733
2734/*
2735 * Free up any resources allocated by the transaction 2677 * Free up any resources allocated by the transaction
2736 * 2678 *
2737 * Remember that EFIs, EFDs, and IUNLINKs are handled later. 2679 * Remember that EFIs, EFDs, and IUNLINKs are handled later.
2738 */ 2680 */
2739STATIC void 2681STATIC void
2740xlog_recover_free_trans( 2682xlog_recover_free_trans(
2741 xlog_recover_t *trans) 2683 struct xlog_recover *trans)
2742{ 2684{
2743 xlog_recover_item_t *item, *n; 2685 xlog_recover_item_t *item, *n;
2744 int i; 2686 int i;
@@ -2757,17 +2699,64 @@ xlog_recover_free_trans(
2757} 2699}
2758 2700
2759STATIC int 2701STATIC int
2702xlog_recover_commit_item(
2703 struct log *log,
2704 struct xlog_recover *trans,
2705 xlog_recover_item_t *item,
2706 int pass)
2707{
2708 trace_xfs_log_recover_item_recover(log, trans, item, pass);
2709
2710 switch (ITEM_TYPE(item)) {
2711 case XFS_LI_BUF:
2712 return xlog_recover_do_buffer_trans(log, item, pass);
2713 case XFS_LI_INODE:
2714 return xlog_recover_do_inode_trans(log, item, pass);
2715 case XFS_LI_EFI:
2716 return xlog_recover_do_efi_trans(log, item, trans->r_lsn, pass);
2717 case XFS_LI_EFD:
2718 xlog_recover_do_efd_trans(log, item, pass);
2719 return 0;
2720 case XFS_LI_DQUOT:
2721 return xlog_recover_do_dquot_trans(log, item, pass);
2722 case XFS_LI_QUOTAOFF:
2723 return xlog_recover_do_quotaoff_trans(log, item, pass);
2724 default:
2725 xlog_warn(
2726 "XFS: invalid item type (%d) xlog_recover_do_trans", ITEM_TYPE(item));
2727 ASSERT(0);
2728 return XFS_ERROR(EIO);
2729 }
2730}
2731
2732/*
2733 * Perform the transaction.
2734 *
2735 * If the transaction modifies a buffer or inode, do it now. Otherwise,
2736 * EFIs and EFDs get queued up by adding entries into the AIL for them.
2737 */
2738STATIC int
2760xlog_recover_commit_trans( 2739xlog_recover_commit_trans(
2761 xlog_t *log, 2740 struct log *log,
2762 xlog_recover_t *trans, 2741 struct xlog_recover *trans,
2763 int pass) 2742 int pass)
2764{ 2743{
2765 int error; 2744 int error = 0;
2745 xlog_recover_item_t *item;
2766 2746
2767 hlist_del(&trans->r_list); 2747 hlist_del(&trans->r_list);
2768 if ((error = xlog_recover_do_trans(log, trans, pass))) 2748
2749 error = xlog_recover_reorder_trans(log, trans, pass);
2750 if (error)
2769 return error; 2751 return error;
2770 xlog_recover_free_trans(trans); /* no error */ 2752
2753 list_for_each_entry(item, &trans->r_itemq, ri_list) {
2754 error = xlog_recover_commit_item(log, trans, item, pass);
2755 if (error)
2756 return error;
2757 }
2758
2759 xlog_recover_free_trans(trans);
2771 return 0; 2760 return 0;
2772} 2761}
2773 2762