mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
spl: Add cmn_err_once() to log a message only on the first call
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Brian Atkinson <batkinson@lanl.gov> Signed-off-by: Attila Fülöp <attila@fueloep.org> Closes #14567
This commit is contained in:
@@ -27,4 +27,38 @@
|
||||
#ifndef _LIBSPL_SYS_CMN_ERR_H
|
||||
#define _LIBSPL_SYS_CMN_ERR_H
|
||||
|
||||
#include <atomic.h>
|
||||
|
||||
#define cmn_err_once(ce, ...) \
|
||||
{ \
|
||||
static volatile uint32_t printed = 0; \
|
||||
if (atomic_cas_32(&printed, 0, 1) == 0) { \
|
||||
cmn_err(ce, __VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define vcmn_err_once(ce, fmt, ap) \
|
||||
{ \
|
||||
static volatile uint32_t printed = 0; \
|
||||
if (atomic_cas_32(&printed, 0, 1) == 0) { \
|
||||
vcmn_err(ce, fmt, ap); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define zcmn_err_once(zone, ce, ...) \
|
||||
{ \
|
||||
static volatile uint32_t printed = 0; \
|
||||
if (atomic_cas_32(&printed, 0, 1) == 0) { \
|
||||
zcmn_err(zone, ce, __VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define vzcmn_err_once(zone, ce, fmt, ap) \
|
||||
{ \
|
||||
static volatile uint32_t printed = 0; \
|
||||
if (atomic_cas_32(&printed, 0, 1) == 0) { \
|
||||
vzcmn_err(zone, ce, fmt, ap); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user