2008-07-14 18:08:37 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file is part of UBIFS.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2006-2008 Nokia Corporation.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
|
* the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., 51
|
|
|
|
|
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*
|
|
|
|
|
* Authors: Artem Bityutskiy (Битюцкий Артём)
|
|
|
|
|
* Adrian Hunter
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __UBIFS_DEBUG_H__
|
|
|
|
|
#define __UBIFS_DEBUG_H__
|
|
|
|
|
|
2011-04-13 00:14:56 +02:00
|
|
|
|
/* Checking helper functions */
|
|
|
|
|
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);
|
|
|
|
|
|
2008-07-14 18:08:37 +02:00
|
|
|
|
#ifdef CONFIG_UBIFS_FS_DEBUG
|
|
|
|
|
|
2011-04-05 12:52:20 +02:00
|
|
|
|
#include <linux/random.h>
|
|
|
|
|
|
2011-05-19 13:13:16 +02:00
|
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
#define UBIFS_DFS_DIR_NAME "ubi%d_%d"
|
|
|
|
|
#define UBIFS_DFS_DIR_LEN (3 + 1 + 2*2 + 1)
|
|
|
|
|
|
2008-10-17 12:31:39 +02:00
|
|
|
|
/**
|
|
|
|
|
* ubifs_debug_info - per-FS debugging information.
|
|
|
|
|
* @old_zroot: old index root - used by 'dbg_check_old_index()'
|
|
|
|
|
* @old_zroot_level: old index root level - used by 'dbg_check_old_index()'
|
|
|
|
|
* @old_zroot_sqnum: old index root sqnum - used by 'dbg_check_old_index()'
|
|
|
|
|
* @failure_mode: failure mode for recovery testing
|
|
|
|
|
* @fail_delay: 0=>don't delay, 1=>delay a time, 2=>delay a number of calls
|
|
|
|
|
* @fail_timeout: time in jiffies when delay of failure mode expires
|
|
|
|
|
* @fail_cnt: current number of calls to failure mode I/O functions
|
|
|
|
|
* @fail_cnt_max: number of calls by which to delay failure mode
|
|
|
|
|
* @chk_lpt_sz: used by LPT tree size checker
|
|
|
|
|
* @chk_lpt_sz2: used by LPT tree size checker
|
|
|
|
|
* @chk_lpt_wastage: used by LPT tree size checker
|
|
|
|
|
* @chk_lpt_lebs: used by LPT tree size checker
|
|
|
|
|
* @new_nhead_offs: used by LPT tree size checker
|
2009-01-23 13:54:59 +01:00
|
|
|
|
* @new_ihead_lnum: used by debugging to check @c->ihead_lnum
|
|
|
|
|
* @new_ihead_offs: used by debugging to check @c->ihead_offs
|
2008-10-23 10:49:28 +02:00
|
|
|
|
*
|
2009-01-23 13:54:59 +01:00
|
|
|
|
* @saved_lst: saved lprops statistics (used by 'dbg_save_space_info()')
|
2011-03-29 17:36:21 +02:00
|
|
|
|
* @saved_bi: saved budgeting information
|
|
|
|
|
* @saved_free: saved amount of free space
|
|
|
|
|
* @saved_idx_gc_cnt: saved value of @c->idx_gc_cnt
|
2009-01-23 13:54:59 +01:00
|
|
|
|
*
|
2011-05-17 13:07:24 +02:00
|
|
|
|
* @dfs_dir_name: name of debugfs directory containing this file-system's files
|
|
|
|
|
* @dfs_dir: direntry object of the file-system debugfs directory
|
|
|
|
|
* @dfs_dump_lprops: "dump lprops" debugfs knob
|
|
|
|
|
* @dfs_dump_budg: "dump budgeting information" debugfs knob
|
|
|
|
|
* @dfs_dump_tnc: "dump TNC" debugfs knob
|
2008-10-17 12:31:39 +02:00
|
|
|
|
*/
|
|
|
|
|
struct ubifs_debug_info {
|
|
|
|
|
struct ubifs_zbranch old_zroot;
|
|
|
|
|
int old_zroot_level;
|
|
|
|
|
unsigned long long old_zroot_sqnum;
|
|
|
|
|
int failure_mode;
|
|
|
|
|
int fail_delay;
|
|
|
|
|
unsigned long fail_timeout;
|
|
|
|
|
unsigned int fail_cnt;
|
|
|
|
|
unsigned int fail_cnt_max;
|
|
|
|
|
long long chk_lpt_sz;
|
|
|
|
|
long long chk_lpt_sz2;
|
|
|
|
|
long long chk_lpt_wastage;
|
|
|
|
|
int chk_lpt_lebs;
|
|
|
|
|
int new_nhead_offs;
|
|
|
|
|
int new_ihead_lnum;
|
|
|
|
|
int new_ihead_offs;
|
2008-10-23 10:49:28 +02:00
|
|
|
|
|
2009-01-23 13:54:59 +01:00
|
|
|
|
struct ubifs_lp_stats saved_lst;
|
2011-03-29 17:36:21 +02:00
|
|
|
|
struct ubifs_budg_info saved_bi;
|
2009-01-23 13:54:59 +01:00
|
|
|
|
long long saved_free;
|
2011-03-29 17:36:21 +02:00
|
|
|
|
int saved_idx_gc_cnt;
|
2009-01-23 13:54:59 +01:00
|
|
|
|
|
2011-05-19 13:13:16 +02:00
|
|
|
|
char dfs_dir_name[UBIFS_DFS_DIR_LEN + 1];
|
2009-01-23 13:54:59 +01:00
|
|
|
|
struct dentry *dfs_dir;
|
|
|
|
|
struct dentry *dfs_dump_lprops;
|
|
|
|
|
struct dentry *dfs_dump_budg;
|
|
|
|
|
struct dentry *dfs_dump_tnc;
|
2008-10-17 12:31:39 +02:00
|
|
|
|
};
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
2008-08-01 17:13:37 +02:00
|
|
|
|
#define ubifs_assert(expr) do { \
|
2008-07-14 18:08:37 +02:00
|
|
|
|
if (unlikely(!(expr))) { \
|
|
|
|
|
printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)\n", \
|
|
|
|
|
__func__, __LINE__, current->pid); \
|
|
|
|
|
dbg_dump_stack(); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define ubifs_assert_cmt_locked(c) do { \
|
|
|
|
|
if (unlikely(down_write_trylock(&(c)->commit_sem))) { \
|
|
|
|
|
up_write(&(c)->commit_sem); \
|
|
|
|
|
printk(KERN_CRIT "commit lock is not locked!\n"); \
|
|
|
|
|
ubifs_assert(0); \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2011-04-26 09:21:54 +02:00
|
|
|
|
#define dbg_dump_stack() dump_stack()
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
|
|
|
|
#define dbg_err(fmt, ...) do { \
|
|
|
|
|
spin_lock(&dbg_lock); \
|
|
|
|
|
ubifs_err(fmt, ##__VA_ARGS__); \
|
|
|
|
|
spin_unlock(&dbg_lock); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
const char *dbg_key_str0(const struct ubifs_info *c,
|
|
|
|
|
const union ubifs_key *key);
|
|
|
|
|
const char *dbg_key_str1(const struct ubifs_info *c,
|
|
|
|
|
const union ubifs_key *key);
|
|
|
|
|
|
|
|
|
|
/*
|
2008-08-01 17:13:37 +02:00
|
|
|
|
* DBGKEY macros require @dbg_lock to be held, which it is in the dbg message
|
2008-07-14 18:08:37 +02:00
|
|
|
|
* macros.
|
|
|
|
|
*/
|
|
|
|
|
#define DBGKEY(key) dbg_key_str0(c, (key))
|
|
|
|
|
#define DBGKEY1(key) dbg_key_str1(c, (key))
|
|
|
|
|
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define ubifs_dbg_msg(type, fmt, ...) do { \
|
|
|
|
|
spin_lock(&dbg_lock); \
|
|
|
|
|
pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__); \
|
|
|
|
|
spin_unlock(&dbg_lock); \
|
|
|
|
|
} while (0)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
2011-05-17 14:15:30 +02:00
|
|
|
|
/* Just a debugging messages not related to any specific UBIFS subsystem */
|
|
|
|
|
#define dbg_msg(fmt, ...) ubifs_dbg_msg("msg", fmt, ##__VA_ARGS__)
|
|
|
|
|
/* General messages */
|
|
|
|
|
#define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional journal messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_jnl(fmt, ...) ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional TNC messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_tnc(fmt, ...) ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional lprops messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_lp(fmt, ...) ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional LEB find messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_find(fmt, ...) ubifs_dbg_msg("find", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional mount messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_mnt(fmt, ...) ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional I/O messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_io(fmt, ...) ubifs_dbg_msg("io", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional commit messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_cmt(fmt, ...) ubifs_dbg_msg("cmt", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional budgeting messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_budg(fmt, ...) ubifs_dbg_msg("budg", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional log messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_log(fmt, ...) ubifs_dbg_msg("log", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional gc messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_gc(fmt, ...) ubifs_dbg_msg("gc", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional scan messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_scan(fmt, ...) ubifs_dbg_msg("scan", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Additional recovery messages */
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
|
|
|
|
/*
|
2011-03-14 16:55:40 +01:00
|
|
|
|
* Debugging check flags.
|
2008-07-14 18:08:37 +02:00
|
|
|
|
*
|
|
|
|
|
* UBIFS_CHK_GEN: general checks
|
|
|
|
|
* UBIFS_CHK_TNC: check TNC
|
|
|
|
|
* UBIFS_CHK_IDX_SZ: check index size
|
|
|
|
|
* UBIFS_CHK_ORPH: check orphans
|
|
|
|
|
* UBIFS_CHK_OLD_IDX: check the old index
|
|
|
|
|
* UBIFS_CHK_LPROPS: check lprops
|
|
|
|
|
* UBIFS_CHK_FS: check the file-system
|
|
|
|
|
*/
|
|
|
|
|
enum {
|
|
|
|
|
UBIFS_CHK_GEN = 0x1,
|
|
|
|
|
UBIFS_CHK_TNC = 0x2,
|
|
|
|
|
UBIFS_CHK_IDX_SZ = 0x4,
|
|
|
|
|
UBIFS_CHK_ORPH = 0x8,
|
|
|
|
|
UBIFS_CHK_OLD_IDX = 0x10,
|
|
|
|
|
UBIFS_CHK_LPROPS = 0x20,
|
|
|
|
|
UBIFS_CHK_FS = 0x40,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
2011-03-14 16:55:40 +01:00
|
|
|
|
* Special testing flags.
|
2008-07-14 18:08:37 +02:00
|
|
|
|
*
|
|
|
|
|
* UBIFS_TST_RCVRY: failure mode for recovery testing
|
|
|
|
|
*/
|
|
|
|
|
enum {
|
|
|
|
|
UBIFS_TST_RCVRY = 0x4,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern spinlock_t dbg_lock;
|
|
|
|
|
|
|
|
|
|
extern unsigned int ubifs_msg_flags;
|
|
|
|
|
extern unsigned int ubifs_chk_flags;
|
|
|
|
|
extern unsigned int ubifs_tst_flags;
|
|
|
|
|
|
2008-10-17 12:31:39 +02:00
|
|
|
|
int ubifs_debugging_init(struct ubifs_info *c);
|
|
|
|
|
void ubifs_debugging_exit(struct ubifs_info *c);
|
|
|
|
|
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/* Dump functions */
|
|
|
|
|
const char *dbg_ntype(int type);
|
|
|
|
|
const char *dbg_cstate(int cmt_state);
|
2009-09-15 14:03:51 +02:00
|
|
|
|
const char *dbg_jhead(int jhead);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
const char *dbg_get_key_dump(const struct ubifs_info *c,
|
|
|
|
|
const union ubifs_key *key);
|
2011-05-25 16:32:42 +02:00
|
|
|
|
void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
void dbg_dump_node(const struct ubifs_info *c, const void *node);
|
2008-10-31 16:32:30 +01:00
|
|
|
|
void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum,
|
|
|
|
|
int offs);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
void dbg_dump_budget_req(const struct ubifs_budget_req *req);
|
|
|
|
|
void dbg_dump_lstats(const struct ubifs_lp_stats *lst);
|
2011-03-29 17:36:21 +02:00
|
|
|
|
void dbg_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp);
|
|
|
|
|
void dbg_dump_lprops(struct ubifs_info *c);
|
2008-09-12 17:13:31 +02:00
|
|
|
|
void dbg_dump_lpt_info(struct ubifs_info *c);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
void dbg_dump_leb(const struct ubifs_info *c, int lnum);
|
|
|
|
|
void dbg_dump_znode(const struct ubifs_info *c,
|
|
|
|
|
const struct ubifs_znode *znode);
|
|
|
|
|
void dbg_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat);
|
|
|
|
|
void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
|
|
|
|
|
struct ubifs_nnode *parent, int iip);
|
|
|
|
|
void dbg_dump_tnc(struct ubifs_info *c);
|
|
|
|
|
void dbg_dump_index(struct ubifs_info *c);
|
2008-10-31 16:32:30 +01:00
|
|
|
|
void dbg_dump_lpt_lebs(const struct ubifs_info *c);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
|
|
|
|
int dbg_walk_index(struct ubifs_info *c, dbg_leaf_callback leaf_cb,
|
|
|
|
|
dbg_znode_callback znode_cb, void *priv);
|
|
|
|
|
|
|
|
|
|
/* Checking functions */
|
2009-01-23 13:54:59 +01:00
|
|
|
|
void dbg_save_space_info(struct ubifs_info *c);
|
|
|
|
|
int dbg_check_space_info(struct ubifs_info *c);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
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);
|
2008-09-12 17:13:31 +02:00
|
|
|
|
int dbg_chk_lpt_free_spc(struct ubifs_info *c);
|
|
|
|
|
int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
int dbg_check_synced_i_size(struct inode *inode);
|
2011-05-25 16:38:29 +02:00
|
|
|
|
int dbg_check_dir(struct ubifs_info *c, const struct inode *dir);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
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);
|
2009-08-27 15:34:19 +02:00
|
|
|
|
int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode,
|
|
|
|
|
loff_t size);
|
2010-08-07 09:06:11 +02:00
|
|
|
|
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);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
|
|
|
|
/* Force the use of in-the-gaps method for testing */
|
2011-04-05 12:52:20 +02:00
|
|
|
|
static inline int dbg_force_in_the_gaps_enabled(void)
|
|
|
|
|
{
|
|
|
|
|
return ubifs_chk_flags & UBIFS_CHK_GEN;
|
|
|
|
|
}
|
2008-07-14 18:08:37 +02:00
|
|
|
|
int dbg_force_in_the_gaps(void);
|
|
|
|
|
|
|
|
|
|
/* Failure mode for recovery testing */
|
|
|
|
|
#define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY)
|
|
|
|
|
|
|
|
|
|
#ifndef UBIFS_DBG_PRESERVE_UBI
|
|
|
|
|
#define ubi_leb_read dbg_leb_read
|
|
|
|
|
#define ubi_leb_write dbg_leb_write
|
|
|
|
|
#define ubi_leb_change dbg_leb_change
|
|
|
|
|
#define ubi_leb_erase dbg_leb_erase
|
|
|
|
|
#define ubi_leb_unmap dbg_leb_unmap
|
|
|
|
|
#define ubi_is_mapped dbg_is_mapped
|
|
|
|
|
#define ubi_leb_map dbg_leb_map
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int dbg_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset,
|
|
|
|
|
int len, int check);
|
|
|
|
|
int dbg_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf,
|
|
|
|
|
int offset, int len, int dtype);
|
|
|
|
|
int dbg_leb_change(struct ubi_volume_desc *desc, int lnum, const void *buf,
|
|
|
|
|
int len, int dtype);
|
|
|
|
|
int dbg_leb_erase(struct ubi_volume_desc *desc, int lnum);
|
|
|
|
|
int dbg_leb_unmap(struct ubi_volume_desc *desc, int lnum);
|
|
|
|
|
int dbg_is_mapped(struct ubi_volume_desc *desc, int lnum);
|
|
|
|
|
int dbg_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype);
|
|
|
|
|
|
|
|
|
|
static inline int dbg_read(struct ubi_volume_desc *desc, int lnum, char *buf,
|
|
|
|
|
int offset, int len)
|
|
|
|
|
{
|
|
|
|
|
return dbg_leb_read(desc, lnum, buf, offset, len, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int dbg_write(struct ubi_volume_desc *desc, int lnum,
|
|
|
|
|
const void *buf, int offset, int len)
|
|
|
|
|
{
|
|
|
|
|
return dbg_leb_write(desc, lnum, buf, offset, len, UBI_UNKNOWN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int dbg_change(struct ubi_volume_desc *desc, int lnum,
|
|
|
|
|
const void *buf, int len)
|
|
|
|
|
{
|
|
|
|
|
return dbg_leb_change(desc, lnum, buf, len, UBI_UNKNOWN);
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-23 10:49:28 +02:00
|
|
|
|
/* Debugfs-related stuff */
|
|
|
|
|
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);
|
|
|
|
|
|
2008-07-14 18:08:37 +02:00
|
|
|
|
#else /* !CONFIG_UBIFS_FS_DEBUG */
|
|
|
|
|
|
2008-08-01 17:13:37 +02:00
|
|
|
|
/* Use "if (0)" to make compiler check arguments even if debugging is off */
|
|
|
|
|
#define ubifs_assert(expr) do { \
|
2011-05-19 13:13:16 +02:00
|
|
|
|
if (0) \
|
2008-08-01 17:13:37 +02:00
|
|
|
|
printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)\n", \
|
|
|
|
|
__func__, __LINE__, current->pid); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define dbg_err(fmt, ...) do { \
|
|
|
|
|
if (0) \
|
|
|
|
|
ubifs_err(fmt, ##__VA_ARGS__); \
|
2008-08-01 17:13:37 +02:00
|
|
|
|
} while (0)
|
|
|
|
|
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#define ubifs_dbg_msg(fmt, ...) do { \
|
|
|
|
|
if (0) \
|
|
|
|
|
pr_debug(fmt "\n", ##__VA_ARGS__); \
|
2008-08-01 17:13:37 +02:00
|
|
|
|
} while (0)
|
|
|
|
|
|
2008-07-14 18:08:37 +02:00
|
|
|
|
#define dbg_dump_stack()
|
2008-08-01 17:13:37 +02:00
|
|
|
|
#define ubifs_assert_cmt_locked(c)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
2011-05-17 14:15:30 +02:00
|
|
|
|
#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_tnc(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_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__)
|
2008-08-01 17:13:37 +02:00
|
|
|
|
|
|
|
|
|
#define DBGKEY(key) ((char *)(key))
|
|
|
|
|
#define DBGKEY1(key) ((char *)(key))
|
|
|
|
|
|
2011-04-13 00:14:56 +02:00
|
|
|
|
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 ""; }
|
2011-05-25 16:32:42 +02:00
|
|
|
|
static inline void dbg_dump_inode(struct ubifs_info *c,
|
2011-04-13 00:14:56 +02:00
|
|
|
|
const struct inode *inode) { return; }
|
|
|
|
|
static inline void dbg_dump_node(const struct ubifs_info *c,
|
|
|
|
|
const void *node) { return; }
|
|
|
|
|
static inline void dbg_dump_lpt_node(const struct ubifs_info *c,
|
|
|
|
|
void *node, int lnum,
|
|
|
|
|
int offs) { return; }
|
|
|
|
|
static inline void
|
|
|
|
|
dbg_dump_budget_req(const struct ubifs_budget_req *req) { return; }
|
|
|
|
|
static inline void
|
|
|
|
|
dbg_dump_lstats(const struct ubifs_lp_stats *lst) { return; }
|
2011-03-29 17:36:21 +02:00
|
|
|
|
static inline void
|
|
|
|
|
dbg_dump_budg(struct ubifs_info *c,
|
|
|
|
|
const struct ubifs_budg_info *bi) { return; }
|
2011-04-13 00:14:56 +02:00
|
|
|
|
static inline void dbg_dump_lprop(const struct ubifs_info *c,
|
|
|
|
|
const struct ubifs_lprops *lp) { return; }
|
|
|
|
|
static inline void dbg_dump_lprops(struct ubifs_info *c) { return; }
|
|
|
|
|
static inline void dbg_dump_lpt_info(struct ubifs_info *c) { return; }
|
|
|
|
|
static inline void dbg_dump_leb(const struct ubifs_info *c,
|
|
|
|
|
int lnum) { return; }
|
|
|
|
|
static inline void
|
|
|
|
|
dbg_dump_znode(const struct ubifs_info *c,
|
|
|
|
|
const struct ubifs_znode *znode) { return; }
|
|
|
|
|
static inline void dbg_dump_heap(struct ubifs_info *c,
|
|
|
|
|
struct ubifs_lpt_heap *heap,
|
|
|
|
|
int cat) { return; }
|
|
|
|
|
static inline void dbg_dump_pnode(struct ubifs_info *c,
|
|
|
|
|
struct ubifs_pnode *pnode,
|
|
|
|
|
struct ubifs_nnode *parent,
|
|
|
|
|
int iip) { return; }
|
|
|
|
|
static inline void dbg_dump_tnc(struct ubifs_info *c) { return; }
|
|
|
|
|
static inline void dbg_dump_index(struct ubifs_info *c) { return; }
|
|
|
|
|
static inline void dbg_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(struct inode *inode) { return 0; }
|
2011-05-25 16:38:29 +02:00
|
|
|
|
static inline int dbg_check_dir(struct ubifs_info *c,
|
2011-05-25 16:32:42 +02:00
|
|
|
|
const struct inode *dir) { return 0; }
|
2011-04-13 00:14:56 +02:00
|
|
|
|
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_force_in_the_gaps(void) { return 0; }
|
2011-04-05 12:52:20 +02:00
|
|
|
|
#define dbg_force_in_the_gaps_enabled() 0
|
|
|
|
|
#define dbg_failure_mode 0
|
2011-04-13 00:14:56 +02:00
|
|
|
|
|
|
|
|
|
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; }
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
2008-10-23 10:49:28 +02:00
|
|
|
|
#endif /* !CONFIG_UBIFS_FS_DEBUG */
|
2008-07-14 18:08:37 +02:00
|
|
|
|
#endif /* !__UBIFS_DEBUG_H__ */
|