|
@@ -198,7 +198,7 @@ xlog_header_check_dump(
|
|
cmn_err(CE_DEBUG, " log : uuid = ");
|
|
cmn_err(CE_DEBUG, " log : uuid = ");
|
|
for (b = 0; b < 16; b++)
|
|
for (b = 0; b < 16; b++)
|
|
cmn_err(CE_DEBUG, "%02x",((uchar_t *)&head->h_fs_uuid)[b]);
|
|
cmn_err(CE_DEBUG, "%02x",((uchar_t *)&head->h_fs_uuid)[b]);
|
|
- cmn_err(CE_DEBUG, ", fmt = %d\n", INT_GET(head->h_fmt, ARCH_CONVERT));
|
|
|
|
|
|
+ cmn_err(CE_DEBUG, ", fmt = %d\n", be32_to_cpu(head->h_fmt));
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
#define xlog_header_check_dump(mp, head)
|
|
#define xlog_header_check_dump(mp, head)
|
|
@@ -212,14 +212,14 @@ xlog_header_check_recover(
|
|
xfs_mount_t *mp,
|
|
xfs_mount_t *mp,
|
|
xlog_rec_header_t *head)
|
|
xlog_rec_header_t *head)
|
|
{
|
|
{
|
|
- ASSERT(INT_GET(head->h_magicno, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM);
|
|
|
|
|
|
+ ASSERT(be32_to_cpu(head->h_magicno) == XLOG_HEADER_MAGIC_NUM);
|
|
|
|
|
|
/*
|
|
/*
|
|
* IRIX doesn't write the h_fmt field and leaves it zeroed
|
|
* IRIX doesn't write the h_fmt field and leaves it zeroed
|
|
* (XLOG_FMT_UNKNOWN). This stops us from trying to recover
|
|
* (XLOG_FMT_UNKNOWN). This stops us from trying to recover
|
|
* a dirty log created in IRIX.
|
|
* a dirty log created in IRIX.
|
|
*/
|
|
*/
|
|
- if (unlikely(INT_GET(head->h_fmt, ARCH_CONVERT) != XLOG_FMT)) {
|
|
|
|
|
|
+ if (unlikely(be32_to_cpu(head->h_fmt) != XLOG_FMT)) {
|
|
xlog_warn(
|
|
xlog_warn(
|
|
"XFS: dirty log written in incompatible format - can't recover");
|
|
"XFS: dirty log written in incompatible format - can't recover");
|
|
xlog_header_check_dump(mp, head);
|
|
xlog_header_check_dump(mp, head);
|
|
@@ -245,7 +245,7 @@ xlog_header_check_mount(
|
|
xfs_mount_t *mp,
|
|
xfs_mount_t *mp,
|
|
xlog_rec_header_t *head)
|
|
xlog_rec_header_t *head)
|
|
{
|
|
{
|
|
- ASSERT(INT_GET(head->h_magicno, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM);
|
|
|
|
|
|
+ ASSERT(be32_to_cpu(head->h_magicno) == XLOG_HEADER_MAGIC_NUM);
|
|
|
|
|
|
if (uuid_is_nil(&head->h_fs_uuid)) {
|
|
if (uuid_is_nil(&head->h_fs_uuid)) {
|
|
/*
|
|
/*
|
|
@@ -293,7 +293,7 @@ xlog_recover_iodone(
|
|
* Note that the algorithm can not be perfect because the disk will not
|
|
* Note that the algorithm can not be perfect because the disk will not
|
|
* necessarily be perfect.
|
|
* necessarily be perfect.
|
|
*/
|
|
*/
|
|
-int
|
|
|
|
|
|
+STATIC int
|
|
xlog_find_cycle_start(
|
|
xlog_find_cycle_start(
|
|
xlog_t *log,
|
|
xlog_t *log,
|
|
xfs_buf_t *bp,
|
|
xfs_buf_t *bp,
|
|
@@ -311,7 +311,7 @@ xlog_find_cycle_start(
|
|
if ((error = xlog_bread(log, mid_blk, 1, bp)))
|
|
if ((error = xlog_bread(log, mid_blk, 1, bp)))
|
|
return error;
|
|
return error;
|
|
offset = xlog_align(log, mid_blk, 1, bp);
|
|
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) {
|
|
if (mid_cycle == cycle) {
|
|
*last_blk = mid_blk;
|
|
*last_blk = mid_blk;
|
|
/* last_half_cycle == mid_cycle */
|
|
/* last_half_cycle == mid_cycle */
|
|
@@ -371,7 +371,7 @@ xlog_find_verify_cycle(
|
|
|
|
|
|
buf = xlog_align(log, i, bcount, bp);
|
|
buf = xlog_align(log, i, bcount, bp);
|
|
for (j = 0; j < bcount; j++) {
|
|
for (j = 0; j < bcount; j++) {
|
|
- cycle = GET_CYCLE(buf, ARCH_CONVERT);
|
|
|
|
|
|
+ cycle = xlog_get_cycle(buf);
|
|
if (cycle == stop_on_cycle_no) {
|
|
if (cycle == stop_on_cycle_no) {
|
|
*new_blk = i+j;
|
|
*new_blk = i+j;
|
|
goto out;
|
|
goto out;
|
|
@@ -447,8 +447,7 @@ xlog_find_verify_log_record(
|
|
|
|
|
|
head = (xlog_rec_header_t *)offset;
|
|
head = (xlog_rec_header_t *)offset;
|
|
|
|
|
|
- if (XLOG_HEADER_MAGIC_NUM ==
|
|
|
|
- INT_GET(head->h_magicno, ARCH_CONVERT))
|
|
|
|
|
|
+ if (XLOG_HEADER_MAGIC_NUM == be32_to_cpu(head->h_magicno))
|
|
break;
|
|
break;
|
|
|
|
|
|
if (!smallmem)
|
|
if (!smallmem)
|
|
@@ -480,7 +479,7 @@ xlog_find_verify_log_record(
|
|
* record do we update last_blk.
|
|
* record do we update last_blk.
|
|
*/
|
|
*/
|
|
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
|
|
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
|
|
- uint h_size = INT_GET(head->h_size, ARCH_CONVERT);
|
|
|
|
|
|
+ uint h_size = be32_to_cpu(head->h_size);
|
|
|
|
|
|
xhdrs = h_size / XLOG_HEADER_CYCLE_SIZE;
|
|
xhdrs = h_size / XLOG_HEADER_CYCLE_SIZE;
|
|
if (h_size % XLOG_HEADER_CYCLE_SIZE)
|
|
if (h_size % XLOG_HEADER_CYCLE_SIZE)
|
|
@@ -489,8 +488,8 @@ xlog_find_verify_log_record(
|
|
xhdrs = 1;
|
|
xhdrs = 1;
|
|
}
|
|
}
|
|
|
|
|
|
- if (*last_blk - i + extra_bblks
|
|
|
|
- != BTOBB(INT_GET(head->h_len, ARCH_CONVERT)) + xhdrs)
|
|
|
|
|
|
+ if (*last_blk - i + extra_bblks !=
|
|
|
|
+ BTOBB(be32_to_cpu(head->h_len)) + xhdrs)
|
|
*last_blk = i;
|
|
*last_blk = i;
|
|
|
|
|
|
out:
|
|
out:
|
|
@@ -550,13 +549,13 @@ xlog_find_head(
|
|
if ((error = xlog_bread(log, 0, 1, bp)))
|
|
if ((error = xlog_bread(log, 0, 1, bp)))
|
|
goto bp_err;
|
|
goto bp_err;
|
|
offset = xlog_align(log, 0, 1, bp);
|
|
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 */
|
|
last_blk = head_blk = log_bbnum - 1; /* get cycle # of last block */
|
|
if ((error = xlog_bread(log, last_blk, 1, bp)))
|
|
if ((error = xlog_bread(log, last_blk, 1, bp)))
|
|
goto bp_err;
|
|
goto bp_err;
|
|
offset = xlog_align(log, last_blk, 1, bp);
|
|
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);
|
|
ASSERT(last_half_cycle != 0);
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -808,7 +807,7 @@ xlog_find_tail(
|
|
if ((error = xlog_bread(log, 0, 1, bp)))
|
|
if ((error = xlog_bread(log, 0, 1, bp)))
|
|
goto bread_err;
|
|
goto bread_err;
|
|
offset = xlog_align(log, 0, 1, bp);
|
|
offset = xlog_align(log, 0, 1, bp);
|
|
- if (GET_CYCLE(offset, ARCH_CONVERT) == 0) {
|
|
|
|
|
|
+ if (xlog_get_cycle(offset) == 0) {
|
|
*tail_blk = 0;
|
|
*tail_blk = 0;
|
|
/* leave all other log inited values alone */
|
|
/* leave all other log inited values alone */
|
|
goto exit;
|
|
goto exit;
|
|
@@ -823,8 +822,7 @@ xlog_find_tail(
|
|
if ((error = xlog_bread(log, i, 1, bp)))
|
|
if ((error = xlog_bread(log, i, 1, bp)))
|
|
goto bread_err;
|
|
goto bread_err;
|
|
offset = xlog_align(log, i, 1, bp);
|
|
offset = xlog_align(log, i, 1, bp);
|
|
- if (XLOG_HEADER_MAGIC_NUM ==
|
|
|
|
- INT_GET(*(uint *)offset, ARCH_CONVERT)) {
|
|
|
|
|
|
+ if (XLOG_HEADER_MAGIC_NUM == be32_to_cpu(*(__be32 *)offset)) {
|
|
found = 1;
|
|
found = 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -841,7 +839,7 @@ xlog_find_tail(
|
|
goto bread_err;
|
|
goto bread_err;
|
|
offset = xlog_align(log, i, 1, bp);
|
|
offset = xlog_align(log, i, 1, bp);
|
|
if (XLOG_HEADER_MAGIC_NUM ==
|
|
if (XLOG_HEADER_MAGIC_NUM ==
|
|
- INT_GET(*(uint*)offset, ARCH_CONVERT)) {
|
|
|
|
|
|
+ be32_to_cpu(*(__be32 *)offset)) {
|
|
found = 2;
|
|
found = 2;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -855,7 +853,7 @@ xlog_find_tail(
|
|
|
|
|
|
/* find blk_no of tail of log */
|
|
/* find blk_no of tail of log */
|
|
rhead = (xlog_rec_header_t *)offset;
|
|
rhead = (xlog_rec_header_t *)offset;
|
|
- *tail_blk = BLOCK_LSN(INT_GET(rhead->h_tail_lsn, ARCH_CONVERT));
|
|
|
|
|
|
+ *tail_blk = BLOCK_LSN(be64_to_cpu(rhead->h_tail_lsn));
|
|
|
|
|
|
/*
|
|
/*
|
|
* Reset log values according to the state of the log when we
|
|
* Reset log values according to the state of the log when we
|
|
@@ -869,11 +867,11 @@ xlog_find_tail(
|
|
*/
|
|
*/
|
|
log->l_prev_block = i;
|
|
log->l_prev_block = i;
|
|
log->l_curr_block = (int)*head_blk;
|
|
log->l_curr_block = (int)*head_blk;
|
|
- log->l_curr_cycle = INT_GET(rhead->h_cycle, ARCH_CONVERT);
|
|
|
|
|
|
+ log->l_curr_cycle = be32_to_cpu(rhead->h_cycle);
|
|
if (found == 2)
|
|
if (found == 2)
|
|
log->l_curr_cycle++;
|
|
log->l_curr_cycle++;
|
|
- log->l_tail_lsn = INT_GET(rhead->h_tail_lsn, ARCH_CONVERT);
|
|
|
|
- log->l_last_sync_lsn = INT_GET(rhead->h_lsn, ARCH_CONVERT);
|
|
|
|
|
|
+ log->l_tail_lsn = be64_to_cpu(rhead->h_tail_lsn);
|
|
|
|
+ log->l_last_sync_lsn = be64_to_cpu(rhead->h_lsn);
|
|
log->l_grant_reserve_cycle = log->l_curr_cycle;
|
|
log->l_grant_reserve_cycle = log->l_curr_cycle;
|
|
log->l_grant_reserve_bytes = BBTOB(log->l_curr_block);
|
|
log->l_grant_reserve_bytes = BBTOB(log->l_curr_block);
|
|
log->l_grant_write_cycle = log->l_curr_cycle;
|
|
log->l_grant_write_cycle = log->l_curr_cycle;
|
|
@@ -891,8 +889,8 @@ xlog_find_tail(
|
|
* unmount record rather than the block after it.
|
|
* unmount record rather than the block after it.
|
|
*/
|
|
*/
|
|
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
|
|
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
|
|
- int h_size = INT_GET(rhead->h_size, ARCH_CONVERT);
|
|
|
|
- int h_version = INT_GET(rhead->h_version, ARCH_CONVERT);
|
|
|
|
|
|
+ int h_size = be32_to_cpu(rhead->h_size);
|
|
|
|
+ int h_version = be32_to_cpu(rhead->h_version);
|
|
|
|
|
|
if ((h_version & XLOG_VERSION_2) &&
|
|
if ((h_version & XLOG_VERSION_2) &&
|
|
(h_size > XLOG_HEADER_CYCLE_SIZE)) {
|
|
(h_size > XLOG_HEADER_CYCLE_SIZE)) {
|
|
@@ -906,10 +904,10 @@ xlog_find_tail(
|
|
hblks = 1;
|
|
hblks = 1;
|
|
}
|
|
}
|
|
after_umount_blk = (i + hblks + (int)
|
|
after_umount_blk = (i + hblks + (int)
|
|
- BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT))) % log->l_logBBsize;
|
|
|
|
|
|
+ BTOBB(be32_to_cpu(rhead->h_len))) % log->l_logBBsize;
|
|
tail_lsn = log->l_tail_lsn;
|
|
tail_lsn = log->l_tail_lsn;
|
|
if (*head_blk == after_umount_blk &&
|
|
if (*head_blk == after_umount_blk &&
|
|
- INT_GET(rhead->h_num_logops, ARCH_CONVERT) == 1) {
|
|
|
|
|
|
+ be32_to_cpu(rhead->h_num_logops) == 1) {
|
|
umount_data_blk = (i + hblks) % log->l_logBBsize;
|
|
umount_data_blk = (i + hblks) % log->l_logBBsize;
|
|
if ((error = xlog_bread(log, umount_data_blk, 1, bp))) {
|
|
if ((error = xlog_bread(log, umount_data_blk, 1, bp))) {
|
|
goto bread_err;
|
|
goto bread_err;
|
|
@@ -922,10 +920,12 @@ xlog_find_tail(
|
|
* log records will point recovery to after the
|
|
* log records will point recovery to after the
|
|
* current unmount record.
|
|
* 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;
|
|
*tail_blk = after_umount_blk;
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -986,7 +986,7 @@ exit:
|
|
* -1 => use *blk_no as the first block of the log
|
|
* -1 => use *blk_no as the first block of the log
|
|
* >0 => error has occurred
|
|
* >0 => error has occurred
|
|
*/
|
|
*/
|
|
-int
|
|
|
|
|
|
+STATIC int
|
|
xlog_find_zeroed(
|
|
xlog_find_zeroed(
|
|
xlog_t *log,
|
|
xlog_t *log,
|
|
xfs_daddr_t *blk_no)
|
|
xfs_daddr_t *blk_no)
|
|
@@ -1007,7 +1007,7 @@ xlog_find_zeroed(
|
|
if ((error = xlog_bread(log, 0, 1, bp)))
|
|
if ((error = xlog_bread(log, 0, 1, bp)))
|
|
goto bp_err;
|
|
goto bp_err;
|
|
offset = xlog_align(log, 0, 1, bp);
|
|
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 */
|
|
if (first_cycle == 0) { /* completely zeroed log */
|
|
*blk_no = 0;
|
|
*blk_no = 0;
|
|
xlog_put_bp(bp);
|
|
xlog_put_bp(bp);
|
|
@@ -1018,7 +1018,7 @@ xlog_find_zeroed(
|
|
if ((error = xlog_bread(log, log_bbnum-1, 1, bp)))
|
|
if ((error = xlog_bread(log, log_bbnum-1, 1, bp)))
|
|
goto bp_err;
|
|
goto bp_err;
|
|
offset = xlog_align(log, log_bbnum-1, 1, bp);
|
|
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 */
|
|
if (last_cycle != 0) { /* log completely written to */
|
|
xlog_put_bp(bp);
|
|
xlog_put_bp(bp);
|
|
return 0;
|
|
return 0;
|
|
@@ -1098,13 +1098,13 @@ xlog_add_record(
|
|
xlog_rec_header_t *recp = (xlog_rec_header_t *)buf;
|
|
xlog_rec_header_t *recp = (xlog_rec_header_t *)buf;
|
|
|
|
|
|
memset(buf, 0, BBSIZE);
|
|
memset(buf, 0, BBSIZE);
|
|
- INT_SET(recp->h_magicno, ARCH_CONVERT, XLOG_HEADER_MAGIC_NUM);
|
|
|
|
- INT_SET(recp->h_cycle, ARCH_CONVERT, cycle);
|
|
|
|
- INT_SET(recp->h_version, ARCH_CONVERT,
|
|
|
|
|
|
+ recp->h_magicno = cpu_to_be32(XLOG_HEADER_MAGIC_NUM);
|
|
|
|
+ recp->h_cycle = cpu_to_be32(cycle);
|
|
|
|
+ recp->h_version = cpu_to_be32(
|
|
XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? 2 : 1);
|
|
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_fmt, ARCH_CONVERT, XLOG_FMT);
|
|
|
|
|
|
+ recp->h_lsn = cpu_to_be64(xlog_assign_lsn(cycle, block));
|
|
|
|
+ recp->h_tail_lsn = cpu_to_be64(xlog_assign_lsn(tail_cycle, tail_block));
|
|
|
|
+ recp->h_fmt = cpu_to_be32(XLOG_FMT);
|
|
memcpy(&recp->h_fs_uuid, &log->l_mp->m_sb.sb_uuid, sizeof(uuid_t));
|
|
memcpy(&recp->h_fs_uuid, &log->l_mp->m_sb.sb_uuid, sizeof(uuid_t));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2211,7 +2211,7 @@ xlog_recover_do_buffer_trans(
|
|
* overlap with future reads of those inodes.
|
|
* overlap with future reads of those inodes.
|
|
*/
|
|
*/
|
|
if (XFS_DINODE_MAGIC ==
|
|
if (XFS_DINODE_MAGIC ==
|
|
- INT_GET(*((__uint16_t *)(xfs_buf_offset(bp, 0))), ARCH_CONVERT) &&
|
|
|
|
|
|
+ be16_to_cpu(*((__be16 *)xfs_buf_offset(bp, 0))) &&
|
|
(XFS_BUF_COUNT(bp) != MAX(log->l_mp->m_sb.sb_blocksize,
|
|
(XFS_BUF_COUNT(bp) != MAX(log->l_mp->m_sb.sb_blocksize,
|
|
(__uint32_t)XFS_INODE_CLUSTER_SIZE(log->l_mp)))) {
|
|
(__uint32_t)XFS_INODE_CLUSTER_SIZE(log->l_mp)))) {
|
|
XFS_BUF_STALE(bp);
|
|
XFS_BUF_STALE(bp);
|
|
@@ -2581,8 +2581,7 @@ xlog_recover_do_dquot_trans(
|
|
/*
|
|
/*
|
|
* This type of quotas was turned off, so ignore this record.
|
|
* This type of quotas was turned off, so ignore this record.
|
|
*/
|
|
*/
|
|
- type = INT_GET(recddq->d_flags, ARCH_CONVERT) &
|
|
|
|
- (XFS_DQ_USER | XFS_DQ_PROJ | XFS_DQ_GROUP);
|
|
|
|
|
|
+ type = recddq->d_flags & (XFS_DQ_USER | XFS_DQ_PROJ | XFS_DQ_GROUP);
|
|
ASSERT(type);
|
|
ASSERT(type);
|
|
if (log->l_quotaoffs_flag & type)
|
|
if (log->l_quotaoffs_flag & type)
|
|
return (0);
|
|
return (0);
|
|
@@ -2660,7 +2659,6 @@ xlog_recover_do_efi_trans(
|
|
xfs_mount_t *mp;
|
|
xfs_mount_t *mp;
|
|
xfs_efi_log_item_t *efip;
|
|
xfs_efi_log_item_t *efip;
|
|
xfs_efi_log_format_t *efi_formatp;
|
|
xfs_efi_log_format_t *efi_formatp;
|
|
- SPLDECL(s);
|
|
|
|
|
|
|
|
if (pass == XLOG_RECOVER_PASS1) {
|
|
if (pass == XLOG_RECOVER_PASS1) {
|
|
return 0;
|
|
return 0;
|
|
@@ -2678,11 +2676,11 @@ xlog_recover_do_efi_trans(
|
|
efip->efi_next_extent = efi_formatp->efi_nextents;
|
|
efip->efi_next_extent = efi_formatp->efi_nextents;
|
|
efip->efi_flags |= XFS_EFI_COMMITTED;
|
|
efip->efi_flags |= XFS_EFI_COMMITTED;
|
|
|
|
|
|
- AIL_LOCK(mp,s);
|
|
|
|
|
|
+ spin_lock(&mp->m_ail_lock);
|
|
/*
|
|
/*
|
|
* xfs_trans_update_ail() drops the AIL lock.
|
|
* xfs_trans_update_ail() drops the AIL lock.
|
|
*/
|
|
*/
|
|
- xfs_trans_update_ail(mp, (xfs_log_item_t *)efip, lsn, s);
|
|
|
|
|
|
+ xfs_trans_update_ail(mp, (xfs_log_item_t *)efip, lsn);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2707,7 +2705,6 @@ xlog_recover_do_efd_trans(
|
|
xfs_log_item_t *lip;
|
|
xfs_log_item_t *lip;
|
|
int gen;
|
|
int gen;
|
|
__uint64_t efi_id;
|
|
__uint64_t efi_id;
|
|
- SPLDECL(s);
|
|
|
|
|
|
|
|
if (pass == XLOG_RECOVER_PASS1) {
|
|
if (pass == XLOG_RECOVER_PASS1) {
|
|
return;
|
|
return;
|
|
@@ -2725,7 +2722,7 @@ xlog_recover_do_efd_trans(
|
|
* in the AIL.
|
|
* in the AIL.
|
|
*/
|
|
*/
|
|
mp = log->l_mp;
|
|
mp = log->l_mp;
|
|
- AIL_LOCK(mp,s);
|
|
|
|
|
|
+ spin_lock(&mp->m_ail_lock);
|
|
lip = xfs_trans_first_ail(mp, &gen);
|
|
lip = xfs_trans_first_ail(mp, &gen);
|
|
while (lip != NULL) {
|
|
while (lip != NULL) {
|
|
if (lip->li_type == XFS_LI_EFI) {
|
|
if (lip->li_type == XFS_LI_EFI) {
|
|
@@ -2735,22 +2732,14 @@ xlog_recover_do_efd_trans(
|
|
* xfs_trans_delete_ail() drops the
|
|
* xfs_trans_delete_ail() drops the
|
|
* AIL lock.
|
|
* AIL lock.
|
|
*/
|
|
*/
|
|
- xfs_trans_delete_ail(mp, lip, s);
|
|
|
|
- break;
|
|
|
|
|
|
+ xfs_trans_delete_ail(mp, lip);
|
|
|
|
+ xfs_efi_item_free(efip);
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
lip = xfs_trans_next_ail(mp, lip, &gen, NULL);
|
|
lip = xfs_trans_next_ail(mp, lip, &gen, NULL);
|
|
}
|
|
}
|
|
-
|
|
|
|
- /*
|
|
|
|
- * If we found it, then free it up. If it wasn't there, it
|
|
|
|
- * must have been overwritten in the log. Oh well.
|
|
|
|
- */
|
|
|
|
- if (lip != NULL) {
|
|
|
|
- xfs_efi_item_free(efip);
|
|
|
|
- } else {
|
|
|
|
- AIL_UNLOCK(mp, s);
|
|
|
|
- }
|
|
|
|
|
|
+ spin_unlock(&mp->m_ail_lock);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -2897,8 +2886,8 @@ xlog_recover_process_data(
|
|
unsigned long hash;
|
|
unsigned long hash;
|
|
uint flags;
|
|
uint flags;
|
|
|
|
|
|
- lp = dp + INT_GET(rhead->h_len, ARCH_CONVERT);
|
|
|
|
- num_logops = INT_GET(rhead->h_num_logops, ARCH_CONVERT);
|
|
|
|
|
|
+ lp = dp + be32_to_cpu(rhead->h_len);
|
|
|
|
+ num_logops = be32_to_cpu(rhead->h_num_logops);
|
|
|
|
|
|
/* check the log format matches our own - else we can't recover */
|
|
/* check the log format matches our own - else we can't recover */
|
|
if (xlog_header_check_recover(log->l_mp, rhead))
|
|
if (xlog_header_check_recover(log->l_mp, rhead))
|
|
@@ -2915,15 +2904,20 @@ xlog_recover_process_data(
|
|
ASSERT(0);
|
|
ASSERT(0);
|
|
return (XFS_ERROR(EIO));
|
|
return (XFS_ERROR(EIO));
|
|
}
|
|
}
|
|
- tid = INT_GET(ohead->oh_tid, ARCH_CONVERT);
|
|
|
|
|
|
+ tid = be32_to_cpu(ohead->oh_tid);
|
|
hash = XLOG_RHASH(tid);
|
|
hash = XLOG_RHASH(tid);
|
|
trans = xlog_recover_find_tid(rhash[hash], tid);
|
|
trans = xlog_recover_find_tid(rhash[hash], tid);
|
|
if (trans == NULL) { /* not found; add new tid */
|
|
if (trans == NULL) { /* not found; add new tid */
|
|
if (ohead->oh_flags & XLOG_START_TRANS)
|
|
if (ohead->oh_flags & XLOG_START_TRANS)
|
|
xlog_recover_new_tid(&rhash[hash], tid,
|
|
xlog_recover_new_tid(&rhash[hash], tid,
|
|
- INT_GET(rhead->h_lsn, ARCH_CONVERT));
|
|
|
|
|
|
+ be64_to_cpu(rhead->h_lsn));
|
|
} else {
|
|
} else {
|
|
- ASSERT(dp+INT_GET(ohead->oh_len, ARCH_CONVERT) <= lp);
|
|
|
|
|
|
+ if (dp + be32_to_cpu(ohead->oh_len) > lp) {
|
|
|
|
+ xlog_warn(
|
|
|
|
+ "XFS: xlog_recover_process_data: bad length");
|
|
|
|
+ WARN_ON(1);
|
|
|
|
+ return (XFS_ERROR(EIO));
|
|
|
|
+ }
|
|
flags = ohead->oh_flags & ~XLOG_END_TRANS;
|
|
flags = ohead->oh_flags & ~XLOG_END_TRANS;
|
|
if (flags & XLOG_WAS_CONT_TRANS)
|
|
if (flags & XLOG_WAS_CONT_TRANS)
|
|
flags &= ~XLOG_CONTINUE_TRANS;
|
|
flags &= ~XLOG_CONTINUE_TRANS;
|
|
@@ -2937,8 +2931,7 @@ xlog_recover_process_data(
|
|
break;
|
|
break;
|
|
case XLOG_WAS_CONT_TRANS:
|
|
case XLOG_WAS_CONT_TRANS:
|
|
error = xlog_recover_add_to_cont_trans(trans,
|
|
error = xlog_recover_add_to_cont_trans(trans,
|
|
- dp, INT_GET(ohead->oh_len,
|
|
|
|
- ARCH_CONVERT));
|
|
|
|
|
|
+ dp, be32_to_cpu(ohead->oh_len));
|
|
break;
|
|
break;
|
|
case XLOG_START_TRANS:
|
|
case XLOG_START_TRANS:
|
|
xlog_warn(
|
|
xlog_warn(
|
|
@@ -2949,8 +2942,7 @@ xlog_recover_process_data(
|
|
case 0:
|
|
case 0:
|
|
case XLOG_CONTINUE_TRANS:
|
|
case XLOG_CONTINUE_TRANS:
|
|
error = xlog_recover_add_to_trans(trans,
|
|
error = xlog_recover_add_to_trans(trans,
|
|
- dp, INT_GET(ohead->oh_len,
|
|
|
|
- ARCH_CONVERT));
|
|
|
|
|
|
+ dp, be32_to_cpu(ohead->oh_len));
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
xlog_warn(
|
|
xlog_warn(
|
|
@@ -2962,7 +2954,7 @@ xlog_recover_process_data(
|
|
if (error)
|
|
if (error)
|
|
return error;
|
|
return error;
|
|
}
|
|
}
|
|
- dp += INT_GET(ohead->oh_len, ARCH_CONVERT);
|
|
|
|
|
|
+ dp += be32_to_cpu(ohead->oh_len);
|
|
num_logops--;
|
|
num_logops--;
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
@@ -3075,10 +3067,9 @@ xlog_recover_process_efis(
|
|
xfs_efi_log_item_t *efip;
|
|
xfs_efi_log_item_t *efip;
|
|
int gen;
|
|
int gen;
|
|
xfs_mount_t *mp;
|
|
xfs_mount_t *mp;
|
|
- SPLDECL(s);
|
|
|
|
|
|
|
|
mp = log->l_mp;
|
|
mp = log->l_mp;
|
|
- AIL_LOCK(mp,s);
|
|
|
|
|
|
+ spin_lock(&mp->m_ail_lock);
|
|
|
|
|
|
lip = xfs_trans_first_ail(mp, &gen);
|
|
lip = xfs_trans_first_ail(mp, &gen);
|
|
while (lip != NULL) {
|
|
while (lip != NULL) {
|
|
@@ -3099,12 +3090,12 @@ xlog_recover_process_efis(
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- AIL_UNLOCK(mp, s);
|
|
|
|
|
|
+ spin_unlock(&mp->m_ail_lock);
|
|
xlog_recover_process_efi(mp, efip);
|
|
xlog_recover_process_efi(mp, efip);
|
|
- AIL_LOCK(mp,s);
|
|
|
|
|
|
+ spin_lock(&mp->m_ail_lock);
|
|
lip = xfs_trans_next_ail(mp, lip, &gen, NULL);
|
|
lip = xfs_trans_next_ail(mp, lip, &gen, NULL);
|
|
}
|
|
}
|
|
- AIL_UNLOCK(mp, s);
|
|
|
|
|
|
+ spin_unlock(&mp->m_ail_lock);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -3315,16 +3306,16 @@ xlog_pack_data_checksum(
|
|
int size)
|
|
int size)
|
|
{
|
|
{
|
|
int i;
|
|
int i;
|
|
- uint *up;
|
|
|
|
|
|
+ __be32 *up;
|
|
uint chksum = 0;
|
|
uint chksum = 0;
|
|
|
|
|
|
- up = (uint *)iclog->ic_datap;
|
|
|
|
|
|
+ up = (__be32 *)iclog->ic_datap;
|
|
/* divide length by 4 to get # words */
|
|
/* divide length by 4 to get # words */
|
|
for (i = 0; i < (size >> 2); i++) {
|
|
for (i = 0; i < (size >> 2); i++) {
|
|
- chksum ^= INT_GET(*up, ARCH_CONVERT);
|
|
|
|
|
|
+ chksum ^= be32_to_cpu(*up);
|
|
up++;
|
|
up++;
|
|
}
|
|
}
|
|
- INT_SET(iclog->ic_header.h_chksum, ARCH_CONVERT, chksum);
|
|
|
|
|
|
+ iclog->ic_header.h_chksum = cpu_to_be32(chksum);
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
#define xlog_pack_data_checksum(log, iclog, size)
|
|
#define xlog_pack_data_checksum(log, iclog, size)
|
|
@@ -3341,7 +3332,7 @@ xlog_pack_data(
|
|
{
|
|
{
|
|
int i, j, k;
|
|
int i, j, k;
|
|
int size = iclog->ic_offset + roundoff;
|
|
int size = iclog->ic_offset + roundoff;
|
|
- uint cycle_lsn;
|
|
|
|
|
|
+ __be32 cycle_lsn;
|
|
xfs_caddr_t dp;
|
|
xfs_caddr_t dp;
|
|
xlog_in_core_2_t *xhdr;
|
|
xlog_in_core_2_t *xhdr;
|
|
|
|
|
|
@@ -3352,8 +3343,8 @@ xlog_pack_data(
|
|
dp = iclog->ic_datap;
|
|
dp = iclog->ic_datap;
|
|
for (i = 0; i < BTOBB(size) &&
|
|
for (i = 0; i < BTOBB(size) &&
|
|
i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) {
|
|
i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) {
|
|
- iclog->ic_header.h_cycle_data[i] = *(uint *)dp;
|
|
|
|
- *(uint *)dp = cycle_lsn;
|
|
|
|
|
|
+ iclog->ic_header.h_cycle_data[i] = *(__be32 *)dp;
|
|
|
|
+ *(__be32 *)dp = cycle_lsn;
|
|
dp += BBSIZE;
|
|
dp += BBSIZE;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3362,8 +3353,8 @@ xlog_pack_data(
|
|
for ( ; i < BTOBB(size); i++) {
|
|
for ( ; i < BTOBB(size); i++) {
|
|
j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
|
j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
|
k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
|
k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
|
- xhdr[j].hic_xheader.xh_cycle_data[k] = *(uint *)dp;
|
|
|
|
- *(uint *)dp = cycle_lsn;
|
|
|
|
|
|
+ xhdr[j].hic_xheader.xh_cycle_data[k] = *(__be32 *)dp;
|
|
|
|
+ *(__be32 *)dp = cycle_lsn;
|
|
dp += BBSIZE;
|
|
dp += BBSIZE;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3380,21 +3371,21 @@ xlog_unpack_data_checksum(
|
|
xfs_caddr_t dp,
|
|
xfs_caddr_t dp,
|
|
xlog_t *log)
|
|
xlog_t *log)
|
|
{
|
|
{
|
|
- uint *up = (uint *)dp;
|
|
|
|
|
|
+ __be32 *up = (__be32 *)dp;
|
|
uint chksum = 0;
|
|
uint chksum = 0;
|
|
int i;
|
|
int i;
|
|
|
|
|
|
/* divide length by 4 to get # words */
|
|
/* divide length by 4 to get # words */
|
|
- for (i=0; i < INT_GET(rhead->h_len, ARCH_CONVERT) >> 2; i++) {
|
|
|
|
- chksum ^= INT_GET(*up, ARCH_CONVERT);
|
|
|
|
|
|
+ for (i=0; i < be32_to_cpu(rhead->h_len) >> 2; i++) {
|
|
|
|
+ chksum ^= be32_to_cpu(*up);
|
|
up++;
|
|
up++;
|
|
}
|
|
}
|
|
- if (chksum != INT_GET(rhead->h_chksum, ARCH_CONVERT)) {
|
|
|
|
|
|
+ if (chksum != be32_to_cpu(rhead->h_chksum)) {
|
|
if (rhead->h_chksum ||
|
|
if (rhead->h_chksum ||
|
|
((log->l_flags & XLOG_CHKSUM_MISMATCH) == 0)) {
|
|
((log->l_flags & XLOG_CHKSUM_MISMATCH) == 0)) {
|
|
cmn_err(CE_DEBUG,
|
|
cmn_err(CE_DEBUG,
|
|
"XFS: LogR chksum mismatch: was (0x%x) is (0x%x)\n",
|
|
"XFS: LogR chksum mismatch: was (0x%x) is (0x%x)\n",
|
|
- INT_GET(rhead->h_chksum, ARCH_CONVERT), chksum);
|
|
|
|
|
|
+ be32_to_cpu(rhead->h_chksum), chksum);
|
|
cmn_err(CE_DEBUG,
|
|
cmn_err(CE_DEBUG,
|
|
"XFS: Disregard message if filesystem was created with non-DEBUG kernel");
|
|
"XFS: Disregard message if filesystem was created with non-DEBUG kernel");
|
|
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
|
|
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
|
|
@@ -3418,18 +3409,18 @@ xlog_unpack_data(
|
|
int i, j, k;
|
|
int i, j, k;
|
|
xlog_in_core_2_t *xhdr;
|
|
xlog_in_core_2_t *xhdr;
|
|
|
|
|
|
- for (i = 0; i < BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)) &&
|
|
|
|
|
|
+ for (i = 0; i < BTOBB(be32_to_cpu(rhead->h_len)) &&
|
|
i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) {
|
|
i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) {
|
|
- *(uint *)dp = *(uint *)&rhead->h_cycle_data[i];
|
|
|
|
|
|
+ *(__be32 *)dp = *(__be32 *)&rhead->h_cycle_data[i];
|
|
dp += BBSIZE;
|
|
dp += BBSIZE;
|
|
}
|
|
}
|
|
|
|
|
|
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
|
|
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
|
|
xhdr = (xlog_in_core_2_t *)rhead;
|
|
xhdr = (xlog_in_core_2_t *)rhead;
|
|
- for ( ; i < BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)); i++) {
|
|
|
|
|
|
+ for ( ; i < BTOBB(be32_to_cpu(rhead->h_len)); i++) {
|
|
j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
|
j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
|
k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
|
k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
|
|
- *(uint *)dp = xhdr[j].hic_xheader.xh_cycle_data[k];
|
|
|
|
|
|
+ *(__be32 *)dp = xhdr[j].hic_xheader.xh_cycle_data[k];
|
|
dp += BBSIZE;
|
|
dp += BBSIZE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3445,24 +3436,21 @@ xlog_valid_rec_header(
|
|
{
|
|
{
|
|
int hlen;
|
|
int hlen;
|
|
|
|
|
|
- if (unlikely(
|
|
|
|
- (INT_GET(rhead->h_magicno, ARCH_CONVERT) !=
|
|
|
|
- XLOG_HEADER_MAGIC_NUM))) {
|
|
|
|
|
|
+ if (unlikely(be32_to_cpu(rhead->h_magicno) != XLOG_HEADER_MAGIC_NUM)) {
|
|
XFS_ERROR_REPORT("xlog_valid_rec_header(1)",
|
|
XFS_ERROR_REPORT("xlog_valid_rec_header(1)",
|
|
XFS_ERRLEVEL_LOW, log->l_mp);
|
|
XFS_ERRLEVEL_LOW, log->l_mp);
|
|
return XFS_ERROR(EFSCORRUPTED);
|
|
return XFS_ERROR(EFSCORRUPTED);
|
|
}
|
|
}
|
|
if (unlikely(
|
|
if (unlikely(
|
|
(!rhead->h_version ||
|
|
(!rhead->h_version ||
|
|
- (INT_GET(rhead->h_version, ARCH_CONVERT) &
|
|
|
|
- (~XLOG_VERSION_OKBITS)) != 0))) {
|
|
|
|
|
|
+ (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS))))) {
|
|
xlog_warn("XFS: %s: unrecognised log version (%d).",
|
|
xlog_warn("XFS: %s: unrecognised log version (%d).",
|
|
- __FUNCTION__, INT_GET(rhead->h_version, ARCH_CONVERT));
|
|
|
|
|
|
+ __FUNCTION__, be32_to_cpu(rhead->h_version));
|
|
return XFS_ERROR(EIO);
|
|
return XFS_ERROR(EIO);
|
|
}
|
|
}
|
|
|
|
|
|
/* LR body must have data or it wouldn't have been written */
|
|
/* LR body must have data or it wouldn't have been written */
|
|
- hlen = INT_GET(rhead->h_len, ARCH_CONVERT);
|
|
|
|
|
|
+ hlen = be32_to_cpu(rhead->h_len);
|
|
if (unlikely( hlen <= 0 || hlen > INT_MAX )) {
|
|
if (unlikely( hlen <= 0 || hlen > INT_MAX )) {
|
|
XFS_ERROR_REPORT("xlog_valid_rec_header(2)",
|
|
XFS_ERROR_REPORT("xlog_valid_rec_header(2)",
|
|
XFS_ERRLEVEL_LOW, log->l_mp);
|
|
XFS_ERRLEVEL_LOW, log->l_mp);
|
|
@@ -3522,9 +3510,8 @@ xlog_do_recovery_pass(
|
|
error = xlog_valid_rec_header(log, rhead, tail_blk);
|
|
error = xlog_valid_rec_header(log, rhead, tail_blk);
|
|
if (error)
|
|
if (error)
|
|
goto bread_err1;
|
|
goto bread_err1;
|
|
- h_size = INT_GET(rhead->h_size, ARCH_CONVERT);
|
|
|
|
- if ((INT_GET(rhead->h_version, ARCH_CONVERT)
|
|
|
|
- & XLOG_VERSION_2) &&
|
|
|
|
|
|
+ h_size = be32_to_cpu(rhead->h_size);
|
|
|
|
+ if ((be32_to_cpu(rhead->h_version) & XLOG_VERSION_2) &&
|
|
(h_size > XLOG_HEADER_CYCLE_SIZE)) {
|
|
(h_size > XLOG_HEADER_CYCLE_SIZE)) {
|
|
hblks = h_size / XLOG_HEADER_CYCLE_SIZE;
|
|
hblks = h_size / XLOG_HEADER_CYCLE_SIZE;
|
|
if (h_size % XLOG_HEADER_CYCLE_SIZE)
|
|
if (h_size % XLOG_HEADER_CYCLE_SIZE)
|
|
@@ -3561,7 +3548,7 @@ xlog_do_recovery_pass(
|
|
goto bread_err2;
|
|
goto bread_err2;
|
|
|
|
|
|
/* blocks in data section */
|
|
/* blocks in data section */
|
|
- bblks = (int)BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT));
|
|
|
|
|
|
+ bblks = (int)BTOBB(be32_to_cpu(rhead->h_len));
|
|
error = xlog_bread(log, blk_no + hblks, bblks, dbp);
|
|
error = xlog_bread(log, blk_no + hblks, bblks, dbp);
|
|
if (error)
|
|
if (error)
|
|
goto bread_err2;
|
|
goto bread_err2;
|
|
@@ -3636,7 +3623,7 @@ xlog_do_recovery_pass(
|
|
if (error)
|
|
if (error)
|
|
goto bread_err2;
|
|
goto bread_err2;
|
|
|
|
|
|
- bblks = (int)BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT));
|
|
|
|
|
|
+ bblks = (int)BTOBB(be32_to_cpu(rhead->h_len));
|
|
blk_no += hblks;
|
|
blk_no += hblks;
|
|
|
|
|
|
/* Read in data for log record */
|
|
/* Read in data for log record */
|
|
@@ -3707,7 +3694,7 @@ xlog_do_recovery_pass(
|
|
error = xlog_valid_rec_header(log, rhead, blk_no);
|
|
error = xlog_valid_rec_header(log, rhead, blk_no);
|
|
if (error)
|
|
if (error)
|
|
goto bread_err2;
|
|
goto bread_err2;
|
|
- bblks = (int)BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT));
|
|
|
|
|
|
+ bblks = (int)BTOBB(be32_to_cpu(rhead->h_len));
|
|
if ((error = xlog_bread(log, blk_no+hblks, bblks, dbp)))
|
|
if ((error = xlog_bread(log, blk_no+hblks, bblks, dbp)))
|
|
goto bread_err2;
|
|
goto bread_err2;
|
|
offset = xlog_align(log, blk_no+hblks, bblks, dbp);
|
|
offset = xlog_align(log, blk_no+hblks, bblks, dbp);
|