Commit d0450948 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Alex Elder

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent d5689eaa
...@@ -2674,100 +2674,89 @@ xlog_recover_do_efd_trans( ...@@ -2674,100 +2674,89 @@ xlog_recover_do_efd_trans(
} }
/* /*
* Perform the transaction * Free up any resources allocated by the transaction
* *
* If the transaction modifies a buffer or inode, do it now. Otherwise, * Remember that EFIs, EFDs, and IUNLINKs are handled later.
* EFIs and EFDs get queued up by adding entries into the AIL for them.
*/ */
STATIC int STATIC void
xlog_recover_do_trans( xlog_recover_free_trans(
xlog_t *log, struct xlog_recover *trans)
xlog_recover_t *trans,
int pass)
{ {
int error = 0; xlog_recover_item_t *item, *n;
xlog_recover_item_t *item; int i;
error = xlog_recover_reorder_trans(log, trans, pass); list_for_each_entry_safe(item, n, &trans->r_itemq, ri_list) {
if (error) /* Free the regions in the item. */
return error; list_del(&item->ri_list);
for (i = 0; i < item->ri_cnt; i++)
kmem_free(item->ri_buf[i].i_addr);
/* Free the item itself */
kmem_free(item->ri_buf);
kmem_free(item);
}
/* Free the transaction recover structure */
kmem_free(trans);
}
list_for_each_entry(item, &trans->r_itemq, ri_list) { STATIC int
xlog_recover_commit_item(
struct log *log,
struct xlog_recover *trans,
xlog_recover_item_t *item,
int pass)
{
trace_xfs_log_recover_item_recover(log, trans, item, pass); trace_xfs_log_recover_item_recover(log, trans, item, pass);
switch (ITEM_TYPE(item)) { switch (ITEM_TYPE(item)) {
case XFS_LI_BUF: case XFS_LI_BUF:
error = xlog_recover_do_buffer_trans(log, item, pass); return xlog_recover_do_buffer_trans(log, item, pass);
break;
case XFS_LI_INODE: case XFS_LI_INODE:
error = xlog_recover_do_inode_trans(log, item, pass); return xlog_recover_do_inode_trans(log, item, pass);
break;
case XFS_LI_EFI: case XFS_LI_EFI:
error = xlog_recover_do_efi_trans(log, item, return xlog_recover_do_efi_trans(log, item, trans->r_lsn, pass);
trans->r_lsn, pass);
break;
case XFS_LI_EFD: case XFS_LI_EFD:
xlog_recover_do_efd_trans(log, item, pass); xlog_recover_do_efd_trans(log, item, pass);
error = 0; return 0;
break;
case XFS_LI_DQUOT: case XFS_LI_DQUOT:
error = xlog_recover_do_dquot_trans(log, item, pass); return xlog_recover_do_dquot_trans(log, item, pass);
break;
case XFS_LI_QUOTAOFF: case XFS_LI_QUOTAOFF:
error = xlog_recover_do_quotaoff_trans(log, item, return xlog_recover_do_quotaoff_trans(log, item, pass);
pass);
break;
default: default:
xlog_warn( xlog_warn(
"XFS: invalid item type (%d) xlog_recover_do_trans", ITEM_TYPE(item)); "XFS: invalid item type (%d) xlog_recover_do_trans", ITEM_TYPE(item));
ASSERT(0); ASSERT(0);
error = XFS_ERROR(EIO); return XFS_ERROR(EIO);
break;
}
if (error)
return error;
} }
return 0;
} }
/* /*
* Free up any resources allocated by the transaction * Perform the transaction.
* *
* Remember that EFIs, EFDs, and IUNLINKs are handled later. * If the transaction modifies a buffer or inode, do it now. Otherwise,
* EFIs and EFDs get queued up by adding entries into the AIL for them.
*/ */
STATIC void
xlog_recover_free_trans(
xlog_recover_t *trans)
{
xlog_recover_item_t *item, *n;
int i;
list_for_each_entry_safe(item, n, &trans->r_itemq, ri_list) {
/* Free the regions in the item. */
list_del(&item->ri_list);
for (i = 0; i < item->ri_cnt; i++)
kmem_free(item->ri_buf[i].i_addr);
/* Free the item itself */
kmem_free(item->ri_buf);
kmem_free(item);
}
/* Free the transaction recover structure */
kmem_free(trans);
}
STATIC int STATIC int
xlog_recover_commit_trans( xlog_recover_commit_trans(
xlog_t *log, struct log *log,
xlog_recover_t *trans, struct xlog_recover *trans,
int pass) int pass)
{ {
int error; int error = 0;
xlog_recover_item_t *item;
hlist_del(&trans->r_list); hlist_del(&trans->r_list);
if ((error = xlog_recover_do_trans(log, trans, pass)))
error = xlog_recover_reorder_trans(log, trans, pass);
if (error)
return error; return error;
xlog_recover_free_trans(trans); /* no error */
list_for_each_entry(item, &trans->r_itemq, ri_list) {
error = xlog_recover_commit_item(log, trans, item, pass);
if (error)
return error;
}
xlog_recover_free_trans(trans);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment