aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_log_recover.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_log_recover.c')
-rw-r--r--fs/xfs/xfs_log_recover.c183
1 files changed, 92 insertions, 91 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 845a92c9c241..fbc2362d13e3 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -179,7 +179,7 @@ xlog_bread_noalign(
179 xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer", 179 xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer",
180 nbblks); 180 nbblks);
181 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); 181 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
182 return EFSCORRUPTED; 182 return -EFSCORRUPTED;
183 } 183 }
184 184
185 blk_no = round_down(blk_no, log->l_sectBBsize); 185 blk_no = round_down(blk_no, log->l_sectBBsize);
@@ -194,7 +194,7 @@ xlog_bread_noalign(
194 bp->b_error = 0; 194 bp->b_error = 0;
195 195
196 if (XFS_FORCED_SHUTDOWN(log->l_mp)) 196 if (XFS_FORCED_SHUTDOWN(log->l_mp))
197 return EIO; 197 return -EIO;
198 198
199 xfs_buf_iorequest(bp); 199 xfs_buf_iorequest(bp);
200 error = xfs_buf_iowait(bp); 200 error = xfs_buf_iowait(bp);
@@ -268,7 +268,7 @@ xlog_bwrite(
268 xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer", 268 xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer",
269 nbblks); 269 nbblks);
270 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp); 270 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
271 return EFSCORRUPTED; 271 return -EFSCORRUPTED;
272 } 272 }
273 273
274 blk_no = round_down(blk_no, log->l_sectBBsize); 274 blk_no = round_down(blk_no, log->l_sectBBsize);
@@ -330,14 +330,14 @@ xlog_header_check_recover(
330 xlog_header_check_dump(mp, head); 330 xlog_header_check_dump(mp, head);
331 XFS_ERROR_REPORT("xlog_header_check_recover(1)", 331 XFS_ERROR_REPORT("xlog_header_check_recover(1)",
332 XFS_ERRLEVEL_HIGH, mp); 332 XFS_ERRLEVEL_HIGH, mp);
333 return EFSCORRUPTED; 333 return -EFSCORRUPTED;
334 } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) { 334 } else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) {
335 xfs_warn(mp, 335 xfs_warn(mp,
336 "dirty log entry has mismatched uuid - can't recover"); 336 "dirty log entry has mismatched uuid - can't recover");
337 xlog_header_check_dump(mp, head); 337 xlog_header_check_dump(mp, head);
338 XFS_ERROR_REPORT("xlog_header_check_recover(2)", 338 XFS_ERROR_REPORT("xlog_header_check_recover(2)",
339 XFS_ERRLEVEL_HIGH, mp); 339 XFS_ERRLEVEL_HIGH, mp);
340 return EFSCORRUPTED; 340 return -EFSCORRUPTED;
341 } 341 }
342 return 0; 342 return 0;
343} 343}
@@ -364,7 +364,7 @@ xlog_header_check_mount(
364 xlog_header_check_dump(mp, head); 364 xlog_header_check_dump(mp, head);
365 XFS_ERROR_REPORT("xlog_header_check_mount", 365 XFS_ERROR_REPORT("xlog_header_check_mount",
366 XFS_ERRLEVEL_HIGH, mp); 366 XFS_ERRLEVEL_HIGH, mp);
367 return EFSCORRUPTED; 367 return -EFSCORRUPTED;
368 } 368 }
369 return 0; 369 return 0;
370} 370}
@@ -462,7 +462,7 @@ xlog_find_verify_cycle(
462 while (!(bp = xlog_get_bp(log, bufblks))) { 462 while (!(bp = xlog_get_bp(log, bufblks))) {
463 bufblks >>= 1; 463 bufblks >>= 1;
464 if (bufblks < log->l_sectBBsize) 464 if (bufblks < log->l_sectBBsize)
465 return ENOMEM; 465 return -ENOMEM;
466 } 466 }
467 467
468 for (i = start_blk; i < start_blk + nbblks; i += bufblks) { 468 for (i = start_blk; i < start_blk + nbblks; i += bufblks) {
@@ -524,7 +524,7 @@ xlog_find_verify_log_record(
524 524
525 if (!(bp = xlog_get_bp(log, num_blks))) { 525 if (!(bp = xlog_get_bp(log, num_blks))) {
526 if (!(bp = xlog_get_bp(log, 1))) 526 if (!(bp = xlog_get_bp(log, 1)))
527 return ENOMEM; 527 return -ENOMEM;
528 smallmem = 1; 528 smallmem = 1;
529 } else { 529 } else {
530 error = xlog_bread(log, start_blk, num_blks, bp, &offset); 530 error = xlog_bread(log, start_blk, num_blks, bp, &offset);
@@ -539,7 +539,7 @@ xlog_find_verify_log_record(
539 xfs_warn(log->l_mp, 539 xfs_warn(log->l_mp,
540 "Log inconsistent (didn't find previous header)"); 540 "Log inconsistent (didn't find previous header)");
541 ASSERT(0); 541 ASSERT(0);
542 error = EIO; 542 error = -EIO;
543 goto out; 543 goto out;
544 } 544 }
545 545
@@ -564,7 +564,7 @@ xlog_find_verify_log_record(
564 * will be called again for the end of the physical log. 564 * will be called again for the end of the physical log.
565 */ 565 */
566 if (i == -1) { 566 if (i == -1) {
567 error = -1; 567 error = 1;
568 goto out; 568 goto out;
569 } 569 }
570 570
@@ -628,7 +628,12 @@ xlog_find_head(
628 int error, log_bbnum = log->l_logBBsize; 628 int error, log_bbnum = log->l_logBBsize;
629 629
630 /* Is the end of the log device zeroed? */ 630 /* Is the end of the log device zeroed? */
631 if ((error = xlog_find_zeroed(log, &first_blk)) == -1) { 631 error = xlog_find_zeroed(log, &first_blk);
632 if (error < 0) {
633 xfs_warn(log->l_mp, "empty log check failed");
634 return error;
635 }
636 if (error == 1) {
632 *return_head_blk = first_blk; 637 *return_head_blk = first_blk;
633 638
634 /* Is the whole lot zeroed? */ 639 /* Is the whole lot zeroed? */
@@ -641,15 +646,12 @@ xlog_find_head(
641 } 646 }
642 647
643 return 0; 648 return 0;
644 } else if (error) {
645 xfs_warn(log->l_mp, "empty log check failed");
646 return error;
647 } 649 }
648 650
649 first_blk = 0; /* get cycle # of 1st block */ 651 first_blk = 0; /* get cycle # of 1st block */
650 bp = xlog_get_bp(log, 1); 652 bp = xlog_get_bp(log, 1);
651 if (!bp) 653 if (!bp)
652 return ENOMEM; 654 return -ENOMEM;
653 655
654 error = xlog_bread(log, 0, 1, bp, &offset); 656 error = xlog_bread(log, 0, 1, bp, &offset);
655 if (error) 657 if (error)
@@ -818,29 +820,29 @@ validate_head:
818 start_blk = head_blk - num_scan_bblks; /* don't read head_blk */ 820 start_blk = head_blk - num_scan_bblks; /* don't read head_blk */
819 821
820 /* start ptr at last block ptr before head_blk */ 822 /* start ptr at last block ptr before head_blk */
821 if ((error = xlog_find_verify_log_record(log, start_blk, 823 error = xlog_find_verify_log_record(log, start_blk, &head_blk, 0);
822 &head_blk, 0)) == -1) { 824 if (error == 1)
823 error = EIO; 825 error = -EIO;
824 goto bp_err; 826 if (error)
825 } else if (error)
826 goto bp_err; 827 goto bp_err;
827 } else { 828 } else {
828 start_blk = 0; 829 start_blk = 0;
829 ASSERT(head_blk <= INT_MAX); 830 ASSERT(head_blk <= INT_MAX);
830 if ((error = xlog_find_verify_log_record(log, start_blk, 831 error = xlog_find_verify_log_record(log, start_blk, &head_blk, 0);
831 &head_blk, 0)) == -1) { 832 if (error < 0)
833 goto bp_err;
834 if (error == 1) {
832 /* We hit the beginning of the log during our search */ 835 /* We hit the beginning of the log during our search */
833 start_blk = log_bbnum - (num_scan_bblks - head_blk); 836 start_blk = log_bbnum - (num_scan_bblks - head_blk);
834 new_blk = log_bbnum; 837 new_blk = log_bbnum;
835 ASSERT(start_blk <= INT_MAX && 838 ASSERT(start_blk <= INT_MAX &&
836 (xfs_daddr_t) log_bbnum-start_blk >= 0); 839 (xfs_daddr_t) log_bbnum-start_blk >= 0);
837 ASSERT(head_blk <= INT_MAX); 840 ASSERT(head_blk <= INT_MAX);
838 if ((error = xlog_find_verify_log_record(log, 841 error = xlog_find_verify_log_record(log, start_blk,
839 start_blk, &new_blk, 842 &new_blk, (int)head_blk);
840 (int)head_blk)) == -1) { 843 if (error == 1)
841 error = EIO; 844 error = -EIO;
842 goto bp_err; 845 if (error)
843 } else if (error)
844 goto bp_err; 846 goto bp_err;
845 if (new_blk != log_bbnum) 847 if (new_blk != log_bbnum)
846 head_blk = new_blk; 848 head_blk = new_blk;
@@ -911,7 +913,7 @@ xlog_find_tail(
911 913
912 bp = xlog_get_bp(log, 1); 914 bp = xlog_get_bp(log, 1);
913 if (!bp) 915 if (!bp)
914 return ENOMEM; 916 return -ENOMEM;
915 if (*head_blk == 0) { /* special case */ 917 if (*head_blk == 0) { /* special case */
916 error = xlog_bread(log, 0, 1, bp, &offset); 918 error = xlog_bread(log, 0, 1, bp, &offset);
917 if (error) 919 if (error)
@@ -961,7 +963,7 @@ xlog_find_tail(
961 xfs_warn(log->l_mp, "%s: couldn't find sync record", __func__); 963 xfs_warn(log->l_mp, "%s: couldn't find sync record", __func__);
962 xlog_put_bp(bp); 964 xlog_put_bp(bp);
963 ASSERT(0); 965 ASSERT(0);
964 return EIO; 966 return -EIO;
965 } 967 }
966 968
967 /* find blk_no of tail of log */ 969 /* find blk_no of tail of log */
@@ -1092,8 +1094,8 @@ done:
1092 * 1094 *
1093 * Return: 1095 * Return:
1094 * 0 => the log is completely written to 1096 * 0 => the log is completely written to
1095 * -1 => use *blk_no as the first block of the log 1097 * 1 => use *blk_no as the first block of the log
1096 * >0 => error has occurred 1098 * <0 => error has occurred
1097 */ 1099 */
1098STATIC int 1100STATIC int
1099xlog_find_zeroed( 1101xlog_find_zeroed(
@@ -1112,7 +1114,7 @@ xlog_find_zeroed(
1112 /* check totally zeroed log */ 1114 /* check totally zeroed log */
1113 bp = xlog_get_bp(log, 1); 1115 bp = xlog_get_bp(log, 1);
1114 if (!bp) 1116 if (!bp)
1115 return ENOMEM; 1117 return -ENOMEM;
1116 error = xlog_bread(log, 0, 1, bp, &offset); 1118 error = xlog_bread(log, 0, 1, bp, &offset);
1117 if (error) 1119 if (error)
1118 goto bp_err; 1120 goto bp_err;
@@ -1121,7 +1123,7 @@ xlog_find_zeroed(
1121 if (first_cycle == 0) { /* completely zeroed log */ 1123 if (first_cycle == 0) { /* completely zeroed log */
1122 *blk_no = 0; 1124 *blk_no = 0;
1123 xlog_put_bp(bp); 1125 xlog_put_bp(bp);
1124 return -1; 1126 return 1;
1125 } 1127 }
1126 1128
1127 /* check partially zeroed log */ 1129 /* check partially zeroed log */
@@ -1141,7 +1143,7 @@ xlog_find_zeroed(
1141 */ 1143 */
1142 xfs_warn(log->l_mp, 1144 xfs_warn(log->l_mp,
1143 "Log inconsistent or not a log (last==0, first!=1)"); 1145 "Log inconsistent or not a log (last==0, first!=1)");
1144 error = EINVAL; 1146 error = -EINVAL;
1145 goto bp_err; 1147 goto bp_err;
1146 } 1148 }
1147 1149
@@ -1179,19 +1181,18 @@ xlog_find_zeroed(
1179 * Potentially backup over partial log record write. We don't need 1181 * Potentially backup over partial log record write. We don't need
1180 * to search the end of the log because we know it is zero. 1182 * to search the end of the log because we know it is zero.
1181 */ 1183 */
1182 if ((error = xlog_find_verify_log_record(log, start_blk, 1184 error = xlog_find_verify_log_record(log, start_blk, &last_blk, 0);
1183 &last_blk, 0)) == -1) { 1185 if (error == 1)
1184 error = EIO; 1186 error = -EIO;
1185 goto bp_err; 1187 if (error)
1186 } else if (error) 1188 goto bp_err;
1187 goto bp_err;
1188 1189
1189 *blk_no = last_blk; 1190 *blk_no = last_blk;
1190bp_err: 1191bp_err:
1191 xlog_put_bp(bp); 1192 xlog_put_bp(bp);
1192 if (error) 1193 if (error)
1193 return error; 1194 return error;
1194 return -1; 1195 return 1;
1195} 1196}
1196 1197
1197/* 1198/*
@@ -1251,7 +1252,7 @@ xlog_write_log_records(
1251 while (!(bp = xlog_get_bp(log, bufblks))) { 1252 while (!(bp = xlog_get_bp(log, bufblks))) {
1252 bufblks >>= 1; 1253 bufblks >>= 1;
1253 if (bufblks < sectbb) 1254 if (bufblks < sectbb)
1254 return ENOMEM; 1255 return -ENOMEM;
1255 } 1256 }
1256 1257
1257 /* We may need to do a read at the start to fill in part of 1258 /* We may need to do a read at the start to fill in part of
@@ -1354,7 +1355,7 @@ xlog_clear_stale_blocks(
1354 if (unlikely(head_block < tail_block || head_block >= log->l_logBBsize)) { 1355 if (unlikely(head_block < tail_block || head_block >= log->l_logBBsize)) {
1355 XFS_ERROR_REPORT("xlog_clear_stale_blocks(1)", 1356 XFS_ERROR_REPORT("xlog_clear_stale_blocks(1)",
1356 XFS_ERRLEVEL_LOW, log->l_mp); 1357 XFS_ERRLEVEL_LOW, log->l_mp);
1357 return EFSCORRUPTED; 1358 return -EFSCORRUPTED;
1358 } 1359 }
1359 tail_distance = tail_block + (log->l_logBBsize - head_block); 1360 tail_distance = tail_block + (log->l_logBBsize - head_block);
1360 } else { 1361 } else {
@@ -1366,7 +1367,7 @@ xlog_clear_stale_blocks(
1366 if (unlikely(head_block >= tail_block || head_cycle != (tail_cycle + 1))){ 1367 if (unlikely(head_block >= tail_block || head_cycle != (tail_cycle + 1))){
1367 XFS_ERROR_REPORT("xlog_clear_stale_blocks(2)", 1368 XFS_ERROR_REPORT("xlog_clear_stale_blocks(2)",
1368 XFS_ERRLEVEL_LOW, log->l_mp); 1369 XFS_ERRLEVEL_LOW, log->l_mp);
1369 return EFSCORRUPTED; 1370 return -EFSCORRUPTED;
1370 } 1371 }
1371 tail_distance = tail_block - head_block; 1372 tail_distance = tail_block - head_block;
1372 } 1373 }
@@ -1551,7 +1552,7 @@ xlog_recover_add_to_trans(
1551 xfs_warn(log->l_mp, "%s: bad header magic number", 1552 xfs_warn(log->l_mp, "%s: bad header magic number",
1552 __func__); 1553 __func__);
1553 ASSERT(0); 1554 ASSERT(0);
1554 return EIO; 1555 return -EIO;
1555 } 1556 }
1556 if (len == sizeof(xfs_trans_header_t)) 1557 if (len == sizeof(xfs_trans_header_t))
1557 xlog_recover_add_item(&trans->r_itemq); 1558 xlog_recover_add_item(&trans->r_itemq);
@@ -1581,7 +1582,7 @@ xlog_recover_add_to_trans(
1581 in_f->ilf_size); 1582 in_f->ilf_size);
1582 ASSERT(0); 1583 ASSERT(0);
1583 kmem_free(ptr); 1584 kmem_free(ptr);
1584 return EIO; 1585 return -EIO;
1585 } 1586 }
1586 1587
1587 item->ri_total = in_f->ilf_size; 1588 item->ri_total = in_f->ilf_size;
@@ -1702,7 +1703,7 @@ xlog_recover_reorder_trans(
1702 */ 1703 */
1703 if (!list_empty(&sort_list)) 1704 if (!list_empty(&sort_list))
1704 list_splice_init(&sort_list, &trans->r_itemq); 1705 list_splice_init(&sort_list, &trans->r_itemq);
1705 error = EIO; 1706 error = -EIO;
1706 goto out; 1707 goto out;
1707 } 1708 }
1708 } 1709 }
@@ -1943,7 +1944,7 @@ xlog_recover_do_inode_buffer(
1943 item, bp); 1944 item, bp);
1944 XFS_ERROR_REPORT("xlog_recover_do_inode_buf", 1945 XFS_ERROR_REPORT("xlog_recover_do_inode_buf",
1945 XFS_ERRLEVEL_LOW, mp); 1946 XFS_ERRLEVEL_LOW, mp);
1946 return EFSCORRUPTED; 1947 return -EFSCORRUPTED;
1947 } 1948 }
1948 1949
1949 buffer_nextp = (xfs_agino_t *)xfs_buf_offset(bp, 1950 buffer_nextp = (xfs_agino_t *)xfs_buf_offset(bp,
@@ -2496,7 +2497,7 @@ xlog_recover_buffer_pass2(
2496 bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len, 2497 bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len,
2497 buf_flags, NULL); 2498 buf_flags, NULL);
2498 if (!bp) 2499 if (!bp)
2499 return ENOMEM; 2500 return -ENOMEM;
2500 error = bp->b_error; 2501 error = bp->b_error;
2501 if (error) { 2502 if (error) {
2502 xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#1)"); 2503 xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#1)");
@@ -2598,7 +2599,7 @@ xfs_recover_inode_owner_change(
2598 2599
2599 ip = xfs_inode_alloc(mp, in_f->ilf_ino); 2600 ip = xfs_inode_alloc(mp, in_f->ilf_ino);
2600 if (!ip) 2601 if (!ip)
2601 return ENOMEM; 2602 return -ENOMEM;
2602 2603
2603 /* instantiate the inode */ 2604 /* instantiate the inode */
2604 xfs_dinode_from_disk(&ip->i_d, dip); 2605 xfs_dinode_from_disk(&ip->i_d, dip);
@@ -2676,7 +2677,7 @@ xlog_recover_inode_pass2(
2676 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 0, 2677 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 0,
2677 &xfs_inode_buf_ops); 2678 &xfs_inode_buf_ops);
2678 if (!bp) { 2679 if (!bp) {
2679 error = ENOMEM; 2680 error = -ENOMEM;
2680 goto error; 2681 goto error;
2681 } 2682 }
2682 error = bp->b_error; 2683 error = bp->b_error;
@@ -2697,7 +2698,7 @@ xlog_recover_inode_pass2(
2697 __func__, dip, bp, in_f->ilf_ino); 2698 __func__, dip, bp, in_f->ilf_ino);
2698 XFS_ERROR_REPORT("xlog_recover_inode_pass2(1)", 2699 XFS_ERROR_REPORT("xlog_recover_inode_pass2(1)",
2699 XFS_ERRLEVEL_LOW, mp); 2700 XFS_ERRLEVEL_LOW, mp);
2700 error = EFSCORRUPTED; 2701 error = -EFSCORRUPTED;
2701 goto out_release; 2702 goto out_release;
2702 } 2703 }
2703 dicp = item->ri_buf[1].i_addr; 2704 dicp = item->ri_buf[1].i_addr;
@@ -2707,7 +2708,7 @@ xlog_recover_inode_pass2(
2707 __func__, item, in_f->ilf_ino); 2708 __func__, item, in_f->ilf_ino);
2708 XFS_ERROR_REPORT("xlog_recover_inode_pass2(2)", 2709 XFS_ERROR_REPORT("xlog_recover_inode_pass2(2)",
2709 XFS_ERRLEVEL_LOW, mp); 2710 XFS_ERRLEVEL_LOW, mp);
2710 error = EFSCORRUPTED; 2711 error = -EFSCORRUPTED;
2711 goto out_release; 2712 goto out_release;
2712 } 2713 }
2713 2714
@@ -2764,7 +2765,7 @@ xlog_recover_inode_pass2(
2764 "%s: Bad regular inode log record, rec ptr 0x%p, " 2765 "%s: Bad regular inode log record, rec ptr 0x%p, "
2765 "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", 2766 "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld",
2766 __func__, item, dip, bp, in_f->ilf_ino); 2767 __func__, item, dip, bp, in_f->ilf_ino);
2767 error = EFSCORRUPTED; 2768 error = -EFSCORRUPTED;
2768 goto out_release; 2769 goto out_release;
2769 } 2770 }
2770 } else if (unlikely(S_ISDIR(dicp->di_mode))) { 2771 } else if (unlikely(S_ISDIR(dicp->di_mode))) {
@@ -2777,7 +2778,7 @@ xlog_recover_inode_pass2(
2777 "%s: Bad dir inode log record, rec ptr 0x%p, " 2778 "%s: Bad dir inode log record, rec ptr 0x%p, "
2778 "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld", 2779 "ino ptr = 0x%p, ino bp = 0x%p, ino %Ld",
2779 __func__, item, dip, bp, in_f->ilf_ino); 2780 __func__, item, dip, bp, in_f->ilf_ino);
2780 error = EFSCORRUPTED; 2781 error = -EFSCORRUPTED;
2781 goto out_release; 2782 goto out_release;
2782 } 2783 }
2783 } 2784 }
@@ -2790,7 +2791,7 @@ xlog_recover_inode_pass2(
2790 __func__, item, dip, bp, in_f->ilf_ino, 2791 __func__, item, dip, bp, in_f->ilf_ino,
2791 dicp->di_nextents + dicp->di_anextents, 2792 dicp->di_nextents + dicp->di_anextents,
2792 dicp->di_nblocks); 2793 dicp->di_nblocks);
2793 error = EFSCORRUPTED; 2794 error = -EFSCORRUPTED;
2794 goto out_release; 2795 goto out_release;
2795 } 2796 }
2796 if (unlikely(dicp->di_forkoff > mp->m_sb.sb_inodesize)) { 2797 if (unlikely(dicp->di_forkoff > mp->m_sb.sb_inodesize)) {
@@ -2800,7 +2801,7 @@ xlog_recover_inode_pass2(
2800 "%s: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, " 2801 "%s: Bad inode log record, rec ptr 0x%p, dino ptr 0x%p, "
2801 "dino bp 0x%p, ino %Ld, forkoff 0x%x", __func__, 2802 "dino bp 0x%p, ino %Ld, forkoff 0x%x", __func__,
2802 item, dip, bp, in_f->ilf_ino, dicp->di_forkoff); 2803 item, dip, bp, in_f->ilf_ino, dicp->di_forkoff);
2803 error = EFSCORRUPTED; 2804 error = -EFSCORRUPTED;
2804 goto out_release; 2805 goto out_release;
2805 } 2806 }
2806 isize = xfs_icdinode_size(dicp->di_version); 2807 isize = xfs_icdinode_size(dicp->di_version);
@@ -2810,7 +2811,7 @@ xlog_recover_inode_pass2(
2810 xfs_alert(mp, 2811 xfs_alert(mp,
2811 "%s: Bad inode log record length %d, rec ptr 0x%p", 2812 "%s: Bad inode log record length %d, rec ptr 0x%p",
2812 __func__, item->ri_buf[1].i_len, item); 2813 __func__, item->ri_buf[1].i_len, item);
2813 error = EFSCORRUPTED; 2814 error = -EFSCORRUPTED;
2814 goto out_release; 2815 goto out_release;
2815 } 2816 }
2816 2817
@@ -2898,7 +2899,7 @@ xlog_recover_inode_pass2(
2898 default: 2899 default:
2899 xfs_warn(log->l_mp, "%s: Invalid flag", __func__); 2900 xfs_warn(log->l_mp, "%s: Invalid flag", __func__);
2900 ASSERT(0); 2901 ASSERT(0);
2901 error = EIO; 2902 error = -EIO;
2902 goto out_release; 2903 goto out_release;
2903 } 2904 }
2904 } 2905 }
@@ -2976,12 +2977,12 @@ xlog_recover_dquot_pass2(
2976 recddq = item->ri_buf[1].i_addr; 2977 recddq = item->ri_buf[1].i_addr;
2977 if (recddq == NULL) { 2978 if (recddq == NULL) {
2978 xfs_alert(log->l_mp, "NULL dquot in %s.", __func__); 2979 xfs_alert(log->l_mp, "NULL dquot in %s.", __func__);
2979 return EIO; 2980 return -EIO;
2980 } 2981 }
2981 if (item->ri_buf[1].i_len < sizeof(xfs_disk_dquot_t)) { 2982 if (item->ri_buf[1].i_len < sizeof(xfs_disk_dquot_t)) {
2982 xfs_alert(log->l_mp, "dquot too small (%d) in %s.", 2983 xfs_alert(log->l_mp, "dquot too small (%d) in %s.",
2983 item->ri_buf[1].i_len, __func__); 2984 item->ri_buf[1].i_len, __func__);
2984 return EIO; 2985 return -EIO;
2985 } 2986 }
2986 2987
2987 /* 2988 /*
@@ -3007,7 +3008,7 @@ xlog_recover_dquot_pass2(
3007 error = xfs_dqcheck(mp, recddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN, 3008 error = xfs_dqcheck(mp, recddq, dq_f->qlf_id, 0, XFS_QMOPT_DOWARN,
3008 "xlog_recover_dquot_pass2 (log copy)"); 3009 "xlog_recover_dquot_pass2 (log copy)");
3009 if (error) 3010 if (error)
3010 return EIO; 3011 return -EIO;
3011 ASSERT(dq_f->qlf_len == 1); 3012 ASSERT(dq_f->qlf_len == 1);
3012 3013
3013 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dq_f->qlf_blkno, 3014 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dq_f->qlf_blkno,
@@ -3028,7 +3029,7 @@ xlog_recover_dquot_pass2(
3028 "xlog_recover_dquot_pass2"); 3029 "xlog_recover_dquot_pass2");
3029 if (error) { 3030 if (error) {
3030 xfs_buf_relse(bp); 3031 xfs_buf_relse(bp);
3031 return EIO; 3032 return -EIO;
3032 } 3033 }
3033 3034
3034 /* 3035 /*
@@ -3178,38 +3179,38 @@ xlog_recover_do_icreate_pass2(
3178 icl = (struct xfs_icreate_log *)item->ri_buf[0].i_addr; 3179 icl = (struct xfs_icreate_log *)item->ri_buf[0].i_addr;
3179 if (icl->icl_type != XFS_LI_ICREATE) { 3180 if (icl->icl_type != XFS_LI_ICREATE) {
3180 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad type"); 3181 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad type");
3181 return EINVAL; 3182 return -EINVAL;
3182 } 3183 }
3183 3184
3184 if (icl->icl_size != 1) { 3185 if (icl->icl_size != 1) {
3185 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad icl size"); 3186 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad icl size");
3186 return EINVAL; 3187 return -EINVAL;
3187 } 3188 }
3188 3189
3189 agno = be32_to_cpu(icl->icl_ag); 3190 agno = be32_to_cpu(icl->icl_ag);
3190 if (agno >= mp->m_sb.sb_agcount) { 3191 if (agno >= mp->m_sb.sb_agcount) {
3191 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agno"); 3192 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agno");
3192 return EINVAL; 3193 return -EINVAL;
3193 } 3194 }
3194 agbno = be32_to_cpu(icl->icl_agbno); 3195 agbno = be32_to_cpu(icl->icl_agbno);
3195 if (!agbno || agbno == NULLAGBLOCK || agbno >= mp->m_sb.sb_agblocks) { 3196 if (!agbno || agbno == NULLAGBLOCK || agbno >= mp->m_sb.sb_agblocks) {
3196 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agbno"); 3197 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad agbno");
3197 return EINVAL; 3198 return -EINVAL;
3198 } 3199 }
3199 isize = be32_to_cpu(icl->icl_isize); 3200 isize = be32_to_cpu(icl->icl_isize);
3200 if (isize != mp->m_sb.sb_inodesize) { 3201 if (isize != mp->m_sb.sb_inodesize) {
3201 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad isize"); 3202 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad isize");
3202 return EINVAL; 3203 return -EINVAL;
3203 } 3204 }
3204 count = be32_to_cpu(icl->icl_count); 3205 count = be32_to_cpu(icl->icl_count);
3205 if (!count) { 3206 if (!count) {
3206 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count"); 3207 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count");
3207 return EINVAL; 3208 return -EINVAL;
3208 } 3209 }
3209 length = be32_to_cpu(icl->icl_length); 3210 length = be32_to_cpu(icl->icl_length);
3210 if (!length || length >= mp->m_sb.sb_agblocks) { 3211 if (!length || length >= mp->m_sb.sb_agblocks) {
3211 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad length"); 3212 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad length");
3212 return EINVAL; 3213 return -EINVAL;
3213 } 3214 }
3214 3215
3215 /* existing allocation is fixed value */ 3216 /* existing allocation is fixed value */
@@ -3218,7 +3219,7 @@ xlog_recover_do_icreate_pass2(
3218 if (count != mp->m_ialloc_inos || 3219 if (count != mp->m_ialloc_inos ||
3219 length != mp->m_ialloc_blks) { 3220 length != mp->m_ialloc_blks) {
3220 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count 2"); 3221 xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad count 2");
3221 return EINVAL; 3222 return -EINVAL;
3222 } 3223 }
3223 3224
3224 /* 3225 /*
@@ -3389,7 +3390,7 @@ xlog_recover_commit_pass1(
3389 xfs_warn(log->l_mp, "%s: invalid item type (%d)", 3390 xfs_warn(log->l_mp, "%s: invalid item type (%d)",
3390 __func__, ITEM_TYPE(item)); 3391 __func__, ITEM_TYPE(item));
3391 ASSERT(0); 3392 ASSERT(0);
3392 return EIO; 3393 return -EIO;
3393 } 3394 }
3394} 3395}
3395 3396
@@ -3425,7 +3426,7 @@ xlog_recover_commit_pass2(
3425 xfs_warn(log->l_mp, "%s: invalid item type (%d)", 3426 xfs_warn(log->l_mp, "%s: invalid item type (%d)",
3426 __func__, ITEM_TYPE(item)); 3427 __func__, ITEM_TYPE(item));
3427 ASSERT(0); 3428 ASSERT(0);
3428 return EIO; 3429 return -EIO;
3429 } 3430 }
3430} 3431}
3431 3432
@@ -3560,7 +3561,7 @@ xlog_recover_process_data(
3560 3561
3561 /* check the log format matches our own - else we can't recover */ 3562 /* check the log format matches our own - else we can't recover */
3562 if (xlog_header_check_recover(log->l_mp, rhead)) 3563 if (xlog_header_check_recover(log->l_mp, rhead))
3563 return EIO; 3564 return -EIO;
3564 3565
3565 while ((dp < lp) && num_logops) { 3566 while ((dp < lp) && num_logops) {
3566 ASSERT(dp + sizeof(xlog_op_header_t) <= lp); 3567 ASSERT(dp + sizeof(xlog_op_header_t) <= lp);
@@ -3571,7 +3572,7 @@ xlog_recover_process_data(
3571 xfs_warn(log->l_mp, "%s: bad clientid 0x%x", 3572 xfs_warn(log->l_mp, "%s: bad clientid 0x%x",
3572 __func__, ohead->oh_clientid); 3573 __func__, ohead->oh_clientid);
3573 ASSERT(0); 3574 ASSERT(0);
3574 return EIO; 3575 return -EIO;
3575 } 3576 }
3576 tid = be32_to_cpu(ohead->oh_tid); 3577 tid = be32_to_cpu(ohead->oh_tid);
3577 hash = XLOG_RHASH(tid); 3578 hash = XLOG_RHASH(tid);
@@ -3585,7 +3586,7 @@ xlog_recover_process_data(
3585 xfs_warn(log->l_mp, "%s: bad length 0x%x", 3586 xfs_warn(log->l_mp, "%s: bad length 0x%x",
3586 __func__, be32_to_cpu(ohead->oh_len)); 3587 __func__, be32_to_cpu(ohead->oh_len));
3587 WARN_ON(1); 3588 WARN_ON(1);
3588 return EIO; 3589 return -EIO;
3589 } 3590 }
3590 flags = ohead->oh_flags & ~XLOG_END_TRANS; 3591 flags = ohead->oh_flags & ~XLOG_END_TRANS;
3591 if (flags & XLOG_WAS_CONT_TRANS) 3592 if (flags & XLOG_WAS_CONT_TRANS)
@@ -3607,7 +3608,7 @@ xlog_recover_process_data(
3607 xfs_warn(log->l_mp, "%s: bad transaction", 3608 xfs_warn(log->l_mp, "%s: bad transaction",
3608 __func__); 3609 __func__);
3609 ASSERT(0); 3610 ASSERT(0);
3610 error = EIO; 3611 error = -EIO;
3611 break; 3612 break;
3612 case 0: 3613 case 0:
3613 case XLOG_CONTINUE_TRANS: 3614 case XLOG_CONTINUE_TRANS:
@@ -3618,7 +3619,7 @@ xlog_recover_process_data(
3618 xfs_warn(log->l_mp, "%s: bad flag 0x%x", 3619 xfs_warn(log->l_mp, "%s: bad flag 0x%x",
3619 __func__, flags); 3620 __func__, flags);
3620 ASSERT(0); 3621 ASSERT(0);
3621 error = EIO; 3622 error = -EIO;
3622 break; 3623 break;
3623 } 3624 }
3624 if (error) { 3625 if (error) {
@@ -3669,7 +3670,7 @@ xlog_recover_process_efi(
3669 */ 3670 */
3670 set_bit(XFS_EFI_RECOVERED, &efip->efi_flags); 3671 set_bit(XFS_EFI_RECOVERED, &efip->efi_flags);
3671 xfs_efi_release(efip, efip->efi_format.efi_nextents); 3672 xfs_efi_release(efip, efip->efi_format.efi_nextents);
3672 return EIO; 3673 return -EIO;
3673 } 3674 }
3674 } 3675 }
3675 3676
@@ -3969,7 +3970,7 @@ xlog_unpack_data_crc(
3969 * CRC protection by punting an error back up the stack. 3970 * CRC protection by punting an error back up the stack.
3970 */ 3971 */
3971 if (xfs_sb_version_hascrc(&log->l_mp->m_sb)) 3972 if (xfs_sb_version_hascrc(&log->l_mp->m_sb))
3972 return EFSCORRUPTED; 3973 return -EFSCORRUPTED;
3973 } 3974 }
3974 3975
3975 return 0; 3976 return 0;
@@ -4018,14 +4019,14 @@ xlog_valid_rec_header(
4018 if (unlikely(rhead->h_magicno != cpu_to_be32(XLOG_HEADER_MAGIC_NUM))) { 4019 if (unlikely(rhead->h_magicno != cpu_to_be32(XLOG_HEADER_MAGIC_NUM))) {
4019 XFS_ERROR_REPORT("xlog_valid_rec_header(1)", 4020 XFS_ERROR_REPORT("xlog_valid_rec_header(1)",
4020 XFS_ERRLEVEL_LOW, log->l_mp); 4021 XFS_ERRLEVEL_LOW, log->l_mp);
4021 return EFSCORRUPTED; 4022 return -EFSCORRUPTED;
4022 } 4023 }
4023 if (unlikely( 4024 if (unlikely(
4024 (!rhead->h_version || 4025 (!rhead->h_version ||
4025 (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS))))) { 4026 (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS))))) {
4026 xfs_warn(log->l_mp, "%s: unrecognised log version (%d).", 4027 xfs_warn(log->l_mp, "%s: unrecognised log version (%d).",
4027 __func__, be32_to_cpu(rhead->h_version)); 4028 __func__, be32_to_cpu(rhead->h_version));
4028 return EIO; 4029 return -EIO;
4029 } 4030 }
4030 4031
4031 /* LR body must have data or it wouldn't have been written */ 4032 /* LR body must have data or it wouldn't have been written */
@@ -4033,12 +4034,12 @@ xlog_valid_rec_header(
4033 if (unlikely( hlen <= 0 || hlen > INT_MAX )) { 4034 if (unlikely( hlen <= 0 || hlen > INT_MAX )) {
4034 XFS_ERROR_REPORT("xlog_valid_rec_header(2)", 4035 XFS_ERROR_REPORT("xlog_valid_rec_header(2)",
4035 XFS_ERRLEVEL_LOW, log->l_mp); 4036 XFS_ERRLEVEL_LOW, log->l_mp);
4036 return EFSCORRUPTED; 4037 return -EFSCORRUPTED;
4037 } 4038 }
4038 if (unlikely( blkno > log->l_logBBsize || blkno > INT_MAX )) { 4039 if (unlikely( blkno > log->l_logBBsize || blkno > INT_MAX )) {
4039 XFS_ERROR_REPORT("xlog_valid_rec_header(3)", 4040 XFS_ERROR_REPORT("xlog_valid_rec_header(3)",
4040 XFS_ERRLEVEL_LOW, log->l_mp); 4041 XFS_ERRLEVEL_LOW, log->l_mp);
4041 return EFSCORRUPTED; 4042 return -EFSCORRUPTED;
4042 } 4043 }
4043 return 0; 4044 return 0;
4044} 4045}
@@ -4081,7 +4082,7 @@ xlog_do_recovery_pass(
4081 */ 4082 */
4082 hbp = xlog_get_bp(log, 1); 4083 hbp = xlog_get_bp(log, 1);
4083 if (!hbp) 4084 if (!hbp)
4084 return ENOMEM; 4085 return -ENOMEM;
4085 4086
4086 error = xlog_bread(log, tail_blk, 1, hbp, &offset); 4087 error = xlog_bread(log, tail_blk, 1, hbp, &offset);
4087 if (error) 4088 if (error)
@@ -4110,11 +4111,11 @@ xlog_do_recovery_pass(
4110 } 4111 }
4111 4112
4112 if (!hbp) 4113 if (!hbp)
4113 return ENOMEM; 4114 return -ENOMEM;
4114 dbp = xlog_get_bp(log, BTOBB(h_size)); 4115 dbp = xlog_get_bp(log, BTOBB(h_size));
4115 if (!dbp) { 4116 if (!dbp) {
4116 xlog_put_bp(hbp); 4117 xlog_put_bp(hbp);
4117 return ENOMEM; 4118 return -ENOMEM;
4118 } 4119 }
4119 4120
4120 memset(rhash, 0, sizeof(rhash)); 4121 memset(rhash, 0, sizeof(rhash));
@@ -4388,7 +4389,7 @@ xlog_do_recover(
4388 * If IO errors happened during recovery, bail out. 4389 * If IO errors happened during recovery, bail out.
4389 */ 4390 */
4390 if (XFS_FORCED_SHUTDOWN(log->l_mp)) { 4391 if (XFS_FORCED_SHUTDOWN(log->l_mp)) {
4391 return EIO; 4392 return -EIO;
4392 } 4393 }
4393 4394
4394 /* 4395 /*
@@ -4415,7 +4416,7 @@ xlog_do_recover(
4415 4416
4416 if (XFS_FORCED_SHUTDOWN(log->l_mp)) { 4417 if (XFS_FORCED_SHUTDOWN(log->l_mp)) {
4417 xfs_buf_relse(bp); 4418 xfs_buf_relse(bp);
4418 return EIO; 4419 return -EIO;
4419 } 4420 }
4420 4421
4421 xfs_buf_iorequest(bp); 4422 xfs_buf_iorequest(bp);
@@ -4492,7 +4493,7 @@ xlog_recover(
4492"Please recover the log on a kernel that supports the unknown features.", 4493"Please recover the log on a kernel that supports the unknown features.",
4493 (log->l_mp->m_sb.sb_features_log_incompat & 4494 (log->l_mp->m_sb.sb_features_log_incompat &
4494 XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN)); 4495 XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN));
4495 return EINVAL; 4496 return -EINVAL;
4496 } 4497 }
4497 4498
4498 xfs_notice(log->l_mp, "Starting recovery (logdev: %s)", 4499 xfs_notice(log->l_mp, "Starting recovery (logdev: %s)",