xfs: stop using bp naming for log recovery buffers

Now that we don't use struct xfs_buf to hold log recovery buffer rename
the related functions and variables to just talk of a buffer instead of
using the bp name that we usually use for xfs_buf related functionality.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
Christoph Hellwig 2019-06-28 19:27:27 -07:00 committed by Darrick J. Wong
parent 6ad5b3255b
commit 6e9b3dd80f

View File

@ -79,7 +79,7 @@ struct xfs_buf_cancel {
* are valid, false otherwise. * are valid, false otherwise.
*/ */
static inline bool static inline bool
xlog_verify_bp( xlog_verify_bno(
struct xlog *log, struct xlog *log,
xfs_daddr_t blk_no, xfs_daddr_t blk_no,
int bbcount) int bbcount)
@ -96,7 +96,7 @@ xlog_verify_bp(
* a range of nbblks basic blocks at any valid offset within the log. * a range of nbblks basic blocks at any valid offset within the log.
*/ */
static char * static char *
xlog_get_bp( xlog_alloc_buffer(
struct xlog *log, struct xlog *log,
int nbblks) int nbblks)
{ {
@ -104,7 +104,7 @@ xlog_get_bp(
* Pass log block 0 since we don't have an addr yet, buffer will be * Pass log block 0 since we don't have an addr yet, buffer will be
* verified on read. * verified on read.
*/ */
if (!xlog_verify_bp(log, 0, nbblks)) { if (!xlog_verify_bno(log, 0, nbblks)) {
xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer", xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer",
nbblks); nbblks);
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
@ -153,7 +153,7 @@ xlog_do_io(
{ {
int error; int error;
if (!xlog_verify_bp(log, blk_no, nbblks)) { if (!xlog_verify_bno(log, blk_no, nbblks)) {
xfs_warn(log->l_mp, xfs_warn(log->l_mp,
"Invalid log block/length (0x%llx, 0x%x) for buffer", "Invalid log block/length (0x%llx, 0x%x) for buffer",
blk_no, nbblks); blk_no, nbblks);
@ -327,7 +327,7 @@ xlog_recover_iodone(
STATIC int STATIC int
xlog_find_cycle_start( xlog_find_cycle_start(
struct xlog *log, struct xlog *log,
char *bp, char *buffer,
xfs_daddr_t first_blk, xfs_daddr_t first_blk,
xfs_daddr_t *last_blk, xfs_daddr_t *last_blk,
uint cycle) uint cycle)
@ -341,7 +341,7 @@ xlog_find_cycle_start(
end_blk = *last_blk; end_blk = *last_blk;
mid_blk = BLK_AVG(first_blk, end_blk); mid_blk = BLK_AVG(first_blk, end_blk);
while (mid_blk != first_blk && mid_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, buffer, &offset);
if (error) if (error)
return error; return error;
mid_cycle = xlog_get_cycle(offset); mid_cycle = xlog_get_cycle(offset);
@ -377,7 +377,7 @@ xlog_find_verify_cycle(
{ {
xfs_daddr_t i, j; xfs_daddr_t i, j;
uint cycle; uint cycle;
char *bp; char *buffer;
xfs_daddr_t bufblks; xfs_daddr_t bufblks;
char *buf = NULL; char *buf = NULL;
int error = 0; int error = 0;
@ -391,7 +391,7 @@ xlog_find_verify_cycle(
bufblks = 1 << ffs(nbblks); bufblks = 1 << ffs(nbblks);
while (bufblks > log->l_logBBsize) while (bufblks > log->l_logBBsize)
bufblks >>= 1; bufblks >>= 1;
while (!(bp = xlog_get_bp(log, bufblks))) { while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
bufblks >>= 1; bufblks >>= 1;
if (bufblks < log->l_sectBBsize) if (bufblks < log->l_sectBBsize)
return -ENOMEM; return -ENOMEM;
@ -402,7 +402,7 @@ xlog_find_verify_cycle(
bcount = min(bufblks, (start_blk + nbblks - i)); bcount = min(bufblks, (start_blk + nbblks - i));
error = xlog_bread(log, i, bcount, bp, &buf); error = xlog_bread(log, i, bcount, buffer, &buf);
if (error) if (error)
goto out; goto out;
@ -420,7 +420,7 @@ xlog_find_verify_cycle(
*new_blk = -1; *new_blk = -1;
out: out:
kmem_free(bp); kmem_free(buffer);
return error; return error;
} }
@ -444,7 +444,7 @@ xlog_find_verify_log_record(
int extra_bblks) int extra_bblks)
{ {
xfs_daddr_t i; xfs_daddr_t i;
char *bp; char *buffer;
char *offset = NULL; char *offset = NULL;
xlog_rec_header_t *head = NULL; xlog_rec_header_t *head = NULL;
int error = 0; int error = 0;
@ -454,12 +454,14 @@ xlog_find_verify_log_record(
ASSERT(start_blk != 0 || *last_blk != start_blk); ASSERT(start_blk != 0 || *last_blk != start_blk);
if (!(bp = xlog_get_bp(log, num_blks))) { buffer = xlog_alloc_buffer(log, num_blks);
if (!(bp = xlog_get_bp(log, 1))) if (!buffer) {
buffer = xlog_alloc_buffer(log, 1);
if (!buffer)
return -ENOMEM; return -ENOMEM;
smallmem = 1; smallmem = 1;
} else { } else {
error = xlog_bread(log, start_blk, num_blks, bp, &offset); error = xlog_bread(log, start_blk, num_blks, buffer, &offset);
if (error) if (error)
goto out; goto out;
offset += ((num_blks - 1) << BBSHIFT); offset += ((num_blks - 1) << BBSHIFT);
@ -476,7 +478,7 @@ xlog_find_verify_log_record(
} }
if (smallmem) { if (smallmem) {
error = xlog_bread(log, i, 1, bp, &offset); error = xlog_bread(log, i, 1, buffer, &offset);
if (error) if (error)
goto out; goto out;
} }
@ -529,7 +531,7 @@ xlog_find_verify_log_record(
*last_blk = i; *last_blk = i;
out: out:
kmem_free(bp); kmem_free(buffer);
return error; return error;
} }
@ -551,7 +553,7 @@ xlog_find_head(
struct xlog *log, struct xlog *log,
xfs_daddr_t *return_head_blk) xfs_daddr_t *return_head_blk)
{ {
char *bp; char *buffer;
char *offset; char *offset;
xfs_daddr_t new_blk, first_blk, start_blk, last_blk, head_blk; xfs_daddr_t new_blk, first_blk, start_blk, last_blk, head_blk;
int num_scan_bblks; int num_scan_bblks;
@ -581,20 +583,20 @@ xlog_find_head(
} }
first_blk = 0; /* get cycle # of 1st block */ first_blk = 0; /* get cycle # of 1st block */
bp = xlog_get_bp(log, 1); buffer = xlog_alloc_buffer(log, 1);
if (!bp) if (!buffer)
return -ENOMEM; return -ENOMEM;
error = xlog_bread(log, 0, 1, bp, &offset); error = xlog_bread(log, 0, 1, buffer, &offset);
if (error) if (error)
goto bp_err; goto out_free_buffer;
first_half_cycle = xlog_get_cycle(offset); first_half_cycle = xlog_get_cycle(offset);
last_blk = head_blk = log_bbnum - 1; /* get cycle # of last block */ last_blk = head_blk = log_bbnum - 1; /* get cycle # of last block */
error = xlog_bread(log, last_blk, 1, bp, &offset); error = xlog_bread(log, last_blk, 1, buffer, &offset);
if (error) if (error)
goto bp_err; goto out_free_buffer;
last_half_cycle = xlog_get_cycle(offset); last_half_cycle = xlog_get_cycle(offset);
ASSERT(last_half_cycle != 0); ASSERT(last_half_cycle != 0);
@ -662,9 +664,10 @@ xlog_find_head(
* ^ we want to locate this spot * ^ 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, error = xlog_find_cycle_start(log, buffer, first_blk, &head_blk,
&head_blk, last_half_cycle))) last_half_cycle);
goto bp_err; if (error)
goto out_free_buffer;
} }
/* /*
@ -684,7 +687,7 @@ xlog_find_head(
if ((error = xlog_find_verify_cycle(log, if ((error = xlog_find_verify_cycle(log,
start_blk, num_scan_bblks, start_blk, num_scan_bblks,
stop_on_cycle, &new_blk))) stop_on_cycle, &new_blk)))
goto bp_err; goto out_free_buffer;
if (new_blk != -1) if (new_blk != -1)
head_blk = new_blk; head_blk = new_blk;
} else { /* need to read 2 parts of log */ } else { /* need to read 2 parts of log */
@ -721,7 +724,7 @@ xlog_find_head(
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)))
goto bp_err; goto out_free_buffer;
if (new_blk != -1) { if (new_blk != -1) {
head_blk = new_blk; head_blk = new_blk;
goto validate_head; goto validate_head;
@ -737,7 +740,7 @@ xlog_find_head(
if ((error = xlog_find_verify_cycle(log, if ((error = xlog_find_verify_cycle(log,
start_blk, (int)head_blk, start_blk, (int)head_blk,
stop_on_cycle, &new_blk))) stop_on_cycle, &new_blk)))
goto bp_err; goto out_free_buffer;
if (new_blk != -1) if (new_blk != -1)
head_blk = new_blk; head_blk = new_blk;
} }
@ -756,13 +759,13 @@ validate_head:
if (error == 1) if (error == 1)
error = -EIO; error = -EIO;
if (error) if (error)
goto bp_err; goto out_free_buffer;
} else { } else {
start_blk = 0; start_blk = 0;
ASSERT(head_blk <= INT_MAX); ASSERT(head_blk <= INT_MAX);
error = xlog_find_verify_log_record(log, start_blk, &head_blk, 0); error = xlog_find_verify_log_record(log, start_blk, &head_blk, 0);
if (error < 0) if (error < 0)
goto bp_err; goto out_free_buffer;
if (error == 1) { if (error == 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);
@ -775,14 +778,14 @@ validate_head:
if (error == 1) if (error == 1)
error = -EIO; error = -EIO;
if (error) if (error)
goto bp_err; goto out_free_buffer;
if (new_blk != log_bbnum) if (new_blk != log_bbnum)
head_blk = new_blk; head_blk = new_blk;
} else if (error) } else if (error)
goto bp_err; goto out_free_buffer;
} }
kmem_free(bp); kmem_free(buffer);
if (head_blk == log_bbnum) if (head_blk == log_bbnum)
*return_head_blk = 0; *return_head_blk = 0;
else else
@ -795,9 +798,8 @@ validate_head:
*/ */
return 0; return 0;
bp_err: out_free_buffer:
kmem_free(bp); kmem_free(buffer);
if (error) if (error)
xfs_warn(log->l_mp, "failed to find log head"); xfs_warn(log->l_mp, "failed to find log head");
return error; return error;
@ -817,7 +819,7 @@ xlog_rseek_logrec_hdr(
xfs_daddr_t head_blk, xfs_daddr_t head_blk,
xfs_daddr_t tail_blk, xfs_daddr_t tail_blk,
int count, int count,
char *bp, char *buffer,
xfs_daddr_t *rblk, xfs_daddr_t *rblk,
struct xlog_rec_header **rhead, struct xlog_rec_header **rhead,
bool *wrapped) bool *wrapped)
@ -836,7 +838,7 @@ xlog_rseek_logrec_hdr(
*/ */
end_blk = head_blk > tail_blk ? tail_blk : 0; end_blk = head_blk > tail_blk ? tail_blk : 0;
for (i = (int) head_blk - 1; i >= end_blk; i--) { for (i = (int) head_blk - 1; i >= end_blk; i--) {
error = xlog_bread(log, i, 1, bp, &offset); error = xlog_bread(log, i, 1, buffer, &offset);
if (error) if (error)
goto out_error; goto out_error;
@ -855,7 +857,7 @@ xlog_rseek_logrec_hdr(
*/ */
if (tail_blk >= head_blk && found != count) { if (tail_blk >= head_blk && found != count) {
for (i = log->l_logBBsize - 1; i >= (int) tail_blk; i--) { for (i = log->l_logBBsize - 1; i >= (int) tail_blk; i--) {
error = xlog_bread(log, i, 1, bp, &offset); error = xlog_bread(log, i, 1, buffer, &offset);
if (error) if (error)
goto out_error; goto out_error;
@ -891,7 +893,7 @@ xlog_seek_logrec_hdr(
xfs_daddr_t head_blk, xfs_daddr_t head_blk,
xfs_daddr_t tail_blk, xfs_daddr_t tail_blk,
int count, int count,
char *bp, char *buffer,
xfs_daddr_t *rblk, xfs_daddr_t *rblk,
struct xlog_rec_header **rhead, struct xlog_rec_header **rhead,
bool *wrapped) bool *wrapped)
@ -910,7 +912,7 @@ xlog_seek_logrec_hdr(
*/ */
end_blk = head_blk > tail_blk ? head_blk : log->l_logBBsize - 1; end_blk = head_blk > tail_blk ? head_blk : log->l_logBBsize - 1;
for (i = (int) tail_blk; i <= end_blk; i++) { for (i = (int) tail_blk; i <= end_blk; i++) {
error = xlog_bread(log, i, 1, bp, &offset); error = xlog_bread(log, i, 1, buffer, &offset);
if (error) if (error)
goto out_error; goto out_error;
@ -928,7 +930,7 @@ xlog_seek_logrec_hdr(
*/ */
if (tail_blk > head_blk && found != count) { if (tail_blk > head_blk && found != count) {
for (i = 0; i < (int) head_blk; i++) { for (i = 0; i < (int) head_blk; i++) {
error = xlog_bread(log, i, 1, bp, &offset); error = xlog_bread(log, i, 1, buffer, &offset);
if (error) if (error)
goto out_error; goto out_error;
@ -991,22 +993,22 @@ xlog_verify_tail(
int hsize) int hsize)
{ {
struct xlog_rec_header *thead; struct xlog_rec_header *thead;
char *bp; char *buffer;
xfs_daddr_t first_bad; xfs_daddr_t first_bad;
int error = 0; int error = 0;
bool wrapped; bool wrapped;
xfs_daddr_t tmp_tail; xfs_daddr_t tmp_tail;
xfs_daddr_t orig_tail = *tail_blk; xfs_daddr_t orig_tail = *tail_blk;
bp = xlog_get_bp(log, 1); buffer = xlog_alloc_buffer(log, 1);
if (!bp) if (!buffer)
return -ENOMEM; return -ENOMEM;
/* /*
* Make sure the tail points to a record (returns positive count on * Make sure the tail points to a record (returns positive count on
* success). * success).
*/ */
error = xlog_seek_logrec_hdr(log, head_blk, *tail_blk, 1, bp, error = xlog_seek_logrec_hdr(log, head_blk, *tail_blk, 1, buffer,
&tmp_tail, &thead, &wrapped); &tmp_tail, &thead, &wrapped);
if (error < 0) if (error < 0)
goto out; goto out;
@ -1035,8 +1037,8 @@ xlog_verify_tail(
break; break;
/* skip to the next record; returns positive count on success */ /* skip to the next record; returns positive count on success */
error = xlog_seek_logrec_hdr(log, head_blk, first_bad, 2, bp, error = xlog_seek_logrec_hdr(log, head_blk, first_bad, 2,
&tmp_tail, &thead, &wrapped); buffer, &tmp_tail, &thead, &wrapped);
if (error < 0) if (error < 0)
goto out; goto out;
@ -1051,7 +1053,7 @@ xlog_verify_tail(
"Tail block (0x%llx) overwrite detected. Updated to 0x%llx", "Tail block (0x%llx) overwrite detected. Updated to 0x%llx",
orig_tail, *tail_blk); orig_tail, *tail_blk);
out: out:
kmem_free(bp); kmem_free(buffer);
return error; return error;
} }
@ -1073,13 +1075,13 @@ xlog_verify_head(
struct xlog *log, struct xlog *log,
xfs_daddr_t *head_blk, /* in/out: unverified head */ xfs_daddr_t *head_blk, /* in/out: unverified head */
xfs_daddr_t *tail_blk, /* out: tail block */ xfs_daddr_t *tail_blk, /* out: tail block */
char *bp, char *buffer,
xfs_daddr_t *rhead_blk, /* start blk of last record */ xfs_daddr_t *rhead_blk, /* start blk of last record */
struct xlog_rec_header **rhead, /* ptr to last record */ struct xlog_rec_header **rhead, /* ptr to last record */
bool *wrapped) /* last rec. wraps phys. log */ bool *wrapped) /* last rec. wraps phys. log */
{ {
struct xlog_rec_header *tmp_rhead; struct xlog_rec_header *tmp_rhead;
char *tmp_bp; char *tmp_buffer;
xfs_daddr_t first_bad; xfs_daddr_t first_bad;
xfs_daddr_t tmp_rhead_blk; xfs_daddr_t tmp_rhead_blk;
int found; int found;
@ -1090,15 +1092,15 @@ xlog_verify_head(
* Check the head of the log for torn writes. Search backwards from the * Check the head of the log for torn writes. Search backwards from the
* head until we hit the tail or the maximum number of log record I/Os * head until we hit the tail or the maximum number of log record I/Os
* that could have been in flight at one time. Use a temporary buffer so * that could have been in flight at one time. Use a temporary buffer so
* we don't trash the rhead/bp pointers from the caller. * we don't trash the rhead/buffer pointers from the caller.
*/ */
tmp_bp = xlog_get_bp(log, 1); tmp_buffer = xlog_alloc_buffer(log, 1);
if (!tmp_bp) if (!tmp_buffer)
return -ENOMEM; return -ENOMEM;
error = xlog_rseek_logrec_hdr(log, *head_blk, *tail_blk, error = xlog_rseek_logrec_hdr(log, *head_blk, *tail_blk,
XLOG_MAX_ICLOGS, tmp_bp, &tmp_rhead_blk, XLOG_MAX_ICLOGS, tmp_buffer,
&tmp_rhead, &tmp_wrapped); &tmp_rhead_blk, &tmp_rhead, &tmp_wrapped);
kmem_free(tmp_bp); kmem_free(tmp_buffer);
if (error < 0) if (error < 0)
return error; return error;
@ -1127,8 +1129,8 @@ xlog_verify_head(
* (i.e., the records with invalid CRC) if the cycle number * (i.e., the records with invalid CRC) if the cycle number
* matches the the current cycle. * matches the the current cycle.
*/ */
found = xlog_rseek_logrec_hdr(log, first_bad, *tail_blk, 1, bp, found = xlog_rseek_logrec_hdr(log, first_bad, *tail_blk, 1,
rhead_blk, rhead, wrapped); buffer, rhead_blk, rhead, wrapped);
if (found < 0) if (found < 0)
return found; return found;
if (found == 0) /* XXX: right thing to do here? */ if (found == 0) /* XXX: right thing to do here? */
@ -1188,7 +1190,7 @@ xlog_check_unmount_rec(
xfs_daddr_t *tail_blk, xfs_daddr_t *tail_blk,
struct xlog_rec_header *rhead, struct xlog_rec_header *rhead,
xfs_daddr_t rhead_blk, xfs_daddr_t rhead_blk,
char *bp, char *buffer,
bool *clean) bool *clean)
{ {
struct xlog_op_header *op_head; struct xlog_op_header *op_head;
@ -1231,7 +1233,7 @@ xlog_check_unmount_rec(
if (*head_blk == after_umount_blk && if (*head_blk == after_umount_blk &&
be32_to_cpu(rhead->h_num_logops) == 1) { be32_to_cpu(rhead->h_num_logops) == 1) {
umount_data_blk = xlog_wrap_logbno(log, rhead_blk + hblks); umount_data_blk = xlog_wrap_logbno(log, rhead_blk + hblks);
error = xlog_bread(log, umount_data_blk, 1, bp, &offset); error = xlog_bread(log, umount_data_blk, 1, buffer, &offset);
if (error) if (error)
return error; return error;
@ -1310,7 +1312,7 @@ xlog_find_tail(
{ {
xlog_rec_header_t *rhead; xlog_rec_header_t *rhead;
char *offset = NULL; char *offset = NULL;
char *bp; char *buffer;
int error; int error;
xfs_daddr_t rhead_blk; xfs_daddr_t rhead_blk;
xfs_lsn_t tail_lsn; xfs_lsn_t tail_lsn;
@ -1324,11 +1326,11 @@ xlog_find_tail(
return error; return error;
ASSERT(*head_blk < INT_MAX); ASSERT(*head_blk < INT_MAX);
bp = xlog_get_bp(log, 1); buffer = xlog_alloc_buffer(log, 1);
if (!bp) if (!buffer)
return -ENOMEM; return -ENOMEM;
if (*head_blk == 0) { /* special case */ if (*head_blk == 0) { /* special case */
error = xlog_bread(log, 0, 1, bp, &offset); error = xlog_bread(log, 0, 1, buffer, &offset);
if (error) if (error)
goto done; goto done;
@ -1344,7 +1346,7 @@ xlog_find_tail(
* block. This wraps all the way back around to the head so something is * block. This wraps all the way back around to the head so something is
* seriously wrong if we can't find it. * seriously wrong if we can't find it.
*/ */
error = xlog_rseek_logrec_hdr(log, *head_blk, *head_blk, 1, bp, error = xlog_rseek_logrec_hdr(log, *head_blk, *head_blk, 1, buffer,
&rhead_blk, &rhead, &wrapped); &rhead_blk, &rhead, &wrapped);
if (error < 0) if (error < 0)
return error; return error;
@ -1365,7 +1367,7 @@ xlog_find_tail(
* state to determine whether recovery is necessary. * state to determine whether recovery is necessary.
*/ */
error = xlog_check_unmount_rec(log, head_blk, tail_blk, rhead, error = xlog_check_unmount_rec(log, head_blk, tail_blk, rhead,
rhead_blk, bp, &clean); rhead_blk, buffer, &clean);
if (error) if (error)
goto done; goto done;
@ -1382,7 +1384,7 @@ xlog_find_tail(
if (!clean) { if (!clean) {
xfs_daddr_t orig_head = *head_blk; xfs_daddr_t orig_head = *head_blk;
error = xlog_verify_head(log, head_blk, tail_blk, bp, error = xlog_verify_head(log, head_blk, tail_blk, buffer,
&rhead_blk, &rhead, &wrapped); &rhead_blk, &rhead, &wrapped);
if (error) if (error)
goto done; goto done;
@ -1393,7 +1395,7 @@ xlog_find_tail(
wrapped); wrapped);
tail_lsn = atomic64_read(&log->l_tail_lsn); tail_lsn = atomic64_read(&log->l_tail_lsn);
error = xlog_check_unmount_rec(log, head_blk, tail_blk, error = xlog_check_unmount_rec(log, head_blk, tail_blk,
rhead, rhead_blk, bp, rhead, rhead_blk, buffer,
&clean); &clean);
if (error) if (error)
goto done; goto done;
@ -1431,7 +1433,7 @@ xlog_find_tail(
error = xlog_clear_stale_blocks(log, tail_lsn); error = xlog_clear_stale_blocks(log, tail_lsn);
done: done:
kmem_free(bp); kmem_free(buffer);
if (error) if (error)
xfs_warn(log->l_mp, "failed to locate log tail"); xfs_warn(log->l_mp, "failed to locate log tail");
@ -1459,7 +1461,7 @@ xlog_find_zeroed(
struct xlog *log, struct xlog *log,
xfs_daddr_t *blk_no) xfs_daddr_t *blk_no)
{ {
char *bp; char *buffer;
char *offset; char *offset;
uint first_cycle, last_cycle; uint first_cycle, last_cycle;
xfs_daddr_t new_blk, last_blk, start_blk; xfs_daddr_t new_blk, last_blk, start_blk;
@ -1469,35 +1471,36 @@ xlog_find_zeroed(
*blk_no = 0; *blk_no = 0;
/* check totally zeroed log */ /* check totally zeroed log */
bp = xlog_get_bp(log, 1); buffer = xlog_alloc_buffer(log, 1);
if (!bp) if (!buffer)
return -ENOMEM; return -ENOMEM;
error = xlog_bread(log, 0, 1, bp, &offset); error = xlog_bread(log, 0, 1, buffer, &offset);
if (error) if (error)
goto bp_err; goto out_free_buffer;
first_cycle = xlog_get_cycle(offset); first_cycle = xlog_get_cycle(offset);
if (first_cycle == 0) { /* completely zeroed log */ if (first_cycle == 0) { /* completely zeroed log */
*blk_no = 0; *blk_no = 0;
kmem_free(bp); kmem_free(buffer);
return 1; return 1;
} }
/* check partially zeroed log */ /* check partially zeroed log */
error = xlog_bread(log, log_bbnum-1, 1, bp, &offset); error = xlog_bread(log, log_bbnum-1, 1, buffer, &offset);
if (error) if (error)
goto bp_err; goto out_free_buffer;
last_cycle = xlog_get_cycle(offset); last_cycle = xlog_get_cycle(offset);
if (last_cycle != 0) { /* log completely written to */ if (last_cycle != 0) { /* log completely written to */
kmem_free(bp); kmem_free(buffer);
return 0; return 0;
} }
/* we have a partially zeroed log */ /* we have a partially zeroed log */
last_blk = log_bbnum-1; last_blk = log_bbnum-1;
if ((error = xlog_find_cycle_start(log, bp, 0, &last_blk, 0))) error = xlog_find_cycle_start(log, buffer, 0, &last_blk, 0);
goto bp_err; if (error)
goto out_free_buffer;
/* /*
* Validate the answer. Because there is no way to guarantee that * Validate the answer. Because there is no way to guarantee that
@ -1520,7 +1523,7 @@ xlog_find_zeroed(
*/ */
if ((error = xlog_find_verify_cycle(log, start_blk, if ((error = xlog_find_verify_cycle(log, start_blk,
(int)num_scan_bblks, 0, &new_blk))) (int)num_scan_bblks, 0, &new_blk)))
goto bp_err; goto out_free_buffer;
if (new_blk != -1) if (new_blk != -1)
last_blk = new_blk; last_blk = new_blk;
@ -1532,11 +1535,11 @@ xlog_find_zeroed(
if (error == 1) if (error == 1)
error = -EIO; error = -EIO;
if (error) if (error)
goto bp_err; goto out_free_buffer;
*blk_no = last_blk; *blk_no = last_blk;
bp_err: out_free_buffer:
kmem_free(bp); kmem_free(buffer);
if (error) if (error)
return error; return error;
return 1; return 1;
@ -1579,7 +1582,7 @@ xlog_write_log_records(
int tail_block) int tail_block)
{ {
char *offset; char *offset;
char *bp; char *buffer;
int balign, ealign; int balign, ealign;
int sectbb = log->l_sectBBsize; int sectbb = log->l_sectBBsize;
int end_block = start_block + blocks; int end_block = start_block + blocks;
@ -1596,7 +1599,7 @@ xlog_write_log_records(
bufblks = 1 << ffs(blocks); bufblks = 1 << ffs(blocks);
while (bufblks > log->l_logBBsize) while (bufblks > log->l_logBBsize)
bufblks >>= 1; bufblks >>= 1;
while (!(bp = xlog_get_bp(log, bufblks))) { while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
bufblks >>= 1; bufblks >>= 1;
if (bufblks < sectbb) if (bufblks < sectbb)
return -ENOMEM; return -ENOMEM;
@ -1608,9 +1611,9 @@ xlog_write_log_records(
*/ */
balign = round_down(start_block, sectbb); balign = round_down(start_block, sectbb);
if (balign != start_block) { if (balign != start_block) {
error = xlog_bread_noalign(log, start_block, 1, bp); error = xlog_bread_noalign(log, start_block, 1, buffer);
if (error) if (error)
goto out_put_bp; goto out_free_buffer;
j = start_block - balign; j = start_block - balign;
} }
@ -1628,27 +1631,27 @@ xlog_write_log_records(
ealign = round_down(end_block, sectbb); ealign = round_down(end_block, sectbb);
if (j == 0 && (start_block + endcount > ealign)) { if (j == 0 && (start_block + endcount > ealign)) {
error = xlog_bread_noalign(log, ealign, sectbb, error = xlog_bread_noalign(log, ealign, sectbb,
bp + BBTOB(ealign - start_block)); buffer + BBTOB(ealign - start_block));
if (error) if (error)
break; break;
} }
offset = bp + xlog_align(log, start_block); offset = buffer + xlog_align(log, start_block);
for (; j < endcount; j++) { for (; j < endcount; j++) {
xlog_add_record(log, offset, cycle, i+j, xlog_add_record(log, offset, cycle, i+j,
tail_cycle, tail_block); tail_cycle, tail_block);
offset += BBSIZE; offset += BBSIZE;
} }
error = xlog_bwrite(log, start_block, endcount, bp); error = xlog_bwrite(log, start_block, endcount, buffer);
if (error) if (error)
break; break;
start_block += endcount; start_block += endcount;
j = 0; j = 0;
} }
out_put_bp: out_free_buffer:
kmem_free(bp); kmem_free(buffer);
return error; return error;
} }
@ -5253,7 +5256,7 @@ xlog_do_recovery_pass(
* iclog header and extract the header size from it. Get a * iclog header and extract the header size from it. Get a
* new hbp that is the correct size. * new hbp that is the correct size.
*/ */
hbp = xlog_get_bp(log, 1); hbp = xlog_alloc_buffer(log, 1);
if (!hbp) if (!hbp)
return -ENOMEM; return -ENOMEM;
@ -5296,20 +5299,20 @@ xlog_do_recovery_pass(
if (h_size % XLOG_HEADER_CYCLE_SIZE) if (h_size % XLOG_HEADER_CYCLE_SIZE)
hblks++; hblks++;
kmem_free(hbp); kmem_free(hbp);
hbp = xlog_get_bp(log, hblks); hbp = xlog_alloc_buffer(log, hblks);
} else { } else {
hblks = 1; hblks = 1;
} }
} else { } else {
ASSERT(log->l_sectBBsize == 1); ASSERT(log->l_sectBBsize == 1);
hblks = 1; hblks = 1;
hbp = xlog_get_bp(log, 1); hbp = xlog_alloc_buffer(log, 1);
h_size = XLOG_BIG_RECORD_BSIZE; h_size = XLOG_BIG_RECORD_BSIZE;
} }
if (!hbp) if (!hbp)
return -ENOMEM; return -ENOMEM;
dbp = xlog_get_bp(log, BTOBB(h_size)); dbp = xlog_alloc_buffer(log, BTOBB(h_size));
if (!dbp) { if (!dbp) {
kmem_free(hbp); kmem_free(hbp);
return -ENOMEM; return -ENOMEM;