xfs: refactor log recovery item sorting into a generic dispatch structure
Create a generic dispatch structure to delegate recovery of different log item types into various code modules. This will enable us to move code specific to a particular log item type out of xfs_log_recover.c and into the log item source. The first operation we virtualize is the log item sorting. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
@ -1785,6 +1785,34 @@ xlog_clear_stale_blocks(
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
static const struct xlog_recover_item_ops *xlog_recover_item_ops[] = {
|
||||
&xlog_buf_item_ops,
|
||||
&xlog_inode_item_ops,
|
||||
&xlog_dquot_item_ops,
|
||||
&xlog_quotaoff_item_ops,
|
||||
&xlog_icreate_item_ops,
|
||||
&xlog_efi_item_ops,
|
||||
&xlog_efd_item_ops,
|
||||
&xlog_rui_item_ops,
|
||||
&xlog_rud_item_ops,
|
||||
&xlog_cui_item_ops,
|
||||
&xlog_cud_item_ops,
|
||||
&xlog_bui_item_ops,
|
||||
&xlog_bud_item_ops,
|
||||
};
|
||||
|
||||
static const struct xlog_recover_item_ops *
|
||||
xlog_find_item_ops(
|
||||
struct xlog_recover_item *item)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(xlog_recover_item_ops); i++)
|
||||
if (ITEM_TYPE(item) == xlog_recover_item_ops[i]->item_type)
|
||||
return xlog_recover_item_ops[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sort the log items in the transaction.
|
||||
@ -1851,41 +1879,10 @@ xlog_recover_reorder_trans(
|
||||
|
||||
list_splice_init(&trans->r_itemq, &sort_list);
|
||||
list_for_each_entry_safe(item, n, &sort_list, ri_list) {
|
||||
xfs_buf_log_format_t *buf_f = item->ri_buf[0].i_addr;
|
||||
enum xlog_recover_reorder fate = XLOG_REORDER_ITEM_LIST;
|
||||
|
||||
switch (ITEM_TYPE(item)) {
|
||||
case XFS_LI_ICREATE:
|
||||
list_move_tail(&item->ri_list, &buffer_list);
|
||||
break;
|
||||
case XFS_LI_BUF:
|
||||
if (buf_f->blf_flags & XFS_BLF_CANCEL) {
|
||||
trace_xfs_log_recover_item_reorder_head(log,
|
||||
trans, item, pass);
|
||||
list_move(&item->ri_list, &cancel_list);
|
||||
break;
|
||||
}
|
||||
if (buf_f->blf_flags & XFS_BLF_INODE_BUF) {
|
||||
list_move(&item->ri_list, &inode_buffer_list);
|
||||
break;
|
||||
}
|
||||
list_move_tail(&item->ri_list, &buffer_list);
|
||||
break;
|
||||
case XFS_LI_INODE:
|
||||
case XFS_LI_DQUOT:
|
||||
case XFS_LI_QUOTAOFF:
|
||||
case XFS_LI_EFD:
|
||||
case XFS_LI_EFI:
|
||||
case XFS_LI_RUI:
|
||||
case XFS_LI_RUD:
|
||||
case XFS_LI_CUI:
|
||||
case XFS_LI_CUD:
|
||||
case XFS_LI_BUI:
|
||||
case XFS_LI_BUD:
|
||||
trace_xfs_log_recover_item_reorder_tail(log,
|
||||
trans, item, pass);
|
||||
list_move_tail(&item->ri_list, &item_list);
|
||||
break;
|
||||
default:
|
||||
item->ri_ops = xlog_find_item_ops(item);
|
||||
if (!item->ri_ops) {
|
||||
xfs_warn(log->l_mp,
|
||||
"%s: unrecognized type of log operation (%d)",
|
||||
__func__, ITEM_TYPE(item));
|
||||
@ -1896,11 +1893,33 @@ xlog_recover_reorder_trans(
|
||||
*/
|
||||
if (!list_empty(&sort_list))
|
||||
list_splice_init(&sort_list, &trans->r_itemq);
|
||||
error = -EIO;
|
||||
goto out;
|
||||
error = -EFSCORRUPTED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (item->ri_ops->reorder)
|
||||
fate = item->ri_ops->reorder(item);
|
||||
|
||||
switch (fate) {
|
||||
case XLOG_REORDER_BUFFER_LIST:
|
||||
list_move_tail(&item->ri_list, &buffer_list);
|
||||
break;
|
||||
case XLOG_REORDER_CANCEL_LIST:
|
||||
trace_xfs_log_recover_item_reorder_head(log,
|
||||
trans, item, pass);
|
||||
list_move(&item->ri_list, &cancel_list);
|
||||
break;
|
||||
case XLOG_REORDER_INODE_BUFFER_LIST:
|
||||
list_move(&item->ri_list, &inode_buffer_list);
|
||||
break;
|
||||
case XLOG_REORDER_ITEM_LIST:
|
||||
trace_xfs_log_recover_item_reorder_tail(log,
|
||||
trans, item, pass);
|
||||
list_move_tail(&item->ri_list, &item_list);
|
||||
break;
|
||||
}
|
||||
}
|
||||
out:
|
||||
|
||||
ASSERT(list_empty(&sort_list));
|
||||
if (!list_empty(&buffer_list))
|
||||
list_splice(&buffer_list, &trans->r_itemq);
|
||||
|
Reference in New Issue
Block a user