Commit 99428ad0 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Alex Elder

xfs: reindent xlog_write

Reindent xlog_write to normal one tab indents and move all variable
declarations into the closest enclosing block.

Split from a bigger patch by Dave Chinner.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent b5203cd0
...@@ -1866,127 +1866,141 @@ xlog_write( ...@@ -1866,127 +1866,141 @@ xlog_write(
struct xlog_in_core **commit_iclog, struct xlog_in_core **commit_iclog,
uint flags) uint flags)
{ {
xlog_t *log = mp->m_log; struct log *log = mp->m_log;
xlog_in_core_t *iclog = NULL; /* ptr to current in-core log */ struct xlog_in_core *iclog = NULL;
xlog_op_header_t *logop_head; /* ptr to log operation header */ int len;
__psint_t ptr; /* copy address into data region */ int index;
int len; /* # xlog_write() bytes 2 still copy */ int partial_copy = 0;
int index; /* region index currently copying */ int partial_copy_len = 0;
int log_offset; /* offset (from 0) into data region */ int contwr = 0;
int start_rec_copy; /* # bytes to copy for start record */ int record_cnt = 0;
int partial_copy; /* did we split a region? */ int data_cnt = 0;
int partial_copy_len;/* # bytes copied if split region */ int error;
int copy_len; /* # bytes actually memcpy'ing */
int copy_off; /* # bytes from entry start */ *start_lsn = 0;
int contwr; /* continued write of in-core log? */
int error; len = xlog_write_calc_vec_length(ticket, reg, nentries);
int record_cnt = 0, data_cnt = 0; if (ticket->t_curr_res < len) {
xlog_print_tic_res(mp, ticket);
partial_copy_len = partial_copy = 0;
contwr = *start_lsn = 0;
len = xlog_write_calc_vec_length(ticket, reg, nentries);
if (ticket->t_curr_res < len) {
xlog_print_tic_res(mp, ticket);
#ifdef DEBUG #ifdef DEBUG
xlog_panic( xlog_panic(
"xfs_log_write: reservation ran out. Need to up reservation"); "xfs_log_write: reservation ran out. Need to up reservation");
#else #else
/* Customer configurable panic */ /* Customer configurable panic */
xfs_cmn_err(XFS_PTAG_LOGRES, CE_ALERT, mp, xfs_cmn_err(XFS_PTAG_LOGRES, CE_ALERT, mp,
"xfs_log_write: reservation ran out. Need to up reservation"); "xfs_log_write: reservation ran out. Need to up reservation");
/* If we did not panic, shutdown the filesystem */
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); /* If we did not panic, shutdown the filesystem */
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
#endif #endif
} else }
ticket->t_curr_res -= len; ticket->t_curr_res -= len;
for (index = 0; index < nentries; ) { for (index = 0; index < nentries; ) {
if ((error = xlog_state_get_iclog_space(log, len, &iclog, ticket, __psint_t ptr;
&contwr, &log_offset))) int log_offset;
return error;
ASSERT(log_offset <= iclog->ic_size - 1); error = xlog_state_get_iclog_space(log, len, &iclog, ticket,
ptr = (__psint_t) ((char *)iclog->ic_datap+log_offset); &contwr, &log_offset);
if (error)
return error;
/* start_lsn is the first lsn written to. That's all we need. */ ASSERT(log_offset <= iclog->ic_size - 1);
if (! *start_lsn) ptr = (__psint_t)((char *)iclog->ic_datap + log_offset);
*start_lsn = be64_to_cpu(iclog->ic_header.h_lsn);
/* This loop writes out as many regions as can fit in the amount /* start_lsn is the first lsn written to. That's all we need. */
* of space which was allocated by xlog_state_get_iclog_space(). if (!*start_lsn)
*/ *start_lsn = be64_to_cpu(iclog->ic_header.h_lsn);
while (index < nentries) {
ASSERT(reg[index].i_len % sizeof(__int32_t) == 0);
ASSERT((__psint_t)ptr % sizeof(__int32_t) == 0);
start_rec_copy = xlog_write_start_rec(ptr, ticket);
if (start_rec_copy) {
record_cnt++;
xlog_write_adv_cnt(ptr, len, log_offset, start_rec_copy);
}
logop_head = xlog_write_setup_ophdr(log, ptr, ticket, flags); /*
if (!logop_head) * This loop writes out as many regions as can fit in the amount
return XFS_ERROR(EIO); * of space which was allocated by xlog_state_get_iclog_space().
xlog_write_adv_cnt(ptr, len, log_offset, sizeof(xlog_op_header_t)); */
while (index < nentries) {
len += xlog_write_setup_copy(ticket, logop_head, struct xlog_op_header *ophdr;
iclog->ic_size - log_offset, int start_rec_copy;
reg[index].i_len, &copy_off, int copy_len;
&copy_len, &partial_copy, int copy_off;
&partial_copy_len);
xlog_verify_dest_ptr(log, ptr); ASSERT(reg[index].i_len % sizeof(__int32_t) == 0);
ASSERT((__psint_t)ptr % sizeof(__int32_t) == 0);
/* copy region */
ASSERT(copy_len >= 0); start_rec_copy = xlog_write_start_rec(ptr, ticket);
memcpy((xfs_caddr_t)ptr, reg[index].i_addr + copy_off, copy_len); if (start_rec_copy) {
xlog_write_adv_cnt(ptr, len, log_offset, copy_len); record_cnt++;
xlog_write_adv_cnt(ptr, len, log_offset,
/* make copy_len total bytes copied, including headers */ start_rec_copy);
copy_len += start_rec_copy + sizeof(xlog_op_header_t); }
record_cnt++;
data_cnt += contwr ? copy_len : 0;
error = xlog_write_copy_finish(log, iclog, flags,
&record_cnt, &data_cnt,
&partial_copy, &partial_copy_len,
log_offset, commit_iclog);
if (error)
return error;
/* ophdr = xlog_write_setup_ophdr(log, ptr, ticket, flags);
* if we had a partial copy, we need to get more iclog if (!ophdr)
* space but we don't want to increment the region return XFS_ERROR(EIO);
* index because there is still more is this region to write.
*
* If we completed writing this region, and we flushed
* the iclog (indicated by resetting of the record
* count), then we also need to get more log space. If
* this was the last record, though, we are done and
* can just return.
*/
if (partial_copy)
break;
index++; xlog_write_adv_cnt(ptr, len, log_offset,
if (record_cnt == 0) { sizeof(struct xlog_op_header));
if (index == nentries)
return 0; len += xlog_write_setup_copy(ticket, ophdr,
break; iclog->ic_size-log_offset,
} reg[index].i_len,
} /* while (index < nentries) */ &copy_off, &copy_len,
} /* for (index = 0; index < nentries; ) */ &partial_copy,
ASSERT(len == 0); &partial_copy_len);
xlog_verify_dest_ptr(log, ptr);
/* copy region */
ASSERT(copy_len >= 0);
memcpy((xfs_caddr_t)ptr, reg[index].i_addr + copy_off,
copy_len);
xlog_write_adv_cnt(ptr, len, log_offset, copy_len);
copy_len += start_rec_copy + sizeof(xlog_op_header_t);
record_cnt++;
data_cnt += contwr ? copy_len : 0;
error = xlog_write_copy_finish(log, iclog, flags,
&record_cnt, &data_cnt,
&partial_copy,
&partial_copy_len,
log_offset,
commit_iclog);
if (error)
return error;
/*
* if we had a partial copy, we need to get more iclog
* space but we don't want to increment the region
* index because there is still more is this region to
* write.
*
* If we completed writing this region, and we flushed
* the iclog (indicated by resetting of the record
* count), then we also need to get more log space. If
* this was the last record, though, we are done and
* can just return.
*/
if (partial_copy)
break;
index++;
if (record_cnt == 0) {
if (index == nentries)
return 0;
break;
}
}
}
ASSERT(len == 0);
xlog_state_finish_copy(log, iclog, record_cnt, data_cnt);
if (!commit_iclog)
return xlog_state_release_iclog(log, iclog);
xlog_state_finish_copy(log, iclog, record_cnt, data_cnt);
if (commit_iclog) {
ASSERT(flags & XLOG_COMMIT_TRANS); ASSERT(flags & XLOG_COMMIT_TRANS);
*commit_iclog = iclog; *commit_iclog = iclog;
return 0; return 0;
} }
return xlog_state_release_iclog(log, iclog);
} /* xlog_write */
/***************************************************************************** /*****************************************************************************
......
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