diff options
Diffstat (limited to 'fs/xfs/xfs_log_recover.c')
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 120 |
1 files changed, 56 insertions, 64 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index f27b6e93a682..35e098d4d749 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -198,7 +198,7 @@ xlog_header_check_dump( | |||
198 | cmn_err(CE_DEBUG, " log : uuid = "); | 198 | cmn_err(CE_DEBUG, " log : uuid = "); |
199 | for (b = 0; b < 16; b++) | 199 | for (b = 0; b < 16; b++) |
200 | cmn_err(CE_DEBUG, "%02x",((uchar_t *)&head->h_fs_uuid)[b]); | 200 | cmn_err(CE_DEBUG, "%02x",((uchar_t *)&head->h_fs_uuid)[b]); |
201 | cmn_err(CE_DEBUG, ", fmt = %d\n", INT_GET(head->h_fmt, ARCH_CONVERT)); | 201 | cmn_err(CE_DEBUG, ", fmt = %d\n", be32_to_cpu(head->h_fmt)); |
202 | } | 202 | } |
203 | #else | 203 | #else |
204 | #define xlog_header_check_dump(mp, head) | 204 | #define xlog_header_check_dump(mp, head) |
@@ -212,14 +212,14 @@ xlog_header_check_recover( | |||
212 | xfs_mount_t *mp, | 212 | xfs_mount_t *mp, |
213 | xlog_rec_header_t *head) | 213 | xlog_rec_header_t *head) |
214 | { | 214 | { |
215 | ASSERT(INT_GET(head->h_magicno, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM); | 215 | ASSERT(be32_to_cpu(head->h_magicno) == XLOG_HEADER_MAGIC_NUM); |
216 | 216 | ||
217 | /* | 217 | /* |
218 | * IRIX doesn't write the h_fmt field and leaves it zeroed | 218 | * IRIX doesn't write the h_fmt field and leaves it zeroed |
219 | * (XLOG_FMT_UNKNOWN). This stops us from trying to recover | 219 | * (XLOG_FMT_UNKNOWN). This stops us from trying to recover |
220 | * a dirty log created in IRIX. | 220 | * a dirty log created in IRIX. |
221 | */ | 221 | */ |
222 | if (unlikely(INT_GET(head->h_fmt, ARCH_CONVERT) != XLOG_FMT)) { | 222 | if (unlikely(be32_to_cpu(head->h_fmt) != XLOG_FMT)) { |
223 | xlog_warn( | 223 | xlog_warn( |
224 | "XFS: dirty log written in incompatible format - can't recover"); | 224 | "XFS: dirty log written in incompatible format - can't recover"); |
225 | xlog_header_check_dump(mp, head); | 225 | xlog_header_check_dump(mp, head); |
@@ -245,7 +245,7 @@ xlog_header_check_mount( | |||
245 | xfs_mount_t *mp, | 245 | xfs_mount_t *mp, |
246 | xlog_rec_header_t *head) | 246 | xlog_rec_header_t *head) |
247 | { | 247 | { |
248 | ASSERT(INT_GET(head->h_magicno, ARCH_CONVERT) == XLOG_HEADER_MAGIC_NUM); | 248 | ASSERT(be32_to_cpu(head->h_magicno) == XLOG_HEADER_MAGIC_NUM); |
249 | 249 | ||
250 | if (uuid_is_nil(&head->h_fs_uuid)) { | 250 | if (uuid_is_nil(&head->h_fs_uuid)) { |
251 | /* | 251 | /* |
@@ -447,8 +447,7 @@ xlog_find_verify_log_record( | |||
447 | 447 | ||
448 | head = (xlog_rec_header_t *)offset; | 448 | head = (xlog_rec_header_t *)offset; |
449 | 449 | ||
450 | if (XLOG_HEADER_MAGIC_NUM == | 450 | if (XLOG_HEADER_MAGIC_NUM == be32_to_cpu(head->h_magicno)) |
451 | INT_GET(head->h_magicno, ARCH_CONVERT)) | ||
452 | break; | 451 | break; |
453 | 452 | ||
454 | if (!smallmem) | 453 | if (!smallmem) |
@@ -480,7 +479,7 @@ xlog_find_verify_log_record( | |||
480 | * record do we update last_blk. | 479 | * record do we update last_blk. |
481 | */ | 480 | */ |
482 | if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { | 481 | if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { |
483 | uint h_size = INT_GET(head->h_size, ARCH_CONVERT); | 482 | uint h_size = be32_to_cpu(head->h_size); |
484 | 483 | ||
485 | xhdrs = h_size / XLOG_HEADER_CYCLE_SIZE; | 484 | xhdrs = h_size / XLOG_HEADER_CYCLE_SIZE; |
486 | if (h_size % XLOG_HEADER_CYCLE_SIZE) | 485 | if (h_size % XLOG_HEADER_CYCLE_SIZE) |
@@ -489,8 +488,8 @@ xlog_find_verify_log_record( | |||
489 | xhdrs = 1; | 488 | xhdrs = 1; |
490 | } | 489 | } |
491 | 490 | ||
492 | if (*last_blk - i + extra_bblks | 491 | if (*last_blk - i + extra_bblks != |
493 | != BTOBB(INT_GET(head->h_len, ARCH_CONVERT)) + xhdrs) | 492 | BTOBB(be32_to_cpu(head->h_len)) + xhdrs) |
494 | *last_blk = i; | 493 | *last_blk = i; |
495 | 494 | ||
496 | out: | 495 | out: |
@@ -823,8 +822,7 @@ xlog_find_tail( | |||
823 | if ((error = xlog_bread(log, i, 1, bp))) | 822 | if ((error = xlog_bread(log, i, 1, bp))) |
824 | goto bread_err; | 823 | goto bread_err; |
825 | offset = xlog_align(log, i, 1, bp); | 824 | offset = xlog_align(log, i, 1, bp); |
826 | if (XLOG_HEADER_MAGIC_NUM == | 825 | if (XLOG_HEADER_MAGIC_NUM == be32_to_cpu(*(__be32 *)offset)) { |
827 | INT_GET(*(uint *)offset, ARCH_CONVERT)) { | ||
828 | found = 1; | 826 | found = 1; |
829 | break; | 827 | break; |
830 | } | 828 | } |
@@ -841,7 +839,7 @@ xlog_find_tail( | |||
841 | goto bread_err; | 839 | goto bread_err; |
842 | offset = xlog_align(log, i, 1, bp); | 840 | offset = xlog_align(log, i, 1, bp); |
843 | if (XLOG_HEADER_MAGIC_NUM == | 841 | if (XLOG_HEADER_MAGIC_NUM == |
844 | INT_GET(*(uint*)offset, ARCH_CONVERT)) { | 842 | be32_to_cpu(*(__be32 *)offset)) { |
845 | found = 2; | 843 | found = 2; |
846 | break; | 844 | break; |
847 | } | 845 | } |
@@ -855,7 +853,7 @@ xlog_find_tail( | |||
855 | 853 | ||
856 | /* find blk_no of tail of log */ | 854 | /* find blk_no of tail of log */ |
857 | rhead = (xlog_rec_header_t *)offset; | 855 | rhead = (xlog_rec_header_t *)offset; |
858 | *tail_blk = BLOCK_LSN(INT_GET(rhead->h_tail_lsn, ARCH_CONVERT)); | 856 | *tail_blk = BLOCK_LSN(be64_to_cpu(rhead->h_tail_lsn)); |
859 | 857 | ||
860 | /* | 858 | /* |
861 | * Reset log values according to the state of the log when we | 859 | * Reset log values according to the state of the log when we |
@@ -869,11 +867,11 @@ xlog_find_tail( | |||
869 | */ | 867 | */ |
870 | log->l_prev_block = i; | 868 | log->l_prev_block = i; |
871 | log->l_curr_block = (int)*head_blk; | 869 | log->l_curr_block = (int)*head_blk; |
872 | log->l_curr_cycle = INT_GET(rhead->h_cycle, ARCH_CONVERT); | 870 | log->l_curr_cycle = be32_to_cpu(rhead->h_cycle); |
873 | if (found == 2) | 871 | if (found == 2) |
874 | log->l_curr_cycle++; | 872 | log->l_curr_cycle++; |
875 | log->l_tail_lsn = INT_GET(rhead->h_tail_lsn, ARCH_CONVERT); | 873 | log->l_tail_lsn = be64_to_cpu(rhead->h_tail_lsn); |
876 | log->l_last_sync_lsn = INT_GET(rhead->h_lsn, ARCH_CONVERT); | 874 | log->l_last_sync_lsn = be64_to_cpu(rhead->h_lsn); |
877 | log->l_grant_reserve_cycle = log->l_curr_cycle; | 875 | log->l_grant_reserve_cycle = log->l_curr_cycle; |
878 | log->l_grant_reserve_bytes = BBTOB(log->l_curr_block); | 876 | log->l_grant_reserve_bytes = BBTOB(log->l_curr_block); |
879 | log->l_grant_write_cycle = log->l_curr_cycle; | 877 | log->l_grant_write_cycle = log->l_curr_cycle; |
@@ -891,8 +889,8 @@ xlog_find_tail( | |||
891 | * unmount record rather than the block after it. | 889 | * unmount record rather than the block after it. |
892 | */ | 890 | */ |
893 | if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { | 891 | if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { |
894 | int h_size = INT_GET(rhead->h_size, ARCH_CONVERT); | 892 | int h_size = be32_to_cpu(rhead->h_size); |
895 | int h_version = INT_GET(rhead->h_version, ARCH_CONVERT); | 893 | int h_version = be32_to_cpu(rhead->h_version); |
896 | 894 | ||
897 | if ((h_version & XLOG_VERSION_2) && | 895 | if ((h_version & XLOG_VERSION_2) && |
898 | (h_size > XLOG_HEADER_CYCLE_SIZE)) { | 896 | (h_size > XLOG_HEADER_CYCLE_SIZE)) { |
@@ -906,10 +904,10 @@ xlog_find_tail( | |||
906 | hblks = 1; | 904 | hblks = 1; |
907 | } | 905 | } |
908 | after_umount_blk = (i + hblks + (int) | 906 | after_umount_blk = (i + hblks + (int) |
909 | BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT))) % log->l_logBBsize; | 907 | BTOBB(be32_to_cpu(rhead->h_len))) % log->l_logBBsize; |
910 | tail_lsn = log->l_tail_lsn; | 908 | tail_lsn = log->l_tail_lsn; |
911 | if (*head_blk == after_umount_blk && | 909 | if (*head_blk == after_umount_blk && |
912 | INT_GET(rhead->h_num_logops, ARCH_CONVERT) == 1) { | 910 | be32_to_cpu(rhead->h_num_logops) == 1) { |
913 | umount_data_blk = (i + hblks) % log->l_logBBsize; | 911 | umount_data_blk = (i + hblks) % log->l_logBBsize; |
914 | if ((error = xlog_bread(log, umount_data_blk, 1, bp))) { | 912 | if ((error = xlog_bread(log, umount_data_blk, 1, bp))) { |
915 | goto bread_err; | 913 | goto bread_err; |
@@ -1100,14 +1098,13 @@ xlog_add_record( | |||
1100 | xlog_rec_header_t *recp = (xlog_rec_header_t *)buf; | 1098 | xlog_rec_header_t *recp = (xlog_rec_header_t *)buf; |
1101 | 1099 | ||
1102 | memset(buf, 0, BBSIZE); | 1100 | memset(buf, 0, BBSIZE); |
1103 | INT_SET(recp->h_magicno, ARCH_CONVERT, XLOG_HEADER_MAGIC_NUM); | 1101 | recp->h_magicno = cpu_to_be32(XLOG_HEADER_MAGIC_NUM); |
1104 | INT_SET(recp->h_cycle, ARCH_CONVERT, cycle); | 1102 | recp->h_cycle = cpu_to_be32(cycle); |
1105 | INT_SET(recp->h_version, ARCH_CONVERT, | 1103 | recp->h_version = cpu_to_be32( |
1106 | XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? 2 : 1); | 1104 | XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? 2 : 1); |
1107 | INT_SET(recp->h_lsn, ARCH_CONVERT, xlog_assign_lsn(cycle, block)); | 1105 | recp->h_lsn = cpu_to_be64(xlog_assign_lsn(cycle, block)); |
1108 | INT_SET(recp->h_tail_lsn, ARCH_CONVERT, | 1106 | recp->h_tail_lsn = cpu_to_be64(xlog_assign_lsn(tail_cycle, tail_block)); |
1109 | xlog_assign_lsn(tail_cycle, tail_block)); | 1107 | recp->h_fmt = cpu_to_be32(XLOG_FMT); |
1110 | INT_SET(recp->h_fmt, ARCH_CONVERT, XLOG_FMT); | ||
1111 | memcpy(&recp->h_fs_uuid, &log->l_mp->m_sb.sb_uuid, sizeof(uuid_t)); | 1108 | memcpy(&recp->h_fs_uuid, &log->l_mp->m_sb.sb_uuid, sizeof(uuid_t)); |
1112 | } | 1109 | } |
1113 | 1110 | ||
@@ -2214,7 +2211,7 @@ xlog_recover_do_buffer_trans( | |||
2214 | * overlap with future reads of those inodes. | 2211 | * overlap with future reads of those inodes. |
2215 | */ | 2212 | */ |
2216 | if (XFS_DINODE_MAGIC == | 2213 | if (XFS_DINODE_MAGIC == |
2217 | INT_GET(*((__uint16_t *)(xfs_buf_offset(bp, 0))), ARCH_CONVERT) && | 2214 | be16_to_cpu(*((__be16 *)xfs_buf_offset(bp, 0))) && |
2218 | (XFS_BUF_COUNT(bp) != MAX(log->l_mp->m_sb.sb_blocksize, | 2215 | (XFS_BUF_COUNT(bp) != MAX(log->l_mp->m_sb.sb_blocksize, |
2219 | (__uint32_t)XFS_INODE_CLUSTER_SIZE(log->l_mp)))) { | 2216 | (__uint32_t)XFS_INODE_CLUSTER_SIZE(log->l_mp)))) { |
2220 | XFS_BUF_STALE(bp); | 2217 | XFS_BUF_STALE(bp); |
@@ -2584,8 +2581,7 @@ xlog_recover_do_dquot_trans( | |||
2584 | /* | 2581 | /* |
2585 | * This type of quotas was turned off, so ignore this record. | 2582 | * This type of quotas was turned off, so ignore this record. |
2586 | */ | 2583 | */ |
2587 | type = INT_GET(recddq->d_flags, ARCH_CONVERT) & | 2584 | type = recddq->d_flags & (XFS_DQ_USER | XFS_DQ_PROJ | XFS_DQ_GROUP); |
2588 | (XFS_DQ_USER | XFS_DQ_PROJ | XFS_DQ_GROUP); | ||
2589 | ASSERT(type); | 2585 | ASSERT(type); |
2590 | if (log->l_quotaoffs_flag & type) | 2586 | if (log->l_quotaoffs_flag & type) |
2591 | return (0); | 2587 | return (0); |
@@ -2898,8 +2894,8 @@ xlog_recover_process_data( | |||
2898 | unsigned long hash; | 2894 | unsigned long hash; |
2899 | uint flags; | 2895 | uint flags; |
2900 | 2896 | ||
2901 | lp = dp + INT_GET(rhead->h_len, ARCH_CONVERT); | 2897 | lp = dp + be32_to_cpu(rhead->h_len); |
2902 | num_logops = INT_GET(rhead->h_num_logops, ARCH_CONVERT); | 2898 | num_logops = be32_to_cpu(rhead->h_num_logops); |
2903 | 2899 | ||
2904 | /* check the log format matches our own - else we can't recover */ | 2900 | /* check the log format matches our own - else we can't recover */ |
2905 | if (xlog_header_check_recover(log->l_mp, rhead)) | 2901 | if (xlog_header_check_recover(log->l_mp, rhead)) |
@@ -2922,7 +2918,7 @@ xlog_recover_process_data( | |||
2922 | if (trans == NULL) { /* not found; add new tid */ | 2918 | if (trans == NULL) { /* not found; add new tid */ |
2923 | if (ohead->oh_flags & XLOG_START_TRANS) | 2919 | if (ohead->oh_flags & XLOG_START_TRANS) |
2924 | xlog_recover_new_tid(&rhash[hash], tid, | 2920 | xlog_recover_new_tid(&rhash[hash], tid, |
2925 | INT_GET(rhead->h_lsn, ARCH_CONVERT)); | 2921 | be64_to_cpu(rhead->h_lsn)); |
2926 | } else { | 2922 | } else { |
2927 | ASSERT(dp + be32_to_cpu(ohead->oh_len) <= lp); | 2923 | ASSERT(dp + be32_to_cpu(ohead->oh_len) <= lp); |
2928 | flags = ohead->oh_flags & ~XLOG_END_TRANS; | 2924 | flags = ohead->oh_flags & ~XLOG_END_TRANS; |
@@ -3313,16 +3309,16 @@ xlog_pack_data_checksum( | |||
3313 | int size) | 3309 | int size) |
3314 | { | 3310 | { |
3315 | int i; | 3311 | int i; |
3316 | uint *up; | 3312 | __be32 *up; |
3317 | uint chksum = 0; | 3313 | uint chksum = 0; |
3318 | 3314 | ||
3319 | up = (uint *)iclog->ic_datap; | 3315 | up = (__be32 *)iclog->ic_datap; |
3320 | /* divide length by 4 to get # words */ | 3316 | /* divide length by 4 to get # words */ |
3321 | for (i = 0; i < (size >> 2); i++) { | 3317 | for (i = 0; i < (size >> 2); i++) { |
3322 | chksum ^= INT_GET(*up, ARCH_CONVERT); | 3318 | chksum ^= be32_to_cpu(*up); |
3323 | up++; | 3319 | up++; |
3324 | } | 3320 | } |
3325 | INT_SET(iclog->ic_header.h_chksum, ARCH_CONVERT, chksum); | 3321 | iclog->ic_header.h_chksum = cpu_to_be32(chksum); |
3326 | } | 3322 | } |
3327 | #else | 3323 | #else |
3328 | #define xlog_pack_data_checksum(log, iclog, size) | 3324 | #define xlog_pack_data_checksum(log, iclog, size) |
@@ -3339,7 +3335,7 @@ xlog_pack_data( | |||
3339 | { | 3335 | { |
3340 | int i, j, k; | 3336 | int i, j, k; |
3341 | int size = iclog->ic_offset + roundoff; | 3337 | int size = iclog->ic_offset + roundoff; |
3342 | uint cycle_lsn; | 3338 | __be32 cycle_lsn; |
3343 | xfs_caddr_t dp; | 3339 | xfs_caddr_t dp; |
3344 | xlog_in_core_2_t *xhdr; | 3340 | xlog_in_core_2_t *xhdr; |
3345 | 3341 | ||
@@ -3350,8 +3346,8 @@ xlog_pack_data( | |||
3350 | dp = iclog->ic_datap; | 3346 | dp = iclog->ic_datap; |
3351 | for (i = 0; i < BTOBB(size) && | 3347 | for (i = 0; i < BTOBB(size) && |
3352 | i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) { | 3348 | i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) { |
3353 | iclog->ic_header.h_cycle_data[i] = *(uint *)dp; | 3349 | iclog->ic_header.h_cycle_data[i] = *(__be32 *)dp; |
3354 | *(uint *)dp = cycle_lsn; | 3350 | *(__be32 *)dp = cycle_lsn; |
3355 | dp += BBSIZE; | 3351 | dp += BBSIZE; |
3356 | } | 3352 | } |
3357 | 3353 | ||
@@ -3360,8 +3356,8 @@ xlog_pack_data( | |||
3360 | for ( ; i < BTOBB(size); i++) { | 3356 | for ( ; i < BTOBB(size); i++) { |
3361 | j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE); | 3357 | j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE); |
3362 | k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE); | 3358 | k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE); |
3363 | xhdr[j].hic_xheader.xh_cycle_data[k] = *(uint *)dp; | 3359 | xhdr[j].hic_xheader.xh_cycle_data[k] = *(__be32 *)dp; |
3364 | *(uint *)dp = cycle_lsn; | 3360 | *(__be32 *)dp = cycle_lsn; |
3365 | dp += BBSIZE; | 3361 | dp += BBSIZE; |
3366 | } | 3362 | } |
3367 | 3363 | ||
@@ -3378,21 +3374,21 @@ xlog_unpack_data_checksum( | |||
3378 | xfs_caddr_t dp, | 3374 | xfs_caddr_t dp, |
3379 | xlog_t *log) | 3375 | xlog_t *log) |
3380 | { | 3376 | { |
3381 | uint *up = (uint *)dp; | 3377 | __be32 *up = (__be32 *)dp; |
3382 | uint chksum = 0; | 3378 | uint chksum = 0; |
3383 | int i; | 3379 | int i; |
3384 | 3380 | ||
3385 | /* divide length by 4 to get # words */ | 3381 | /* divide length by 4 to get # words */ |
3386 | for (i=0; i < INT_GET(rhead->h_len, ARCH_CONVERT) >> 2; i++) { | 3382 | for (i=0; i < be32_to_cpu(rhead->h_len) >> 2; i++) { |
3387 | chksum ^= INT_GET(*up, ARCH_CONVERT); | 3383 | chksum ^= be32_to_cpu(*up); |
3388 | up++; | 3384 | up++; |
3389 | } | 3385 | } |
3390 | if (chksum != INT_GET(rhead->h_chksum, ARCH_CONVERT)) { | 3386 | if (chksum != be32_to_cpu(rhead->h_chksum)) { |
3391 | if (rhead->h_chksum || | 3387 | if (rhead->h_chksum || |
3392 | ((log->l_flags & XLOG_CHKSUM_MISMATCH) == 0)) { | 3388 | ((log->l_flags & XLOG_CHKSUM_MISMATCH) == 0)) { |
3393 | cmn_err(CE_DEBUG, | 3389 | cmn_err(CE_DEBUG, |
3394 | "XFS: LogR chksum mismatch: was (0x%x) is (0x%x)\n", | 3390 | "XFS: LogR chksum mismatch: was (0x%x) is (0x%x)\n", |
3395 | INT_GET(rhead->h_chksum, ARCH_CONVERT), chksum); | 3391 | be32_to_cpu(rhead->h_chksum), chksum); |
3396 | cmn_err(CE_DEBUG, | 3392 | cmn_err(CE_DEBUG, |
3397 | "XFS: Disregard message if filesystem was created with non-DEBUG kernel"); | 3393 | "XFS: Disregard message if filesystem was created with non-DEBUG kernel"); |
3398 | if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { | 3394 | if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { |
@@ -3416,18 +3412,18 @@ xlog_unpack_data( | |||
3416 | int i, j, k; | 3412 | int i, j, k; |
3417 | xlog_in_core_2_t *xhdr; | 3413 | xlog_in_core_2_t *xhdr; |
3418 | 3414 | ||
3419 | for (i = 0; i < BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)) && | 3415 | for (i = 0; i < BTOBB(be32_to_cpu(rhead->h_len)) && |
3420 | i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) { | 3416 | i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) { |
3421 | *(uint *)dp = *(uint *)&rhead->h_cycle_data[i]; | 3417 | *(__be32 *)dp = *(__be32 *)&rhead->h_cycle_data[i]; |
3422 | dp += BBSIZE; | 3418 | dp += BBSIZE; |
3423 | } | 3419 | } |
3424 | 3420 | ||
3425 | if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { | 3421 | if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { |
3426 | xhdr = (xlog_in_core_2_t *)rhead; | 3422 | xhdr = (xlog_in_core_2_t *)rhead; |
3427 | for ( ; i < BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)); i++) { | 3423 | for ( ; i < BTOBB(be32_to_cpu(rhead->h_len)); i++) { |
3428 | j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE); | 3424 | j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE); |
3429 | k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE); | 3425 | k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE); |
3430 | *(uint *)dp = xhdr[j].hic_xheader.xh_cycle_data[k]; | 3426 | *(__be32 *)dp = xhdr[j].hic_xheader.xh_cycle_data[k]; |
3431 | dp += BBSIZE; | 3427 | dp += BBSIZE; |
3432 | } | 3428 | } |
3433 | } | 3429 | } |
@@ -3443,24 +3439,21 @@ xlog_valid_rec_header( | |||
3443 | { | 3439 | { |
3444 | int hlen; | 3440 | int hlen; |
3445 | 3441 | ||
3446 | if (unlikely( | 3442 | if (unlikely(be32_to_cpu(rhead->h_magicno) != XLOG_HEADER_MAGIC_NUM)) { |
3447 | (INT_GET(rhead->h_magicno, ARCH_CONVERT) != | ||
3448 | XLOG_HEADER_MAGIC_NUM))) { | ||
3449 | XFS_ERROR_REPORT("xlog_valid_rec_header(1)", | 3443 | XFS_ERROR_REPORT("xlog_valid_rec_header(1)", |
3450 | XFS_ERRLEVEL_LOW, log->l_mp); | 3444 | XFS_ERRLEVEL_LOW, log->l_mp); |
3451 | return XFS_ERROR(EFSCORRUPTED); | 3445 | return XFS_ERROR(EFSCORRUPTED); |
3452 | } | 3446 | } |
3453 | if (unlikely( | 3447 | if (unlikely( |
3454 | (!rhead->h_version || | 3448 | (!rhead->h_version || |
3455 | (INT_GET(rhead->h_version, ARCH_CONVERT) & | 3449 | (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS))))) { |
3456 | (~XLOG_VERSION_OKBITS)) != 0))) { | ||
3457 | xlog_warn("XFS: %s: unrecognised log version (%d).", | 3450 | xlog_warn("XFS: %s: unrecognised log version (%d).", |
3458 | __FUNCTION__, INT_GET(rhead->h_version, ARCH_CONVERT)); | 3451 | __FUNCTION__, be32_to_cpu(rhead->h_version)); |
3459 | return XFS_ERROR(EIO); | 3452 | return XFS_ERROR(EIO); |
3460 | } | 3453 | } |
3461 | 3454 | ||
3462 | /* LR body must have data or it wouldn't have been written */ | 3455 | /* LR body must have data or it wouldn't have been written */ |
3463 | hlen = INT_GET(rhead->h_len, ARCH_CONVERT); | 3456 | hlen = be32_to_cpu(rhead->h_len); |
3464 | if (unlikely( hlen <= 0 || hlen > INT_MAX )) { | 3457 | if (unlikely( hlen <= 0 || hlen > INT_MAX )) { |
3465 | XFS_ERROR_REPORT("xlog_valid_rec_header(2)", | 3458 | XFS_ERROR_REPORT("xlog_valid_rec_header(2)", |
3466 | XFS_ERRLEVEL_LOW, log->l_mp); | 3459 | XFS_ERRLEVEL_LOW, log->l_mp); |
@@ -3520,9 +3513,8 @@ xlog_do_recovery_pass( | |||
3520 | error = xlog_valid_rec_header(log, rhead, tail_blk); | 3513 | error = xlog_valid_rec_header(log, rhead, tail_blk); |
3521 | if (error) | 3514 | if (error) |
3522 | goto bread_err1; | 3515 | goto bread_err1; |
3523 | h_size = INT_GET(rhead->h_size, ARCH_CONVERT); | 3516 | h_size = be32_to_cpu(rhead->h_size); |
3524 | if ((INT_GET(rhead->h_version, ARCH_CONVERT) | 3517 | if ((be32_to_cpu(rhead->h_version) & XLOG_VERSION_2) && |
3525 | & XLOG_VERSION_2) && | ||
3526 | (h_size > XLOG_HEADER_CYCLE_SIZE)) { | 3518 | (h_size > XLOG_HEADER_CYCLE_SIZE)) { |
3527 | hblks = h_size / XLOG_HEADER_CYCLE_SIZE; | 3519 | hblks = h_size / XLOG_HEADER_CYCLE_SIZE; |
3528 | if (h_size % XLOG_HEADER_CYCLE_SIZE) | 3520 | if (h_size % XLOG_HEADER_CYCLE_SIZE) |
@@ -3559,7 +3551,7 @@ xlog_do_recovery_pass( | |||
3559 | goto bread_err2; | 3551 | goto bread_err2; |
3560 | 3552 | ||
3561 | /* blocks in data section */ | 3553 | /* blocks in data section */ |
3562 | bblks = (int)BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)); | 3554 | bblks = (int)BTOBB(be32_to_cpu(rhead->h_len)); |
3563 | error = xlog_bread(log, blk_no + hblks, bblks, dbp); | 3555 | error = xlog_bread(log, blk_no + hblks, bblks, dbp); |
3564 | if (error) | 3556 | if (error) |
3565 | goto bread_err2; | 3557 | goto bread_err2; |
@@ -3634,7 +3626,7 @@ xlog_do_recovery_pass( | |||
3634 | if (error) | 3626 | if (error) |
3635 | goto bread_err2; | 3627 | goto bread_err2; |
3636 | 3628 | ||
3637 | bblks = (int)BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)); | 3629 | bblks = (int)BTOBB(be32_to_cpu(rhead->h_len)); |
3638 | blk_no += hblks; | 3630 | blk_no += hblks; |
3639 | 3631 | ||
3640 | /* Read in data for log record */ | 3632 | /* Read in data for log record */ |
@@ -3705,7 +3697,7 @@ xlog_do_recovery_pass( | |||
3705 | error = xlog_valid_rec_header(log, rhead, blk_no); | 3697 | error = xlog_valid_rec_header(log, rhead, blk_no); |
3706 | if (error) | 3698 | if (error) |
3707 | goto bread_err2; | 3699 | goto bread_err2; |
3708 | bblks = (int)BTOBB(INT_GET(rhead->h_len, ARCH_CONVERT)); | 3700 | bblks = (int)BTOBB(be32_to_cpu(rhead->h_len)); |
3709 | if ((error = xlog_bread(log, blk_no+hblks, bblks, dbp))) | 3701 | if ((error = xlog_bread(log, blk_no+hblks, bblks, dbp))) |
3710 | goto bread_err2; | 3702 | goto bread_err2; |
3711 | offset = xlog_align(log, blk_no+hblks, bblks, dbp); | 3703 | offset = xlog_align(log, blk_no+hblks, bblks, dbp); |