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: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com>
This commit is contained in:
committed by
Alex Elder
parent
b5203cd0a4
commit
99428ad0f6
212
fs/xfs/xfs_log.c
212
fs/xfs/xfs_log.c
@@ -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 */
|
|
||||||
int contwr; /* continued write of in-core log? */
|
|
||||||
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) {
|
||||||
xlog_print_tic_res(mp, ticket);
|
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) {
|
* This loop writes out as many regions as can fit in the amount
|
||||||
record_cnt++;
|
* of space which was allocated by xlog_state_get_iclog_space().
|
||||||
xlog_write_adv_cnt(ptr, len, log_offset, start_rec_copy);
|
*/
|
||||||
}
|
while (index < nentries) {
|
||||||
|
struct xlog_op_header *ophdr;
|
||||||
|
int start_rec_copy;
|
||||||
|
int copy_len;
|
||||||
|
int copy_off;
|
||||||
|
|
||||||
logop_head = xlog_write_setup_ophdr(log, ptr, ticket, flags);
|
ASSERT(reg[index].i_len % sizeof(__int32_t) == 0);
|
||||||
if (!logop_head)
|
ASSERT((__psint_t)ptr % sizeof(__int32_t) == 0);
|
||||||
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,
|
start_rec_copy = xlog_write_start_rec(ptr, ticket);
|
||||||
iclog->ic_size - log_offset,
|
if (start_rec_copy) {
|
||||||
reg[index].i_len, ©_off,
|
record_cnt++;
|
||||||
©_len, &partial_copy,
|
xlog_write_adv_cnt(ptr, len, log_offset,
|
||||||
&partial_copy_len);
|
start_rec_copy);
|
||||||
xlog_verify_dest_ptr(log, ptr);
|
}
|
||||||
|
|
||||||
/* copy region */
|
ophdr = xlog_write_setup_ophdr(log, ptr, ticket, flags);
|
||||||
ASSERT(copy_len >= 0);
|
if (!ophdr)
|
||||||
memcpy((xfs_caddr_t)ptr, reg[index].i_addr + copy_off, copy_len);
|
return XFS_ERROR(EIO);
|
||||||
xlog_write_adv_cnt(ptr, len, log_offset, copy_len);
|
|
||||||
|
|
||||||
/* make copy_len total bytes copied, including headers */
|
xlog_write_adv_cnt(ptr, len, log_offset,
|
||||||
copy_len += start_rec_copy + sizeof(xlog_op_header_t);
|
sizeof(struct xlog_op_header));
|
||||||
record_cnt++;
|
|
||||||
data_cnt += contwr ? copy_len : 0;
|
|
||||||
|
|
||||||
error = xlog_write_copy_finish(log, iclog, flags,
|
len += xlog_write_setup_copy(ticket, ophdr,
|
||||||
&record_cnt, &data_cnt,
|
iclog->ic_size-log_offset,
|
||||||
&partial_copy, &partial_copy_len,
|
reg[index].i_len,
|
||||||
log_offset, commit_iclog);
|
©_off, ©_len,
|
||||||
if (error)
|
&partial_copy,
|
||||||
return error;
|
&partial_copy_len);
|
||||||
|
xlog_verify_dest_ptr(log, ptr);
|
||||||
|
|
||||||
/*
|
/* copy region */
|
||||||
* if we had a partial copy, we need to get more iclog
|
ASSERT(copy_len >= 0);
|
||||||
* space but we don't want to increment the region
|
memcpy((xfs_caddr_t)ptr, reg[index].i_addr + copy_off,
|
||||||
* index because there is still more is this region to write.
|
copy_len);
|
||||||
*
|
xlog_write_adv_cnt(ptr, len, log_offset, copy_len);
|
||||||
* 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++;
|
copy_len += start_rec_copy + sizeof(xlog_op_header_t);
|
||||||
if (record_cnt == 0) {
|
record_cnt++;
|
||||||
if (index == nentries)
|
data_cnt += contwr ? copy_len : 0;
|
||||||
return 0;
|
|
||||||
break;
|
error = xlog_write_copy_finish(log, iclog, flags,
|
||||||
}
|
&record_cnt, &data_cnt,
|
||||||
} /* while (index < nentries) */
|
&partial_copy,
|
||||||
} /* for (index = 0; index < nentries; ) */
|
&partial_copy_len,
|
||||||
ASSERT(len == 0);
|
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 */
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
Reference in New Issue
Block a user