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>
This commit is contained in:
parent
9db127edb5
commit
e3bb2e30d5
1 changed files with 13 additions and 12 deletions
|
@ -354,26 +354,27 @@ xlog_find_cycle_start(
|
||||||
{
|
{
|
||||||
xfs_caddr_t offset;
|
xfs_caddr_t offset;
|
||||||
xfs_daddr_t mid_blk;
|
xfs_daddr_t mid_blk;
|
||||||
|
xfs_daddr_t end_blk;
|
||||||
uint mid_cycle;
|
uint mid_cycle;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
mid_blk = BLK_AVG(first_blk, *last_blk);
|
end_blk = *last_blk;
|
||||||
while (mid_blk != first_blk && mid_blk != *last_blk) {
|
mid_blk = BLK_AVG(first_blk, end_blk);
|
||||||
|
while (mid_blk != first_blk && mid_blk != end_blk) {
|
||||||
error = xlog_bread(log, mid_blk, 1, bp, &offset);
|
error = xlog_bread(log, mid_blk, 1, bp, &offset);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
mid_cycle = xlog_get_cycle(offset);
|
mid_cycle = xlog_get_cycle(offset);
|
||||||
if (mid_cycle == cycle) {
|
if (mid_cycle == cycle)
|
||||||
*last_blk = mid_blk;
|
end_blk = mid_blk; /* last_half_cycle == mid_cycle */
|
||||||
/* last_half_cycle == mid_cycle */
|
else
|
||||||
} else {
|
first_blk = mid_blk; /* first_half_cycle == mid_cycle */
|
||||||
first_blk = mid_blk;
|
mid_blk = BLK_AVG(first_blk, end_blk);
|
||||||
/* first_half_cycle == mid_cycle */
|
|
||||||
}
|
|
||||||
mid_blk = BLK_AVG(first_blk, *last_blk);
|
|
||||||
}
|
}
|
||||||
ASSERT((mid_blk == first_blk && mid_blk+1 == *last_blk) ||
|
ASSERT((mid_blk == first_blk && mid_blk+1 == end_blk) ||
|
||||||
(mid_blk == *last_blk && mid_blk-1 == first_blk));
|
(mid_blk == end_blk && mid_blk-1 == first_blk));
|
||||||
|
|
||||||
|
*last_blk = end_blk;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue