Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
debug.h File Reference

Go to the source code of this file.

Data Structures

struct  ubifs_debug_info
 
struct  ubifs_global_debug_info
 

Macros

#define UBIFS_DFS_DIR_NAME   "ubi%d_%d"
 
#define UBIFS_DFS_DIR_LEN   (3 + 1 + 2*2 + 1)
 
#define ubifs_assert(expr)
 
#define ubifs_assert_cmt_locked(c)
 
#define ubifs_dbg_msg(type, fmt,...)
 
#define DBG_KEY_BUF_LEN   48
 
#define ubifs_dbg_msg_key(type, key, fmt,...)
 
#define dbg_gen(fmt,...)   ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__)
 
#define dbg_jnl(fmt,...)   ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__)
 
#define dbg_jnlk(key, fmt,...)   ubifs_dbg_msg_key("jnl", key, fmt, ##__VA_ARGS__)
 
#define dbg_tnc(fmt,...)   ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__)
 
#define dbg_tnck(key, fmt,...)   ubifs_dbg_msg_key("tnc", key, fmt, ##__VA_ARGS__)
 
#define dbg_lp(fmt,...)   ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__)
 
#define dbg_find(fmt,...)   ubifs_dbg_msg("find", fmt, ##__VA_ARGS__)
 
#define dbg_mnt(fmt,...)   ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__)
 
#define dbg_mntk(key, fmt,...)   ubifs_dbg_msg_key("mnt", key, fmt, ##__VA_ARGS__)
 
#define dbg_io(fmt,...)   ubifs_dbg_msg("io", fmt, ##__VA_ARGS__)
 
#define dbg_cmt(fmt,...)   ubifs_dbg_msg("cmt", fmt, ##__VA_ARGS__)
 
#define dbg_budg(fmt,...)   ubifs_dbg_msg("budg", fmt, ##__VA_ARGS__)
 
#define dbg_log(fmt,...)   ubifs_dbg_msg("log", fmt, ##__VA_ARGS__)
 
#define dbg_gc(fmt,...)   ubifs_dbg_msg("gc", fmt, ##__VA_ARGS__)
 
#define dbg_scan(fmt,...)   ubifs_dbg_msg("scan", fmt, ##__VA_ARGS__)
 
#define dbg_rcvry(fmt,...)   ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__)
 

Typedefs

typedef int(* dbg_leaf_callback )(struct ubifs_info *c, struct ubifs_zbranch *zbr, void *priv)
 
typedef int(* dbg_znode_callback )(struct ubifs_info *c, struct ubifs_znode *znode, void *priv)
 

Functions

int ubifs_debugging_init (struct ubifs_info *c)
 
void ubifs_debugging_exit (struct ubifs_info *c)
 
const chardbg_ntype (int type)
 
const chardbg_cstate (int cmt_state)
 
const chardbg_jhead (int jhead)
 
const chardbg_get_key_dump (const struct ubifs_info *c, const union ubifs_key *key)
 
const chardbg_snprintf_key (const struct ubifs_info *c, const union ubifs_key *key, char *buffer, int len)
 
void ubifs_dump_inode (struct ubifs_info *c, const struct inode *inode)
 
void ubifs_dump_node (const struct ubifs_info *c, const void *node)
 
void ubifs_dump_budget_req (const struct ubifs_budget_req *req)
 
void ubifs_dump_lstats (const struct ubifs_lp_stats *lst)
 
void ubifs_dump_budg (struct ubifs_info *c, const struct ubifs_budg_info *bi)
 
void ubifs_dump_lprop (const struct ubifs_info *c, const struct ubifs_lprops *lp)
 
void ubifs_dump_lprops (struct ubifs_info *c)
 
void ubifs_dump_lpt_info (struct ubifs_info *c)
 
void ubifs_dump_leb (const struct ubifs_info *c, int lnum)
 
void ubifs_dump_sleb (const struct ubifs_info *c, const struct ubifs_scan_leb *sleb, int offs)
 
void ubifs_dump_znode (const struct ubifs_info *c, const struct ubifs_znode *znode)
 
void ubifs_dump_heap (struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
 
void ubifs_dump_pnode (struct ubifs_info *c, struct ubifs_pnode *pnode, struct ubifs_nnode *parent, int iip)
 
void ubifs_dump_tnc (struct ubifs_info *c)
 
void ubifs_dump_index (struct ubifs_info *c)
 
void ubifs_dump_lpt_lebs (const struct ubifs_info *c)
 
int dbg_walk_index (struct ubifs_info *c, dbg_leaf_callback leaf_cb, dbg_znode_callback znode_cb, void *priv)
 
void dbg_save_space_info (struct ubifs_info *c)
 
int dbg_check_space_info (struct ubifs_info *c)
 
int dbg_check_lprops (struct ubifs_info *c)
 
int dbg_old_index_check_init (struct ubifs_info *c, struct ubifs_zbranch *zroot)
 
int dbg_check_old_index (struct ubifs_info *c, struct ubifs_zbranch *zroot)
 
int dbg_check_cats (struct ubifs_info *c)
 
int dbg_check_ltab (struct ubifs_info *c)
 
int dbg_chk_lpt_free_spc (struct ubifs_info *c)
 
int dbg_chk_lpt_sz (struct ubifs_info *c, int action, int len)
 
int dbg_check_synced_i_size (const struct ubifs_info *c, struct inode *inode)
 
int dbg_check_dir (struct ubifs_info *c, const struct inode *dir)
 
int dbg_check_tnc (struct ubifs_info *c, int extra)
 
int dbg_check_idx_size (struct ubifs_info *c, long long idx_size)
 
int dbg_check_filesystem (struct ubifs_info *c)
 
void dbg_check_heap (struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat, int add_pos)
 
int dbg_check_lpt_nodes (struct ubifs_info *c, struct ubifs_cnode *cnode, int row, int col)
 
int dbg_check_inode_size (struct ubifs_info *c, const struct inode *inode, loff_t size)
 
int dbg_check_data_nodes_order (struct ubifs_info *c, struct list_head *head)
 
int dbg_check_nondata_nodes_order (struct ubifs_info *c, struct list_head *head)
 
int dbg_leb_write (struct ubifs_info *c, int lnum, const void *buf, int offs, int len)
 
int dbg_leb_change (struct ubifs_info *c, int lnum, const void *buf, int len)
 
int dbg_leb_unmap (struct ubifs_info *c, int lnum)
 
int dbg_leb_map (struct ubifs_info *c, int lnum)
 
int dbg_debugfs_init (void)
 
void dbg_debugfs_exit (void)
 
int dbg_debugfs_init_fs (struct ubifs_info *c)
 
void dbg_debugfs_exit_fs (struct ubifs_info *c)
 

Variables

struct ubifs_global_debug_info ubifs_dbg
 

Macro Definition Documentation

#define dbg_budg (   fmt,
  ... 
)    ubifs_dbg_msg("budg", fmt, ##__VA_ARGS__)

Definition at line 202 of file debug.h.

#define dbg_cmt (   fmt,
  ... 
)    ubifs_dbg_msg("cmt", fmt, ##__VA_ARGS__)

Definition at line 200 of file debug.h.

#define dbg_find (   fmt,
  ... 
)    ubifs_dbg_msg("find", fmt, ##__VA_ARGS__)

Definition at line 192 of file debug.h.

#define dbg_gc (   fmt,
  ... 
)    ubifs_dbg_msg("gc", fmt, ##__VA_ARGS__)

Definition at line 206 of file debug.h.

#define dbg_gen (   fmt,
  ... 
)    ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__)

Definition at line 180 of file debug.h.

#define dbg_io (   fmt,
  ... 
)    ubifs_dbg_msg("io", fmt, ##__VA_ARGS__)

Definition at line 198 of file debug.h.

#define dbg_jnl (   fmt,
  ... 
)    ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__)

Definition at line 182 of file debug.h.

#define dbg_jnlk (   key,
  fmt,
  ... 
)    ubifs_dbg_msg_key("jnl", key, fmt, ##__VA_ARGS__)

Definition at line 183 of file debug.h.

#define DBG_KEY_BUF_LEN   48

Definition at line 171 of file debug.h.

#define dbg_log (   fmt,
  ... 
)    ubifs_dbg_msg("log", fmt, ##__VA_ARGS__)

Definition at line 204 of file debug.h.

#define dbg_lp (   fmt,
  ... 
)    ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__)

Definition at line 190 of file debug.h.

#define dbg_mnt (   fmt,
  ... 
)    ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__)

Definition at line 194 of file debug.h.

#define dbg_mntk (   key,
  fmt,
  ... 
)    ubifs_dbg_msg_key("mnt", key, fmt, ##__VA_ARGS__)

Definition at line 195 of file debug.h.

#define dbg_rcvry (   fmt,
  ... 
)    ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__)

Definition at line 210 of file debug.h.

#define dbg_scan (   fmt,
  ... 
)    ubifs_dbg_msg("scan", fmt, ##__VA_ARGS__)

Definition at line 208 of file debug.h.

#define dbg_tnc (   fmt,
  ... 
)    ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__)

Definition at line 186 of file debug.h.

#define dbg_tnck (   key,
  fmt,
  ... 
)    ubifs_dbg_msg_key("tnc", key, fmt, ##__VA_ARGS__)

Definition at line 187 of file debug.h.

#define ubifs_assert (   expr)
Value:
do { \
if (unlikely(!(expr))) { \
pr_crit("UBIFS assert failed in %s at %u (pid %d)\n", \
__func__, __LINE__, current->pid); \
dump_stack(); \
} \
} while (0)

Definition at line 151 of file debug.h.

#define ubifs_assert_cmt_locked (   c)
Value:
do { \
if (unlikely(down_write_trylock(&(c)->commit_sem))) { \
up_write(&(c)->commit_sem); \
pr_crit("commit lock is not locked!\n"); \
ubifs_assert(0); \
} \
} while (0)

Definition at line 159 of file debug.h.

#define ubifs_dbg_msg (   type,
  fmt,
  ... 
)
Value:
pr_debug("UBIFS DBG " type " (pid %d): " fmt "\n", current->pid, \
##__VA_ARGS__)

Definition at line 167 of file debug.h.

#define ubifs_dbg_msg_key (   type,
  key,
  fmt,
  ... 
)
Value:
do { \
char __tmp_key_buf[DBG_KEY_BUF_LEN]; \
pr_debug("UBIFS DBG " type " (pid %d): " fmt "%s\n", current->pid, \
##__VA_ARGS__, \
dbg_snprintf_key(c, key, __tmp_key_buf, DBG_KEY_BUF_LEN)); \
} while (0)

Definition at line 172 of file debug.h.

#define UBIFS_DFS_DIR_LEN   (3 + 1 + 2*2 + 1)

Definition at line 37 of file debug.h.

#define UBIFS_DFS_DIR_NAME   "ubi%d_%d"

Definition at line 36 of file debug.h.

Typedef Documentation

typedef int(* dbg_leaf_callback)(struct ubifs_info *c, struct ubifs_zbranch *zbr, void *priv)

Definition at line 27 of file debug.h.

typedef int(* dbg_znode_callback)(struct ubifs_info *c, struct ubifs_znode *znode, void *priv)

Definition at line 29 of file debug.h.

Function Documentation

int dbg_check_cats ( struct ubifs_info c)

dbg_check_cats - check category heaps and lists. : UBIFS file-system description object

This function returns %0 on success and a negative error code on failure.

Definition at line 865 of file lprops.c.

int dbg_check_data_nodes_order ( struct ubifs_info c,
struct list_head head 
)

dbg_check_data_nodes_order - check that list of data nodes is sorted. : UBIFS file-system description object : the list of nodes ('struct ubifs_scan_node' objects)

This function returns zero if the list of data nodes is sorted correctly, and %-EINVAL if not.

Definition at line 2311 of file debug.c.

int dbg_check_dir ( struct ubifs_info c,
const struct inode dir 
)

Definition at line 1103 of file debug.c.

int dbg_check_filesystem ( struct ubifs_info c)

dbg_check_filesystem - check the file-system. : UBIFS file-system description object

This function checks the file system, namely: o makes sure that all leaf nodes exist and their CRCs are correct; o makes sure inode nlink, size, xattr size/count are correct (for all inodes).

The function reads whole indexing tree and all nodes, so it is pretty heavy-weight. Returns zero if the file-system is consistent, %-EINVAL if not, and a negative error code in case of failure.

Definition at line 2276 of file debug.c.

void dbg_check_heap ( struct ubifs_info c,
struct ubifs_lpt_heap heap,
int  cat,
int  add_pos 
)

Definition at line 964 of file lprops.c.

int dbg_check_idx_size ( struct ubifs_info c,
long long  idx_size 
)

dbg_check_idx_size - check index size. : UBIFS file-system description object : size to check

This function walks the UBIFS index, calculates its size and checks that the size is equivalent to . Returns zero in case of success and a negative error code in case of failure.

Definition at line 1713 of file debug.c.

int dbg_check_inode_size ( struct ubifs_info c,
const struct inode inode,
loff_t  size 
)

dbg_check_inode_size - check if inode size is correct. : UBIFS file-system description object : inode number : inode size

This function makes sure that the inode size () is correct and it does not have any pages beyond . Returns zero if the inode is OK, %-EINVAL if it has a data page beyond , and other negative error code in case of other errors.

Definition at line 3289 of file tnc.c.

int dbg_check_lprops ( struct ubifs_info c)

dbg_check_lprops - check all LEB properties. : UBIFS file-system description object

This function checks all LEB properties and makes sure they are all correct. It returns zero if everything is fine, %-EINVAL if there is an inconsistency and other negative error codes in case of other errors. This function is called while the file system is locked (because of commit start), so no additional locking is required. Note that locking the LPT mutex would cause a circular lock dependency with the TNC mutex.

Definition at line 1266 of file lprops.c.

int dbg_check_lpt_nodes ( struct ubifs_info c,
struct ubifs_cnode cnode,
int  row,
int  col 
)

dbg_check_lpt_nodes - check nnodes and pnodes. : the UBIFS file-system description object : next cnode (nnode or pnode) to check : row of cnode (root is zero) : column of cnode (leftmost is zero)

This function returns %0 on success and a negative error code on failure.

Definition at line 2223 of file lpt.c.

int dbg_check_ltab ( struct ubifs_info c)

dbg_check_ltab - check the free and dirty space in the ltab. : the UBIFS file-system description object

This function returns %0 on success and a negative error code on failure.

Definition at line 1703 of file lpt_commit.c.

int dbg_check_nondata_nodes_order ( struct ubifs_info c,
struct list_head head 
)

dbg_check_nondata_nodes_order - check that list of data nodes is sorted. : UBIFS file-system description object : the list of nodes ('struct ubifs_scan_node' objects)

This function returns zero if the list of non-data nodes is sorted correctly, and %-EINVAL if not.

Definition at line 2378 of file debug.c.

int dbg_check_old_index ( struct ubifs_info c,
struct ubifs_zbranch zroot 
)

dbg_check_old_index - check the old copy of the index. : UBIFS file-system description object : root of the new index

In order to be able to recover from an unclean unmount, a complete copy of the index must exist on flash. This is the "old" index. The commit process must write the "new" index to flash without overwriting or destroying any part of the old index. This function is run at commit end in order to check that the old index does indeed exist completely intact.

This function returns %0 on success and a negative error code on failure.

Definition at line 569 of file commit.c.

int dbg_check_space_info ( struct ubifs_info c)

dbg_check_space_info - check flash space information. : UBIFS file-system description object

This function compares current flash space information with the information which was saved when the 'dbg_save_space_info()' function was called. Returns zero if the information has not changed, and %-EINVAL it it has changed.

Definition at line 1018 of file debug.c.

int dbg_check_synced_i_size ( const struct ubifs_info c,
struct inode inode 
)

dbg_check_synced_i_size - check synchronized inode size. : UBIFS file-system description object : inode to check

If inode is clean, synchronized inode size has to be equivalent to current inode size. This function has to be called only for locked inodes ( has to be locked). Returns %0 if synchronized inode size if correct, and %-EINVAL if not.

Definition at line 1065 of file debug.c.

int dbg_check_tnc ( struct ubifs_info c,
int  extra 
)

dbg_check_tnc - check TNC tree. : UBIFS file-system description object : do extra checks that are possible at start commit

This function traverses whole TNC tree and checks every znode. Returns zero if everything is all right and %-EINVAL if something is wrong with TNC.

Definition at line 1467 of file debug.c.

int dbg_chk_lpt_free_spc ( struct ubifs_info c)

dbg_chk_lpt_free_spc - check LPT free space is enough to write entire LPT. : the UBIFS file-system description object

This function returns %0 on success and a negative error code on failure.

Definition at line 1745 of file lpt_commit.c.

int dbg_chk_lpt_sz ( struct ubifs_info c,
int  action,
int  len 
)

dbg_chk_lpt_sz - check LPT does not write more than LPT size. : the UBIFS file-system description object : what to do : length written

This function returns %0 on success and a negative error code on failure. The argument may be one of: o %0 - LPT debugging checking starts, initialize debugging variables; o %1 - wrote an LPT node, increase LPT size by bytes; o %2 - switched to a different LEB and wasted bytes; o %3 - check that we've written the right number of bytes. o %4 - wasted bytes;

Definition at line 1786 of file lpt_commit.c.

const char* dbg_cstate ( int  cmt_state)

Definition at line 186 of file debug.c.

void dbg_debugfs_exit ( void  )

dbg_debugfs_exit - remove the "ubifs" directory from debugfs file-system.

Definition at line 3085 of file debug.c.

void dbg_debugfs_exit_fs ( struct ubifs_info c)

dbg_debugfs_exit_fs - remove all debugfs files. : UBIFS file-system description object

Definition at line 2932 of file debug.c.

int dbg_debugfs_init ( void  )

dbg_debugfs_init - initialize debugfs file-system.

UBIFS uses debugfs file-system to expose various debugging knobs to user-space. This function creates "ubifs" directory in the debugfs file-system. Returns zero in case of success and a negative error code in case of failure.

Definition at line 3014 of file debug.c.

int dbg_debugfs_init_fs ( struct ubifs_info c)

dbg_debugfs_init_fs - initialize debugfs for UBIFS instance. : UBIFS file-system description object

This function creates all debugfs files for this instance of UBIFS. Returns zero in case of success and a negative error code in case of failure.

Note, the only reason we have not merged this function with the 'ubifs_debugging_init()' function is because it is better to initialize debugfs interfaces at the very end of the mount process, and remove them at the very beginning of the mount process.

Definition at line 2825 of file debug.c.

const char* dbg_get_key_dump ( const struct ubifs_info c,
const union ubifs_key key 
)
const char* dbg_jhead ( int  jhead)

Definition at line 206 of file debug.c.

int dbg_leb_change ( struct ubifs_info c,
int  lnum,
const void buf,
int  len 
)

Definition at line 2604 of file debug.c.

int dbg_leb_map ( struct ubifs_info c,
int  lnum 
)

Definition at line 2637 of file debug.c.

int dbg_leb_unmap ( struct ubifs_info c,
int  lnum 
)

Definition at line 2621 of file debug.c.

int dbg_leb_write ( struct ubifs_info c,
int  lnum,
const void buf,
int  offs,
int  len 
)

Definition at line 2583 of file debug.c.

const char* dbg_ntype ( int  type)

Definition at line 140 of file debug.c.

int dbg_old_index_check_init ( struct ubifs_info c,
struct ubifs_zbranch zroot 
)

dbg_old_index_check_init - get information for the next old index check. : UBIFS file-system description object : root of the index

This function records information about the index that will be needed for the next old index check i.e. 'dbg_check_old_index()'.

This function returns %0 on success and a negative error code on failure.

Definition at line 530 of file commit.c.

void dbg_save_space_info ( struct ubifs_info c)

dbg_save_space_info - save information about flash space. : UBIFS file-system description object

This function saves information about UBIFS free space, dirty space, etc, in order to check it later.

Definition at line 968 of file debug.c.

const char* dbg_snprintf_key ( const struct ubifs_info c,
const union ubifs_key key,
char buffer,
int  len 
)

Definition at line 101 of file debug.c.

int dbg_walk_index ( struct ubifs_info c,
dbg_leaf_callback  leaf_cb,
dbg_znode_callback  znode_cb,
void priv 
)

dbg_walk_index - walk the on-flash index. : UBIFS file-system description object : called for each leaf node : called for each indexing node : private data which is passed to callbacks

This function walks the UBIFS index and calls the for each leaf node and for each indexing node. Returns zero in case of success and a negative error code in case of failure.

It would be better if this function removed every znode it pulled to into the TNC, so that the behavior more closely matched the non-debugging behavior.

Definition at line 1561 of file debug.c.

void ubifs_debugging_exit ( struct ubifs_info c)

ubifs_debugging_exit - free debugging data. : UBIFS file-system description object

Definition at line 3112 of file debug.c.

int ubifs_debugging_init ( struct ubifs_info c)

ubifs_debugging_init - initialize UBIFS debugging. : UBIFS file-system description object

This function initializes debugging-related data for the file system. Returns zero in case of success and a negative error code in case of failure.

Definition at line 3099 of file debug.c.

void ubifs_dump_budg ( struct ubifs_info c,
const struct ubifs_budg_info bi 
)

Definition at line 577 of file debug.c.

void ubifs_dump_budget_req ( const struct ubifs_budget_req req)

Definition at line 548 of file debug.c.

void ubifs_dump_heap ( struct ubifs_info c,
struct ubifs_lpt_heap heap,
int  cat 
)

Definition at line 887 of file debug.c.

void ubifs_dump_index ( struct ubifs_info c)

ubifs_dump_index - dump the on-flash index. : UBIFS file-system description object

This function dumps whole UBIFS indexing B-tree, unlike 'ubifs_dump_tnc()' which dumps only in-memory znodes and does not read znodes which from flash.

Definition at line 956 of file debug.c.

void ubifs_dump_inode ( struct ubifs_info c,
const struct inode inode 
)

Definition at line 233 of file debug.c.

void ubifs_dump_leb ( const struct ubifs_info c,
int  lnum 
)

Definition at line 810 of file debug.c.

void ubifs_dump_lprop ( const struct ubifs_info c,
const struct ubifs_lprops lp 
)

Definition at line 645 of file debug.c.

void ubifs_dump_lprops ( struct ubifs_info c)

Definition at line 736 of file debug.c.

void ubifs_dump_lpt_info ( struct ubifs_info c)

Definition at line 756 of file debug.c.

void ubifs_dump_lpt_lebs ( const struct ubifs_info c)

ubifs_dump_lpt_lebs - dump LPT lebs. : UBIFS file-system description object

This function dumps all LPT LEBs. The caller has to make sure the LPT is locked.

Definition at line 1983 of file lpt_commit.c.

void ubifs_dump_lstats ( const struct ubifs_lp_stats lst)

Definition at line 565 of file debug.c.

void ubifs_dump_node ( const struct ubifs_info c,
const void node 
)

Definition at line 301 of file debug.c.

void ubifs_dump_pnode ( struct ubifs_info c,
struct ubifs_pnode pnode,
struct ubifs_nnode parent,
int  iip 
)

Definition at line 903 of file debug.c.

void ubifs_dump_sleb ( const struct ubifs_info c,
const struct ubifs_scan_leb sleb,
int  offs 
)

Definition at line 794 of file debug.c.

void ubifs_dump_tnc ( struct ubifs_info c)

Definition at line 921 of file debug.c.

void ubifs_dump_znode ( const struct ubifs_info c,
const struct ubifs_znode znode 
)

Definition at line 848 of file debug.c.

Variable Documentation

Definition at line 2938 of file debug.c.