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,24 +1866,18 @@ xlog_write( ...@@ -1866,24 +1866,18 @@ 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 copy_len; /* # bytes actually memcpy'ing */
int copy_off; /* # bytes from entry start */
int contwr; /* continued write of in-core log? */
int error; int error;
int record_cnt = 0, data_cnt = 0;
partial_copy_len = partial_copy = 0; *start_lsn = 0;
contwr = *start_lsn = 0;
len = xlog_write_calc_vec_length(ticket, reg, nentries); len = xlog_write_calc_vec_length(ticket, reg, nentries);
if (ticket->t_curr_res < len) { if (ticket->t_curr_res < len) {
...@@ -1895,70 +1889,89 @@ xlog_write( ...@@ -1895,70 +1889,89 @@ xlog_write(
/* 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 */ /* If we did not panic, shutdown the filesystem */
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 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;
error = xlog_state_get_iclog_space(log, len, &iclog, ticket,
&contwr, &log_offset);
if (error)
return error; return error;
ASSERT(log_offset <= iclog->ic_size - 1); ASSERT(log_offset <= iclog->ic_size - 1);
ptr = (__psint_t) ((char *)iclog->ic_datap+log_offset); ptr = (__psint_t)((char *)iclog->ic_datap + log_offset);
/* start_lsn is the first lsn written to. That's all we need. */ /* start_lsn is the first lsn written to. That's all we need. */
if (! *start_lsn) if (!*start_lsn)
*start_lsn = be64_to_cpu(iclog->ic_header.h_lsn); *start_lsn = be64_to_cpu(iclog->ic_header.h_lsn);
/* This loop writes out as many regions as can fit in the amount /*
* This loop writes out as many regions as can fit in the amount
* of space which was allocated by xlog_state_get_iclog_space(). * of space which was allocated by xlog_state_get_iclog_space().
*/ */
while (index < nentries) { while (index < nentries) {
struct xlog_op_header *ophdr;
int start_rec_copy;
int copy_len;
int copy_off;
ASSERT(reg[index].i_len % sizeof(__int32_t) == 0); ASSERT(reg[index].i_len % sizeof(__int32_t) == 0);
ASSERT((__psint_t)ptr % sizeof(__int32_t) == 0); ASSERT((__psint_t)ptr % sizeof(__int32_t) == 0);
start_rec_copy = xlog_write_start_rec(ptr, ticket); start_rec_copy = xlog_write_start_rec(ptr, ticket);
if (start_rec_copy) { if (start_rec_copy) {
record_cnt++; record_cnt++;
xlog_write_adv_cnt(ptr, len, log_offset, start_rec_copy); xlog_write_adv_cnt(ptr, len, log_offset,
start_rec_copy);
} }
logop_head = xlog_write_setup_ophdr(log, ptr, ticket, flags); ophdr = xlog_write_setup_ophdr(log, ptr, ticket, flags);
if (!logop_head) if (!ophdr)
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
xlog_write_adv_cnt(ptr, len, log_offset, sizeof(xlog_op_header_t));
len += xlog_write_setup_copy(ticket, logop_head, xlog_write_adv_cnt(ptr, len, log_offset,
iclog->ic_size - log_offset, sizeof(struct xlog_op_header));
reg[index].i_len, &copy_off,
&copy_len, &partial_copy, len += xlog_write_setup_copy(ticket, ophdr,
iclog->ic_size-log_offset,
reg[index].i_len,
&copy_off, &copy_len,
&partial_copy,
&partial_copy_len); &partial_copy_len);
xlog_verify_dest_ptr(log, ptr); xlog_verify_dest_ptr(log, ptr);
/* copy region */ /* copy region */
ASSERT(copy_len >= 0); ASSERT(copy_len >= 0);
memcpy((xfs_caddr_t)ptr, reg[index].i_addr + copy_off, copy_len); memcpy((xfs_caddr_t)ptr, reg[index].i_addr + copy_off,
copy_len);
xlog_write_adv_cnt(ptr, len, log_offset, copy_len); xlog_write_adv_cnt(ptr, len, log_offset, copy_len);
/* make copy_len total bytes copied, including headers */
copy_len += start_rec_copy + sizeof(xlog_op_header_t); copy_len += start_rec_copy + sizeof(xlog_op_header_t);
record_cnt++; record_cnt++;
data_cnt += contwr ? copy_len : 0; data_cnt += contwr ? copy_len : 0;
error = xlog_write_copy_finish(log, iclog, flags, error = xlog_write_copy_finish(log, iclog, flags,
&record_cnt, &data_cnt, &record_cnt, &data_cnt,
&partial_copy, &partial_copy_len, &partial_copy,
log_offset, commit_iclog); &partial_copy_len,
log_offset,
commit_iclog);
if (error) if (error)
return error; return error;
/* /*
* if we had a partial copy, we need to get more iclog * if we had a partial copy, we need to get more iclog
* space but we don't want to increment the region * space but we don't want to increment the region
* index because there is still more is this region to write. * index because there is still more is this region to
* write.
* *
* If we completed writing this region, and we flushed * If we completed writing this region, and we flushed
* the iclog (indicated by resetting of the record * the iclog (indicated by resetting of the record
...@@ -1975,18 +1988,19 @@ xlog_write( ...@@ -1975,18 +1988,19 @@ xlog_write(
return 0; return 0;
break; break;
} }
} /* while (index < nentries) */ }
} /* for (index = 0; index < nentries; ) */ }
ASSERT(len == 0); ASSERT(len == 0);
xlog_state_finish_copy(log, iclog, record_cnt, data_cnt); xlog_state_finish_copy(log, iclog, record_cnt, data_cnt);
if (commit_iclog) { if (!commit_iclog)
return xlog_state_release_iclog(log, 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