xfs: dump log intent items that cannot be recovered due to corruption
authorDarrick J. Wong <djwong@kernel.org>
Fri, 6 Aug 2021 18:06:35 +0000 (11:06 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 9 Aug 2021 18:13:17 +0000 (11:13 -0700)
If we try to recover a log intent item and the operation fails due to
filesystem corruption, dump the contents of the item to the log for
further analysis.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_bmap_item.c
fs/xfs/xfs_extfree_item.c
fs/xfs/xfs_refcount_item.c
fs/xfs/xfs_rmap_item.c

index e3a691937e92f08258b2a4dfc20ce9d145356735..3d6f70da8820ed321630a0437fa54a46e62083a6 100644 (file)
@@ -522,6 +522,9 @@ xfs_bui_item_recover(
        error = xfs_trans_log_finish_bmap_update(tp, budp, bui_type, ip,
                        whichfork, bmap->me_startoff, bmap->me_startblock,
                        &count, state);
+       if (error == -EFSCORRUPTED)
+               XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bmap,
+                               sizeof(*bmap));
        if (error)
                goto err_cancel;
 
index 2424230ca2c3f6db7dae99b991532022bbfa1f36..3f8a0713573ad533918ead4be4ea437374582163 100644 (file)
@@ -629,6 +629,9 @@ xfs_efi_item_recover(
                error = xfs_trans_free_extent(tp, efdp, extp->ext_start,
                                              extp->ext_len,
                                              &XFS_RMAP_OINFO_ANY_OWNER, false);
+               if (error == -EFSCORRUPTED)
+                       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
+                                       extp, sizeof(*extp));
                if (error)
                        goto abort_error;
 
index 746f4eda724ce35d1d6adc50c399b3ba14cefb38..163615285b18807b2ec1f70d81171546b0d25196 100644 (file)
@@ -522,6 +522,9 @@ xfs_cui_item_recover(
                        error = xfs_trans_log_finish_refcount_update(tp, cudp,
                                type, refc->pe_startblock, refc->pe_len,
                                &new_fsb, &new_len, &rcur);
+               if (error == -EFSCORRUPTED)
+                       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
+                                       refc, sizeof(*refc));
                if (error)
                        goto abort_error;
 
index dc4f0c9f0897af385abfe02bf851a6422eb6bd97..9b91a788722abddbc34929b869e1d19b53f2d0f1 100644 (file)
@@ -578,6 +578,9 @@ xfs_rui_item_recover(
                                rmap->me_owner, whichfork,
                                rmap->me_startoff, rmap->me_startblock,
                                rmap->me_len, state, &rcur);
+               if (error == -EFSCORRUPTED)
+                       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
+                                       rmap, sizeof(*rmap));
                if (error)
                        goto abort_error;