@@ -289,4 +289,51 @@ void xfs_bulkstat_health(struct xfs_inode *ip, struct xfs_bulkstat *bs);
#define xfs_metadata_is_sick(error) \
(unlikely((error) == -EFSCORRUPTED || (error) == -EFSBADCRC))
+/*
+ * Parameters for tracking health updates. The enum below is passed as the
+ * hook function argument.
+ */
+enum xfs_health_update_type {
+ XFS_HEALTHUP_SICK = 1, /* runtime corruption observed */
+ XFS_HEALTHUP_CORRUPT, /* fsck reported corruption */
+ XFS_HEALTHUP_HEALTHY, /* fsck reported healthy structure */
+ XFS_HEALTHUP_UNMOUNT, /* filesystem is unmounting */
+};
+
+/* Where in the filesystem was the event observed? */
+enum xfs_health_update_domain {
+ XFS_HEALTHUP_FS = 1, /* main filesystem */
+ XFS_HEALTHUP_AG, /* allocation group */
+ XFS_HEALTHUP_INODE, /* inode */
+ XFS_HEALTHUP_RTGROUP, /* realtime group */
+};
+
+struct xfs_health_update_params {
+ /* XFS_HEALTHUP_INODE */
+ xfs_ino_t ino;
+ uint32_t gen;
+
+ /* XFS_HEALTHUP_AG/RTGROUP */
+ uint32_t group;
+
+ /* XFS_SICK_* flags */
+ unsigned int old_mask;
+ unsigned int new_mask;
+
+ enum xfs_health_update_domain domain;
+};
+
+#ifdef CONFIG_XFS_LIVE_HOOKS
+struct xfs_health_hook {
+ struct xfs_hook health_hook;
+};
+
+void xfs_health_hook_disable(void);
+void xfs_health_hook_enable(void);
+
+int xfs_health_hook_add(struct xfs_mount *mp, struct xfs_health_hook *hook);
+void xfs_health_hook_del(struct xfs_mount *mp, struct xfs_health_hook *hook);
+void xfs_health_hook_setup(struct xfs_health_hook *hook, notifier_fn_t mod_fn);
+#endif /* CONFIG_XFS_LIVE_HOOKS */
+
#endif /* __XFS_HEALTH_H__ */