]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: report inode corruption errors to the health system
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:00:55 +0000 (10:00 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:36 +0000 (11:37 -0700)
Source kernel commit: baf44fa5c37a2357a7ae92889f74bc1824f33fd4

Whenever we encounter corrupt inode records, we should report that to
the health monitoring system for later reporting.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
libxfs/util.c
libxfs/xfs_ialloc.c
libxfs/xfs_inode_buf.c
libxfs/xfs_inode_fork.c

index 6c326e84aab623dc9ca19293c3120f2b4f3fae3e..6d8847363433ef6818a8c57b8376a8a5b5aecc86 100644 (file)
@@ -736,3 +736,4 @@ void xfs_bmap_mark_sick(struct xfs_inode *ip, int whichfork) { }
 void xfs_btree_mark_sick(struct xfs_btree_cur *cur) { }
 void xfs_dirattr_mark_sick(struct xfs_inode *ip, int whichfork) { }
 void xfs_da_mark_sick(struct xfs_da_args *args) { }
+void xfs_inode_mark_sick(struct xfs_inode *ip, unsigned int mask) { }
index 92ca3d460e04bf15dc87d6f796c916eaff5b31db..63922f44ffe7fcfd722be8cb067ddf57b34a5756 100644 (file)
@@ -2994,6 +2994,7 @@ xfs_ialloc_check_shrink(
                goto out;
 
        if (!has) {
+               xfs_ag_mark_sick(pag, XFS_SICK_AG_INOBT);
                error = -EFSCORRUPTED;
                goto out;
        }
index fd351c252af013b781d975dfb0132b3cc5680aa7..83d936981166572319dc2341f8ef3b7a021f54f5 100644 (file)
@@ -16,6 +16,7 @@
 #include "xfs_trans.h"
 #include "xfs_ialloc.h"
 #include "xfs_dir2.h"
+#include "xfs_health.h"
 
 
 /*
@@ -129,9 +130,14 @@ xfs_imap_to_bp(
        struct xfs_imap         *imap,
        struct xfs_buf          **bpp)
 {
-       return xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno,
-                                  imap->im_len, XBF_UNMAPPED, bpp,
-                                  &xfs_inode_buf_ops);
+       int                     error;
+
+       error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno,
+                       imap->im_len, XBF_UNMAPPED, bpp, &xfs_inode_buf_ops);
+       if (xfs_metadata_is_sick(error))
+               xfs_agno_mark_sick(mp, xfs_daddr_to_agno(mp, imap->im_blkno),
+                               XFS_SICK_AG_INOBT);
+       return error;
 }
 
 static inline struct timespec64 xfs_inode_decode_bigtime(uint64_t ts)
index 6d81757239bb1d1d357b2d74d061e52e3ec5c653..53ff8267803b8285be293c4366e4450c72dd2d15 100644 (file)
@@ -23,6 +23,7 @@
 #include "xfs_attr_leaf.h"
 #include "xfs_types.h"
 #include "xfs_errortag.h"
+#include "xfs_health.h"
 
 struct kmem_cache *xfs_ifork_cache;
 
@@ -86,6 +87,7 @@ xfs_iformat_local(
                xfs_inode_verifier_error(ip, -EFSCORRUPTED,
                                "xfs_iformat_local", dip, sizeof(*dip),
                                __this_address);
+               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                return -EFSCORRUPTED;
        }
 
@@ -123,6 +125,7 @@ xfs_iformat_extents(
                xfs_inode_verifier_error(ip, -EFSCORRUPTED,
                                "xfs_iformat_extents(1)", dip, sizeof(*dip),
                                __this_address);
+               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                return -EFSCORRUPTED;
        }
 
@@ -142,6 +145,7 @@ xfs_iformat_extents(
                                xfs_inode_verifier_error(ip, -EFSCORRUPTED,
                                                "xfs_iformat_extents(2)",
                                                dp, sizeof(*dp), fa);
+                               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                                return xfs_bmap_complain_bad_rec(ip, whichfork,
                                                fa, &new);
                        }
@@ -200,6 +204,7 @@ xfs_iformat_btree(
                xfs_inode_verifier_error(ip, -EFSCORRUPTED,
                                "xfs_iformat_btree", dfp, size,
                                __this_address);
+               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                return -EFSCORRUPTED;
        }
 
@@ -265,12 +270,14 @@ xfs_iformat_data_fork(
                default:
                        xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__,
                                        dip, sizeof(*dip), __this_address);
+                       xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                        return -EFSCORRUPTED;
                }
                break;
        default:
                xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, dip,
                                sizeof(*dip), __this_address);
+               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                return -EFSCORRUPTED;
        }
 }
@@ -342,6 +349,7 @@ xfs_iformat_attr_fork(
        default:
                xfs_inode_verifier_error(ip, error, __func__, dip,
                                sizeof(*dip), __this_address);
+               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                error = -EFSCORRUPTED;
                break;
        }