[XFS] sanitize xlog_in_core_t definition
Move all fields from xlog_iclog_fields_t into xlog_in_core_t instead of having them in a substructure and the using #defines to make it look like they were directly in xlog_in_core_t. Also document that xlog_in_core_2_t is grossly misnamed, and make all references to it typesafe. (First sent on Semptember 15th) Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Niv Sardi <xaiki@sgi.com>
This commit is contained in:
parent
4805621a37
commit
b28708d6a0
|
@ -1029,12 +1029,6 @@ xlog_iodone(xfs_buf_t *bp)
|
|||
ASSERT(XFS_BUF_FSPRIVATE2(bp, unsigned long) == (unsigned long) 2);
|
||||
XFS_BUF_SET_FSPRIVATE2(bp, (unsigned long)1);
|
||||
aborted = 0;
|
||||
|
||||
/*
|
||||
* Some versions of cpp barf on the recursive definition of
|
||||
* ic_log -> hic_fields.ic_log and expand ic_log twice when
|
||||
* it is passed through two macros. Workaround broken cpp.
|
||||
*/
|
||||
l = iclog->ic_log;
|
||||
|
||||
/*
|
||||
|
@ -1301,7 +1295,7 @@ xlog_alloc_log(xfs_mount_t *mp,
|
|||
XFS_BUF_SET_BDSTRAT_FUNC(bp, xlog_bdstrat_cb);
|
||||
XFS_BUF_SET_FSPRIVATE2(bp, (unsigned long)1);
|
||||
iclog->ic_bp = bp;
|
||||
iclog->hic_data = bp->b_addr;
|
||||
iclog->ic_data = bp->b_addr;
|
||||
#ifdef DEBUG
|
||||
log->l_iclog_bak[i] = (xfs_caddr_t)&(iclog->ic_header);
|
||||
#endif
|
||||
|
@ -1321,7 +1315,7 @@ xlog_alloc_log(xfs_mount_t *mp,
|
|||
atomic_set(&iclog->ic_refcnt, 0);
|
||||
spin_lock_init(&iclog->ic_callback_lock);
|
||||
iclog->ic_callback_tail = &(iclog->ic_callback);
|
||||
iclog->ic_datap = (char *)iclog->hic_data + log->l_iclog_hsize;
|
||||
iclog->ic_datap = (char *)iclog->ic_data + log->l_iclog_hsize;
|
||||
|
||||
ASSERT(XFS_BUF_ISBUSY(iclog->ic_bp));
|
||||
ASSERT(XFS_BUF_VALUSEMA(iclog->ic_bp) <= 0);
|
||||
|
@ -3463,7 +3457,7 @@ xlog_verify_iclog(xlog_t *log,
|
|||
ptr = iclog->ic_datap;
|
||||
base_ptr = ptr;
|
||||
ophead = (xlog_op_header_t *)ptr;
|
||||
xhdr = (xlog_in_core_2_t *)&iclog->ic_header;
|
||||
xhdr = iclog->ic_data;
|
||||
for (i = 0; i < len; i++) {
|
||||
ophead = (xlog_op_header_t *)ptr;
|
||||
|
||||
|
|
|
@ -310,6 +310,16 @@ typedef struct xlog_rec_ext_header {
|
|||
} xlog_rec_ext_header_t;
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/*
|
||||
* Quite misnamed, because this union lays out the actual on-disk log buffer.
|
||||
*/
|
||||
typedef union xlog_in_core2 {
|
||||
xlog_rec_header_t hic_header;
|
||||
xlog_rec_ext_header_t hic_xheader;
|
||||
char hic_sector[XLOG_HEADER_SIZE];
|
||||
} xlog_in_core_2_t;
|
||||
|
||||
/*
|
||||
* - A log record header is 512 bytes. There is plenty of room to grow the
|
||||
* xlog_rec_header_t into the reserved space.
|
||||
|
@ -339,7 +349,7 @@ typedef struct xlog_rec_ext_header {
|
|||
* We'll put all the read-only and l_icloglock fields in the first cacheline,
|
||||
* and move everything else out to subsequent cachelines.
|
||||
*/
|
||||
typedef struct xlog_iclog_fields {
|
||||
typedef struct xlog_in_core {
|
||||
sv_t ic_force_wait;
|
||||
sv_t ic_write_wait;
|
||||
struct xlog_in_core *ic_next;
|
||||
|
@ -362,40 +372,10 @@ typedef struct xlog_iclog_fields {
|
|||
|
||||
/* reference counts need their own cacheline */
|
||||
atomic_t ic_refcnt ____cacheline_aligned_in_smp;
|
||||
} xlog_iclog_fields_t;
|
||||
|
||||
typedef union xlog_in_core2 {
|
||||
xlog_rec_header_t hic_header;
|
||||
xlog_rec_ext_header_t hic_xheader;
|
||||
char hic_sector[XLOG_HEADER_SIZE];
|
||||
} xlog_in_core_2_t;
|
||||
|
||||
typedef struct xlog_in_core {
|
||||
xlog_iclog_fields_t hic_fields;
|
||||
xlog_in_core_2_t *hic_data;
|
||||
xlog_in_core_2_t *ic_data;
|
||||
#define ic_header ic_data->hic_header
|
||||
} xlog_in_core_t;
|
||||
|
||||
/*
|
||||
* Defines to save our code from this glop.
|
||||
*/
|
||||
#define ic_force_wait hic_fields.ic_force_wait
|
||||
#define ic_write_wait hic_fields.ic_write_wait
|
||||
#define ic_next hic_fields.ic_next
|
||||
#define ic_prev hic_fields.ic_prev
|
||||
#define ic_bp hic_fields.ic_bp
|
||||
#define ic_log hic_fields.ic_log
|
||||
#define ic_callback hic_fields.ic_callback
|
||||
#define ic_callback_lock hic_fields.ic_callback_lock
|
||||
#define ic_callback_tail hic_fields.ic_callback_tail
|
||||
#define ic_trace hic_fields.ic_trace
|
||||
#define ic_size hic_fields.ic_size
|
||||
#define ic_offset hic_fields.ic_offset
|
||||
#define ic_refcnt hic_fields.ic_refcnt
|
||||
#define ic_bwritecnt hic_fields.ic_bwritecnt
|
||||
#define ic_state hic_fields.ic_state
|
||||
#define ic_datap hic_fields.ic_datap
|
||||
#define ic_header hic_data->hic_header
|
||||
|
||||
/*
|
||||
* The reservation head lsn is not made up of a cycle number and block number.
|
||||
* Instead, it uses a cycle number and byte number. Logs don't expect to
|
||||
|
|
|
@ -3332,7 +3332,6 @@ xlog_pack_data(
|
|||
int size = iclog->ic_offset + roundoff;
|
||||
__be32 cycle_lsn;
|
||||
xfs_caddr_t dp;
|
||||
xlog_in_core_2_t *xhdr;
|
||||
|
||||
xlog_pack_data_checksum(log, iclog, size);
|
||||
|
||||
|
@ -3347,7 +3346,8 @@ xlog_pack_data(
|
|||
}
|
||||
|
||||
if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
|
||||
xhdr = (xlog_in_core_2_t *)&iclog->ic_header;
|
||||
xlog_in_core_2_t *xhdr = iclog->ic_data;
|
||||
|
||||
for ( ; i < BTOBB(size); i++) {
|
||||
j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
||||
k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
||||
|
@ -3405,7 +3405,6 @@ xlog_unpack_data(
|
|||
xlog_t *log)
|
||||
{
|
||||
int i, j, k;
|
||||
xlog_in_core_2_t *xhdr;
|
||||
|
||||
for (i = 0; i < BTOBB(be32_to_cpu(rhead->h_len)) &&
|
||||
i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) {
|
||||
|
@ -3414,7 +3413,7 @@ xlog_unpack_data(
|
|||
}
|
||||
|
||||
if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
|
||||
xhdr = (xlog_in_core_2_t *)rhead;
|
||||
xlog_in_core_2_t *xhdr = (xlog_in_core_2_t *)rhead;
|
||||
for ( ; i < BTOBB(be32_to_cpu(rhead->h_len)); i++) {
|
||||
j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
||||
k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
||||
|
|
Loading…
Reference in New Issue