xfs: clean up xlog_write_adv_cnt
Replace the awkward xlog_write_adv_cnt with an inline helper that makes it more obvious that it's modifying it's paramters, and replace the use of an integer type for "ptr" with a real void pointer. Also move xlog_write_adv_cnt to xfs_log_priv.h as it will be used outside of xfs_log.c in the delayed logging series. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com>
This commit is contained in:
parent
55b66332d0
commit
e6b1f27370
|
@ -44,11 +44,6 @@
|
||||||
|
|
||||||
kmem_zone_t *xfs_log_ticket_zone;
|
kmem_zone_t *xfs_log_ticket_zone;
|
||||||
|
|
||||||
#define xlog_write_adv_cnt(ptr, len, off, bytes) \
|
|
||||||
{ (ptr) += (bytes); \
|
|
||||||
(len) -= (bytes); \
|
|
||||||
(off) += (bytes);}
|
|
||||||
|
|
||||||
/* Local miscellaneous function prototypes */
|
/* Local miscellaneous function prototypes */
|
||||||
STATIC int xlog_commit_record(struct log *log, struct xlog_ticket *ticket,
|
STATIC int xlog_commit_record(struct log *log, struct xlog_ticket *ticket,
|
||||||
xlog_in_core_t **, xfs_lsn_t *);
|
xlog_in_core_t **, xfs_lsn_t *);
|
||||||
|
@ -100,7 +95,7 @@ STATIC xlog_ticket_t *xlog_ticket_alloc(xlog_t *log,
|
||||||
uint flags);
|
uint flags);
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
STATIC void xlog_verify_dest_ptr(xlog_t *log, __psint_t ptr);
|
STATIC void xlog_verify_dest_ptr(xlog_t *log, char *ptr);
|
||||||
STATIC void xlog_verify_grant_head(xlog_t *log, int equals);
|
STATIC void xlog_verify_grant_head(xlog_t *log, int equals);
|
||||||
STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog,
|
STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog,
|
||||||
int count, boolean_t syncing);
|
int count, boolean_t syncing);
|
||||||
|
@ -1683,11 +1678,9 @@ xlog_write_calc_vec_length(
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xlog_write_start_rec(
|
xlog_write_start_rec(
|
||||||
__psint_t ptr,
|
struct xlog_op_header *ophdr,
|
||||||
struct xlog_ticket *ticket)
|
struct xlog_ticket *ticket)
|
||||||
{
|
{
|
||||||
struct xlog_op_header *ophdr = (struct xlog_op_header *)ptr;
|
|
||||||
|
|
||||||
if (!(ticket->t_flags & XLOG_TIC_INITED))
|
if (!(ticket->t_flags & XLOG_TIC_INITED))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1705,12 +1698,10 @@ xlog_write_start_rec(
|
||||||
static xlog_op_header_t *
|
static xlog_op_header_t *
|
||||||
xlog_write_setup_ophdr(
|
xlog_write_setup_ophdr(
|
||||||
struct log *log,
|
struct log *log,
|
||||||
__psint_t ptr,
|
struct xlog_op_header *ophdr,
|
||||||
struct xlog_ticket *ticket,
|
struct xlog_ticket *ticket,
|
||||||
uint flags)
|
uint flags)
|
||||||
{
|
{
|
||||||
struct xlog_op_header *ophdr = (struct xlog_op_header *)ptr;
|
|
||||||
|
|
||||||
ophdr->oh_tid = cpu_to_be32(ticket->t_tid);
|
ophdr->oh_tid = cpu_to_be32(ticket->t_tid);
|
||||||
ophdr->oh_clientid = ticket->t_clientid;
|
ophdr->oh_clientid = ticket->t_clientid;
|
||||||
ophdr->oh_res2 = 0;
|
ophdr->oh_res2 = 0;
|
||||||
|
@ -1917,7 +1908,7 @@ xlog_write(
|
||||||
lv = log_vector;
|
lv = log_vector;
|
||||||
vecp = lv->lv_iovecp;
|
vecp = lv->lv_iovecp;
|
||||||
while (lv && index < lv->lv_niovecs) {
|
while (lv && index < lv->lv_niovecs) {
|
||||||
__psint_t ptr;
|
void *ptr;
|
||||||
int log_offset;
|
int log_offset;
|
||||||
|
|
||||||
error = xlog_state_get_iclog_space(log, len, &iclog, ticket,
|
error = xlog_state_get_iclog_space(log, len, &iclog, ticket,
|
||||||
|
@ -1926,7 +1917,7 @@ xlog_write(
|
||||||
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 = 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)
|
||||||
|
@ -1944,12 +1935,12 @@ xlog_write(
|
||||||
int copy_off;
|
int copy_off;
|
||||||
|
|
||||||
ASSERT(reg->i_len % sizeof(__int32_t) == 0);
|
ASSERT(reg->i_len % sizeof(__int32_t) == 0);
|
||||||
ASSERT((__psint_t)ptr % sizeof(__int32_t) == 0);
|
ASSERT((unsigned long)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,
|
xlog_write_adv_cnt(&ptr, &len, &log_offset,
|
||||||
start_rec_copy);
|
start_rec_copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1957,7 +1948,7 @@ xlog_write(
|
||||||
if (!ophdr)
|
if (!ophdr)
|
||||||
return XFS_ERROR(EIO);
|
return XFS_ERROR(EIO);
|
||||||
|
|
||||||
xlog_write_adv_cnt(ptr, len, log_offset,
|
xlog_write_adv_cnt(&ptr, &len, &log_offset,
|
||||||
sizeof(struct xlog_op_header));
|
sizeof(struct xlog_op_header));
|
||||||
|
|
||||||
len += xlog_write_setup_copy(ticket, ophdr,
|
len += xlog_write_setup_copy(ticket, ophdr,
|
||||||
|
@ -1970,9 +1961,8 @@ xlog_write(
|
||||||
|
|
||||||
/* copy region */
|
/* copy region */
|
||||||
ASSERT(copy_len >= 0);
|
ASSERT(copy_len >= 0);
|
||||||
memcpy((xfs_caddr_t)ptr, reg->i_addr + copy_off,
|
memcpy(ptr, reg->i_addr + copy_off, copy_len);
|
||||||
copy_len);
|
xlog_write_adv_cnt(&ptr, &len, &log_offset, copy_len);
|
||||||
xlog_write_adv_cnt(ptr, len, log_offset, copy_len);
|
|
||||||
|
|
||||||
copy_len += start_rec_copy + sizeof(xlog_op_header_t);
|
copy_len += start_rec_copy + sizeof(xlog_op_header_t);
|
||||||
record_cnt++;
|
record_cnt++;
|
||||||
|
@ -3454,20 +3444,22 @@ xlog_ticket_alloc(
|
||||||
* part of the log in case we trash the log structure.
|
* part of the log in case we trash the log structure.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xlog_verify_dest_ptr(xlog_t *log,
|
xlog_verify_dest_ptr(
|
||||||
__psint_t ptr)
|
struct log *log,
|
||||||
|
char *ptr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int good_ptr = 0;
|
int good_ptr = 0;
|
||||||
|
|
||||||
for (i=0; i < log->l_iclog_bufs; i++) {
|
for (i = 0; i < log->l_iclog_bufs; i++) {
|
||||||
if (ptr >= (__psint_t)log->l_iclog_bak[i] &&
|
if (ptr >= log->l_iclog_bak[i] &&
|
||||||
ptr <= (__psint_t)log->l_iclog_bak[i]+log->l_iclog_size)
|
ptr <= log->l_iclog_bak[i] + log->l_iclog_size)
|
||||||
good_ptr++;
|
good_ptr++;
|
||||||
}
|
}
|
||||||
if (! good_ptr)
|
|
||||||
|
if (!good_ptr)
|
||||||
xlog_panic("xlog_verify_dest_ptr: invalid ptr");
|
xlog_panic("xlog_verify_dest_ptr: invalid ptr");
|
||||||
} /* xlog_verify_dest_ptr */
|
}
|
||||||
|
|
||||||
STATIC void
|
STATIC void
|
||||||
xlog_verify_grant_head(xlog_t *log, int equals)
|
xlog_verify_grant_head(xlog_t *log, int equals)
|
||||||
|
|
|
@ -449,6 +449,14 @@ extern void xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog, int);
|
||||||
|
|
||||||
extern kmem_zone_t *xfs_log_ticket_zone;
|
extern kmem_zone_t *xfs_log_ticket_zone;
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
xlog_write_adv_cnt(void **ptr, int *len, int *off, size_t bytes)
|
||||||
|
{
|
||||||
|
*ptr += bytes;
|
||||||
|
*len -= bytes;
|
||||||
|
*off += bytes;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unmount record type is used as a pseudo transaction type for the ticket.
|
* Unmount record type is used as a pseudo transaction type for the ticket.
|
||||||
* It's value must be outside the range of XFS_TRANS_* values.
|
* It's value must be outside the range of XFS_TRANS_* values.
|
||||||
|
|
Loading…
Reference in a new issue