aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_log_recover.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-09-28 19:45:54 -0400
committerDave Chinner <david@fromorbit.com>2014-09-28 19:45:54 -0400
commitb818cca1976d1a01754033ac08724e05d07cce8f (patch)
tree1b8f9a03f32787b9e8d90431eab826052c90f716 /fs/xfs/xfs_log_recover.c
parent76560669868d3b4d650d91d9bf467a8d81171766 (diff)
xfs: refactor recovery transaction start handling
Rework the transaction lookup and allocation code in xlog_recovery_process_ophdr() to fold two related call-once helper functions into a single helper. Then fold in all the XLOG_START_TRANS logic to that helper to clean up the remaining logic in xlog_recovery_process_ophdr(). Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_log_recover.c')
-rw-r--r--fs/xfs/xfs_log_recover.c77
1 files changed, 34 insertions, 43 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 6af9e1a74155..5019f52e4cc2 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -3353,38 +3353,6 @@ out:
3353 return error ? error : error2; 3353 return error ? error : error2;
3354} 3354}
3355 3355
3356
3357STATIC xlog_recover_t *
3358xlog_recover_find_tid(
3359 struct hlist_head *head,
3360 xlog_tid_t tid)
3361{
3362 xlog_recover_t *trans;
3363
3364 hlist_for_each_entry(trans, head, r_list) {
3365 if (trans->r_log_tid == tid)
3366 return trans;
3367 }
3368 return NULL;
3369}
3370
3371STATIC void
3372xlog_recover_new_tid(
3373 struct hlist_head *head,
3374 xlog_tid_t tid,
3375 xfs_lsn_t lsn)
3376{
3377 xlog_recover_t *trans;
3378
3379 trans = kmem_zalloc(sizeof(xlog_recover_t), KM_SLEEP);
3380 trans->r_log_tid = tid;
3381 trans->r_lsn = lsn;
3382 INIT_LIST_HEAD(&trans->r_itemq);
3383
3384 INIT_HLIST_NODE(&trans->r_list);
3385 hlist_add_head(&trans->r_list, head);
3386}
3387
3388STATIC void 3356STATIC void
3389xlog_recover_add_item( 3357xlog_recover_add_item(
3390 struct list_head *head) 3358 struct list_head *head)
@@ -3507,6 +3475,7 @@ xlog_recover_add_to_trans(
3507 trace_xfs_log_recover_item_add(log, trans, item, 0); 3475 trace_xfs_log_recover_item_add(log, trans, item, 0);
3508 return 0; 3476 return 0;
3509} 3477}
3478
3510/* 3479/*
3511 * Free up any resources allocated by the transaction 3480 * Free up any resources allocated by the transaction
3512 * 3481 *
@@ -3589,6 +3558,13 @@ xlog_recovery_process_trans(
3589 return error; 3558 return error;
3590} 3559}
3591 3560
3561/*
3562 * Lookup the transaction recovery structure associated with the ID in the
3563 * current ophdr. If the transaction doesn't exist and the start flag is set in
3564 * the ophdr, then allocate a new transaction for future ID matches to find.
3565 * Either way, return what we found during the lookup - an existing transaction
3566 * or nothing.
3567 */
3592STATIC struct xlog_recover * 3568STATIC struct xlog_recover *
3593xlog_recover_ophdr_to_trans( 3569xlog_recover_ophdr_to_trans(
3594 struct hlist_head rhash[], 3570 struct hlist_head rhash[],
@@ -3601,20 +3577,35 @@ xlog_recover_ophdr_to_trans(
3601 3577
3602 tid = be32_to_cpu(ohead->oh_tid); 3578 tid = be32_to_cpu(ohead->oh_tid);
3603 rhp = &rhash[XLOG_RHASH(tid)]; 3579 rhp = &rhash[XLOG_RHASH(tid)];
3604 trans = xlog_recover_find_tid(rhp, tid); 3580 hlist_for_each_entry(trans, rhp, r_list) {
3605 if (trans) 3581 if (trans->r_log_tid == tid)
3606 return trans; 3582 return trans;
3583 }
3607 3584
3608 /* 3585 /*
3609 * If this is a new transaction, the ophdr only contains the 3586 * skip over non-start transaction headers - we could be
3610 * start record. In that case, the only processing we need to do 3587 * processing slack space before the next transaction starts
3611 * on this opheader is allocate a new recovery container to hold 3588 */
3612 * the recovery ops that will follow. 3589 if (!(ohead->oh_flags & XLOG_START_TRANS))
3590 return NULL;
3591
3592 ASSERT(be32_to_cpu(ohead->oh_len) == 0);
3593
3594 /*
3595 * This is a new transaction so allocate a new recovery container to
3596 * hold the recovery ops that will follow.
3597 */
3598 trans = kmem_zalloc(sizeof(struct xlog_recover), KM_SLEEP);
3599 trans->r_log_tid = tid;
3600 trans->r_lsn = be64_to_cpu(rhead->h_lsn);
3601 INIT_LIST_HEAD(&trans->r_itemq);
3602 INIT_HLIST_NODE(&trans->r_list);
3603 hlist_add_head(&trans->r_list, rhp);
3604
3605 /*
3606 * Nothing more to do for this ophdr. Items to be added to this new
3607 * transaction will be in subsequent ophdr containers.
3613 */ 3608 */
3614 if (ohead->oh_flags & XLOG_START_TRANS) {
3615 ASSERT(be32_to_cpu(ohead->oh_len) == 0);
3616 xlog_recover_new_tid(rhp, tid, be64_to_cpu(rhead->h_lsn));
3617 }
3618 return NULL; 3609 return NULL;
3619} 3610}
3620 3611