aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/orphan.c
diff options
context:
space:
mode:
authorSheng Yong <shengyong1@huawei.com>2015-03-20 06:39:42 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2015-03-25 05:08:41 -0400
commit235c362bd0f6afcf767bc72aa0c647e1434cc631 (patch)
tree1cbc858f95877e51ddf48ea00dec0f6f7a481469 /fs/ubifs/orphan.c
parent8a87dc55f75f19ffdbb52066afea1b633577c79f (diff)
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI devices, it may be not that easy to tell which volume prints the messages. Add ubi number and volume id in ubifs_msg/warn/error to help debug. These two values are passed by struct ubifs_info. For those where ubifs_info is not initialized yet, ubifs_* is replaced by pr_*. For those where ubifs_info is not avaliable, ubifs_info is passed to the calling function as a const parameter. The output looks like, [ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696 [ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1" [ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes [ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs) [ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB) [ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model [ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699 [ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2" [ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes [ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs) [ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB) [ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model [ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6) [ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1 Signed-off-by: Sheng Yong <shengyong1@huawei.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'fs/ubifs/orphan.c')
-rw-r--r--fs/ubifs/orphan.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c
index 4409f486ecef..caf2d123e9ee 100644
--- a/fs/ubifs/orphan.c
+++ b/fs/ubifs/orphan.c
@@ -88,7 +88,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
88 else if (inum > o->inum) 88 else if (inum > o->inum)
89 p = &(*p)->rb_right; 89 p = &(*p)->rb_right;
90 else { 90 else {
91 ubifs_err("orphaned twice"); 91 ubifs_err(c, "orphaned twice");
92 spin_unlock(&c->orphan_lock); 92 spin_unlock(&c->orphan_lock);
93 kfree(orphan); 93 kfree(orphan);
94 return 0; 94 return 0;
@@ -155,7 +155,7 @@ void ubifs_delete_orphan(struct ubifs_info *c, ino_t inum)
155 } 155 }
156 } 156 }
157 spin_unlock(&c->orphan_lock); 157 spin_unlock(&c->orphan_lock);
158 ubifs_err("missing orphan ino %lu", (unsigned long)inum); 158 ubifs_err(c, "missing orphan ino %lu", (unsigned long)inum);
159 dump_stack(); 159 dump_stack();
160} 160}
161 161
@@ -287,7 +287,7 @@ static int write_orph_node(struct ubifs_info *c, int atomic)
287 * We limit the number of orphans so that this should 287 * We limit the number of orphans so that this should
288 * never happen. 288 * never happen.
289 */ 289 */
290 ubifs_err("out of space in orphan area"); 290 ubifs_err(c, "out of space in orphan area");
291 return -EINVAL; 291 return -EINVAL;
292 } 292 }
293 } 293 }
@@ -397,7 +397,7 @@ static int consolidate(struct ubifs_info *c)
397 * We limit the number of orphans so that this should 397 * We limit the number of orphans so that this should
398 * never happen. 398 * never happen.
399 */ 399 */
400 ubifs_err("out of space in orphan area"); 400 ubifs_err(c, "out of space in orphan area");
401 err = -EINVAL; 401 err = -EINVAL;
402 } 402 }
403 spin_unlock(&c->orphan_lock); 403 spin_unlock(&c->orphan_lock);
@@ -569,7 +569,7 @@ static int do_kill_orphans(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
569 569
570 list_for_each_entry(snod, &sleb->nodes, list) { 570 list_for_each_entry(snod, &sleb->nodes, list) {
571 if (snod->type != UBIFS_ORPH_NODE) { 571 if (snod->type != UBIFS_ORPH_NODE) {
572 ubifs_err("invalid node type %d in orphan area at %d:%d", 572 ubifs_err(c, "invalid node type %d in orphan area at %d:%d",
573 snod->type, sleb->lnum, snod->offs); 573 snod->type, sleb->lnum, snod->offs);
574 ubifs_dump_node(c, snod->node); 574 ubifs_dump_node(c, snod->node);
575 return -EINVAL; 575 return -EINVAL;
@@ -596,7 +596,7 @@ static int do_kill_orphans(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
596 * number. That makes this orphan node, out of date. 596 * number. That makes this orphan node, out of date.
597 */ 597 */
598 if (!first) { 598 if (!first) {
599 ubifs_err("out of order commit number %llu in orphan node at %d:%d", 599 ubifs_err(c, "out of order commit number %llu in orphan node at %d:%d",
600 cmt_no, sleb->lnum, snod->offs); 600 cmt_no, sleb->lnum, snod->offs);
601 ubifs_dump_node(c, snod->node); 601 ubifs_dump_node(c, snod->node);
602 return -EINVAL; 602 return -EINVAL;
@@ -831,20 +831,20 @@ static int dbg_orphan_check(struct ubifs_info *c, struct ubifs_zbranch *zbr,
831 if (inum != ci->last_ino) { 831 if (inum != ci->last_ino) {
832 /* Lowest node type is the inode node, so it comes first */ 832 /* Lowest node type is the inode node, so it comes first */
833 if (key_type(c, &zbr->key) != UBIFS_INO_KEY) 833 if (key_type(c, &zbr->key) != UBIFS_INO_KEY)
834 ubifs_err("found orphan node ino %lu, type %d", 834 ubifs_err(c, "found orphan node ino %lu, type %d",
835 (unsigned long)inum, key_type(c, &zbr->key)); 835 (unsigned long)inum, key_type(c, &zbr->key));
836 ci->last_ino = inum; 836 ci->last_ino = inum;
837 ci->tot_inos += 1; 837 ci->tot_inos += 1;
838 err = ubifs_tnc_read_node(c, zbr, ci->node); 838 err = ubifs_tnc_read_node(c, zbr, ci->node);
839 if (err) { 839 if (err) {
840 ubifs_err("node read failed, error %d", err); 840 ubifs_err(c, "node read failed, error %d", err);
841 return err; 841 return err;
842 } 842 }
843 if (ci->node->nlink == 0) 843 if (ci->node->nlink == 0)
844 /* Must be recorded as an orphan */ 844 /* Must be recorded as an orphan */
845 if (!dbg_find_check_orphan(&ci->root, inum) && 845 if (!dbg_find_check_orphan(&ci->root, inum) &&
846 !dbg_find_orphan(c, inum)) { 846 !dbg_find_orphan(c, inum)) {
847 ubifs_err("missing orphan, ino %lu", 847 ubifs_err(c, "missing orphan, ino %lu",
848 (unsigned long)inum); 848 (unsigned long)inum);
849 ci->missing += 1; 849 ci->missing += 1;
850 } 850 }
@@ -887,7 +887,7 @@ static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci)
887 887
888 buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); 888 buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
889 if (!buf) { 889 if (!buf) {
890 ubifs_err("cannot allocate memory to check orphans"); 890 ubifs_err(c, "cannot allocate memory to check orphans");
891 return 0; 891 return 0;
892 } 892 }
893 893
@@ -925,7 +925,7 @@ static int dbg_check_orphans(struct ubifs_info *c)
925 ci.root = RB_ROOT; 925 ci.root = RB_ROOT;
926 ci.node = kmalloc(UBIFS_MAX_INO_NODE_SZ, GFP_NOFS); 926 ci.node = kmalloc(UBIFS_MAX_INO_NODE_SZ, GFP_NOFS);
927 if (!ci.node) { 927 if (!ci.node) {
928 ubifs_err("out of memory"); 928 ubifs_err(c, "out of memory");
929 return -ENOMEM; 929 return -ENOMEM;
930 } 930 }
931 931
@@ -935,12 +935,12 @@ static int dbg_check_orphans(struct ubifs_info *c)
935 935
936 err = dbg_walk_index(c, &dbg_orphan_check, NULL, &ci); 936 err = dbg_walk_index(c, &dbg_orphan_check, NULL, &ci);
937 if (err) { 937 if (err) {
938 ubifs_err("cannot scan TNC, error %d", err); 938 ubifs_err(c, "cannot scan TNC, error %d", err);
939 goto out; 939 goto out;
940 } 940 }
941 941
942 if (ci.missing) { 942 if (ci.missing) {
943 ubifs_err("%lu missing orphan(s)", ci.missing); 943 ubifs_err(c, "%lu missing orphan(s)", ci.missing);
944 err = -EINVAL; 944 err = -EINVAL;
945 goto out; 945 goto out;
946 } 946 }