Commit 786c90cb authored by J. R. Okajima's avatar J. R. Okajima
Browse files

aufs: debug print



Print various info about aufs inode. This feature is enabled when
CONFIG_AUFS_DEBUG and the module parameter 'debug' are set.
Signed-off-by: default avatarJ. R. Okajima <hooanon05g@gmail.com>
parent 6011ea2b
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
-include ${srctree}/${src}/priv_def.mk -include ${srctree}/${src}/priv_def.mk
# cf. include/linux/kernel.h
# enable pr_debug
ccflags-y += -DDEBUG
# sparse requires the full pathname # sparse requires the full pathname
ccflags-y += -include ${srctree}/include/uapi/linux/aufs_type.h ccflags-y += -include ${srctree}/include/uapi/linux/aufs_type.h
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "debug.h" #include "debug.h"
#include "fstype.h"
#include "inode.h" #include "inode.h"
#include "module.h" #include "module.h"
#include "rwsem.h" #include "rwsem.h"
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* debug print functions * debug print functions
*/ */
#include <linux/iversion.h>
#include "aufs.h" #include "aufs.h"
/* Returns 0, or -errno. arg is in kp->arg. */ /* Returns 0, or -errno. arg is in kp->arg. */
...@@ -42,3 +43,57 @@ static struct kernel_param_ops param_ops_atomic_t = { ...@@ -42,3 +43,57 @@ static struct kernel_param_ops param_ops_atomic_t = {
atomic_t aufs_debug = ATOMIC_INIT(0); atomic_t aufs_debug = ATOMIC_INIT(0);
MODULE_PARM_DESC(debug, "debug print"); MODULE_PARM_DESC(debug, "debug print");
module_param_named(debug, aufs_debug, atomic_t, 0664); module_param_named(debug, aufs_debug, atomic_t, 0664);
DEFINE_MUTEX(au_dbg_mtx); /* just to serialize the dbg msgs */
char *au_plevel = KERN_DEBUG;
#define dpri(fmt, ...) do { \
if ((au_plevel \
&& strcmp(au_plevel, KERN_DEBUG)) \
|| au_debug_test()) \
printk("%s" fmt, au_plevel, ##__VA_ARGS__); \
} while (0)
/* ---------------------------------------------------------------------- */
static int do_pri_inode(aufs_bindex_t bindex, struct inode *inode)
{
if (!inode || IS_ERR(inode)) {
dpri("i%d: err %ld\n", bindex, PTR_ERR(inode));
return -1;
}
/* the type of i_blocks depends upon CONFIG_LBDAF */
BUILD_BUG_ON(sizeof(inode->i_blocks) != sizeof(unsigned long)
&& sizeof(inode->i_blocks) != sizeof(u64));
dpri("i%d: %p, i%lu, %s, cnt %d, nl %u, 0%o, sz %llu, blk %llu,"
" ct %lld, np %lu, st 0x%lx, f 0x%x, v %llu, g %x\n",
bindex, inode,
inode->i_ino, inode->i_sb ? au_sbtype(inode->i_sb) : "??",
atomic_read(&inode->i_count), inode->i_nlink, inode->i_mode,
i_size_read(inode), (unsigned long long)inode->i_blocks,
(long long)timespec64_to_ns(&inode->i_ctime) & 0x0ffff,
inode->i_mapping ? inode->i_mapping->nrpages : 0,
inode->i_state, inode->i_flags, inode_peek_iversion(inode),
inode->i_generation);
return 0;
}
void au_dpri_inode(struct inode *inode)
{
struct au_iinfo *iinfo;
aufs_bindex_t bindex;
int err;
err = do_pri_inode(-1, inode);
if (err || !au_test_aufs(inode->i_sb) || au_is_bad_inode(inode))
return;
iinfo = au_ii(inode);
dpri("i-1: btop %d, bbot %d\n",
iinfo->ii_btop, iinfo->ii_bbot);
if (iinfo->ii_btop < 0)
return;
for (bindex = iinfo->ii_btop; bindex <= iinfo->ii_bbot; bindex++)
do_pri_inode(bindex, iinfo->ii_hinode[0 + bindex].hi_inode);
}
...@@ -42,5 +42,34 @@ AuStubInt0(au_debug_test, void) ...@@ -42,5 +42,34 @@ AuStubInt0(au_debug_test, void)
#define param_check_atomic_t(name, p) __param_check(name, p, atomic_t) #define param_check_atomic_t(name, p) __param_check(name, p, atomic_t)
/* ---------------------------------------------------------------------- */
/* debug print */
#define AuDbg(fmt, ...) do { \
if (au_debug_test()) \
pr_debug("DEBUG: " fmt, ##__VA_ARGS__); \
} while (0)
#define AuLabel(l) AuDbg(#l "\n")
/* ---------------------------------------------------------------------- */
struct dentry;
#ifdef CONFIG_AUFS_DEBUG
extern struct mutex au_dbg_mtx;
extern char *au_plevel;
struct inode;
void au_dpri_inode(struct inode *inode);
#define AuDbgInode(i) do { \
mutex_lock(&au_dbg_mtx); \
AuDbg(#i "\n"); \
au_dpri_inode(i); \
mutex_unlock(&au_dbg_mtx); \
} while (0)
#else
#define AuDbgInode(i) do {} while (0)
#endif /* CONFIG_AUFS_DEBUG */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* __AUFS_DEBUG_H__ */ #endif /* __AUFS_DEBUG_H__ */
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2005-2019 Junjiro R. Okajima
*/
/*
* judging filesystem type
*/
#ifndef __AUFS_FSTYPE_H__
#define __AUFS_FSTYPE_H__
#ifdef __KERNEL__
#include <linux/fs.h>
#include <linux/magic.h>
static inline int au_test_aufs(struct super_block *sb)
{
return sb->s_magic == AUFS_SUPER_MAGIC;
}
static inline const char *au_sbtype(struct super_block *sb)
{
return sb->s_type->name;
}
#endif /* __KERNEL__ */
#endif /* __AUFS_FSTYPE_H__ */
...@@ -115,7 +115,9 @@ AuRWLockFuncs(new_child, NEW_CHILD); ...@@ -115,7 +115,9 @@ AuRWLockFuncs(new_child, NEW_CHILD);
static inline void au_icntnr_init(struct au_icntnr *c) static inline void au_icntnr_init(struct au_icntnr *c)
{ {
/* re-commit later */ #ifdef CONFIG_AUFS_DEBUG
c->vfs_inode.i_mode = 0;
#endif
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
......
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