mirror of
https://github.com/versity/scoutfs.git
synced 2026-09-08 09:07:30 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user