2019-05-30 07:57:50 +08:00
|
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/*
|
|
|
|
|
* This file is part of UBIFS.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2006-2008 Nokia Corporation.
|
|
|
|
|
*
|
|
|
|
|
* Authors: Artem Bityutskiy (Битюцкий Артём)
|
|
|
|
|
* Adrian Hunter
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __UBIFS_DEBUG_H__
|
|
|
|
|
#define __UBIFS_DEBUG_H__
|
|
|
|
|
|
2011-04-13 06:14:56 +08: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);
|
|
|
|
|
|
2011-05-19 19:13:16 +08:00
|
|
|
|
/*
|
|
|
|
|
* The UBIFS debugfs directory name pattern and maximum name length (3 for "ubi"
|
ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity
The UBIFS_DFS_DIR_LEN macro, which defines the maximum length of the UBIFS
debugfs directory name, has an incorrect formula and misleading comments.
The current formula is (3 + 1 + 2*2 + 1), which assumes that both UBI device
number and volume ID are limited to 2 characters. However, UBI device number
ranges from 0 to 31 (2 characters), and volume ID ranges from 0 to 127 (up
to 3 characters).
Although the current code works due to the cancellation of mathematical
errors (9 + 1 = 10, which matches the correct UBIFS_DFS_DIR_LEN value), it
can lead to confusion and potential issues in the future.
This patch aims to improve the code clarity and maintainability by making
the following changes:
1. Corrects the UBIFS_DFS_DIR_LEN macro definition to (3 + 1 + 2 + 3 + 1),
accommodating the maximum lengths of both UBI device number and volume ID,
plus the separators and null terminator.
2. Updates the snprintf calls to use UBIFS_DFS_DIR_LEN instead of
UBIFS_DFS_DIR_LEN + 1, removing the unnecessary +1.
3. Modifies the error checks to compare against UBIFS_DFS_DIR_LEN using >=
instead of >, aligning with the corrected macro definition.
4. Removes the redundant +1 in the dfs_dir_name array definitions in ubi.h
and debug.h.
While these changes do not affect the runtime behavior, they make the code
more readable, maintainable, and less prone to future errors.
v2->v3:
- Removes the duplicated UBIFS_DFS_DIR_LEN and UBIFS_DFS_DIR_NAME macro
definitions in ubifs.h, as they are already defined in debug.h.
Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2024-04-18 15:07:04 +08:00
|
|
|
|
* + 1 for "_" and 2 for UBI device numbers and 3 for volume number and 1 for
|
|
|
|
|
* the trailing zero byte.
|
2011-05-19 19:13:16 +08:00
|
|
|
|
*/
|
|
|
|
|
#define UBIFS_DFS_DIR_NAME "ubi%d_%d"
|
ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity
The UBIFS_DFS_DIR_LEN macro, which defines the maximum length of the UBIFS
debugfs directory name, has an incorrect formula and misleading comments.
The current formula is (3 + 1 + 2*2 + 1), which assumes that both UBI device
number and volume ID are limited to 2 characters. However, UBI device number
ranges from 0 to 31 (2 characters), and volume ID ranges from 0 to 127 (up
to 3 characters).
Although the current code works due to the cancellation of mathematical
errors (9 + 1 = 10, which matches the correct UBIFS_DFS_DIR_LEN value), it
can lead to confusion and potential issues in the future.
This patch aims to improve the code clarity and maintainability by making
the following changes:
1. Corrects the UBIFS_DFS_DIR_LEN macro definition to (3 + 1 + 2 + 3 + 1),
accommodating the maximum lengths of both UBI device number and volume ID,
plus the separators and null terminator.
2. Updates the snprintf calls to use UBIFS_DFS_DIR_LEN instead of
UBIFS_DFS_DIR_LEN + 1, removing the unnecessary +1.
3. Modifies the error checks to compare against UBIFS_DFS_DIR_LEN using >=
instead of >, aligning with the corrected macro definition.
4. Removes the redundant +1 in the dfs_dir_name array definitions in ubi.h
and debug.h.
While these changes do not affect the runtime behavior, they make the code
more readable, maintainable, and less prone to future errors.
v2->v3:
- Removes the duplicated UBIFS_DFS_DIR_LEN and UBIFS_DFS_DIR_NAME macro
definitions in ubifs.h, as they are already defined in debug.h.
Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2024-04-18 15:07:04 +08:00
|
|
|
|
#define UBIFS_DFS_DIR_LEN (3 + 1 + 2 + 3 + 1)
|
2011-05-19 19:13:16 +08:00
|
|
|
|
|
2008-10-17 18:31:39 +08: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()'
|
2011-05-31 23:16:34 +08:00
|
|
|
|
*
|
2011-06-03 20:10:33 +08:00
|
|
|
|
* @pc_happened: non-zero if an emulated power cut happened
|
|
|
|
|
* @pc_delay: 0=>don't delay, 1=>delay a time, 2=>delay a number of calls
|
|
|
|
|
* @pc_timeout: time in jiffies when delay of failure mode expires
|
|
|
|
|
* @pc_cnt: current number of calls to failure mode I/O functions
|
|
|
|
|
* @pc_cnt_max: number of calls by which to delay failure mode
|
2011-05-31 23:16:34 +08:00
|
|
|
|
*
|
2008-10-17 18:31:39 +08:00
|
|
|
|
* @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 20:54:59 +08: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 16:49:28 +08:00
|
|
|
|
*
|
2009-01-23 20:54:59 +08:00
|
|
|
|
* @saved_lst: saved lprops statistics (used by 'dbg_save_space_info()')
|
2011-03-29 23:36:21 +08: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 20:54:59 +08:00
|
|
|
|
*
|
2011-05-31 23:16:34 +08:00
|
|
|
|
* @chk_gen: if general extra checks are enabled
|
|
|
|
|
* @chk_index: if index xtra checks are enabled
|
|
|
|
|
* @chk_orph: if orphans extra checks are enabled
|
|
|
|
|
* @chk_lprops: if lprops extra checks are enabled
|
|
|
|
|
* @chk_fs: if UBIFS contents extra checks are enabled
|
|
|
|
|
* @tst_rcvry: if UBIFS recovery testing mode enabled
|
|
|
|
|
*
|
2011-05-17 19:07:24 +08: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
|
2011-05-31 23:16:34 +08:00
|
|
|
|
* @dfs_chk_gen: debugfs knob to enable UBIFS general extra checks
|
|
|
|
|
* @dfs_chk_index: debugfs knob to enable UBIFS index extra checks
|
|
|
|
|
* @dfs_chk_orph: debugfs knob to enable UBIFS orphans extra checks
|
|
|
|
|
* @dfs_chk_lprops: debugfs knob to enable UBIFS LEP properties extra checks
|
|
|
|
|
* @dfs_chk_fs: debugfs knob to enable UBIFS contents extra checks
|
|
|
|
|
* @dfs_tst_rcvry: debugfs knob to enable UBIFS recovery testing
|
2012-07-14 19:19:46 +08:00
|
|
|
|
* @dfs_ro_error: debugfs knob to switch UBIFS to R/O mode (different to
|
|
|
|
|
* re-mounting to R/O mode because it does not flush any buffers
|
|
|
|
|
* and UBIFS just starts returning -EROFS on all write
|
|
|
|
|
* operations)
|
2008-10-17 18:31:39 +08:00
|
|
|
|
*/
|
|
|
|
|
struct ubifs_debug_info {
|
|
|
|
|
struct ubifs_zbranch old_zroot;
|
|
|
|
|
int old_zroot_level;
|
|
|
|
|
unsigned long long old_zroot_sqnum;
|
2011-05-31 23:16:34 +08:00
|
|
|
|
|
2011-06-03 20:10:33 +08:00
|
|
|
|
int pc_happened;
|
|
|
|
|
int pc_delay;
|
|
|
|
|
unsigned long pc_timeout;
|
|
|
|
|
unsigned int pc_cnt;
|
|
|
|
|
unsigned int pc_cnt_max;
|
2011-05-31 23:16:34 +08:00
|
|
|
|
|
2008-10-17 18:31:39 +08:00
|
|
|
|
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 16:49:28 +08:00
|
|
|
|
|
2009-01-23 20:54:59 +08:00
|
|
|
|
struct ubifs_lp_stats saved_lst;
|
2011-03-29 23:36:21 +08:00
|
|
|
|
struct ubifs_budg_info saved_bi;
|
2009-01-23 20:54:59 +08:00
|
|
|
|
long long saved_free;
|
2011-03-29 23:36:21 +08:00
|
|
|
|
int saved_idx_gc_cnt;
|
2009-01-23 20:54:59 +08:00
|
|
|
|
|
2011-05-31 23:16:34 +08:00
|
|
|
|
unsigned int chk_gen:1;
|
|
|
|
|
unsigned int chk_index:1;
|
|
|
|
|
unsigned int chk_orph:1;
|
|
|
|
|
unsigned int chk_lprops:1;
|
|
|
|
|
unsigned int chk_fs:1;
|
|
|
|
|
unsigned int tst_rcvry:1;
|
|
|
|
|
|
ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity
The UBIFS_DFS_DIR_LEN macro, which defines the maximum length of the UBIFS
debugfs directory name, has an incorrect formula and misleading comments.
The current formula is (3 + 1 + 2*2 + 1), which assumes that both UBI device
number and volume ID are limited to 2 characters. However, UBI device number
ranges from 0 to 31 (2 characters), and volume ID ranges from 0 to 127 (up
to 3 characters).
Although the current code works due to the cancellation of mathematical
errors (9 + 1 = 10, which matches the correct UBIFS_DFS_DIR_LEN value), it
can lead to confusion and potential issues in the future.
This patch aims to improve the code clarity and maintainability by making
the following changes:
1. Corrects the UBIFS_DFS_DIR_LEN macro definition to (3 + 1 + 2 + 3 + 1),
accommodating the maximum lengths of both UBI device number and volume ID,
plus the separators and null terminator.
2. Updates the snprintf calls to use UBIFS_DFS_DIR_LEN instead of
UBIFS_DFS_DIR_LEN + 1, removing the unnecessary +1.
3. Modifies the error checks to compare against UBIFS_DFS_DIR_LEN using >=
instead of >, aligning with the corrected macro definition.
4. Removes the redundant +1 in the dfs_dir_name array definitions in ubi.h
and debug.h.
While these changes do not affect the runtime behavior, they make the code
more readable, maintainable, and less prone to future errors.
v2->v3:
- Removes the duplicated UBIFS_DFS_DIR_LEN and UBIFS_DFS_DIR_NAME macro
definitions in ubifs.h, as they are already defined in debug.h.
Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2024-04-18 15:07:04 +08:00
|
|
|
|
char dfs_dir_name[UBIFS_DFS_DIR_LEN];
|
2009-01-23 20:54:59 +08:00
|
|
|
|
struct dentry *dfs_dir;
|
|
|
|
|
struct dentry *dfs_dump_lprops;
|
|
|
|
|
struct dentry *dfs_dump_budg;
|
|
|
|
|
struct dentry *dfs_dump_tnc;
|
2011-05-31 23:16:34 +08:00
|
|
|
|
struct dentry *dfs_chk_gen;
|
|
|
|
|
struct dentry *dfs_chk_index;
|
|
|
|
|
struct dentry *dfs_chk_orph;
|
|
|
|
|
struct dentry *dfs_chk_lprops;
|
|
|
|
|
struct dentry *dfs_chk_fs;
|
|
|
|
|
struct dentry *dfs_tst_rcvry;
|
2012-07-14 19:19:46 +08:00
|
|
|
|
struct dentry *dfs_ro_error;
|
2008-10-17 18:31:39 +08:00
|
|
|
|
};
|
2008-07-15 00:08:37 +08:00
|
|
|
|
|
2011-06-01 22:43:43 +08:00
|
|
|
|
/**
|
|
|
|
|
* ubifs_global_debug_info - global (not per-FS) UBIFS debugging information.
|
|
|
|
|
*
|
|
|
|
|
* @chk_gen: if general extra checks are enabled
|
|
|
|
|
* @chk_index: if index xtra checks are enabled
|
|
|
|
|
* @chk_orph: if orphans extra checks are enabled
|
|
|
|
|
* @chk_lprops: if lprops extra checks are enabled
|
|
|
|
|
* @chk_fs: if UBIFS contents extra checks are enabled
|
|
|
|
|
* @tst_rcvry: if UBIFS recovery testing mode enabled
|
|
|
|
|
*/
|
|
|
|
|
struct ubifs_global_debug_info {
|
|
|
|
|
unsigned int chk_gen:1;
|
|
|
|
|
unsigned int chk_index:1;
|
|
|
|
|
unsigned int chk_orph:1;
|
|
|
|
|
unsigned int chk_lprops:1;
|
|
|
|
|
unsigned int chk_fs:1;
|
|
|
|
|
unsigned int tst_rcvry:1;
|
|
|
|
|
};
|
|
|
|
|
|
2018-07-12 19:01:58 +08:00
|
|
|
|
void ubifs_assert_failed(struct ubifs_info *c, const char *expr,
|
|
|
|
|
const char *file, int line);
|
|
|
|
|
|
2018-07-12 19:01:57 +08:00
|
|
|
|
#define ubifs_assert(c, expr) do { \
|
2008-07-15 00:08:37 +08:00
|
|
|
|
if (unlikely(!(expr))) { \
|
2018-07-12 19:01:58 +08:00
|
|
|
|
ubifs_assert_failed((struct ubifs_info *)c, #expr, __FILE__, \
|
|
|
|
|
__LINE__); \
|
2008-07-15 00:08:37 +08:00
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
#define ubifs_assert_cmt_locked(c) do { \
|
|
|
|
|
if (unlikely(down_write_trylock(&(c)->commit_sem))) { \
|
|
|
|
|
up_write(&(c)->commit_sem); \
|
2018-07-12 19:01:58 +08:00
|
|
|
|
ubifs_err(c, "commit lock is not locked!\n"); \
|
2018-07-12 19:01:57 +08:00
|
|
|
|
ubifs_assert(c, 0); \
|
2008-07-15 00:08:37 +08:00
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2012-01-11 21:13:27 +08:00
|
|
|
|
#define ubifs_dbg_msg(type, fmt, ...) \
|
2012-08-22 21:37:13 +08:00
|
|
|
|
pr_debug("UBIFS DBG " type " (pid %d): " fmt "\n", current->pid, \
|
|
|
|
|
##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
|
2012-08-22 02:50:58 +08:00
|
|
|
|
#define DBG_KEY_BUF_LEN 48
|
2012-01-13 18:33:53 +08:00
|
|
|
|
#define ubifs_dbg_msg_key(type, key, fmt, ...) do { \
|
|
|
|
|
char __tmp_key_buf[DBG_KEY_BUF_LEN]; \
|
2012-08-22 21:37:13 +08:00
|
|
|
|
pr_debug("UBIFS DBG " type " (pid %d): " fmt "%s\n", current->pid, \
|
|
|
|
|
##__VA_ARGS__, \
|
2012-01-13 18:33:53 +08:00
|
|
|
|
dbg_snprintf_key(c, key, __tmp_key_buf, DBG_KEY_BUF_LEN)); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2011-05-17 20:15:30 +08:00
|
|
|
|
/* General messages */
|
|
|
|
|
#define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional journal messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_jnl(fmt, ...) ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__)
|
2012-01-13 18:33:53 +08:00
|
|
|
|
#define dbg_jnlk(key, fmt, ...) \
|
|
|
|
|
ubifs_dbg_msg_key("jnl", key, fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional TNC messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_tnc(fmt, ...) ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__)
|
2012-01-13 18:33:53 +08:00
|
|
|
|
#define dbg_tnck(key, fmt, ...) \
|
|
|
|
|
ubifs_dbg_msg_key("tnc", key, fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional lprops messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_lp(fmt, ...) ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional LEB find messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_find(fmt, ...) ubifs_dbg_msg("find", fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional mount messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_mnt(fmt, ...) ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__)
|
2012-01-13 18:33:53 +08:00
|
|
|
|
#define dbg_mntk(key, fmt, ...) \
|
|
|
|
|
ubifs_dbg_msg_key("mnt", key, fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional I/O messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_io(fmt, ...) ubifs_dbg_msg("io", fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional commit messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_cmt(fmt, ...) ubifs_dbg_msg("cmt", fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional budgeting messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_budg(fmt, ...) ubifs_dbg_msg("budg", fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional log messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_log(fmt, ...) ubifs_dbg_msg("log", fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional gc messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_gc(fmt, ...) ubifs_dbg_msg("gc", fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional scan messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_scan(fmt, ...) ubifs_dbg_msg("scan", fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Additional recovery messages */
|
2011-05-17 20:15:30 +08:00
|
|
|
|
#define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__)
|
2008-07-15 00:08:37 +08:00
|
|
|
|
|
2011-06-01 22:43:43 +08:00
|
|
|
|
extern struct ubifs_global_debug_info ubifs_dbg;
|
2011-06-03 13:31:29 +08:00
|
|
|
|
|
|
|
|
|
static inline int dbg_is_chk_gen(const struct ubifs_info *c)
|
|
|
|
|
{
|
2011-06-01 22:43:43 +08:00
|
|
|
|
return !!(ubifs_dbg.chk_gen || c->dbg->chk_gen);
|
2011-06-03 13:31:29 +08:00
|
|
|
|
}
|
2011-06-03 13:53:35 +08:00
|
|
|
|
static inline int dbg_is_chk_index(const struct ubifs_info *c)
|
2011-06-03 13:31:29 +08:00
|
|
|
|
{
|
2011-06-01 22:43:43 +08:00
|
|
|
|
return !!(ubifs_dbg.chk_index || c->dbg->chk_index);
|
2011-06-03 13:31:29 +08:00
|
|
|
|
}
|
|
|
|
|
static inline int dbg_is_chk_orph(const struct ubifs_info *c)
|
|
|
|
|
{
|
2011-06-01 22:43:43 +08:00
|
|
|
|
return !!(ubifs_dbg.chk_orph || c->dbg->chk_orph);
|
2011-06-03 13:31:29 +08:00
|
|
|
|
}
|
|
|
|
|
static inline int dbg_is_chk_lprops(const struct ubifs_info *c)
|
|
|
|
|
{
|
2011-06-01 22:43:43 +08:00
|
|
|
|
return !!(ubifs_dbg.chk_lprops || c->dbg->chk_lprops);
|
2011-06-03 13:31:29 +08:00
|
|
|
|
}
|
|
|
|
|
static inline int dbg_is_chk_fs(const struct ubifs_info *c)
|
|
|
|
|
{
|
2011-06-01 22:43:43 +08:00
|
|
|
|
return !!(ubifs_dbg.chk_fs || c->dbg->chk_fs);
|
2011-06-03 13:31:29 +08:00
|
|
|
|
}
|
|
|
|
|
static inline int dbg_is_tst_rcvry(const struct ubifs_info *c)
|
|
|
|
|
{
|
2011-06-01 22:43:43 +08:00
|
|
|
|
return !!(ubifs_dbg.tst_rcvry || c->dbg->tst_rcvry);
|
2011-06-03 13:31:29 +08:00
|
|
|
|
}
|
2011-06-03 18:45:09 +08:00
|
|
|
|
static inline int dbg_is_power_cut(const struct ubifs_info *c)
|
|
|
|
|
{
|
2011-06-03 20:10:33 +08:00
|
|
|
|
return !!c->dbg->pc_happened;
|
2011-06-03 18:45:09 +08:00
|
|
|
|
}
|
2011-06-03 13:31:29 +08:00
|
|
|
|
|
2008-10-17 18:31:39 +08:00
|
|
|
|
int ubifs_debugging_init(struct ubifs_info *c);
|
|
|
|
|
void ubifs_debugging_exit(struct ubifs_info *c);
|
|
|
|
|
|
2008-07-15 00:08:37 +08:00
|
|
|
|
/* Dump functions */
|
|
|
|
|
const char *dbg_ntype(int type);
|
|
|
|
|
const char *dbg_cstate(int cmt_state);
|
2009-09-15 20:03:51 +08:00
|
|
|
|
const char *dbg_jhead(int jhead);
|
2008-07-15 00:08:37 +08:00
|
|
|
|
const char *dbg_get_key_dump(const struct ubifs_info *c,
|
|
|
|
|
const union ubifs_key *key);
|
2012-01-13 18:33:53 +08:00
|
|
|
|
const char *dbg_snprintf_key(const struct ubifs_info *c,
|
|
|
|
|
const union ubifs_key *key, char *buffer, int len);
|
2012-05-17 00:15:56 +08:00
|
|
|
|
void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode);
|
2020-06-16 15:11:42 +08:00
|
|
|
|
void ubifs_dump_node(const struct ubifs_info *c, const void *node,
|
|
|
|
|
int node_len);
|
2012-05-17 00:15:56 +08:00
|
|
|
|
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_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);
|
2008-07-15 00:08:37 +08: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 20:54:59 +08:00
|
|
|
|
void dbg_save_space_info(struct ubifs_info *c);
|
|
|
|
|
int dbg_check_space_info(struct ubifs_info *c);
|
2008-07-15 00:08:37 +08: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 23:13:31 +08:00
|
|
|
|
int dbg_chk_lpt_free_spc(struct ubifs_info *c);
|
|
|
|
|
int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len);
|
2011-05-31 23:14:38 +08:00
|
|
|
|
int dbg_check_synced_i_size(const struct ubifs_info *c, struct inode *inode);
|
2011-05-25 22:38:29 +08:00
|
|
|
|
int dbg_check_dir(struct ubifs_info *c, const struct inode *dir);
|
2008-07-15 00:08:37 +08: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 21:34:19 +08:00
|
|
|
|
int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode,
|
|
|
|
|
loff_t size);
|
2010-08-07 15:06:11 +08: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-15 00:08:37 +08:00
|
|
|
|
|
2011-06-03 19:51:41 +08:00
|
|
|
|
int dbg_leb_write(struct ubifs_info *c, int lnum, const void *buf, int offs,
|
2012-05-14 23:55:51 +08:00
|
|
|
|
int len);
|
|
|
|
|
int dbg_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len);
|
2011-06-03 19:51:41 +08:00
|
|
|
|
int dbg_leb_unmap(struct ubifs_info *c, int lnum);
|
2012-05-14 23:55:51 +08:00
|
|
|
|
int dbg_leb_map(struct ubifs_info *c, int lnum);
|
2008-07-15 00:08:37 +08:00
|
|
|
|
|
2008-10-23 16:49:28 +08:00
|
|
|
|
/* Debugfs-related stuff */
|
2019-06-12 23:21:20 +08:00
|
|
|
|
void dbg_debugfs_init(void);
|
2008-10-23 16:49:28 +08:00
|
|
|
|
void dbg_debugfs_exit(void);
|
2019-06-12 23:21:20 +08:00
|
|
|
|
void dbg_debugfs_init_fs(struct ubifs_info *c);
|
2008-10-23 16:49:28 +08:00
|
|
|
|
void dbg_debugfs_exit_fs(struct ubifs_info *c);
|
|
|
|
|
|
2008-07-15 00:08:37 +08:00
|
|
|
|
#endif /* !__UBIFS_DEBUG_H__ */
|