Skip to content

Commit 950f0d5

Browse files
author
Darrick J. Wong
committed
xfs: dump corrupt recovered log intent items to dmesg consistently
If log recovery decides that an intent item is corrupt and wants to abort the mount, capture a hexdump of the corrupt log item in the kernel log for further analysis. Some of the log item code already did this, so we're fixing the rest to do it consistently. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 921ed96 commit 950f0d5

File tree

5 files changed

+43
-20
lines changed

5 files changed

+43
-20
lines changed

fs/xfs/xfs_attr_item.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -717,31 +717,37 @@ xlog_recover_attri_commit_pass2(
717717
/* Validate xfs_attri_log_format before the large memory allocation */
718718
len = sizeof(struct xfs_attri_log_format);
719719
if (item->ri_buf[0].i_len != len) {
720-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
720+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
721+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
721722
return -EFSCORRUPTED;
722723
}
723724

724725
if (!xfs_attri_validate(mp, attri_formatp)) {
725-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
726+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
727+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
726728
return -EFSCORRUPTED;
727729
}
728730

729731
/* Validate the attr name */
730732
if (item->ri_buf[1].i_len !=
731733
xlog_calc_iovec_len(attri_formatp->alfi_name_len)) {
732-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
734+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
735+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
733736
return -EFSCORRUPTED;
734737
}
735738

736739
if (!xfs_attr_namecheck(attr_name, attri_formatp->alfi_name_len)) {
737-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
740+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
741+
item->ri_buf[1].i_addr, item->ri_buf[1].i_len);
738742
return -EFSCORRUPTED;
739743
}
740744

741745
/* Validate the attr value, if present */
742746
if (attri_formatp->alfi_value_len != 0) {
743747
if (item->ri_buf[2].i_len != xlog_calc_iovec_len(attri_formatp->alfi_value_len)) {
744-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
748+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
749+
item->ri_buf[0].i_addr,
750+
item->ri_buf[0].i_len);
745751
return -EFSCORRUPTED;
746752
}
747753

@@ -834,7 +840,8 @@ xlog_recover_attrd_commit_pass2(
834840

835841
attrd_formatp = item->ri_buf[0].i_addr;
836842
if (item->ri_buf[0].i_len != sizeof(struct xfs_attrd_log_format)) {
837-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL);
843+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
844+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
838845
return -EFSCORRUPTED;
839846
}
840847

fs/xfs/xfs_bmap_item.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,18 +644,21 @@ xlog_recover_bui_commit_pass2(
644644
bui_formatp = item->ri_buf[0].i_addr;
645645

646646
if (item->ri_buf[0].i_len < xfs_bui_log_format_sizeof(0)) {
647-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
647+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
648+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
648649
return -EFSCORRUPTED;
649650
}
650651

651652
if (bui_formatp->bui_nextents != XFS_BUI_MAX_FAST_EXTENTS) {
652-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
653+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
654+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
653655
return -EFSCORRUPTED;
654656
}
655657

656658
len = xfs_bui_log_format_sizeof(bui_formatp->bui_nextents);
657659
if (item->ri_buf[0].i_len != len) {
658-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
660+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
661+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
659662
return -EFSCORRUPTED;
660663
}
661664

@@ -694,7 +697,8 @@ xlog_recover_bud_commit_pass2(
694697

695698
bud_formatp = item->ri_buf[0].i_addr;
696699
if (item->ri_buf[0].i_len != sizeof(struct xfs_bud_log_format)) {
697-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
700+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
701+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
698702
return -EFSCORRUPTED;
699703
}
700704

fs/xfs/xfs_extfree_item.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt)
216216
}
217217
return 0;
218218
}
219-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL);
219+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, NULL, buf->i_addr,
220+
buf->i_len);
220221
return -EFSCORRUPTED;
221222
}
222223

@@ -711,7 +712,8 @@ xlog_recover_efi_commit_pass2(
711712
efi_formatp = item->ri_buf[0].i_addr;
712713

713714
if (item->ri_buf[0].i_len < xfs_efi_log_format_sizeof(0)) {
714-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
715+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
716+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
715717
return -EFSCORRUPTED;
716718
}
717719

fs/xfs/xfs_refcount_item.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,9 @@ xfs_cui_item_recover(
523523
type = refc_type;
524524
break;
525525
default:
526-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
526+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
527+
&cuip->cui_format,
528+
sizeof(cuip->cui_format));
527529
error = -EFSCORRUPTED;
528530
goto abort_error;
529531
}
@@ -536,7 +538,8 @@ xfs_cui_item_recover(
536538
&new_fsb, &new_len, &rcur);
537539
if (error == -EFSCORRUPTED)
538540
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
539-
refc, sizeof(*refc));
541+
&cuip->cui_format,
542+
sizeof(cuip->cui_format));
540543
if (error)
541544
goto abort_error;
542545

@@ -658,13 +661,15 @@ xlog_recover_cui_commit_pass2(
658661
cui_formatp = item->ri_buf[0].i_addr;
659662

660663
if (item->ri_buf[0].i_len < xfs_cui_log_format_sizeof(0)) {
661-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
664+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
665+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
662666
return -EFSCORRUPTED;
663667
}
664668

665669
len = xfs_cui_log_format_sizeof(cui_formatp->cui_nextents);
666670
if (item->ri_buf[0].i_len != len) {
667-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
671+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
672+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
668673
return -EFSCORRUPTED;
669674
}
670675

@@ -703,7 +708,8 @@ xlog_recover_cud_commit_pass2(
703708

704709
cud_formatp = item->ri_buf[0].i_addr;
705710
if (item->ri_buf[0].i_len != sizeof(struct xfs_cud_log_format)) {
706-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
711+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
712+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
707713
return -EFSCORRUPTED;
708714
}
709715

fs/xfs/xfs_rmap_item.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,9 @@ xfs_rui_item_recover(
557557
type = XFS_RMAP_FREE;
558558
break;
559559
default:
560-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL);
560+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
561+
&ruip->rui_format,
562+
sizeof(ruip->rui_format));
561563
error = -EFSCORRUPTED;
562564
goto abort_error;
563565
}
@@ -663,13 +665,15 @@ xlog_recover_rui_commit_pass2(
663665
rui_formatp = item->ri_buf[0].i_addr;
664666

665667
if (item->ri_buf[0].i_len < xfs_rui_log_format_sizeof(0)) {
666-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
668+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
669+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
667670
return -EFSCORRUPTED;
668671
}
669672

670673
len = xfs_rui_log_format_sizeof(rui_formatp->rui_nextents);
671674
if (item->ri_buf[0].i_len != len) {
672-
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
675+
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
676+
item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
673677
return -EFSCORRUPTED;
674678
}
675679

0 commit comments

Comments
 (0)