aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/tnc_misc.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/tnc_misc.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/tnc_misc.c')
-rw-r--r--fs/ubifs/tnc_misc.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c
index f6bf8995c7b1..93f5b7859e6f 100644
--- a/fs/ubifs/tnc_misc.c
+++ b/fs/ubifs/tnc_misc.c
@@ -293,9 +293,9 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
293 lnum, offs, znode->level, znode->child_cnt); 293 lnum, offs, znode->level, znode->child_cnt);
294 294
295 if (znode->child_cnt > c->fanout || znode->level > UBIFS_MAX_LEVELS) { 295 if (znode->child_cnt > c->fanout || znode->level > UBIFS_MAX_LEVELS) {
296 ubifs_err("current fanout %d, branch count %d", 296 ubifs_err(c, "current fanout %d, branch count %d",
297 c->fanout, znode->child_cnt); 297 c->fanout, znode->child_cnt);
298 ubifs_err("max levels %d, znode level %d", 298 ubifs_err(c, "max levels %d, znode level %d",
299 UBIFS_MAX_LEVELS, znode->level); 299 UBIFS_MAX_LEVELS, znode->level);
300 err = 1; 300 err = 1;
301 goto out_dump; 301 goto out_dump;
@@ -316,7 +316,7 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
316 if (zbr->lnum < c->main_first || 316 if (zbr->lnum < c->main_first ||
317 zbr->lnum >= c->leb_cnt || zbr->offs < 0 || 317 zbr->lnum >= c->leb_cnt || zbr->offs < 0 ||
318 zbr->offs + zbr->len > c->leb_size || zbr->offs & 7) { 318 zbr->offs + zbr->len > c->leb_size || zbr->offs & 7) {
319 ubifs_err("bad branch %d", i); 319 ubifs_err(c, "bad branch %d", i);
320 err = 2; 320 err = 2;
321 goto out_dump; 321 goto out_dump;
322 } 322 }
@@ -328,7 +328,7 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
328 case UBIFS_XENT_KEY: 328 case UBIFS_XENT_KEY:
329 break; 329 break;
330 default: 330 default:
331 ubifs_err("bad key type at slot %d: %d", 331 ubifs_err(c, "bad key type at slot %d: %d",
332 i, key_type(c, &zbr->key)); 332 i, key_type(c, &zbr->key));
333 err = 3; 333 err = 3;
334 goto out_dump; 334 goto out_dump;
@@ -340,17 +340,17 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
340 type = key_type(c, &zbr->key); 340 type = key_type(c, &zbr->key);
341 if (c->ranges[type].max_len == 0) { 341 if (c->ranges[type].max_len == 0) {
342 if (zbr->len != c->ranges[type].len) { 342 if (zbr->len != c->ranges[type].len) {
343 ubifs_err("bad target node (type %d) length (%d)", 343 ubifs_err(c, "bad target node (type %d) length (%d)",
344 type, zbr->len); 344 type, zbr->len);
345 ubifs_err("have to be %d", c->ranges[type].len); 345 ubifs_err(c, "have to be %d", c->ranges[type].len);
346 err = 4; 346 err = 4;
347 goto out_dump; 347 goto out_dump;
348 } 348 }
349 } else if (zbr->len < c->ranges[type].min_len || 349 } else if (zbr->len < c->ranges[type].min_len ||
350 zbr->len > c->ranges[type].max_len) { 350 zbr->len > c->ranges[type].max_len) {
351 ubifs_err("bad target node (type %d) length (%d)", 351 ubifs_err(c, "bad target node (type %d) length (%d)",
352 type, zbr->len); 352 type, zbr->len);
353 ubifs_err("have to be in range of %d-%d", 353 ubifs_err(c, "have to be in range of %d-%d",
354 c->ranges[type].min_len, 354 c->ranges[type].min_len,
355 c->ranges[type].max_len); 355 c->ranges[type].max_len);
356 err = 5; 356 err = 5;
@@ -370,12 +370,12 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
370 370
371 cmp = keys_cmp(c, key1, key2); 371 cmp = keys_cmp(c, key1, key2);
372 if (cmp > 0) { 372 if (cmp > 0) {
373 ubifs_err("bad key order (keys %d and %d)", i, i + 1); 373 ubifs_err(c, "bad key order (keys %d and %d)", i, i + 1);
374 err = 6; 374 err = 6;
375 goto out_dump; 375 goto out_dump;
376 } else if (cmp == 0 && !is_hash_key(c, key1)) { 376 } else if (cmp == 0 && !is_hash_key(c, key1)) {
377 /* These can only be keys with colliding hash */ 377 /* These can only be keys with colliding hash */
378 ubifs_err("keys %d and %d are not hashed but equivalent", 378 ubifs_err(c, "keys %d and %d are not hashed but equivalent",
379 i, i + 1); 379 i, i + 1);
380 err = 7; 380 err = 7;
381 goto out_dump; 381 goto out_dump;
@@ -386,7 +386,7 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
386 return 0; 386 return 0;
387 387
388out_dump: 388out_dump:
389 ubifs_err("bad indexing node at LEB %d:%d, error %d", lnum, offs, err); 389 ubifs_err(c, "bad indexing node at LEB %d:%d, error %d", lnum, offs, err);
390 ubifs_dump_node(c, idx); 390 ubifs_dump_node(c, idx);
391 kfree(idx); 391 kfree(idx);
392 return -EINVAL; 392 return -EINVAL;
@@ -482,7 +482,7 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
482 /* Make sure the key of the read node is correct */ 482 /* Make sure the key of the read node is correct */
483 key_read(c, node + UBIFS_KEY_OFFSET, &key1); 483 key_read(c, node + UBIFS_KEY_OFFSET, &key1);
484 if (!keys_eq(c, key, &key1)) { 484 if (!keys_eq(c, key, &key1)) {
485 ubifs_err("bad key in node at LEB %d:%d", 485 ubifs_err(c, "bad key in node at LEB %d:%d",
486 zbr->lnum, zbr->offs); 486 zbr->lnum, zbr->offs);
487 dbg_tnck(key, "looked for key "); 487 dbg_tnck(key, "looked for key ");
488 dbg_tnck(&key1, "but found node's key "); 488 dbg_tnck(&key1, "but found node's key ");