diff options
Diffstat (limited to 'fs/ubifs/debug.c')
-rw-r--r-- | fs/ubifs/debug.c | 170 |
1 files changed, 87 insertions, 83 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 1934084e2088..92df3b081539 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -34,8 +34,6 @@ | |||
34 | #include <linux/random.h> | 34 | #include <linux/random.h> |
35 | #include "ubifs.h" | 35 | #include "ubifs.h" |
36 | 36 | ||
37 | #ifdef CONFIG_UBIFS_FS_DEBUG | ||
38 | |||
39 | static DEFINE_SPINLOCK(dbg_lock); | 37 | static DEFINE_SPINLOCK(dbg_lock); |
40 | 38 | ||
41 | static const char *get_key_fmt(int fmt) | 39 | static const char *get_key_fmt(int fmt) |
@@ -232,7 +230,7 @@ static void dump_ch(const struct ubifs_ch *ch) | |||
232 | printk(KERN_ERR "\tlen %u\n", le32_to_cpu(ch->len)); | 230 | printk(KERN_ERR "\tlen %u\n", le32_to_cpu(ch->len)); |
233 | } | 231 | } |
234 | 232 | ||
235 | void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode) | 233 | void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode) |
236 | { | 234 | { |
237 | const struct ubifs_inode *ui = ubifs_inode(inode); | 235 | const struct ubifs_inode *ui = ubifs_inode(inode); |
238 | struct qstr nm = { .name = NULL }; | 236 | struct qstr nm = { .name = NULL }; |
@@ -300,7 +298,7 @@ void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode) | |||
300 | kfree(pdent); | 298 | kfree(pdent); |
301 | } | 299 | } |
302 | 300 | ||
303 | void dbg_dump_node(const struct ubifs_info *c, const void *node) | 301 | void ubifs_dump_node(const struct ubifs_info *c, const void *node) |
304 | { | 302 | { |
305 | int i, n; | 303 | int i, n; |
306 | union ubifs_key key; | 304 | union ubifs_key key; |
@@ -603,7 +601,7 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node) | |||
603 | spin_unlock(&dbg_lock); | 601 | spin_unlock(&dbg_lock); |
604 | } | 602 | } |
605 | 603 | ||
606 | void dbg_dump_budget_req(const struct ubifs_budget_req *req) | 604 | void ubifs_dump_budget_req(const struct ubifs_budget_req *req) |
607 | { | 605 | { |
608 | spin_lock(&dbg_lock); | 606 | spin_lock(&dbg_lock); |
609 | printk(KERN_ERR "Budgeting request: new_ino %d, dirtied_ino %d\n", | 607 | printk(KERN_ERR "Budgeting request: new_ino %d, dirtied_ino %d\n", |
@@ -620,7 +618,7 @@ void dbg_dump_budget_req(const struct ubifs_budget_req *req) | |||
620 | spin_unlock(&dbg_lock); | 618 | spin_unlock(&dbg_lock); |
621 | } | 619 | } |
622 | 620 | ||
623 | void dbg_dump_lstats(const struct ubifs_lp_stats *lst) | 621 | void ubifs_dump_lstats(const struct ubifs_lp_stats *lst) |
624 | { | 622 | { |
625 | spin_lock(&dbg_lock); | 623 | spin_lock(&dbg_lock); |
626 | printk(KERN_ERR "(pid %d) Lprops statistics: empty_lebs %d, " | 624 | printk(KERN_ERR "(pid %d) Lprops statistics: empty_lebs %d, " |
@@ -634,7 +632,7 @@ void dbg_dump_lstats(const struct ubifs_lp_stats *lst) | |||
634 | spin_unlock(&dbg_lock); | 632 | spin_unlock(&dbg_lock); |
635 | } | 633 | } |
636 | 634 | ||
637 | void dbg_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi) | 635 | void ubifs_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi) |
638 | { | 636 | { |
639 | int i; | 637 | int i; |
640 | struct rb_node *rb; | 638 | struct rb_node *rb; |
@@ -707,7 +705,7 @@ out_unlock: | |||
707 | spin_unlock(&c->space_lock); | 705 | spin_unlock(&c->space_lock); |
708 | } | 706 | } |
709 | 707 | ||
710 | void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp) | 708 | void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp) |
711 | { | 709 | { |
712 | int i, spc, dark = 0, dead = 0; | 710 | int i, spc, dark = 0, dead = 0; |
713 | struct rb_node *rb; | 711 | struct rb_node *rb; |
@@ -801,7 +799,7 @@ void dbg_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp) | |||
801 | printk(KERN_CONT ")\n"); | 799 | printk(KERN_CONT ")\n"); |
802 | } | 800 | } |
803 | 801 | ||
804 | void dbg_dump_lprops(struct ubifs_info *c) | 802 | void ubifs_dump_lprops(struct ubifs_info *c) |
805 | { | 803 | { |
806 | int lnum, err; | 804 | int lnum, err; |
807 | struct ubifs_lprops lp; | 805 | struct ubifs_lprops lp; |
@@ -810,20 +808,20 @@ void dbg_dump_lprops(struct ubifs_info *c) | |||
810 | printk(KERN_ERR "(pid %d) start dumping LEB properties\n", | 808 | printk(KERN_ERR "(pid %d) start dumping LEB properties\n", |
811 | current->pid); | 809 | current->pid); |
812 | ubifs_get_lp_stats(c, &lst); | 810 | ubifs_get_lp_stats(c, &lst); |
813 | dbg_dump_lstats(&lst); | 811 | ubifs_dump_lstats(&lst); |
814 | 812 | ||
815 | for (lnum = c->main_first; lnum < c->leb_cnt; lnum++) { | 813 | for (lnum = c->main_first; lnum < c->leb_cnt; lnum++) { |
816 | err = ubifs_read_one_lp(c, lnum, &lp); | 814 | err = ubifs_read_one_lp(c, lnum, &lp); |
817 | if (err) | 815 | if (err) |
818 | ubifs_err("cannot read lprops for LEB %d", lnum); | 816 | ubifs_err("cannot read lprops for LEB %d", lnum); |
819 | 817 | ||
820 | dbg_dump_lprop(c, &lp); | 818 | ubifs_dump_lprop(c, &lp); |
821 | } | 819 | } |
822 | printk(KERN_ERR "(pid %d) finish dumping LEB properties\n", | 820 | printk(KERN_ERR "(pid %d) finish dumping LEB properties\n", |
823 | current->pid); | 821 | current->pid); |
824 | } | 822 | } |
825 | 823 | ||
826 | void dbg_dump_lpt_info(struct ubifs_info *c) | 824 | void ubifs_dump_lpt_info(struct ubifs_info *c) |
827 | { | 825 | { |
828 | int i; | 826 | int i; |
829 | 827 | ||
@@ -862,8 +860,8 @@ void dbg_dump_lpt_info(struct ubifs_info *c) | |||
862 | spin_unlock(&dbg_lock); | 860 | spin_unlock(&dbg_lock); |
863 | } | 861 | } |
864 | 862 | ||
865 | void dbg_dump_sleb(const struct ubifs_info *c, | 863 | void ubifs_dump_sleb(const struct ubifs_info *c, |
866 | const struct ubifs_scan_leb *sleb, int offs) | 864 | const struct ubifs_scan_leb *sleb, int offs) |
867 | { | 865 | { |
868 | struct ubifs_scan_node *snod; | 866 | struct ubifs_scan_node *snod; |
869 | 867 | ||
@@ -874,11 +872,11 @@ void dbg_dump_sleb(const struct ubifs_info *c, | |||
874 | cond_resched(); | 872 | cond_resched(); |
875 | printk(KERN_ERR "Dumping node at LEB %d:%d len %d\n", sleb->lnum, | 873 | printk(KERN_ERR "Dumping node at LEB %d:%d len %d\n", sleb->lnum, |
876 | snod->offs, snod->len); | 874 | snod->offs, snod->len); |
877 | dbg_dump_node(c, snod->node); | 875 | ubifs_dump_node(c, snod->node); |
878 | } | 876 | } |
879 | } | 877 | } |
880 | 878 | ||
881 | void dbg_dump_leb(const struct ubifs_info *c, int lnum) | 879 | void ubifs_dump_leb(const struct ubifs_info *c, int lnum) |
882 | { | 880 | { |
883 | struct ubifs_scan_leb *sleb; | 881 | struct ubifs_scan_leb *sleb; |
884 | struct ubifs_scan_node *snod; | 882 | struct ubifs_scan_node *snod; |
@@ -909,7 +907,7 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum) | |||
909 | cond_resched(); | 907 | cond_resched(); |
910 | printk(KERN_ERR "Dumping node at LEB %d:%d len %d\n", lnum, | 908 | printk(KERN_ERR "Dumping node at LEB %d:%d len %d\n", lnum, |
911 | snod->offs, snod->len); | 909 | snod->offs, snod->len); |
912 | dbg_dump_node(c, snod->node); | 910 | ubifs_dump_node(c, snod->node); |
913 | } | 911 | } |
914 | 912 | ||
915 | printk(KERN_ERR "(pid %d) finish dumping LEB %d\n", | 913 | printk(KERN_ERR "(pid %d) finish dumping LEB %d\n", |
@@ -921,8 +919,8 @@ out: | |||
921 | return; | 919 | return; |
922 | } | 920 | } |
923 | 921 | ||
924 | void dbg_dump_znode(const struct ubifs_info *c, | 922 | void ubifs_dump_znode(const struct ubifs_info *c, |
925 | const struct ubifs_znode *znode) | 923 | const struct ubifs_znode *znode) |
926 | { | 924 | { |
927 | int n; | 925 | int n; |
928 | const struct ubifs_zbranch *zbr; | 926 | const struct ubifs_zbranch *zbr; |
@@ -965,7 +963,7 @@ void dbg_dump_znode(const struct ubifs_info *c, | |||
965 | spin_unlock(&dbg_lock); | 963 | spin_unlock(&dbg_lock); |
966 | } | 964 | } |
967 | 965 | ||
968 | void dbg_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat) | 966 | void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat) |
969 | { | 967 | { |
970 | int i; | 968 | int i; |
971 | 969 | ||
@@ -981,8 +979,8 @@ void dbg_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat) | |||
981 | printk(KERN_ERR "(pid %d) finish dumping heap\n", current->pid); | 979 | printk(KERN_ERR "(pid %d) finish dumping heap\n", current->pid); |
982 | } | 980 | } |
983 | 981 | ||
984 | void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, | 982 | void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, |
985 | struct ubifs_nnode *parent, int iip) | 983 | struct ubifs_nnode *parent, int iip) |
986 | { | 984 | { |
987 | int i; | 985 | int i; |
988 | 986 | ||
@@ -999,7 +997,7 @@ void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, | |||
999 | } | 997 | } |
1000 | } | 998 | } |
1001 | 999 | ||
1002 | void dbg_dump_tnc(struct ubifs_info *c) | 1000 | void ubifs_dump_tnc(struct ubifs_info *c) |
1003 | { | 1001 | { |
1004 | struct ubifs_znode *znode; | 1002 | struct ubifs_znode *znode; |
1005 | int level; | 1003 | int level; |
@@ -1014,7 +1012,7 @@ void dbg_dump_tnc(struct ubifs_info *c) | |||
1014 | level = znode->level; | 1012 | level = znode->level; |
1015 | printk(KERN_ERR "== Level %d ==\n", level); | 1013 | printk(KERN_ERR "== Level %d ==\n", level); |
1016 | } | 1014 | } |
1017 | dbg_dump_znode(c, znode); | 1015 | ubifs_dump_znode(c, znode); |
1018 | znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode); | 1016 | znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode); |
1019 | } | 1017 | } |
1020 | printk(KERN_ERR "(pid %d) finish dumping TNC tree\n", current->pid); | 1018 | printk(KERN_ERR "(pid %d) finish dumping TNC tree\n", current->pid); |
@@ -1023,18 +1021,18 @@ void dbg_dump_tnc(struct ubifs_info *c) | |||
1023 | static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode, | 1021 | static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode, |
1024 | void *priv) | 1022 | void *priv) |
1025 | { | 1023 | { |
1026 | dbg_dump_znode(c, znode); | 1024 | ubifs_dump_znode(c, znode); |
1027 | return 0; | 1025 | return 0; |
1028 | } | 1026 | } |
1029 | 1027 | ||
1030 | /** | 1028 | /** |
1031 | * dbg_dump_index - dump the on-flash index. | 1029 | * ubifs_dump_index - dump the on-flash index. |
1032 | * @c: UBIFS file-system description object | 1030 | * @c: UBIFS file-system description object |
1033 | * | 1031 | * |
1034 | * This function dumps whole UBIFS indexing B-tree, unlike 'dbg_dump_tnc()' | 1032 | * This function dumps whole UBIFS indexing B-tree, unlike 'ubifs_dump_tnc()' |
1035 | * which dumps only in-memory znodes and does not read znodes which from flash. | 1033 | * which dumps only in-memory znodes and does not read znodes which from flash. |
1036 | */ | 1034 | */ |
1037 | void dbg_dump_index(struct ubifs_info *c) | 1035 | void ubifs_dump_index(struct ubifs_info *c) |
1038 | { | 1036 | { |
1039 | dbg_walk_index(c, NULL, dump_znode, NULL); | 1037 | dbg_walk_index(c, NULL, dump_znode, NULL); |
1040 | } | 1038 | } |
@@ -1120,15 +1118,15 @@ int dbg_check_space_info(struct ubifs_info *c) | |||
1120 | 1118 | ||
1121 | out: | 1119 | out: |
1122 | ubifs_msg("saved lprops statistics dump"); | 1120 | ubifs_msg("saved lprops statistics dump"); |
1123 | dbg_dump_lstats(&d->saved_lst); | 1121 | ubifs_dump_lstats(&d->saved_lst); |
1124 | ubifs_msg("saved budgeting info dump"); | 1122 | ubifs_msg("saved budgeting info dump"); |
1125 | dbg_dump_budg(c, &d->saved_bi); | 1123 | ubifs_dump_budg(c, &d->saved_bi); |
1126 | ubifs_msg("saved idx_gc_cnt %d", d->saved_idx_gc_cnt); | 1124 | ubifs_msg("saved idx_gc_cnt %d", d->saved_idx_gc_cnt); |
1127 | ubifs_msg("current lprops statistics dump"); | 1125 | ubifs_msg("current lprops statistics dump"); |
1128 | ubifs_get_lp_stats(c, &lst); | 1126 | ubifs_get_lp_stats(c, &lst); |
1129 | dbg_dump_lstats(&lst); | 1127 | ubifs_dump_lstats(&lst); |
1130 | ubifs_msg("current budgeting info dump"); | 1128 | ubifs_msg("current budgeting info dump"); |
1131 | dbg_dump_budg(c, &c->bi); | 1129 | ubifs_dump_budg(c, &c->bi); |
1132 | dump_stack(); | 1130 | dump_stack(); |
1133 | return -EINVAL; | 1131 | return -EINVAL; |
1134 | } | 1132 | } |
@@ -1160,7 +1158,7 @@ int dbg_check_synced_i_size(const struct ubifs_info *c, struct inode *inode) | |||
1160 | "is clean", ui->ui_size, ui->synced_i_size); | 1158 | "is clean", ui->ui_size, ui->synced_i_size); |
1161 | ubifs_err("i_ino %lu, i_mode %#x, i_size %lld", inode->i_ino, | 1159 | ubifs_err("i_ino %lu, i_mode %#x, i_size %lld", inode->i_ino, |
1162 | inode->i_mode, i_size_read(inode)); | 1160 | inode->i_mode, i_size_read(inode)); |
1163 | dbg_dump_stack(); | 1161 | dump_stack(); |
1164 | err = -EINVAL; | 1162 | err = -EINVAL; |
1165 | } | 1163 | } |
1166 | spin_unlock(&ui->ui_lock); | 1164 | spin_unlock(&ui->ui_lock); |
@@ -1223,14 +1221,14 @@ int dbg_check_dir(struct ubifs_info *c, const struct inode *dir) | |||
1223 | "but calculated size is %llu", dir->i_ino, | 1221 | "but calculated size is %llu", dir->i_ino, |
1224 | (unsigned long long)i_size_read(dir), | 1222 | (unsigned long long)i_size_read(dir), |
1225 | (unsigned long long)size); | 1223 | (unsigned long long)size); |
1226 | dbg_dump_inode(c, dir); | 1224 | ubifs_dump_inode(c, dir); |
1227 | dump_stack(); | 1225 | dump_stack(); |
1228 | return -EINVAL; | 1226 | return -EINVAL; |
1229 | } | 1227 | } |
1230 | if (dir->i_nlink != nlink) { | 1228 | if (dir->i_nlink != nlink) { |
1231 | ubifs_err("directory inode %lu has nlink %u, but calculated " | 1229 | ubifs_err("directory inode %lu has nlink %u, but calculated " |
1232 | "nlink is %u", dir->i_ino, dir->i_nlink, nlink); | 1230 | "nlink is %u", dir->i_ino, dir->i_nlink, nlink); |
1233 | dbg_dump_inode(c, dir); | 1231 | ubifs_dump_inode(c, dir); |
1234 | dump_stack(); | 1232 | dump_stack(); |
1235 | return -EINVAL; | 1233 | return -EINVAL; |
1236 | } | 1234 | } |
@@ -1287,25 +1285,25 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1, | |||
1287 | err = 1; | 1285 | err = 1; |
1288 | key_read(c, &dent1->key, &key); | 1286 | key_read(c, &dent1->key, &key); |
1289 | if (keys_cmp(c, &zbr1->key, &key)) { | 1287 | if (keys_cmp(c, &zbr1->key, &key)) { |
1290 | dbg_err("1st entry at %d:%d has key %s", zbr1->lnum, | 1288 | ubifs_err("1st entry at %d:%d has key %s", zbr1->lnum, |
1291 | zbr1->offs, dbg_snprintf_key(c, &key, key_buf, | 1289 | zbr1->offs, dbg_snprintf_key(c, &key, key_buf, |
1292 | DBG_KEY_BUF_LEN)); | 1290 | DBG_KEY_BUF_LEN)); |
1293 | dbg_err("but it should have key %s according to tnc", | 1291 | ubifs_err("but it should have key %s according to tnc", |
1294 | dbg_snprintf_key(c, &zbr1->key, key_buf, | 1292 | dbg_snprintf_key(c, &zbr1->key, key_buf, |
1295 | DBG_KEY_BUF_LEN)); | 1293 | DBG_KEY_BUF_LEN)); |
1296 | dbg_dump_node(c, dent1); | 1294 | ubifs_dump_node(c, dent1); |
1297 | goto out_free; | 1295 | goto out_free; |
1298 | } | 1296 | } |
1299 | 1297 | ||
1300 | key_read(c, &dent2->key, &key); | 1298 | key_read(c, &dent2->key, &key); |
1301 | if (keys_cmp(c, &zbr2->key, &key)) { | 1299 | if (keys_cmp(c, &zbr2->key, &key)) { |
1302 | dbg_err("2nd entry at %d:%d has key %s", zbr1->lnum, | 1300 | ubifs_err("2nd entry at %d:%d has key %s", zbr1->lnum, |
1303 | zbr1->offs, dbg_snprintf_key(c, &key, key_buf, | 1301 | zbr1->offs, dbg_snprintf_key(c, &key, key_buf, |
1304 | DBG_KEY_BUF_LEN)); | 1302 | DBG_KEY_BUF_LEN)); |
1305 | dbg_err("but it should have key %s according to tnc", | 1303 | ubifs_err("but it should have key %s according to tnc", |
1306 | dbg_snprintf_key(c, &zbr2->key, key_buf, | 1304 | dbg_snprintf_key(c, &zbr2->key, key_buf, |
1307 | DBG_KEY_BUF_LEN)); | 1305 | DBG_KEY_BUF_LEN)); |
1308 | dbg_dump_node(c, dent2); | 1306 | ubifs_dump_node(c, dent2); |
1309 | goto out_free; | 1307 | goto out_free; |
1310 | } | 1308 | } |
1311 | 1309 | ||
@@ -1318,15 +1316,15 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1, | |||
1318 | goto out_free; | 1316 | goto out_free; |
1319 | } | 1317 | } |
1320 | if (cmp == 0 && nlen1 == nlen2) | 1318 | if (cmp == 0 && nlen1 == nlen2) |
1321 | dbg_err("2 xent/dent nodes with the same name"); | 1319 | ubifs_err("2 xent/dent nodes with the same name"); |
1322 | else | 1320 | else |
1323 | dbg_err("bad order of colliding key %s", | 1321 | ubifs_err("bad order of colliding key %s", |
1324 | dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN)); | 1322 | dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN)); |
1325 | 1323 | ||
1326 | ubifs_msg("first node at %d:%d\n", zbr1->lnum, zbr1->offs); | 1324 | ubifs_msg("first node at %d:%d\n", zbr1->lnum, zbr1->offs); |
1327 | dbg_dump_node(c, dent1); | 1325 | ubifs_dump_node(c, dent1); |
1328 | ubifs_msg("second node at %d:%d\n", zbr2->lnum, zbr2->offs); | 1326 | ubifs_msg("second node at %d:%d\n", zbr2->lnum, zbr2->offs); |
1329 | dbg_dump_node(c, dent2); | 1327 | ubifs_dump_node(c, dent2); |
1330 | 1328 | ||
1331 | out_free: | 1329 | out_free: |
1332 | kfree(dent2); | 1330 | kfree(dent2); |
@@ -1529,10 +1527,10 @@ static int dbg_check_znode(struct ubifs_info *c, struct ubifs_zbranch *zbr) | |||
1529 | out: | 1527 | out: |
1530 | ubifs_err("failed, error %d", err); | 1528 | ubifs_err("failed, error %d", err); |
1531 | ubifs_msg("dump of the znode"); | 1529 | ubifs_msg("dump of the znode"); |
1532 | dbg_dump_znode(c, znode); | 1530 | ubifs_dump_znode(c, znode); |
1533 | if (zp) { | 1531 | if (zp) { |
1534 | ubifs_msg("dump of the parent znode"); | 1532 | ubifs_msg("dump of the parent znode"); |
1535 | dbg_dump_znode(c, zp); | 1533 | ubifs_dump_znode(c, zp); |
1536 | } | 1534 | } |
1537 | dump_stack(); | 1535 | dump_stack(); |
1538 | return -EINVAL; | 1536 | return -EINVAL; |
@@ -1599,9 +1597,9 @@ int dbg_check_tnc(struct ubifs_info *c, int extra) | |||
1599 | return err; | 1597 | return err; |
1600 | if (err) { | 1598 | if (err) { |
1601 | ubifs_msg("first znode"); | 1599 | ubifs_msg("first znode"); |
1602 | dbg_dump_znode(c, prev); | 1600 | ubifs_dump_znode(c, prev); |
1603 | ubifs_msg("second znode"); | 1601 | ubifs_msg("second znode"); |
1604 | dbg_dump_znode(c, znode); | 1602 | ubifs_dump_znode(c, znode); |
1605 | return -EINVAL; | 1603 | return -EINVAL; |
1606 | } | 1604 | } |
1607 | } | 1605 | } |
@@ -1690,7 +1688,7 @@ int dbg_walk_index(struct ubifs_info *c, dbg_leaf_callback leaf_cb, | |||
1690 | if (err) { | 1688 | if (err) { |
1691 | ubifs_err("znode checking function returned " | 1689 | ubifs_err("znode checking function returned " |
1692 | "error %d", err); | 1690 | "error %d", err); |
1693 | dbg_dump_znode(c, znode); | 1691 | ubifs_dump_znode(c, znode); |
1694 | goto out_dump; | 1692 | goto out_dump; |
1695 | } | 1693 | } |
1696 | } | 1694 | } |
@@ -1758,7 +1756,7 @@ out_dump: | |||
1758 | else | 1756 | else |
1759 | zbr = &c->zroot; | 1757 | zbr = &c->zroot; |
1760 | ubifs_msg("dump of znode at LEB %d:%d", zbr->lnum, zbr->offs); | 1758 | ubifs_msg("dump of znode at LEB %d:%d", zbr->lnum, zbr->offs); |
1761 | dbg_dump_znode(c, znode); | 1759 | ubifs_dump_znode(c, znode); |
1762 | out_unlock: | 1760 | out_unlock: |
1763 | mutex_unlock(&c->tnc_mutex); | 1761 | mutex_unlock(&c->tnc_mutex); |
1764 | return err; | 1762 | return err; |
@@ -2194,7 +2192,7 @@ out: | |||
2194 | 2192 | ||
2195 | out_dump: | 2193 | out_dump: |
2196 | ubifs_msg("dump of node at LEB %d:%d", zbr->lnum, zbr->offs); | 2194 | ubifs_msg("dump of node at LEB %d:%d", zbr->lnum, zbr->offs); |
2197 | dbg_dump_node(c, node); | 2195 | ubifs_dump_node(c, node); |
2198 | out_free: | 2196 | out_free: |
2199 | kfree(node); | 2197 | kfree(node); |
2200 | return err; | 2198 | return err; |
@@ -2352,7 +2350,7 @@ out_dump: | |||
2352 | 2350 | ||
2353 | ubifs_msg("dump of the inode %lu sitting in LEB %d:%d", | 2351 | ubifs_msg("dump of the inode %lu sitting in LEB %d:%d", |
2354 | (unsigned long)fscki->inum, zbr->lnum, zbr->offs); | 2352 | (unsigned long)fscki->inum, zbr->lnum, zbr->offs); |
2355 | dbg_dump_node(c, ino); | 2353 | ubifs_dump_node(c, ino); |
2356 | kfree(ino); | 2354 | kfree(ino); |
2357 | return -EINVAL; | 2355 | return -EINVAL; |
2358 | } | 2356 | } |
@@ -2423,12 +2421,12 @@ int dbg_check_data_nodes_order(struct ubifs_info *c, struct list_head *head) | |||
2423 | 2421 | ||
2424 | if (sa->type != UBIFS_DATA_NODE) { | 2422 | if (sa->type != UBIFS_DATA_NODE) { |
2425 | ubifs_err("bad node type %d", sa->type); | 2423 | ubifs_err("bad node type %d", sa->type); |
2426 | dbg_dump_node(c, sa->node); | 2424 | ubifs_dump_node(c, sa->node); |
2427 | return -EINVAL; | 2425 | return -EINVAL; |
2428 | } | 2426 | } |
2429 | if (sb->type != UBIFS_DATA_NODE) { | 2427 | if (sb->type != UBIFS_DATA_NODE) { |
2430 | ubifs_err("bad node type %d", sb->type); | 2428 | ubifs_err("bad node type %d", sb->type); |
2431 | dbg_dump_node(c, sb->node); | 2429 | ubifs_dump_node(c, sb->node); |
2432 | return -EINVAL; | 2430 | return -EINVAL; |
2433 | } | 2431 | } |
2434 | 2432 | ||
@@ -2459,8 +2457,8 @@ int dbg_check_data_nodes_order(struct ubifs_info *c, struct list_head *head) | |||
2459 | return 0; | 2457 | return 0; |
2460 | 2458 | ||
2461 | error_dump: | 2459 | error_dump: |
2462 | dbg_dump_node(c, sa->node); | 2460 | ubifs_dump_node(c, sa->node); |
2463 | dbg_dump_node(c, sb->node); | 2461 | ubifs_dump_node(c, sb->node); |
2464 | return -EINVAL; | 2462 | return -EINVAL; |
2465 | } | 2463 | } |
2466 | 2464 | ||
@@ -2491,13 +2489,13 @@ int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head) | |||
2491 | if (sa->type != UBIFS_INO_NODE && sa->type != UBIFS_DENT_NODE && | 2489 | if (sa->type != UBIFS_INO_NODE && sa->type != UBIFS_DENT_NODE && |
2492 | sa->type != UBIFS_XENT_NODE) { | 2490 | sa->type != UBIFS_XENT_NODE) { |
2493 | ubifs_err("bad node type %d", sa->type); | 2491 | ubifs_err("bad node type %d", sa->type); |
2494 | dbg_dump_node(c, sa->node); | 2492 | ubifs_dump_node(c, sa->node); |
2495 | return -EINVAL; | 2493 | return -EINVAL; |
2496 | } | 2494 | } |
2497 | if (sa->type != UBIFS_INO_NODE && sa->type != UBIFS_DENT_NODE && | 2495 | if (sa->type != UBIFS_INO_NODE && sa->type != UBIFS_DENT_NODE && |
2498 | sa->type != UBIFS_XENT_NODE) { | 2496 | sa->type != UBIFS_XENT_NODE) { |
2499 | ubifs_err("bad node type %d", sb->type); | 2497 | ubifs_err("bad node type %d", sb->type); |
2500 | dbg_dump_node(c, sb->node); | 2498 | ubifs_dump_node(c, sb->node); |
2501 | return -EINVAL; | 2499 | return -EINVAL; |
2502 | } | 2500 | } |
2503 | 2501 | ||
@@ -2547,9 +2545,9 @@ int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head) | |||
2547 | 2545 | ||
2548 | error_dump: | 2546 | error_dump: |
2549 | ubifs_msg("dumping first node"); | 2547 | ubifs_msg("dumping first node"); |
2550 | dbg_dump_node(c, sa->node); | 2548 | ubifs_dump_node(c, sa->node); |
2551 | ubifs_msg("dumping second node"); | 2549 | ubifs_msg("dumping second node"); |
2552 | dbg_dump_node(c, sb->node); | 2550 | ubifs_dump_node(c, sb->node); |
2553 | return -EINVAL; | 2551 | return -EINVAL; |
2554 | return 0; | 2552 | return 0; |
2555 | } | 2553 | } |
@@ -2678,7 +2676,7 @@ static void cut_data(const void *buf, unsigned int len) | |||
2678 | } | 2676 | } |
2679 | 2677 | ||
2680 | int dbg_leb_write(struct ubifs_info *c, int lnum, const void *buf, | 2678 | int dbg_leb_write(struct ubifs_info *c, int lnum, const void *buf, |
2681 | int offs, int len, int dtype) | 2679 | int offs, int len) |
2682 | { | 2680 | { |
2683 | int err, failing; | 2681 | int err, failing; |
2684 | 2682 | ||
@@ -2688,7 +2686,7 @@ int dbg_leb_write(struct ubifs_info *c, int lnum, const void *buf, | |||
2688 | failing = power_cut_emulated(c, lnum, 1); | 2686 | failing = power_cut_emulated(c, lnum, 1); |
2689 | if (failing) | 2687 | if (failing) |
2690 | cut_data(buf, len); | 2688 | cut_data(buf, len); |
2691 | err = ubi_leb_write(c->ubi, lnum, buf, offs, len, dtype); | 2689 | err = ubi_leb_write(c->ubi, lnum, buf, offs, len); |
2692 | if (err) | 2690 | if (err) |
2693 | return err; | 2691 | return err; |
2694 | if (failing) | 2692 | if (failing) |
@@ -2697,7 +2695,7 @@ int dbg_leb_write(struct ubifs_info *c, int lnum, const void *buf, | |||
2697 | } | 2695 | } |
2698 | 2696 | ||
2699 | int dbg_leb_change(struct ubifs_info *c, int lnum, const void *buf, | 2697 | int dbg_leb_change(struct ubifs_info *c, int lnum, const void *buf, |
2700 | int len, int dtype) | 2698 | int len) |
2701 | { | 2699 | { |
2702 | int err; | 2700 | int err; |
2703 | 2701 | ||
@@ -2705,7 +2703,7 @@ int dbg_leb_change(struct ubifs_info *c, int lnum, const void *buf, | |||
2705 | return -EROFS; | 2703 | return -EROFS; |
2706 | if (power_cut_emulated(c, lnum, 1)) | 2704 | if (power_cut_emulated(c, lnum, 1)) |
2707 | return -EROFS; | 2705 | return -EROFS; |
2708 | err = ubi_leb_change(c->ubi, lnum, buf, len, dtype); | 2706 | err = ubi_leb_change(c->ubi, lnum, buf, len); |
2709 | if (err) | 2707 | if (err) |
2710 | return err; | 2708 | return err; |
2711 | if (power_cut_emulated(c, lnum, 1)) | 2709 | if (power_cut_emulated(c, lnum, 1)) |
@@ -2729,7 +2727,7 @@ int dbg_leb_unmap(struct ubifs_info *c, int lnum) | |||
2729 | return 0; | 2727 | return 0; |
2730 | } | 2728 | } |
2731 | 2729 | ||
2732 | int dbg_leb_map(struct ubifs_info *c, int lnum, int dtype) | 2730 | int dbg_leb_map(struct ubifs_info *c, int lnum) |
2733 | { | 2731 | { |
2734 | int err; | 2732 | int err; |
2735 | 2733 | ||
@@ -2737,7 +2735,7 @@ int dbg_leb_map(struct ubifs_info *c, int lnum, int dtype) | |||
2737 | return -EROFS; | 2735 | return -EROFS; |
2738 | if (power_cut_emulated(c, lnum, 0)) | 2736 | if (power_cut_emulated(c, lnum, 0)) |
2739 | return -EROFS; | 2737 | return -EROFS; |
2740 | err = ubi_leb_map(c->ubi, lnum, dtype); | 2738 | err = ubi_leb_map(c->ubi, lnum); |
2741 | if (err) | 2739 | if (err) |
2742 | return err; | 2740 | return err; |
2743 | if (power_cut_emulated(c, lnum, 0)) | 2741 | if (power_cut_emulated(c, lnum, 0)) |
@@ -2857,16 +2855,16 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u, | |||
2857 | * 'ubifs-debug' file-system instead. | 2855 | * 'ubifs-debug' file-system instead. |
2858 | */ | 2856 | */ |
2859 | if (file->f_path.dentry == d->dfs_dump_lprops) { | 2857 | if (file->f_path.dentry == d->dfs_dump_lprops) { |
2860 | dbg_dump_lprops(c); | 2858 | ubifs_dump_lprops(c); |
2861 | return count; | 2859 | return count; |
2862 | } | 2860 | } |
2863 | if (file->f_path.dentry == d->dfs_dump_budg) { | 2861 | if (file->f_path.dentry == d->dfs_dump_budg) { |
2864 | dbg_dump_budg(c, &c->bi); | 2862 | ubifs_dump_budg(c, &c->bi); |
2865 | return count; | 2863 | return count; |
2866 | } | 2864 | } |
2867 | if (file->f_path.dentry == d->dfs_dump_tnc) { | 2865 | if (file->f_path.dentry == d->dfs_dump_tnc) { |
2868 | mutex_lock(&c->tnc_mutex); | 2866 | mutex_lock(&c->tnc_mutex); |
2869 | dbg_dump_tnc(c); | 2867 | ubifs_dump_tnc(c); |
2870 | mutex_unlock(&c->tnc_mutex); | 2868 | mutex_unlock(&c->tnc_mutex); |
2871 | return count; | 2869 | return count; |
2872 | } | 2870 | } |
@@ -2920,6 +2918,9 @@ int dbg_debugfs_init_fs(struct ubifs_info *c) | |||
2920 | struct dentry *dent; | 2918 | struct dentry *dent; |
2921 | struct ubifs_debug_info *d = c->dbg; | 2919 | struct ubifs_debug_info *d = c->dbg; |
2922 | 2920 | ||
2921 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) | ||
2922 | return 0; | ||
2923 | |||
2923 | n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN + 1, UBIFS_DFS_DIR_NAME, | 2924 | n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN + 1, UBIFS_DFS_DIR_NAME, |
2924 | c->vi.ubi_num, c->vi.vol_id); | 2925 | c->vi.ubi_num, c->vi.vol_id); |
2925 | if (n == UBIFS_DFS_DIR_LEN) { | 2926 | if (n == UBIFS_DFS_DIR_LEN) { |
@@ -3012,7 +3013,8 @@ out: | |||
3012 | */ | 3013 | */ |
3013 | void dbg_debugfs_exit_fs(struct ubifs_info *c) | 3014 | void dbg_debugfs_exit_fs(struct ubifs_info *c) |
3014 | { | 3015 | { |
3015 | debugfs_remove_recursive(c->dbg->dfs_dir); | 3016 | if (IS_ENABLED(CONFIG_DEBUG_FS)) |
3017 | debugfs_remove_recursive(c->dbg->dfs_dir); | ||
3016 | } | 3018 | } |
3017 | 3019 | ||
3018 | struct ubifs_global_debug_info ubifs_dbg; | 3020 | struct ubifs_global_debug_info ubifs_dbg; |
@@ -3097,6 +3099,9 @@ int dbg_debugfs_init(void) | |||
3097 | const char *fname; | 3099 | const char *fname; |
3098 | struct dentry *dent; | 3100 | struct dentry *dent; |
3099 | 3101 | ||
3102 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) | ||
3103 | return 0; | ||
3104 | |||
3100 | fname = "ubifs"; | 3105 | fname = "ubifs"; |
3101 | dent = debugfs_create_dir(fname, NULL); | 3106 | dent = debugfs_create_dir(fname, NULL); |
3102 | if (IS_ERR_OR_NULL(dent)) | 3107 | if (IS_ERR_OR_NULL(dent)) |
@@ -3161,7 +3166,8 @@ out: | |||
3161 | */ | 3166 | */ |
3162 | void dbg_debugfs_exit(void) | 3167 | void dbg_debugfs_exit(void) |
3163 | { | 3168 | { |
3164 | debugfs_remove_recursive(dfs_rootdir); | 3169 | if (IS_ENABLED(CONFIG_DEBUG_FS)) |
3170 | debugfs_remove_recursive(dfs_rootdir); | ||
3165 | } | 3171 | } |
3166 | 3172 | ||
3167 | /** | 3173 | /** |
@@ -3189,5 +3195,3 @@ void ubifs_debugging_exit(struct ubifs_info *c) | |||
3189 | { | 3195 | { |
3190 | kfree(c->dbg); | 3196 | kfree(c->dbg); |
3191 | } | 3197 | } |
3192 | |||
3193 | #endif /* CONFIG_UBIFS_FS_DEBUG */ | ||