Skip to content

Commit

Permalink
UBIFS: remove Kconfig debugging option
Browse files Browse the repository at this point in the history
Have the debugging stuff always compiled-in instead. It simplifies maintanance
a lot.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
  • Loading branch information
dedekind committed May 16, 2012
1 parent 1baafd2 commit f70b7e5
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 238 deletions.
17 changes: 0 additions & 17 deletions fs/ubifs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,3 @@ config UBIFS_FS_ZLIB
default y
help
Zlib compresses better than LZO but it is slower. Say 'Y' if unsure.

# Debugging-related stuff
config UBIFS_FS_DEBUG
bool "Enable debugging support"
depends on UBIFS_FS
select DEBUG_FS
select KALLSYMS
help
This option enables UBIFS debugging support. It makes sure various
assertions, self-checks, debugging messages and test modes are compiled
in (this all is compiled out otherwise). Assertions are light-weight
and this option also enables them. Self-checks, debugging messages and
test modes are switched off by default. Thus, it is safe and actually
recommended to have debugging support enabled, and it should not slow
down UBIFS. You can then further enable / disable individual debugging
features using UBIFS module parameters and the corresponding sysfs
interfaces.
4 changes: 1 addition & 3 deletions fs/ubifs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ obj-$(CONFIG_UBIFS_FS) += ubifs.o
ubifs-y += shrinker.o journal.o file.o dir.o super.o sb.o io.o
ubifs-y += tnc.o master.o scan.o replay.o log.o commit.o gc.o orphan.o
ubifs-y += budget.o find.o tnc_commit.o compress.o lpt.o lprops.o
ubifs-y += recovery.o ioctl.o lpt_commit.o tnc_misc.o xattr.o

ubifs-$(CONFIG_UBIFS_FS_DEBUG) += debug.o
ubifs-y += recovery.o ioctl.o lpt_commit.o tnc_misc.o xattr.o debug.o
6 changes: 3 additions & 3 deletions fs/ubifs/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,9 @@ int ubifs_gc_should_commit(struct ubifs_info *c)
return ret;
}

#ifdef CONFIG_UBIFS_FS_DEBUG
/*
* Everything below is related to debugging.
*/

/**
* struct idx_node - hold index nodes during index tree traversal.
Expand Down Expand Up @@ -734,5 +736,3 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
err = -EINVAL;
return err;
}

#endif /* CONFIG_UBIFS_FS_DEBUG */
4 changes: 0 additions & 4 deletions fs/ubifs/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
#include <linux/random.h>
#include "ubifs.h"

#ifdef CONFIG_UBIFS_FS_DEBUG

static DEFINE_SPINLOCK(dbg_lock);

static const char *get_key_fmt(int fmt)
Expand Down Expand Up @@ -3189,5 +3187,3 @@ void ubifs_debugging_exit(struct ubifs_info *c)
{
kfree(c->dbg);
}

#endif /* CONFIG_UBIFS_FS_DEBUG */
153 changes: 0 additions & 153 deletions fs/ubifs/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ typedef int (*dbg_leaf_callback)(struct ubifs_info *c,
typedef int (*dbg_znode_callback)(struct ubifs_info *c,
struct ubifs_znode *znode, void *priv);

#ifdef CONFIG_UBIFS_FS_DEBUG

/*
* The UBIFS debugfs directory name pattern and maximum name length (3 for "ubi"
* + 1 for "_" and plus 2x2 for 2 UBI numbers and 1 for the trailing zero byte.
Expand Down Expand Up @@ -317,155 +315,4 @@ void dbg_debugfs_exit(void);
int dbg_debugfs_init_fs(struct ubifs_info *c);
void dbg_debugfs_exit_fs(struct ubifs_info *c);

#else /* !CONFIG_UBIFS_FS_DEBUG */

/* Use "if (0)" to make compiler check arguments even if debugging is off */
#define ubifs_assert(expr) do { \
if (0) \
printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)\n", \
__func__, __LINE__, current->pid); \
} while (0)

#define dbg_err(fmt, ...) do { \
if (0) \
ubifs_err(fmt, ##__VA_ARGS__); \
} while (0)

#define ubifs_dbg_msg(fmt, ...) do { \
if (0) \
printk(KERN_DEBUG fmt "\n", ##__VA_ARGS__); \
} while (0)

#define ubifs_assert_cmt_locked(c)

#define dbg_msg(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_gen(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_jnl(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_jnlk(key, fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_tnc(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_tnck(key, fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_lp(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_find(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_mnt(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_mntk(key, fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_io(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_cmt(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_budg(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_log(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_gc(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_scan(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_rcvry(fmt, ...) ubifs_dbg_msg(fmt, ##__VA_ARGS__)

static inline int ubifs_debugging_init(struct ubifs_info *c) { return 0; }
static inline void ubifs_debugging_exit(struct ubifs_info *c) { return; }
static inline const char *dbg_ntype(int type) { return ""; }
static inline const char *dbg_cstate(int cmt_state) { return ""; }
static inline const char *dbg_jhead(int jhead) { return ""; }
static inline const char *
dbg_get_key_dump(const struct ubifs_info *c,
const union ubifs_key *key) { return ""; }
static inline const char *
dbg_snprintf_key(const struct ubifs_info *c,
const union ubifs_key *key, char *buffer,
int len) { return ""; }
static inline void ubifs_dump_inode(struct ubifs_info *c,
const struct inode *inode) { return; }
static inline void ubifs_dump_node(const struct ubifs_info *c,
const void *node) { return; }
static inline void
ubifs_dump_budget_req(const struct ubifs_budget_req *req) { return; }
static inline void
ubifs_dump_lstats(const struct ubifs_lp_stats *lst) { return; }
static inline void
ubifs_dump_budg(struct ubifs_info *c,
const struct ubifs_budg_info *bi) { return; }
static inline void ubifs_dump_lprop(const struct ubifs_info *c,
const struct ubifs_lprops *lp){ return; }
static inline void ubifs_dump_lprops(struct ubifs_info *c) { return; }
static inline void ubifs_dump_lpt_info(struct ubifs_info *c) { return; }
static inline void ubifs_dump_leb(const struct ubifs_info *c,
int lnum) { return; }
static inline void
ubifs_dump_sleb(const struct ubifs_info *c,
const struct ubifs_scan_leb *sleb, int offs) { return; }
static inline void
ubifs_dump_znode(const struct ubifs_info *c,
const struct ubifs_znode *znode) { return; }
static inline void ubifs_dump_heap(struct ubifs_info *c,
struct ubifs_lpt_heap *heap,
int cat) { return; }
static inline void ubifs_dump_pnode(struct ubifs_info *c,
struct ubifs_pnode *pnode,
struct ubifs_nnode *parent,
int iip) { return; }
static inline void ubifs_dump_tnc(struct ubifs_info *c) { return; }
static inline void ubifs_dump_index(struct ubifs_info *c) { return; }
static inline void ubifs_dump_lpt_lebs(const struct ubifs_info *c){ return; }

static inline int dbg_walk_index(struct ubifs_info *c,
dbg_leaf_callback leaf_cb,
dbg_znode_callback znode_cb,
void *priv) { return 0; }
static inline void dbg_save_space_info(struct ubifs_info *c) { return; }
static inline int dbg_check_space_info(struct ubifs_info *c) { return 0; }
static inline int dbg_check_lprops(struct ubifs_info *c) { return 0; }
static inline int
dbg_old_index_check_init(struct ubifs_info *c,
struct ubifs_zbranch *zroot) { return 0; }
static inline int
dbg_check_old_index(struct ubifs_info *c,
struct ubifs_zbranch *zroot) { return 0; }
static inline int dbg_check_cats(struct ubifs_info *c) { return 0; }
static inline int dbg_check_ltab(struct ubifs_info *c) { return 0; }
static inline int dbg_chk_lpt_free_spc(struct ubifs_info *c) { return 0; }
static inline int dbg_chk_lpt_sz(struct ubifs_info *c,
int action, int len) { return 0; }
static inline int
dbg_check_synced_i_size(const struct ubifs_info *c,
struct inode *inode) { return 0; }
static inline int dbg_check_dir(struct ubifs_info *c,
const struct inode *dir) { return 0; }
static inline int dbg_check_tnc(struct ubifs_info *c, int extra) { return 0; }
static inline int dbg_check_idx_size(struct ubifs_info *c,
long long idx_size) { return 0; }
static inline int dbg_check_filesystem(struct ubifs_info *c) { return 0; }
static inline void dbg_check_heap(struct ubifs_info *c,
struct ubifs_lpt_heap *heap,
int cat, int add_pos) { return; }
static inline int dbg_check_lpt_nodes(struct ubifs_info *c,
struct ubifs_cnode *cnode, int row, int col) { return 0; }
static inline int dbg_check_inode_size(struct ubifs_info *c,
const struct inode *inode,
loff_t size) { return 0; }
static inline int
dbg_check_data_nodes_order(struct ubifs_info *c,
struct list_head *head) { return 0; }
static inline int
dbg_check_nondata_nodes_order(struct ubifs_info *c,
struct list_head *head) { return 0; }

static inline int dbg_leb_write(struct ubifs_info *c, int lnum,
const void *buf, int offset,
int len, int dtype) { return 0; }
static inline int dbg_leb_change(struct ubifs_info *c, int lnum,
const void *buf, int len,
int dtype) { return 0; }
static inline int dbg_leb_unmap(struct ubifs_info *c, int lnum) { return 0; }
static inline int dbg_leb_map(struct ubifs_info *c, int lnum,
int dtype) { return 0; }

static inline int dbg_is_chk_gen(const struct ubifs_info *c) { return 0; }
static inline int dbg_is_chk_index(const struct ubifs_info *c) { return 0; }
static inline int dbg_is_chk_orph(const struct ubifs_info *c) { return 0; }
static inline int dbg_is_chk_lprops(const struct ubifs_info *c) { return 0; }
static inline int dbg_is_chk_fs(const struct ubifs_info *c) { return 0; }
static inline int dbg_is_tst_rcvry(const struct ubifs_info *c) { return 0; }
static inline int dbg_is_power_cut(const struct ubifs_info *c) { return 0; }

static inline int dbg_debugfs_init(void) { return 0; }
static inline void dbg_debugfs_exit(void) { return; }
static inline int dbg_debugfs_init_fs(struct ubifs_info *c) { return 0; }
static inline int dbg_debugfs_exit_fs(struct ubifs_info *c) { return 0; }

#endif /* !CONFIG_UBIFS_FS_DEBUG */
#endif /* !__UBIFS_DEBUG_H__ */
8 changes: 0 additions & 8 deletions fs/ubifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
return inode;
}

#ifdef CONFIG_UBIFS_FS_DEBUG

static int dbg_check_name(const struct ubifs_info *c,
const struct ubifs_dent_node *dent,
const struct qstr *nm)
Expand All @@ -185,12 +183,6 @@ static int dbg_check_name(const struct ubifs_info *c,
return 0;
}

#else

#define dbg_check_name(c, dent, nm) 0

#endif

static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd)
{
Expand Down
8 changes: 0 additions & 8 deletions fs/ubifs/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@

#include "ubifs.h"

#ifdef CONFIG_UBIFS_FS_DEBUG
static int dbg_check_bud_bytes(struct ubifs_info *c);
#else
#define dbg_check_bud_bytes(c) 0
#endif

/**
* ubifs_search_bud - search bud LEB.
Expand Down Expand Up @@ -734,8 +730,6 @@ int ubifs_consolidate_log(struct ubifs_info *c)
return err;
}

#ifdef CONFIG_UBIFS_FS_DEBUG

/**
* dbg_check_bud_bytes - make sure bud bytes calculation are all right.
* @c: UBIFS file-system description object
Expand Down Expand Up @@ -767,5 +761,3 @@ static int dbg_check_bud_bytes(struct ubifs_info *c)

return err;
}

#endif /* CONFIG_UBIFS_FS_DEBUG */
6 changes: 3 additions & 3 deletions fs/ubifs/lprops.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,9 @@ const struct ubifs_lprops *ubifs_fast_find_frdi_idx(struct ubifs_info *c)
return lprops;
}

#ifdef CONFIG_UBIFS_FS_DEBUG
/*
* Everything below is related to debugging.
*/

/**
* dbg_check_cats - check category heaps and lists.
Expand Down Expand Up @@ -1315,5 +1317,3 @@ int dbg_check_lprops(struct ubifs_info *c)
out:
return err;
}

#endif /* CONFIG_UBIFS_FS_DEBUG */
4 changes: 0 additions & 4 deletions fs/ubifs/lpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2080,8 +2080,6 @@ int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum,
return err;
}

#ifdef CONFIG_UBIFS_FS_DEBUG

/**
* dbg_chk_pnode - check a pnode.
* @c: the UBIFS file-system description object
Expand Down Expand Up @@ -2274,5 +2272,3 @@ int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode,
}
return 0;
}

#endif /* CONFIG_UBIFS_FS_DEBUG */
10 changes: 3 additions & 7 deletions fs/ubifs/lpt_commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
#include <linux/random.h>
#include "ubifs.h"

#ifdef CONFIG_UBIFS_FS_DEBUG
static int dbg_populate_lsave(struct ubifs_info *c);
#else
#define dbg_populate_lsave(c) 0
#endif

/**
* first_dirty_cnode - find first dirty cnode.
Expand Down Expand Up @@ -1497,7 +1493,9 @@ void ubifs_lpt_free(struct ubifs_info *c, int wr_only)
kfree(c->lpt_nod_buf);
}

#ifdef CONFIG_UBIFS_FS_DEBUG
/*
* Everything below is related to debugging.
*/

/**
* dbg_is_all_ff - determine if a buffer contains only 0xFF bytes.
Expand Down Expand Up @@ -2046,5 +2044,3 @@ static int dbg_populate_lsave(struct ubifs_info *c)

return 1;
}

#endif /* CONFIG_UBIFS_FS_DEBUG */
10 changes: 3 additions & 7 deletions fs/ubifs/orphan.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@
* than the maximum number of orphans allowed.
*/

#ifdef CONFIG_UBIFS_FS_DEBUG
static int dbg_check_orphans(struct ubifs_info *c);
#else
#define dbg_check_orphans(c) 0
#endif

/**
* ubifs_add_orphan - add an orphan.
Expand Down Expand Up @@ -725,7 +721,9 @@ int ubifs_mount_orphans(struct ubifs_info *c, int unclean, int read_only)
return err;
}

#ifdef CONFIG_UBIFS_FS_DEBUG
/*
* Everything below is related to debugging.
*/

struct check_orphan {
struct rb_node rb;
Expand Down Expand Up @@ -968,5 +966,3 @@ static int dbg_check_orphans(struct ubifs_info *c)
kfree(ci.node);
return err;
}

#endif /* CONFIG_UBIFS_FS_DEBUG */
2 changes: 0 additions & 2 deletions fs/ubifs/sb.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,13 @@ static int create_default_filesystem(struct ubifs_info *c)
* orphan node.
*/
orph_lebs = UBIFS_MIN_ORPH_LEBS;
#ifdef CONFIG_UBIFS_FS_DEBUG
if (c->leb_cnt - min_leb_cnt > 1)
/*
* For debugging purposes it is better to have at least 2
* orphan LEBs, because the orphan subsystem would need to do
* consolidations and would be stressed more.
*/
orph_lebs += 1;
#endif

main_lebs = c->leb_cnt - UBIFS_SB_LEBS - UBIFS_MST_LEBS - log_lebs;
main_lebs -= orph_lebs;
Expand Down
4 changes: 0 additions & 4 deletions fs/ubifs/tnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3275,8 +3275,6 @@ int ubifs_dirty_idx_node(struct ubifs_info *c, union ubifs_key *key, int level,
return err;
}

#ifdef CONFIG_UBIFS_FS_DEBUG

/**
* dbg_check_inode_size - check if inode size is correct.
* @c: UBIFS file-system description object
Expand Down Expand Up @@ -3343,5 +3341,3 @@ int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode,
mutex_unlock(&c->tnc_mutex);
return err;
}

#endif /* CONFIG_UBIFS_FS_DEBUG */
Loading

0 comments on commit f70b7e5

Please sign in to comment.