Commit 3f943d85 authored by Alex Elder's avatar Alex Elder

xfs: minor odds and ends in xfs_log_recover.c

Odds and ends in "xfs_log_recover.c".  This patch just contains some
minor things that didn't seem to warrant their own individual
patches:
- In xlog_bread_noalign(), drop an assertion that a pointer is
  non-null (the crash will tell us it was a bad pointer).
- Add a more descriptive header comment for xlog_find_verify_cycle().
- Make a few additions to the comments in xlog_find_head().  Also
  rearrange some expressions in a few spots to produce the same
  result, but in a way that seems more clear what's being computed.

(Updated in response to Dave's review comments.  Note I did not
split this patch like I said I would.)
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent e3bb2e30
...@@ -167,7 +167,6 @@ xlog_bread_noalign( ...@@ -167,7 +167,6 @@ xlog_bread_noalign(
ASSERT(nbblks > 0); ASSERT(nbblks > 0);
ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp)); ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp));
ASSERT(bp);
XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no); XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no);
XFS_BUF_READ(bp); XFS_BUF_READ(bp);
...@@ -380,14 +379,12 @@ xlog_find_cycle_start( ...@@ -380,14 +379,12 @@ xlog_find_cycle_start(
} }
/* /*
* Check that the range of blocks does not contain the cycle number * Check that a range of blocks does not contain stop_on_cycle_no.
* given. The scan needs to occur from front to back and the ptr into the * Fill in *new_blk with the block offset where such a block is
* region must be updated since a later routine will need to perform another * found, or with -1 (an invalid block number) if there is no such
* test. If the region is completely good, we end up returning the same * block in the range. The scan needs to occur from front to back
* last block number. * and the pointer into the region must be updated since a later
* * routine will need to perform another test.
* Set blkno to -1 if we encounter no errors. This is an invalid block number
* since we don't ever expect logs to get this large.
*/ */
STATIC int STATIC int
xlog_find_verify_cycle( xlog_find_verify_cycle(
...@@ -661,7 +658,7 @@ xlog_find_head( ...@@ -661,7 +658,7 @@ xlog_find_head(
* In this case we want to find the first block with cycle * In this case we want to find the first block with cycle
* number matching last_half_cycle. We expect the log to be * number matching last_half_cycle. We expect the log to be
* some variation on * some variation on
* x + 1 ... | x ... * x + 1 ... | x ... | x
* The first block with cycle number x (last_half_cycle) will * The first block with cycle number x (last_half_cycle) will
* be where the new head belongs. First we do a binary search * be where the new head belongs. First we do a binary search
* for the first occurrence of last_half_cycle. The binary * for the first occurrence of last_half_cycle. The binary
...@@ -671,11 +668,13 @@ xlog_find_head( ...@@ -671,11 +668,13 @@ xlog_find_head(
* the log, then we look for occurrences of last_half_cycle - 1 * the log, then we look for occurrences of last_half_cycle - 1
* at the end of the log. The cases we're looking for look * at the end of the log. The cases we're looking for look
* like * like
* x + 1 ... | x | x + 1 | x ... * v binary search stopped here
* ^ binary search stopped here * x + 1 ... | x | x + 1 | x ... | x
* ^ but we want to locate this spot
* or * or
* x + 1 ... | x ... | x - 1 | x
* <---------> less than scan distance * <---------> less than scan distance
* x + 1 ... | x ... | x - 1 | x
* ^ we want to locate this spot
*/ */
stop_on_cycle = last_half_cycle; stop_on_cycle = last_half_cycle;
if ((error = xlog_find_cycle_start(log, bp, first_blk, if ((error = xlog_find_cycle_start(log, bp, first_blk,
...@@ -731,9 +730,9 @@ xlog_find_head( ...@@ -731,9 +730,9 @@ xlog_find_head(
* certainly not the head of the log. By searching for * certainly not the head of the log. By searching for
* last_half_cycle-1 we accomplish that. * last_half_cycle-1 we accomplish that.
*/ */
start_blk = log_bbnum - num_scan_bblks + head_blk;
ASSERT(head_blk <= INT_MAX && ASSERT(head_blk <= INT_MAX &&
(xfs_daddr_t) num_scan_bblks - head_blk >= 0); (xfs_daddr_t) num_scan_bblks >= head_blk);
start_blk = log_bbnum - (num_scan_bblks - head_blk);
if ((error = xlog_find_verify_cycle(log, start_blk, if ((error = xlog_find_verify_cycle(log, start_blk,
num_scan_bblks - (int)head_blk, num_scan_bblks - (int)head_blk,
(stop_on_cycle - 1), &new_blk))) (stop_on_cycle - 1), &new_blk)))
...@@ -780,7 +779,7 @@ xlog_find_head( ...@@ -780,7 +779,7 @@ xlog_find_head(
if ((error = xlog_find_verify_log_record(log, start_blk, if ((error = xlog_find_verify_log_record(log, start_blk,
&head_blk, 0)) == -1) { &head_blk, 0)) == -1) {
/* We hit the beginning of the log during our search */ /* We hit the beginning of the log during our search */
start_blk = log_bbnum - num_scan_bblks + head_blk; start_blk = log_bbnum - (num_scan_bblks - head_blk);
new_blk = log_bbnum; new_blk = log_bbnum;
ASSERT(start_blk <= INT_MAX && ASSERT(start_blk <= INT_MAX &&
(xfs_daddr_t) log_bbnum-start_blk >= 0); (xfs_daddr_t) log_bbnum-start_blk >= 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