diff options
author | Dave Chinner <dchinner@redhat.com> | 2010-12-20 20:02:52 -0500 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2010-12-20 20:02:52 -0500 |
commit | 3f336c6fa17c2b3d14b3dd1bd6e64e9cc97b6359 (patch) | |
tree | 14bd6f82656ad71586b94b7851a7c748ce86de13 /fs/xfs | |
parent | 1054794198e39103cb986618c4c10ec2252b7089 (diff) |
xfs: fact out common grant head/log tail verification code
Factor repeated debug code out of grant head manipulation functions into a
separate function. This removes ifdef DEBUG spagetti from the code and makes
the code easier to follow.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_log.c | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 1b82735471ab..99c62855432e 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -82,6 +82,7 @@ STATIC void xlog_ungrant_log_space(xlog_t *log, | |||
82 | #if defined(DEBUG) | 82 | #if defined(DEBUG) |
83 | STATIC void xlog_verify_dest_ptr(xlog_t *log, char *ptr); | 83 | STATIC void xlog_verify_dest_ptr(xlog_t *log, char *ptr); |
84 | STATIC void xlog_verify_grant_head(xlog_t *log, int equals); | 84 | STATIC void xlog_verify_grant_head(xlog_t *log, int equals); |
85 | STATIC void xlog_verify_grant_tail(struct log *log); | ||
85 | STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, | 86 | STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, |
86 | int count, boolean_t syncing); | 87 | int count, boolean_t syncing); |
87 | STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog, | 88 | STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog, |
@@ -89,6 +90,7 @@ STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog, | |||
89 | #else | 90 | #else |
90 | #define xlog_verify_dest_ptr(a,b) | 91 | #define xlog_verify_dest_ptr(a,b) |
91 | #define xlog_verify_grant_head(a,b) | 92 | #define xlog_verify_grant_head(a,b) |
93 | #define xlog_verify_grant_tail(a) | ||
92 | #define xlog_verify_iclog(a,b,c,d) | 94 | #define xlog_verify_iclog(a,b,c,d) |
93 | #define xlog_verify_tail_lsn(a,b,c) | 95 | #define xlog_verify_tail_lsn(a,b,c) |
94 | #endif | 96 | #endif |
@@ -2503,10 +2505,6 @@ xlog_grant_log_space(xlog_t *log, | |||
2503 | { | 2505 | { |
2504 | int free_bytes; | 2506 | int free_bytes; |
2505 | int need_bytes; | 2507 | int need_bytes; |
2506 | #ifdef DEBUG | ||
2507 | xfs_lsn_t tail_lsn; | ||
2508 | #endif | ||
2509 | |||
2510 | 2508 | ||
2511 | #ifdef DEBUG | 2509 | #ifdef DEBUG |
2512 | if (log->l_flags & XLOG_ACTIVE_RECOVERY) | 2510 | if (log->l_flags & XLOG_ACTIVE_RECOVERY) |
@@ -2577,21 +2575,9 @@ redo: | |||
2577 | 2575 | ||
2578 | /* we've got enough space */ | 2576 | /* we've got enough space */ |
2579 | xlog_grant_add_space(log, need_bytes); | 2577 | xlog_grant_add_space(log, need_bytes); |
2580 | #ifdef DEBUG | ||
2581 | tail_lsn = log->l_tail_lsn; | ||
2582 | /* | ||
2583 | * Check to make sure the grant write head didn't just over lap the | ||
2584 | * tail. If the cycles are the same, we can't be overlapping. | ||
2585 | * Otherwise, make sure that the cycles differ by exactly one and | ||
2586 | * check the byte count. | ||
2587 | */ | ||
2588 | if (CYCLE_LSN(tail_lsn) != log->l_grant_write_cycle) { | ||
2589 | ASSERT(log->l_grant_write_cycle-1 == CYCLE_LSN(tail_lsn)); | ||
2590 | ASSERT(log->l_grant_write_bytes <= BBTOB(BLOCK_LSN(tail_lsn))); | ||
2591 | } | ||
2592 | #endif | ||
2593 | trace_xfs_log_grant_exit(log, tic); | 2578 | trace_xfs_log_grant_exit(log, tic); |
2594 | xlog_verify_grant_head(log, 1); | 2579 | xlog_verify_grant_head(log, 1); |
2580 | xlog_verify_grant_tail(log); | ||
2595 | spin_unlock(&log->l_grant_lock); | 2581 | spin_unlock(&log->l_grant_lock); |
2596 | return 0; | 2582 | return 0; |
2597 | 2583 | ||
@@ -2621,9 +2607,6 @@ xlog_regrant_write_log_space(xlog_t *log, | |||
2621 | xlog_ticket_t *tic) | 2607 | xlog_ticket_t *tic) |
2622 | { | 2608 | { |
2623 | int free_bytes, need_bytes; | 2609 | int free_bytes, need_bytes; |
2624 | #ifdef DEBUG | ||
2625 | xfs_lsn_t tail_lsn; | ||
2626 | #endif | ||
2627 | 2610 | ||
2628 | tic->t_curr_res = tic->t_unit_res; | 2611 | tic->t_curr_res = tic->t_unit_res; |
2629 | xlog_tic_reset_res(tic); | 2612 | xlog_tic_reset_res(tic); |
@@ -2719,17 +2702,9 @@ redo: | |||
2719 | 2702 | ||
2720 | /* we've got enough space */ | 2703 | /* we've got enough space */ |
2721 | xlog_grant_add_space_write(log, need_bytes); | 2704 | xlog_grant_add_space_write(log, need_bytes); |
2722 | #ifdef DEBUG | ||
2723 | tail_lsn = log->l_tail_lsn; | ||
2724 | if (CYCLE_LSN(tail_lsn) != log->l_grant_write_cycle) { | ||
2725 | ASSERT(log->l_grant_write_cycle-1 == CYCLE_LSN(tail_lsn)); | ||
2726 | ASSERT(log->l_grant_write_bytes <= BBTOB(BLOCK_LSN(tail_lsn))); | ||
2727 | } | ||
2728 | #endif | ||
2729 | |||
2730 | trace_xfs_log_regrant_write_exit(log, tic); | 2705 | trace_xfs_log_regrant_write_exit(log, tic); |
2731 | |||
2732 | xlog_verify_grant_head(log, 1); | 2706 | xlog_verify_grant_head(log, 1); |
2707 | xlog_verify_grant_tail(log); | ||
2733 | spin_unlock(&log->l_grant_lock); | 2708 | spin_unlock(&log->l_grant_lock); |
2734 | return 0; | 2709 | return 0; |
2735 | 2710 | ||
@@ -3465,6 +3440,24 @@ xlog_verify_grant_head(xlog_t *log, int equals) | |||
3465 | } | 3440 | } |
3466 | } /* xlog_verify_grant_head */ | 3441 | } /* xlog_verify_grant_head */ |
3467 | 3442 | ||
3443 | STATIC void | ||
3444 | xlog_verify_grant_tail( | ||
3445 | struct log *log) | ||
3446 | { | ||
3447 | xfs_lsn_t tail_lsn = log->l_tail_lsn; | ||
3448 | |||
3449 | /* | ||
3450 | * Check to make sure the grant write head didn't just over lap the | ||
3451 | * tail. If the cycles are the same, we can't be overlapping. | ||
3452 | * Otherwise, make sure that the cycles differ by exactly one and | ||
3453 | * check the byte count. | ||
3454 | */ | ||
3455 | if (CYCLE_LSN(tail_lsn) != log->l_grant_write_cycle) { | ||
3456 | ASSERT(log->l_grant_write_cycle - 1 == CYCLE_LSN(tail_lsn)); | ||
3457 | ASSERT(log->l_grant_write_bytes <= BBTOB(BLOCK_LSN(tail_lsn))); | ||
3458 | } | ||
3459 | } | ||
3460 | |||
3468 | /* check if it will fit */ | 3461 | /* check if it will fit */ |
3469 | STATIC void | 3462 | STATIC void |
3470 | xlog_verify_tail_lsn(xlog_t *log, | 3463 | xlog_verify_tail_lsn(xlog_t *log, |