fs/ocfs2/cluster/masklog.h

Source file repositories/reference/linux-study-clean/fs/ocfs2/cluster/masklog.h

File Facts

System
Linux kernel
Corpus path
fs/ocfs2/cluster/masklog.h
Extension
.h
Size
6898 bytes
Lines
197
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct mlog_bits {
	unsigned long words[MLOG_MAX_BITS / BITS_PER_LONG];
};

extern struct mlog_bits mlog_and_bits, mlog_not_bits;

#if BITS_PER_LONG == 32

#define __mlog_test_u64(mask, bits)			\
	( (u32)(mask & 0xffffffff) & bits.words[0] || 	\
	  ((u64)(mask) >> 32) & bits.words[1] )
#define __mlog_set_u64(mask, bits) do {			\
	bits.words[0] |= (u32)(mask & 0xffffffff);	\
       	bits.words[1] |= (u64)(mask) >> 32;		\
} while (0)
#define __mlog_clear_u64(mask, bits) do {		\
	bits.words[0] &= ~((u32)(mask & 0xffffffff));	\
       	bits.words[1] &= ~((u64)(mask) >> 32);		\
} while (0)
#define MLOG_BITS_RHS(mask) {				\
	{						\
		[0] = (u32)(mask & 0xffffffff),		\
		[1] = (u64)(mask) >> 32,		\
	}						\
}

#else /* 32bit long above, 64bit long below */

#define __mlog_test_u64(mask, bits)	((mask) & bits.words[0])
#define __mlog_set_u64(mask, bits) do {		\
	bits.words[0] |= (mask);		\
} while (0)
#define __mlog_clear_u64(mask, bits) do {	\
	bits.words[0] &= ~(mask);		\
} while (0)
#define MLOG_BITS_RHS(mask) { { (mask) } }

#endif

__printf(4, 5)
void __mlog_printk(const u64 *m, const char *func, int line,
		   const char *fmt, ...);

/*
 * Testing before the __mlog_printk call lets the compiler eliminate the
 * call completely when (m & ML_ALLOWED_BITS) is 0.
 */
#define mlog(mask, fmt, ...)						\
do {									\
	u64 _m = MLOG_MASK_PREFIX | (mask);				\
	if (_m & ML_ALLOWED_BITS)					\
		__mlog_printk(&_m, __func__, __LINE__, fmt,		\
			      ##__VA_ARGS__);				\
} while (0)

#define mlog_ratelimited(mask, fmt, ...)				\
do {									\
	static DEFINE_RATELIMIT_STATE(_rs,				\
				      DEFAULT_RATELIMIT_INTERVAL,	\
				      DEFAULT_RATELIMIT_BURST);		\
	if (__ratelimit(&_rs))						\
		mlog(mask, fmt, ##__VA_ARGS__);				\
} while (0)

#define mlog_errno(st) ({						\
	int _st = (st);							\
	if (_st != -ERESTARTSYS && _st != -EINTR &&			\
	    _st != AOP_TRUNCATED_PAGE && _st != -ENOSPC &&		\
	    _st != -EDQUOT)						\
		mlog(ML_ERROR, "status = %lld\n", (long long)_st);	\
	_st;								\
})

#define mlog_bug_on_msg(cond, fmt, args...) do {			\
	if (cond) {							\
		mlog(ML_ERROR, "bug expression: " #cond "\n");		\
		mlog(ML_ERROR, fmt, ##args);				\
		BUG();							\
	}								\
} while (0)

#include <linux/kobject.h>
#include <linux/sysfs.h>
int mlog_sys_init(struct kset *o2cb_subsys);
void mlog_sys_shutdown(void);

#endif /* O2CLUSTER_MASKLOG_H */

Annotation

Implementation Notes