Skip to contentSkip to conversation

xfs_repair: print XFS_WANT_CORRUPTED info with -vvv

PATCH In review Eric Sandeen 2 participants 2 messages Nov 12, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_repair: print XFS_WANT_CORRUPTED info with -vvv

In the kernel, the XFS_WANT_CORRUPTED_* macros print the caller information via XFS_ERROR_REPORT, but in userspace this is silenced, because i.e. xfs_repair's job is to find and fix corruption, not to complain loudly about it.

However, there are times when we would like to know if we've hit an unexpected corruption point. To that end, make "xfs_repair -vvv" enable noisiness from these macros, so that they will print the function and line of the caller.

---

include/xfs_mount.h +1 -0
index 5ec6866..67f3b05 100644
@@ -143,6 +143,7 @@ typedef struct xfs_perag {
 #define LIBXFS_MOUNT_32BITINOOPT	0x0004
 #define LIBXFS_MOUNT_COMPAT_ATTR	0x0008
 #define LIBXFS_MOUNT_ATTR2		0x0010
+#define LIBXFS_MOUNT_WANT_CORRUPTED	0x0020
 
 #define LIBXFS_BHASHSIZE(sbp) 		(1<<10)
 
libxfs/libxfs_priv.h +19 -4
index 9135aac..0f4d3e5 100644
@@ -147,10 +147,25 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
 #define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp,tp,ip,nblks,ninos,fl)	0
 #define XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp,tp,ip,nblks,ninos,fl)	0
 #define XFS_TEST_ERROR(expr,a,b,c)	( expr )
-#define XFS_WANT_CORRUPTED_GOTO(mp, expr, l)	\
-		{ (mp) = (mp); if (!(expr)) { error = -EFSCORRUPTED; goto l; } }
-#define XFS_WANT_CORRUPTED_RETURN(mp, expr)	\
-		{ (mp) = (mp); if (!(expr)) { return -EFSCORRUPTED; } }
+#define XFS_WANT_CORRUPTED_GOTO(mp, expr, l)				\
+{									\
+	if (!(expr)) {							\
+		if ((mp)->m_flags & LIBXFS_MOUNT_WANT_CORRUPTED)	\
+			printf("WANT_CORRUPTED_GOTO at %s:%d\n",	\
+				__func__, __LINE__);			\
+		error = -EFSCORRUPTED;					\
+		goto l;							\
+	}								\
+}
+#define XFS_WANT_CORRUPTED_RETURN(mp, expr)				\
+{									\
+	if (!(expr)) {							\
+		if ((mp)->m_flags & LIBXFS_MOUNT_WANT_CORRUPTED)	\
+			printf("WANT_CORRUPTED_RETURN at %s:%d\n",	\
+				__func__, __LINE__);			\
+		return -EFSCORRUPTED;					\
+	}								\
+}
 
 #ifdef __GNUC__
 #define __return_address	__builtin_return_address(0)
man/man8/xfs_repair.8 +1 -1
index 0394c50..1b4d9e3 100644
@@ -158,7 +158,7 @@ outputs its progress every 15 minutes. Reporting is only activated when
 ag_stride is enabled.
 .TP
 .B \-v
-Verbose output.
+Verbose output.  May be specified multiple times to increase verbosity.
 .TP
 .B \-d
 Repair dangerously. Allow
repair/xfs_repair.c +4 -0
index bed2ff5..1aeac5b 100644
@@ -695,6 +695,10 @@ main(int argc, char **argv)
 	}
 	mp->m_log = &log;
 
+	/* Spit out function & line on these corruption macros */
+	if (verbose > 2)
+		mp->m_flags |= LIBXFS_MOUNT_WANT_CORRUPTED;
+
 	/*
 	 * set XFS-independent status vars from the mount/sb structure
 	 */

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Eric Sandeen

In the kernel, the XFS_WANT_CORRUPTED_* macros print the caller information via XFS_ERROR_REPORT, but in userspace this is silenced, because i.e. xfs_repair's job is to find and fix corruption, not to complain loudly about it.

Quoted 7 lines

However, there are times when we would like to know if we've hit an unexpected corruption point. To that end, make "xfs_repair -vvv" enable noisiness from these macros, so that they will print the function and line of the caller.

---

Quoted 77 lines
include/xfs_mount.h +1 -0
index 5ec6866..67f3b05 100644
@@ -143,6 +143,7 @@ typedef struct xfs_perag {
 #define LIBXFS_MOUNT_32BITINOOPT	0x0004
 #define LIBXFS_MOUNT_COMPAT_ATTR	0x0008
 #define LIBXFS_MOUNT_ATTR2		0x0010
+#define LIBXFS_MOUNT_WANT_CORRUPTED	0x0020
 
 #define LIBXFS_BHASHSIZE(sbp) 		(1<<10)
 
libxfs/libxfs_priv.h +19 -4
index 9135aac..0f4d3e5 100644
@@ -147,10 +147,25 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
 #define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp,tp,ip,nblks,ninos,fl)	0
 #define XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp,tp,ip,nblks,ninos,fl)	0
 #define XFS_TEST_ERROR(expr,a,b,c)	( expr )
-#define XFS_WANT_CORRUPTED_GOTO(mp, expr, l)	\
-		{ (mp) = (mp); if (!(expr)) { error = -EFSCORRUPTED; goto l; } }
-#define XFS_WANT_CORRUPTED_RETURN(mp, expr)	\
-		{ (mp) = (mp); if (!(expr)) { return -EFSCORRUPTED; } }
+#define XFS_WANT_CORRUPTED_GOTO(mp, expr, l)				\
+{									\
+	if (!(expr)) {							\
+		if ((mp)->m_flags & LIBXFS_MOUNT_WANT_CORRUPTED)	\
+			printf("WANT_CORRUPTED_GOTO at %s:%d\n",	\
+				__func__, __LINE__);			\
+		error = -EFSCORRUPTED;					\
+		goto l;							\
+	}								\
+}
+#define XFS_WANT_CORRUPTED_RETURN(mp, expr)				\
+{									\
+	if (!(expr)) {							\
+		if ((mp)->m_flags & LIBXFS_MOUNT_WANT_CORRUPTED)	\
+			printf("WANT_CORRUPTED_RETURN at %s:%d\n",	\
+				__func__, __LINE__);			\
+		return -EFSCORRUPTED;					\
+	}								\
+}
 
 #ifdef __GNUC__
 #define __return_address	__builtin_return_address(0)
man/man8/xfs_repair.8 +1 -1
index 0394c50..1b4d9e3 100644
@@ -158,7 +158,7 @@ outputs its progress every 15 minutes. Reporting is only activated when
 ag_stride is enabled.
 .TP
 .B \-v
-Verbose output.
+Verbose output.  May be specified multiple times to increase verbosity.
 .TP
 .B \-d
 Repair dangerously. Allow
repair/xfs_repair.c +4 -0
index bed2ff5..1aeac5b 100644
@@ -695,6 +695,10 @@ main(int argc, char **argv)
 	}
 	mp->m_log = &log;
 
+	/* Spit out function & line on these corruption macros */
+	if (verbose > 2)
+		mp->m_flags |= LIBXFS_MOUNT_WANT_CORRUPTED;
+
 	/*
 	 * set XFS-independent status vars from the mount/sb structure
 	 */
Quoted 4 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs