xfs: refactor releasing finished intents during log recovery
Replace the open-coded AIL item walking with a proper helper when we're trying to release an intent item that has been finished. We add a new ->iop_match method to decide if an intent item matches a supplied ID. 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:
@@ -1779,6 +1779,38 @@ xlog_clear_stale_blocks(
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the recovered intent item in the AIL that matches the given intent
|
||||
* type and intent id.
|
||||
*/
|
||||
void
|
||||
xlog_recover_release_intent(
|
||||
struct xlog *log,
|
||||
unsigned short intent_type,
|
||||
uint64_t intent_id)
|
||||
{
|
||||
struct xfs_ail_cursor cur;
|
||||
struct xfs_log_item *lip;
|
||||
struct xfs_ail *ailp = log->l_ailp;
|
||||
|
||||
spin_lock(&ailp->ail_lock);
|
||||
for (lip = xfs_trans_ail_cursor_first(ailp, &cur, 0); lip != NULL;
|
||||
lip = xfs_trans_ail_cursor_next(ailp, &cur)) {
|
||||
if (lip->li_type != intent_type)
|
||||
continue;
|
||||
if (!lip->li_ops->iop_match(lip, intent_id))
|
||||
continue;
|
||||
|
||||
spin_unlock(&ailp->ail_lock);
|
||||
lip->li_ops->iop_release(lip);
|
||||
spin_lock(&ailp->ail_lock);
|
||||
break;
|
||||
}
|
||||
|
||||
xfs_trans_ail_cursor_done(&cur);
|
||||
spin_unlock(&ailp->ail_lock);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Log recover routines
|
||||
@@ -2583,7 +2615,8 @@ xlog_finish_defer_ops(
|
||||
/* Is this log item a deferred action intent? */
|
||||
static inline bool xlog_item_is_intent(struct xfs_log_item *lip)
|
||||
{
|
||||
return lip->li_ops->iop_recover != NULL;
|
||||
return lip->li_ops->iop_recover != NULL &&
|
||||
lip->li_ops->iop_match != NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user