Commit 6011ea2b authored by J. R. Okajima's avatar J. R. Okajima
Browse files

aufs: module parameter, debug



This parameter is available only when CONFIG_AUFS_DEBUG is enabled, and
its default value is 0. Setting 1 will enable the various verifications
and debug outputs.
Signed-off-by: default avatarJ. R. Okajima <hooanon05g@gmail.com>
parent c74884be
......@@ -8,3 +8,6 @@ ccflags-y += -include ${srctree}/include/uapi/linux/aufs_type.h
obj-$(CONFIG_AUFS_FS) += aufs.o
aufs-y := module.o super.o \
iinfo.o
# all are boolean
aufs-$(CONFIG_AUFS_DEBUG) += debug.o
......@@ -12,6 +12,14 @@
#ifdef __KERNEL__
#define AuStub(type, name, body, ...) \
static inline type name(__VA_ARGS__) { body; }
#define AuStubVoid(name, ...) \
AuStub(void, name, , __VA_ARGS__)
#define AuStubInt0(name, ...) \
AuStub(int, name, return 0, __VA_ARGS__)
#include "debug.h"
#include "inode.h"
......
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2005-2019 Junjiro R. Okajima
*/
/*
* debug print functions
*/
#include "aufs.h"
/* Returns 0, or -errno. arg is in kp->arg. */
static int param_atomic_t_set(const char *val, const struct kernel_param *kp)
{
int err, n;
err = kstrtoint(val, 0, &n);
if (!err) {
if (n > 0)
au_debug_on();
else
au_debug_off();
}
return err;
}
/* Returns length written or -errno. Buffer is 4k (ie. be short!) */
static int param_atomic_t_get(char *buffer, const struct kernel_param *kp)
{
atomic_t *a;
a = kp->arg;
return sprintf(buffer, "%d", atomic_read(a));
}
static struct kernel_param_ops param_ops_atomic_t = {
.set = param_atomic_t_set,
.get = param_atomic_t_get
/* void (*free)(void *arg) */
};
atomic_t aufs_debug = ATOMIC_INIT(0);
MODULE_PARM_DESC(debug, "debug print");
module_param_named(debug, aufs_debug, atomic_t, 0664);
......@@ -12,11 +12,35 @@
#ifdef __KERNEL__
#include <linux/atomic.h>
#include <linux/module.h>
#ifdef CONFIG_AUFS_DEBUG
#define AuDebugOn(a) BUG_ON(a)
/* module parameter */
extern atomic_t aufs_debug;
static inline void au_debug_on(void)
{
atomic_inc(&aufs_debug);
}
static inline void au_debug_off(void)
{
atomic_dec_if_positive(&aufs_debug);
}
static inline int au_debug_test(void)
{
return atomic_read(&aufs_debug) > 0;
}
#else
#define AuDebugOn(a) do {} while (0)
AuStubVoid(au_debug_on, void)
AuStubVoid(au_debug_off, void)
AuStubInt0(au_debug_test, void)
#endif /* CONFIG_AUFS_DEBUG */
#define param_check_atomic_t(name, p) __param_check(name, p, atomic_t)
#endif /* __KERNEL__ */
#endif /* __AUFS_DEBUG_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment