From 1ec28615d2489882e7d47da4214c7ea1f5728fc7 Mon Sep 17 00:00:00 2001
From: "Darrick J. Wong" <darrick.wong@oracle.com>
Date: Mon, 11 Nov 2019 12:52:01 -0800
Subject: [PATCH] xfs: add a XFS_IS_CORRUPT macro
Git-commit: 1ec28615d2489882e7d47da4214c7ea1f5728fc7
Patch-mainline: v5.5-rc1
References: bsc#1166686
Add a new macro, XFS_IS_CORRUPT, which we will use to integrate some
corruption reporting when the corruption test expression is true. This
will be used in the next patch to remove the ugly XFS_WANT_CORRUPT*
macros.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
---
fs/xfs/xfs_linux.h | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index 2271db4e8d66..64bbbcc77851 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -229,6 +229,10 @@ int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count,
#define ASSERT(expr) \
(likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__))
+#define XFS_IS_CORRUPT(mp, expr) \
+ (unlikely(expr) ? assfail((mp), #expr, __FILE__, __LINE__), \
+ true : false)
+
#else /* !DEBUG */
#ifdef XFS_WARN
@@ -236,9 +240,16 @@ int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count,
#define ASSERT(expr) \
(likely(expr) ? (void)0 : asswarn(NULL, #expr, __FILE__, __LINE__))
+#define XFS_IS_CORRUPT(mp, expr) \
+ (unlikely(expr) ? asswarn((mp), #expr, __FILE__, __LINE__), \
+ true : false)
+
#else /* !DEBUG && !XFS_WARN */
-#define ASSERT(expr) ((void)0)
+#define ASSERT(expr) ((void)0)
+#define XFS_IS_CORRUPT(mp, expr) \
+ (unlikely(expr) ? XFS_ERROR_REPORT(#expr, XFS_ERRLEVEL_LOW, (mp)), \
+ true : false)
#endif /* XFS_WARN */
#endif /* DEBUG */
--
2.16.4