Skip to content

Commit efd87a1

Browse files
Darrick J. Wongbrauner
authored andcommitted
xfs: report fs metadata errors via fsnotify
Report filesystem corruption problems to the fserror helpers so that fsnotify can also convey metadata problems to userspace. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Link: https://patch.msgid.link/176826402652.3490369.2609467634858507969.stgit@frogsfrogsfrogs Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent a9d573e commit efd87a1

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

fs/xfs/xfs_fsops.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include "xfs_rtrefcount_btree.h"
2727
#include "xfs_metafile.h"
2828

29+
#include <linux/fserror.h>
30+
2931
/*
3032
* Write new AG headers to disk. Non-transactional, but need to be
3133
* written and completed prior to the growfs transaction being logged.
@@ -540,6 +542,8 @@ xfs_do_force_shutdown(
540542
"Please unmount the filesystem and rectify the problem(s)");
541543
if (xfs_error_level >= XFS_ERRLEVEL_HIGH)
542544
xfs_stack_trace();
545+
546+
fserror_report_shutdown(mp->m_super, GFP_KERNEL);
543547
}
544548

545549
/*

fs/xfs/xfs_health.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "xfs_quota_defs.h"
2121
#include "xfs_rtgroup.h"
2222

23+
#include <linux/fserror.h>
24+
2325
static void
2426
xfs_health_unmount_group(
2527
struct xfs_group *xg,
@@ -111,6 +113,8 @@ xfs_fs_mark_sick(
111113
spin_lock(&mp->m_sb_lock);
112114
mp->m_fs_sick |= mask;
113115
spin_unlock(&mp->m_sb_lock);
116+
117+
fserror_report_metadata(mp->m_super, -EFSCORRUPTED, GFP_NOFS);
114118
}
115119

116120
/* Mark per-fs metadata as having been checked and found unhealthy by fsck. */
@@ -126,6 +130,8 @@ xfs_fs_mark_corrupt(
126130
mp->m_fs_sick |= mask;
127131
mp->m_fs_checked |= mask;
128132
spin_unlock(&mp->m_sb_lock);
133+
134+
fserror_report_metadata(mp->m_super, -EFSCORRUPTED, GFP_NOFS);
129135
}
130136

131137
/* Mark a per-fs metadata healed. */
@@ -198,6 +204,8 @@ xfs_group_mark_sick(
198204
spin_lock(&xg->xg_state_lock);
199205
xg->xg_sick |= mask;
200206
spin_unlock(&xg->xg_state_lock);
207+
208+
fserror_report_metadata(xg->xg_mount->m_super, -EFSCORRUPTED, GFP_NOFS);
201209
}
202210

203211
/*
@@ -215,6 +223,8 @@ xfs_group_mark_corrupt(
215223
xg->xg_sick |= mask;
216224
xg->xg_checked |= mask;
217225
spin_unlock(&xg->xg_state_lock);
226+
227+
fserror_report_metadata(xg->xg_mount->m_super, -EFSCORRUPTED, GFP_NOFS);
218228
}
219229

220230
/*
@@ -287,6 +297,8 @@ xfs_inode_mark_sick(
287297
spin_lock(&VFS_I(ip)->i_lock);
288298
inode_state_clear(VFS_I(ip), I_DONTCACHE);
289299
spin_unlock(&VFS_I(ip)->i_lock);
300+
301+
fserror_report_file_metadata(VFS_I(ip), -EFSCORRUPTED, GFP_NOFS);
290302
}
291303

292304
/* Mark inode metadata as having been checked and found unhealthy by fsck. */
@@ -311,6 +323,8 @@ xfs_inode_mark_corrupt(
311323
spin_lock(&VFS_I(ip)->i_lock);
312324
inode_state_clear(VFS_I(ip), I_DONTCACHE);
313325
spin_unlock(&VFS_I(ip)->i_lock);
326+
327+
fserror_report_file_metadata(VFS_I(ip), -EFSCORRUPTED, GFP_NOFS);
314328
}
315329

316330
/* Mark parts of an inode healed. */

0 commit comments

Comments
 (0)