log->l_flags |= XLOG_ACTIVE_RECOVERY;
log->l_prev_block = -1;
- ASSIGN_ANY_LSN_HOST(log->l_tail_lsn, 1, 0);
+ log->l_tail_lsn = xlog_assign_lsn(1, 0);
/* log->l_tail_lsn = 0x100000000LL; cycle = 1; current block = 0 */
log->l_last_sync_lsn = log->l_tail_lsn;
log->l_curr_cycle = 1; /* 0 is bad since this is initial value */
threshold_block -= log->l_logBBsize;
threshold_cycle += 1;
}
- ASSIGN_ANY_LSN_HOST(threshold_lsn, threshold_cycle,
- threshold_block);
+ threshold_lsn = xlog_assign_lsn(threshold_cycle, threshold_block);
/* Don't pass in an lsn greater than the lsn of the last
* log record known to be on disk.
log->l_iclog_hsize,
XLOG_REG_TYPE_LRHEADER);
INT_SET(head->h_cycle, ARCH_CONVERT, log->l_curr_cycle);
- ASSIGN_LSN(head->h_lsn, log);
+ INT_SET(head->h_lsn, ARCH_CONVERT,
+ xlog_assign_lsn(log->l_curr_cycle, log->l_curr_block));
ASSERT(log->l_curr_block >= 0);
}
if (idx >= (XLOG_HEADER_CYCLE_SIZE / BBSIZE)) {
j = idx / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
k = idx % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
- clientid = GET_CLIENT_ID(xhdr[j].hic_xheader.xh_cycle_data[k], ARCH_CONVERT);
+ clientid = xlog_get_client_id(
+ xhdr[j].hic_xheader.xh_cycle_data[k]);
} else {
- clientid = GET_CLIENT_ID(iclog->ic_header.h_cycle_data[idx], ARCH_CONVERT);
+ clientid = xlog_get_client_id(
+ iclog->ic_header.h_cycle_data[idx]);
}
}
if (clientid != XFS_TRANSACTION && clientid != XFS_LOG)
BTOBB(XLOG_MAX_ICLOGS << (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? \
XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
-/*
- * set lsns
- */
-#define ASSIGN_ANY_LSN_HOST(lsn,cycle,block) \
- { \
- (lsn) = ((xfs_lsn_t)(cycle)<<32)|(block); \
- }
-#define ASSIGN_ANY_LSN_DISK(lsn,cycle,block) \
- { \
- INT_SET(((uint *)&(lsn))[0], ARCH_CONVERT, (cycle)); \
- INT_SET(((uint *)&(lsn))[1], ARCH_CONVERT, (block)); \
- }
-#define ASSIGN_LSN(lsn,log) \
- ASSIGN_ANY_LSN_DISK(lsn,(log)->l_curr_cycle,(log)->l_curr_block);
-
-#define XLOG_SET(f,b) (((f) & (b)) == (b))
-
-#define GET_CYCLE(ptr, arch) \
- (INT_GET(*(uint *)(ptr), arch) == XLOG_HEADER_MAGIC_NUM ? \
- INT_GET(*((uint *)(ptr)+1), arch) : \
- INT_GET(*(uint *)(ptr), arch) \
- )
+static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block)
+{
+ return ((xfs_lsn_t)cycle << 32) | block;
+}
-#define BLK_AVG(blk1, blk2) ((blk1+blk2) >> 1)
+static inline uint xlog_get_cycle(char *ptr)
+{
+ if (INT_GET(*(uint *)ptr, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM)
+ return INT_GET(*((uint *)ptr + 1), ARCH_CONVERT);
+ else
+ return INT_GET(*(uint *)ptr, ARCH_CONVERT);
+}
+#define BLK_AVG(blk1, blk2) ((blk1+blk2) >> 1)
#ifdef __KERNEL__
*
* this has endian issues, of course.
*/
-
-#ifndef XFS_NATIVE_HOST
-#define GET_CLIENT_ID(i,arch) \
- ((i) & 0xff)
-#else
-#define GET_CLIENT_ID(i,arch) \
- ((i) >> 24)
-#endif
+static inline uint xlog_get_client_id(uint i)
+{
+ return INT_GET(i, ARCH_CONVERT) >> 24;
+}
#define xlog_panic(args...) cmn_err(CE_PANIC, ## args)
#define xlog_exit(args...) cmn_err(CE_PANIC, ## args)
if ((error = xlog_bread(log, mid_blk, 1, bp)))
return error;
offset = xlog_align(log, mid_blk, 1, bp);
- mid_cycle = GET_CYCLE(offset, ARCH_CONVERT);
+ mid_cycle = xlog_get_cycle(offset);
if (mid_cycle == cycle) {
*last_blk = mid_blk;
/* last_half_cycle == mid_cycle */
buf = xlog_align(log, i, bcount, bp);
for (j = 0; j < bcount; j++) {
- cycle = GET_CYCLE(buf, ARCH_CONVERT);
+ cycle = xlog_get_cycle(buf);
if (cycle == stop_on_cycle_no) {
*new_blk = i+j;
goto out;
if ((error = xlog_bread(log, 0, 1, bp)))
goto bp_err;
offset = xlog_align(log, 0, 1, bp);
- first_half_cycle = GET_CYCLE(offset, ARCH_CONVERT);
+ first_half_cycle = xlog_get_cycle(offset);
last_blk = head_blk = log_bbnum - 1; /* get cycle # of last block */
if ((error = xlog_bread(log, last_blk, 1, bp)))
goto bp_err;
offset = xlog_align(log, last_blk, 1, bp);
- last_half_cycle = GET_CYCLE(offset, ARCH_CONVERT);
+ last_half_cycle = xlog_get_cycle(offset);
ASSERT(last_half_cycle != 0);
/*
if ((error = xlog_bread(log, 0, 1, bp)))
goto bread_err;
offset = xlog_align(log, 0, 1, bp);
- if (GET_CYCLE(offset, ARCH_CONVERT) == 0) {
+ if (xlog_get_cycle(offset) == 0) {
*tail_blk = 0;
/* leave all other log inited values alone */
goto exit;
* log records will point recovery to after the
* current unmount record.
*/
- ASSIGN_ANY_LSN_HOST(log->l_tail_lsn, log->l_curr_cycle,
- after_umount_blk);
- ASSIGN_ANY_LSN_HOST(log->l_last_sync_lsn, log->l_curr_cycle,
- after_umount_blk);
+ log->l_tail_lsn =
+ xlog_assign_lsn(log->l_curr_cycle,
+ after_umount_blk);
+ log->l_last_sync_lsn =
+ xlog_assign_lsn(log->l_curr_cycle,
+ after_umount_blk);
*tail_blk = after_umount_blk;
/*
if ((error = xlog_bread(log, 0, 1, bp)))
goto bp_err;
offset = xlog_align(log, 0, 1, bp);
- first_cycle = GET_CYCLE(offset, ARCH_CONVERT);
+ first_cycle = xlog_get_cycle(offset);
if (first_cycle == 0) { /* completely zeroed log */
*blk_no = 0;
xlog_put_bp(bp);
if ((error = xlog_bread(log, log_bbnum-1, 1, bp)))
goto bp_err;
offset = xlog_align(log, log_bbnum-1, 1, bp);
- last_cycle = GET_CYCLE(offset, ARCH_CONVERT);
+ last_cycle = xlog_get_cycle(offset);
if (last_cycle != 0) { /* log completely written to */
xlog_put_bp(bp);
return 0;
INT_SET(recp->h_cycle, ARCH_CONVERT, cycle);
INT_SET(recp->h_version, ARCH_CONVERT,
XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? 2 : 1);
- ASSIGN_ANY_LSN_DISK(recp->h_lsn, cycle, block);
- ASSIGN_ANY_LSN_DISK(recp->h_tail_lsn, tail_cycle, tail_block);
+ INT_SET(recp->h_lsn, ARCH_CONVERT, xlog_assign_lsn(cycle, block));
+ INT_SET(recp->h_tail_lsn, ARCH_CONVERT,
+ xlog_assign_lsn(tail_cycle, tail_block));
INT_SET(recp->h_fmt, ARCH_CONVERT, XLOG_FMT);
memcpy(&recp->h_fs_uuid, &log->l_mp->m_sb.sb_uuid, sizeof(uuid_t));
}