diff options
author | Alex Elder <aelder@sgi.com> | 2010-04-15 14:17:30 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-05-19 10:58:14 -0400 |
commit | e3bb2e30d532b00a9bdda997e174a9f9916cb1c0 (patch) | |
tree | 33d82124eb213877450072f6fa1df6dbf05be7bf | |
parent | 9db127edb54048707eb84517eb0573e597a2370a (diff) |
xfs: avoid repeated pointer dereferences
In xlog_find_cycle_start() use a local variable for some repeated
operations rather than constantly accessing the memory location
whose address is passed in.
(This version drops an assertion that a pointer is non-null.)
Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index a6cbc140c330..7b3375db6728 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -354,26 +354,27 @@ xlog_find_cycle_start( | |||
354 | { | 354 | { |
355 | xfs_caddr_t offset; | 355 | xfs_caddr_t offset; |
356 | xfs_daddr_t mid_blk; | 356 | xfs_daddr_t mid_blk; |
357 | xfs_daddr_t end_blk; | ||
357 | uint mid_cycle; | 358 | uint mid_cycle; |
358 | int error; | 359 | int error; |
359 | 360 | ||
360 | mid_blk = BLK_AVG(first_blk, *last_blk); | 361 | end_blk = *last_blk; |
361 | while (mid_blk != first_blk && mid_blk != *last_blk) { | 362 | mid_blk = BLK_AVG(first_blk, end_blk); |
363 | while (mid_blk != first_blk && mid_blk != end_blk) { | ||
362 | error = xlog_bread(log, mid_blk, 1, bp, &offset); | 364 | error = xlog_bread(log, mid_blk, 1, bp, &offset); |
363 | if (error) | 365 | if (error) |
364 | return error; | 366 | return error; |
365 | mid_cycle = xlog_get_cycle(offset); | 367 | mid_cycle = xlog_get_cycle(offset); |
366 | if (mid_cycle == cycle) { | 368 | if (mid_cycle == cycle) |
367 | *last_blk = mid_blk; | 369 | end_blk = mid_blk; /* last_half_cycle == mid_cycle */ |
368 | /* last_half_cycle == mid_cycle */ | 370 | else |
369 | } else { | 371 | first_blk = mid_blk; /* first_half_cycle == mid_cycle */ |
370 | first_blk = mid_blk; | 372 | mid_blk = BLK_AVG(first_blk, end_blk); |
371 | /* first_half_cycle == mid_cycle */ | ||
372 | } | ||
373 | mid_blk = BLK_AVG(first_blk, *last_blk); | ||
374 | } | 373 | } |
375 | ASSERT((mid_blk == first_blk && mid_blk+1 == *last_blk) || | 374 | ASSERT((mid_blk == first_blk && mid_blk+1 == end_blk) || |
376 | (mid_blk == *last_blk && mid_blk-1 == first_blk)); | 375 | (mid_blk == end_blk && mid_blk-1 == first_blk)); |
376 | |||
377 | *last_blk = end_blk; | ||
377 | 378 | ||
378 | return 0; | 379 | return 0; |
379 | } | 380 | } |