scoutfs: add scoutfs_corruption()

Add a helper for printing a message warning about corruption.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2018-04-27 09:06:35 -07:00
committed by Zach Brown
parent ac259c82a0
commit c9573d13bb
3 changed files with 33 additions and 0 deletions
+9
View File
@@ -645,4 +645,13 @@ struct scoutfs_fid {
#define FILEID_SCOUTFS 0x81
#define FILEID_SCOUTFS_WITH_PARENT 0x82
/*
* Identifiers for sources of corruption that can generate messages.
*/
enum {
SC_NR_SOURCES,
};
#define SC_NR_LONGS DIV_ROUND_UP(SC_NR_SOURCES, BITS_PER_LONG)
#endif
+22
View File
@@ -1,6 +1,7 @@
#ifndef _SCOUTFS_MSG_H_
#define _SCOUTFS_MSG_H_
#include <linux/bitops.h>
#include "key.h"
void __printf(4, 5) scoutfs_msg(struct super_block *sb, const char *prefix,
@@ -23,4 +24,25 @@ do { \
} \
} while (0) \
/*
* Each message is only generated once per volume. Remounting resets
* the messages.
*/
#define scoutfs_corruption(sb, which, counter, fmt, args...) \
do { \
__typeof__(sb) _sb = (sb); \
struct scoutfs_sb_info *_sbi = SCOUTFS_SB(_sb); \
unsigned int _bit = (which); \
\
if (WARN_ON_ONCE(_bit >= SC_NR_SOURCES)) \
break; \
\
scoutfs_inc_counter(_sb, counter); \
if (!test_and_set_bit(_bit, _sbi->corruption_messages_once)) { \
scoutfs_err(_sb, "corruption (see scoutfs-corruption(5)): " \
#which ": " fmt, ##args); \
dump_stack(); \
} \
} while (0) \
#endif
+2
View File
@@ -70,6 +70,8 @@ struct scoutfs_sb_info {
struct dentry *debug_root;
bool shutdown;
unsigned long corruption_messages_once[SC_NR_LONGS];
};
static inline struct scoutfs_sb_info *SCOUTFS_SB(struct super_block *sb)