summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2020-02-19 17:01:54 -0800
committerDarrick J. Wong <darrick.wong@oracle.com>2020-06-01 21:16:33 -0700
commitbbaee8d41a24a3499a1a9eacecbf5fa84f77d87a (patch)
treea814df62d121b7956e06d968a1404e9d757b5fbe
parentbb298b3dd9382b10df78a27c0e8cb0f9d17e5d19 (diff)
xfs: report quota block corruption errors to the health system
Whenever we encounter corrupt quota blocks, we should report that to the health monitoring system for later reporting. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r--fs/xfs/libxfs/xfs_health.h1
-rw-r--r--fs/xfs/xfs_dquot.c6
-rw-r--r--fs/xfs/xfs_health.c15
-rw-r--r--fs/xfs/xfs_qm.c9
4 files changed, 29 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h
index b7ffcabf5d81..d55026c9073a 100644
--- a/fs/xfs/libxfs/xfs_health.h
+++ b/fs/xfs/libxfs/xfs_health.h
@@ -144,6 +144,7 @@ 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_quota_mark_sick(struct xfs_mount *mp, uint dq_flags);
/* Now some helpers. */
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index cb78def30b03..bf2272788686 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -23,6 +23,7 @@
#include "xfs_trace.h"
#include "xfs_log.h"
#include "xfs_bmap_btree.h"
+#include "xfs_health.h"
/*
* Lock order:
@@ -455,6 +456,8 @@ xfs_dquot_disk_read(
error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno,
mp->m_quotainfo->qi_dqchunklen, 0, &bp,
&xfs_dquot_buf_ops);
+ if (xfs_metadata_is_sick(error))
+ xfs_quota_mark_sick(mp, dqp->dq_flags);
if (error) {
ASSERT(bp == NULL);
return error;
@@ -1143,6 +1146,8 @@ xfs_qm_dqflush(
error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno,
mp->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK,
&bp, &xfs_dquot_buf_ops);
+ if (xfs_metadata_is_sick(error))
+ xfs_quota_mark_sick(mp, dqp->dq_flags);
if (error)
goto out_unlock;
@@ -1162,6 +1167,7 @@ xfs_qm_dqflush(
xfs_buf_relse(bp);
xfs_dqfunlock(dqp);
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
+ xfs_quota_mark_sick(mp, dqp->dq_flags);
return -EFSCORRUPTED;
}
diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c
index d8b71cba36de..68856ff39b90 100644
--- a/fs/xfs/xfs_health.c
+++ b/fs/xfs/xfs_health.c
@@ -17,6 +17,7 @@
#include "xfs_btree.h"
#include "xfs_da_format.h"
#include "xfs_da_btree.h"
+#include "xfs_quota_defs.h"
/*
* Warn about metadata corruption that we detected but haven't fixed, and
@@ -555,3 +556,17 @@ xfs_da_mark_sick(
{
xfs_dirattr_mark_sick(args->dp, args->whichfork);
}
+
+/* Record observations of quota corruption with the health tracking system. */
+void
+xfs_quota_mark_sick(
+ struct xfs_mount *mp,
+ uint dq_flags)
+{
+ if (dq_flags & XFS_DQ_USER)
+ xfs_fs_mark_sick(mp, XFS_SICK_FS_UQUOTA);
+ if (dq_flags & XFS_DQ_GROUP)
+ xfs_fs_mark_sick(mp, XFS_SICK_FS_GQUOTA);
+ if (dq_flags & XFS_DQ_PROJ)
+ xfs_fs_mark_sick(mp, XFS_SICK_FS_PQUOTA);
+}
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index c225691fad15..35df0ea298ec 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -23,6 +23,7 @@
#include "xfs_trace.h"
#include "xfs_icache.h"
#include "xfs_error.h"
+#include "xfs_health.h"
/*
* The global quota manager. There is only one of these for the entire
@@ -760,14 +761,18 @@ xfs_qm_qino_alloc(
(mp->m_sb.sb_gquotino != NULLFSINO)) {
ino = mp->m_sb.sb_gquotino;
if (XFS_IS_CORRUPT(mp,
- mp->m_sb.sb_pquotino != NULLFSINO))
+ mp->m_sb.sb_pquotino != NULLFSINO)) {
+ xfs_quota_mark_sick(mp, XFS_DQ_PROJ);
return -EFSCORRUPTED;
+ }
} else if ((flags & XFS_QMOPT_GQUOTA) &&
(mp->m_sb.sb_pquotino != NULLFSINO)) {
ino = mp->m_sb.sb_pquotino;
if (XFS_IS_CORRUPT(mp,
- mp->m_sb.sb_gquotino != NULLFSINO))
+ mp->m_sb.sb_gquotino != NULLFSINO)) {
+ xfs_quota_mark_sick(mp, XFS_DQ_GROUP);
return -EFSCORRUPTED;
+ }
}
if (ino != NULLFSINO) {
error = xfs_iget(mp, NULL, ino, 0, 0, ip);