diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-10-17 06:31:39 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-12-03 06:14:33 -0500 |
commit | 17c2f9f85c896b48a5d74a9155d99ec5b241a0e6 (patch) | |
tree | 9d3e38e673d1d3af650072388a671ec767d3941a /fs | |
parent | 5dd7cbc083f3a91fa7454125fe992826701b67bc (diff) |
UBIFS: separate debugging fields out
Introduce a new data structure which contains all debugging
stuff inside. This is cleaner than having debugging stuff
directly in 'c'.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ubifs/commit.c | 25 | ||||
-rw-r--r-- | fs/ubifs/debug.c | 71 | ||||
-rw-r--r-- | fs/ubifs/debug.h | 51 | ||||
-rw-r--r-- | fs/ubifs/lprops.c | 2 | ||||
-rw-r--r-- | fs/ubifs/lpt_commit.c | 55 | ||||
-rw-r--r-- | fs/ubifs/orphan.c | 2 | ||||
-rw-r--r-- | fs/ubifs/super.c | 22 | ||||
-rw-r--r-- | fs/ubifs/tnc_commit.c | 7 | ||||
-rw-r--r-- | fs/ubifs/ubifs.h | 34 |
9 files changed, 156 insertions, 113 deletions
diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c index b49884c8c10e..f3a7945527fb 100644 --- a/fs/ubifs/commit.c +++ b/fs/ubifs/commit.c | |||
@@ -470,12 +470,12 @@ int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot) | |||
470 | { | 470 | { |
471 | struct ubifs_idx_node *idx; | 471 | struct ubifs_idx_node *idx; |
472 | int lnum, offs, len, err = 0; | 472 | int lnum, offs, len, err = 0; |
473 | struct ubifs_debug_info *d = c->dbg; | ||
473 | 474 | ||
474 | c->old_zroot = *zroot; | 475 | d->old_zroot = *zroot; |
475 | 476 | lnum = d->old_zroot.lnum; | |
476 | lnum = c->old_zroot.lnum; | 477 | offs = d->old_zroot.offs; |
477 | offs = c->old_zroot.offs; | 478 | len = d->old_zroot.len; |
478 | len = c->old_zroot.len; | ||
479 | 479 | ||
480 | idx = kmalloc(c->max_idx_node_sz, GFP_NOFS); | 480 | idx = kmalloc(c->max_idx_node_sz, GFP_NOFS); |
481 | if (!idx) | 481 | if (!idx) |
@@ -485,8 +485,8 @@ int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot) | |||
485 | if (err) | 485 | if (err) |
486 | goto out; | 486 | goto out; |
487 | 487 | ||
488 | c->old_zroot_level = le16_to_cpu(idx->level); | 488 | d->old_zroot_level = le16_to_cpu(idx->level); |
489 | c->old_zroot_sqnum = le64_to_cpu(idx->ch.sqnum); | 489 | d->old_zroot_sqnum = le64_to_cpu(idx->ch.sqnum); |
490 | out: | 490 | out: |
491 | kfree(idx); | 491 | kfree(idx); |
492 | return err; | 492 | return err; |
@@ -509,6 +509,7 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot) | |||
509 | { | 509 | { |
510 | int lnum, offs, len, err = 0, uninitialized_var(last_level), child_cnt; | 510 | int lnum, offs, len, err = 0, uninitialized_var(last_level), child_cnt; |
511 | int first = 1, iip; | 511 | int first = 1, iip; |
512 | struct ubifs_debug_info *d = c->dbg; | ||
512 | union ubifs_key lower_key, upper_key, l_key, u_key; | 513 | union ubifs_key lower_key, upper_key, l_key, u_key; |
513 | unsigned long long uninitialized_var(last_sqnum); | 514 | unsigned long long uninitialized_var(last_sqnum); |
514 | struct ubifs_idx_node *idx; | 515 | struct ubifs_idx_node *idx; |
@@ -525,9 +526,9 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot) | |||
525 | UBIFS_IDX_NODE_SZ; | 526 | UBIFS_IDX_NODE_SZ; |
526 | 527 | ||
527 | /* Start at the old zroot */ | 528 | /* Start at the old zroot */ |
528 | lnum = c->old_zroot.lnum; | 529 | lnum = d->old_zroot.lnum; |
529 | offs = c->old_zroot.offs; | 530 | offs = d->old_zroot.offs; |
530 | len = c->old_zroot.len; | 531 | len = d->old_zroot.len; |
531 | iip = 0; | 532 | iip = 0; |
532 | 533 | ||
533 | /* | 534 | /* |
@@ -560,11 +561,11 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot) | |||
560 | if (first) { | 561 | if (first) { |
561 | first = 0; | 562 | first = 0; |
562 | /* Check root level and sqnum */ | 563 | /* Check root level and sqnum */ |
563 | if (le16_to_cpu(idx->level) != c->old_zroot_level) { | 564 | if (le16_to_cpu(idx->level) != d->old_zroot_level) { |
564 | err = 2; | 565 | err = 2; |
565 | goto out_dump; | 566 | goto out_dump; |
566 | } | 567 | } |
567 | if (le64_to_cpu(idx->ch.sqnum) != c->old_zroot_sqnum) { | 568 | if (le64_to_cpu(idx->ch.sqnum) != d->old_zroot_sqnum) { |
568 | err = 3; | 569 | err = 3; |
569 | goto out_dump; | 570 | goto out_dump; |
570 | } | 571 | } |
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 510ffa0bbda4..0332a856a082 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -705,7 +705,7 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum) | |||
705 | 705 | ||
706 | printk(KERN_DEBUG "(pid %d) Dumping LEB %d\n", current->pid, lnum); | 706 | printk(KERN_DEBUG "(pid %d) Dumping LEB %d\n", current->pid, lnum); |
707 | 707 | ||
708 | sleb = ubifs_scan(c, lnum, 0, c->dbg_buf); | 708 | sleb = ubifs_scan(c, lnum, 0, c->dbg->buf); |
709 | if (IS_ERR(sleb)) { | 709 | if (IS_ERR(sleb)) { |
710 | ubifs_err("scan error %d", (int)PTR_ERR(sleb)); | 710 | ubifs_err("scan error %d", (int)PTR_ERR(sleb)); |
711 | return; | 711 | return; |
@@ -2097,7 +2097,7 @@ static int simple_rand(void) | |||
2097 | return (next >> 16) & 32767; | 2097 | return (next >> 16) & 32767; |
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | void dbg_failure_mode_registration(struct ubifs_info *c) | 2100 | static void failure_mode_init(struct ubifs_info *c) |
2101 | { | 2101 | { |
2102 | struct failure_mode_info *fmi; | 2102 | struct failure_mode_info *fmi; |
2103 | 2103 | ||
@@ -2112,7 +2112,7 @@ void dbg_failure_mode_registration(struct ubifs_info *c) | |||
2112 | spin_unlock(&fmi_lock); | 2112 | spin_unlock(&fmi_lock); |
2113 | } | 2113 | } |
2114 | 2114 | ||
2115 | void dbg_failure_mode_deregistration(struct ubifs_info *c) | 2115 | static void failure_mode_exit(struct ubifs_info *c) |
2116 | { | 2116 | { |
2117 | struct failure_mode_info *fmi, *tmp; | 2117 | struct failure_mode_info *fmi, *tmp; |
2118 | 2118 | ||
@@ -2146,42 +2146,44 @@ static int in_failure_mode(struct ubi_volume_desc *desc) | |||
2146 | struct ubifs_info *c = dbg_find_info(desc); | 2146 | struct ubifs_info *c = dbg_find_info(desc); |
2147 | 2147 | ||
2148 | if (c && dbg_failure_mode) | 2148 | if (c && dbg_failure_mode) |
2149 | return c->failure_mode; | 2149 | return c->dbg->failure_mode; |
2150 | return 0; | 2150 | return 0; |
2151 | } | 2151 | } |
2152 | 2152 | ||
2153 | static int do_fail(struct ubi_volume_desc *desc, int lnum, int write) | 2153 | static int do_fail(struct ubi_volume_desc *desc, int lnum, int write) |
2154 | { | 2154 | { |
2155 | struct ubifs_info *c = dbg_find_info(desc); | 2155 | struct ubifs_info *c = dbg_find_info(desc); |
2156 | struct ubifs_debug_info *d; | ||
2156 | 2157 | ||
2157 | if (!c || !dbg_failure_mode) | 2158 | if (!c || !dbg_failure_mode) |
2158 | return 0; | 2159 | return 0; |
2159 | if (c->failure_mode) | 2160 | d = c->dbg; |
2161 | if (d->failure_mode) | ||
2160 | return 1; | 2162 | return 1; |
2161 | if (!c->fail_cnt) { | 2163 | if (!d->fail_cnt) { |
2162 | /* First call - decide delay to failure */ | 2164 | /* First call - decide delay to failure */ |
2163 | if (chance(1, 2)) { | 2165 | if (chance(1, 2)) { |
2164 | unsigned int delay = 1 << (simple_rand() >> 11); | 2166 | unsigned int delay = 1 << (simple_rand() >> 11); |
2165 | 2167 | ||
2166 | if (chance(1, 2)) { | 2168 | if (chance(1, 2)) { |
2167 | c->fail_delay = 1; | 2169 | d->fail_delay = 1; |
2168 | c->fail_timeout = jiffies + | 2170 | d->fail_timeout = jiffies + |
2169 | msecs_to_jiffies(delay); | 2171 | msecs_to_jiffies(delay); |
2170 | dbg_rcvry("failing after %ums", delay); | 2172 | dbg_rcvry("failing after %ums", delay); |
2171 | } else { | 2173 | } else { |
2172 | c->fail_delay = 2; | 2174 | d->fail_delay = 2; |
2173 | c->fail_cnt_max = delay; | 2175 | d->fail_cnt_max = delay; |
2174 | dbg_rcvry("failing after %u calls", delay); | 2176 | dbg_rcvry("failing after %u calls", delay); |
2175 | } | 2177 | } |
2176 | } | 2178 | } |
2177 | c->fail_cnt += 1; | 2179 | d->fail_cnt += 1; |
2178 | } | 2180 | } |
2179 | /* Determine if failure delay has expired */ | 2181 | /* Determine if failure delay has expired */ |
2180 | if (c->fail_delay == 1) { | 2182 | if (d->fail_delay == 1) { |
2181 | if (time_before(jiffies, c->fail_timeout)) | 2183 | if (time_before(jiffies, d->fail_timeout)) |
2182 | return 0; | 2184 | return 0; |
2183 | } else if (c->fail_delay == 2) | 2185 | } else if (d->fail_delay == 2) |
2184 | if (c->fail_cnt++ < c->fail_cnt_max) | 2186 | if (d->fail_cnt++ < d->fail_cnt_max) |
2185 | return 0; | 2187 | return 0; |
2186 | if (lnum == UBIFS_SB_LNUM) { | 2188 | if (lnum == UBIFS_SB_LNUM) { |
2187 | if (write) { | 2189 | if (write) { |
@@ -2239,7 +2241,7 @@ static int do_fail(struct ubi_volume_desc *desc, int lnum, int write) | |||
2239 | dbg_rcvry("failing in bud LEB %d commit not running", lnum); | 2241 | dbg_rcvry("failing in bud LEB %d commit not running", lnum); |
2240 | } | 2242 | } |
2241 | ubifs_err("*** SETTING FAILURE MODE ON (LEB %d) ***", lnum); | 2243 | ubifs_err("*** SETTING FAILURE MODE ON (LEB %d) ***", lnum); |
2242 | c->failure_mode = 1; | 2244 | d->failure_mode = 1; |
2243 | dump_stack(); | 2245 | dump_stack(); |
2244 | return 1; | 2246 | return 1; |
2245 | } | 2247 | } |
@@ -2344,4 +2346,41 @@ int dbg_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype) | |||
2344 | return 0; | 2346 | return 0; |
2345 | } | 2347 | } |
2346 | 2348 | ||
2349 | /** | ||
2350 | * ubifs_debugging_init - initialize UBIFS debugging. | ||
2351 | * @c: UBIFS file-system description object | ||
2352 | * | ||
2353 | * This function initializes debugging-related data for the file system. | ||
2354 | * Returns zero in case of success and a negative error code in case of | ||
2355 | * failure. | ||
2356 | */ | ||
2357 | int ubifs_debugging_init(struct ubifs_info *c) | ||
2358 | { | ||
2359 | c->dbg = kzalloc(sizeof(struct ubifs_debug_info), GFP_KERNEL); | ||
2360 | if (!c->dbg) | ||
2361 | return -ENOMEM; | ||
2362 | |||
2363 | c->dbg->buf = vmalloc(c->leb_size); | ||
2364 | if (!c->dbg->buf) | ||
2365 | goto out; | ||
2366 | |||
2367 | failure_mode_init(c); | ||
2368 | return 0; | ||
2369 | |||
2370 | out: | ||
2371 | kfree(c->dbg); | ||
2372 | return -ENOMEM; | ||
2373 | } | ||
2374 | |||
2375 | /** | ||
2376 | * ubifs_debugging_exit - free debugging data. | ||
2377 | * @c: UBIFS file-system description object | ||
2378 | */ | ||
2379 | void ubifs_debugging_exit(struct ubifs_info *c) | ||
2380 | { | ||
2381 | failure_mode_exit(c); | ||
2382 | vfree(c->dbg->buf); | ||
2383 | kfree(c->dbg); | ||
2384 | } | ||
2385 | |||
2347 | #endif /* CONFIG_UBIFS_FS_DEBUG */ | 2386 | #endif /* CONFIG_UBIFS_FS_DEBUG */ |
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h index 33d6b95071e4..d6ea1362d56a 100644 --- a/fs/ubifs/debug.h +++ b/fs/ubifs/debug.h | |||
@@ -25,7 +25,43 @@ | |||
25 | 25 | ||
26 | #ifdef CONFIG_UBIFS_FS_DEBUG | 26 | #ifdef CONFIG_UBIFS_FS_DEBUG |
27 | 27 | ||
28 | #define UBIFS_DBG(op) op | 28 | /** |
29 | * ubifs_debug_info - per-FS debugging information. | ||
30 | * @buf: a buffer of LEB size, used for various purposes | ||
31 | * @old_zroot: old index root - used by 'dbg_check_old_index()' | ||
32 | * @old_zroot_level: old index root level - used by 'dbg_check_old_index()' | ||
33 | * @old_zroot_sqnum: old index root sqnum - used by 'dbg_check_old_index()' | ||
34 | * @failure_mode: failure mode for recovery testing | ||
35 | * @fail_delay: 0=>don't delay, 1=>delay a time, 2=>delay a number of calls | ||
36 | * @fail_timeout: time in jiffies when delay of failure mode expires | ||
37 | * @fail_cnt: current number of calls to failure mode I/O functions | ||
38 | * @fail_cnt_max: number of calls by which to delay failure mode | ||
39 | * @chk_lpt_sz: used by LPT tree size checker | ||
40 | * @chk_lpt_sz2: used by LPT tree size checker | ||
41 | * @chk_lpt_wastage: used by LPT tree size checker | ||
42 | * @chk_lpt_lebs: used by LPT tree size checker | ||
43 | * @new_nhead_offs: used by LPT tree size checker | ||
44 | * @new_ihead_lnum: used by debugging to check ihead_lnum | ||
45 | * @new_ihead_offs: used by debugging to check ihead_offs | ||
46 | */ | ||
47 | struct ubifs_debug_info { | ||
48 | void *buf; | ||
49 | struct ubifs_zbranch old_zroot; | ||
50 | int old_zroot_level; | ||
51 | unsigned long long old_zroot_sqnum; | ||
52 | int failure_mode; | ||
53 | int fail_delay; | ||
54 | unsigned long fail_timeout; | ||
55 | unsigned int fail_cnt; | ||
56 | unsigned int fail_cnt_max; | ||
57 | long long chk_lpt_sz; | ||
58 | long long chk_lpt_sz2; | ||
59 | long long chk_lpt_wastage; | ||
60 | int chk_lpt_lebs; | ||
61 | int new_nhead_offs; | ||
62 | int new_ihead_lnum; | ||
63 | int new_ihead_offs; | ||
64 | }; | ||
29 | 65 | ||
30 | #define ubifs_assert(expr) do { \ | 66 | #define ubifs_assert(expr) do { \ |
31 | if (unlikely(!(expr))) { \ | 67 | if (unlikely(!(expr))) { \ |
@@ -211,6 +247,9 @@ extern unsigned int ubifs_msg_flags; | |||
211 | extern unsigned int ubifs_chk_flags; | 247 | extern unsigned int ubifs_chk_flags; |
212 | extern unsigned int ubifs_tst_flags; | 248 | extern unsigned int ubifs_tst_flags; |
213 | 249 | ||
250 | int ubifs_debugging_init(struct ubifs_info *c); | ||
251 | void ubifs_debugging_exit(struct ubifs_info *c); | ||
252 | |||
214 | /* Dump functions */ | 253 | /* Dump functions */ |
215 | 254 | ||
216 | const char *dbg_ntype(int type); | 255 | const char *dbg_ntype(int type); |
@@ -274,9 +313,6 @@ int dbg_force_in_the_gaps(void); | |||
274 | 313 | ||
275 | #define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY) | 314 | #define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY) |
276 | 315 | ||
277 | void dbg_failure_mode_registration(struct ubifs_info *c); | ||
278 | void dbg_failure_mode_deregistration(struct ubifs_info *c); | ||
279 | |||
280 | #ifndef UBIFS_DBG_PRESERVE_UBI | 316 | #ifndef UBIFS_DBG_PRESERVE_UBI |
281 | 317 | ||
282 | #define ubi_leb_read dbg_leb_read | 318 | #define ubi_leb_read dbg_leb_read |
@@ -320,8 +356,6 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum, | |||
320 | 356 | ||
321 | #else /* !CONFIG_UBIFS_FS_DEBUG */ | 357 | #else /* !CONFIG_UBIFS_FS_DEBUG */ |
322 | 358 | ||
323 | #define UBIFS_DBG(op) | ||
324 | |||
325 | /* Use "if (0)" to make compiler check arguments even if debugging is off */ | 359 | /* Use "if (0)" to make compiler check arguments even if debugging is off */ |
326 | #define ubifs_assert(expr) do { \ | 360 | #define ubifs_assert(expr) do { \ |
327 | if (0 && (expr)) \ | 361 | if (0 && (expr)) \ |
@@ -360,6 +394,9 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum, | |||
360 | #define DBGKEY(key) ((char *)(key)) | 394 | #define DBGKEY(key) ((char *)(key)) |
361 | #define DBGKEY1(key) ((char *)(key)) | 395 | #define DBGKEY1(key) ((char *)(key)) |
362 | 396 | ||
397 | #define ubifs_debugging_init(c) 0 | ||
398 | #define ubifs_debugging_exit(c) ({}) | ||
399 | |||
363 | #define dbg_ntype(type) "" | 400 | #define dbg_ntype(type) "" |
364 | #define dbg_cstate(cmt_state) "" | 401 | #define dbg_cstate(cmt_state) "" |
365 | #define dbg_get_key_dump(c, key) ({}) | 402 | #define dbg_get_key_dump(c, key) ({}) |
@@ -396,8 +433,6 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum, | |||
396 | #define dbg_force_in_the_gaps_enabled 0 | 433 | #define dbg_force_in_the_gaps_enabled 0 |
397 | #define dbg_force_in_the_gaps() 0 | 434 | #define dbg_force_in_the_gaps() 0 |
398 | #define dbg_failure_mode 0 | 435 | #define dbg_failure_mode 0 |
399 | #define dbg_failure_mode_registration(c) ({}) | ||
400 | #define dbg_failure_mode_deregistration(c) ({}) | ||
401 | 436 | ||
402 | #endif /* !CONFIG_UBIFS_FS_DEBUG */ | 437 | #endif /* !CONFIG_UBIFS_FS_DEBUG */ |
403 | 438 | ||
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c index f27176e9b70d..10ba663eb329 100644 --- a/fs/ubifs/lprops.c +++ b/fs/ubifs/lprops.c | |||
@@ -1088,7 +1088,7 @@ static int scan_check_cb(struct ubifs_info *c, | |||
1088 | } | 1088 | } |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | sleb = ubifs_scan(c, lnum, 0, c->dbg_buf); | 1091 | sleb = ubifs_scan(c, lnum, 0, c->dbg->buf); |
1092 | if (IS_ERR(sleb)) { | 1092 | if (IS_ERR(sleb)) { |
1093 | /* | 1093 | /* |
1094 | * After an unclean unmount, empty and freeable LEBs | 1094 | * After an unclean unmount, empty and freeable LEBs |
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index a41434b42785..1aefab9f0b5e 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c | |||
@@ -1602,7 +1602,7 @@ static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum) | |||
1602 | { | 1602 | { |
1603 | int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len; | 1603 | int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len; |
1604 | int ret; | 1604 | int ret; |
1605 | void *buf = c->dbg_buf; | 1605 | void *buf = c->dbg->buf; |
1606 | 1606 | ||
1607 | dbg_lp("LEB %d", lnum); | 1607 | dbg_lp("LEB %d", lnum); |
1608 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); | 1608 | err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); |
@@ -1731,15 +1731,16 @@ int dbg_chk_lpt_free_spc(struct ubifs_info *c) | |||
1731 | */ | 1731 | */ |
1732 | int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) | 1732 | int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) |
1733 | { | 1733 | { |
1734 | struct ubifs_debug_info *d = c->dbg; | ||
1734 | long long chk_lpt_sz, lpt_sz; | 1735 | long long chk_lpt_sz, lpt_sz; |
1735 | int err = 0; | 1736 | int err = 0; |
1736 | 1737 | ||
1737 | switch (action) { | 1738 | switch (action) { |
1738 | case 0: | 1739 | case 0: |
1739 | c->chk_lpt_sz = 0; | 1740 | d->chk_lpt_sz = 0; |
1740 | c->chk_lpt_sz2 = 0; | 1741 | d->chk_lpt_sz2 = 0; |
1741 | c->chk_lpt_lebs = 0; | 1742 | d->chk_lpt_lebs = 0; |
1742 | c->chk_lpt_wastage = 0; | 1743 | d->chk_lpt_wastage = 0; |
1743 | if (c->dirty_pn_cnt > c->pnode_cnt) { | 1744 | if (c->dirty_pn_cnt > c->pnode_cnt) { |
1744 | dbg_err("dirty pnodes %d exceed max %d", | 1745 | dbg_err("dirty pnodes %d exceed max %d", |
1745 | c->dirty_pn_cnt, c->pnode_cnt); | 1746 | c->dirty_pn_cnt, c->pnode_cnt); |
@@ -1752,35 +1753,35 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) | |||
1752 | } | 1753 | } |
1753 | return err; | 1754 | return err; |
1754 | case 1: | 1755 | case 1: |
1755 | c->chk_lpt_sz += len; | 1756 | d->chk_lpt_sz += len; |
1756 | return 0; | 1757 | return 0; |
1757 | case 2: | 1758 | case 2: |
1758 | c->chk_lpt_sz += len; | 1759 | d->chk_lpt_sz += len; |
1759 | c->chk_lpt_wastage += len; | 1760 | d->chk_lpt_wastage += len; |
1760 | c->chk_lpt_lebs += 1; | 1761 | d->chk_lpt_lebs += 1; |
1761 | return 0; | 1762 | return 0; |
1762 | case 3: | 1763 | case 3: |
1763 | chk_lpt_sz = c->leb_size; | 1764 | chk_lpt_sz = c->leb_size; |
1764 | chk_lpt_sz *= c->chk_lpt_lebs; | 1765 | chk_lpt_sz *= d->chk_lpt_lebs; |
1765 | chk_lpt_sz += len - c->nhead_offs; | 1766 | chk_lpt_sz += len - c->nhead_offs; |
1766 | if (c->chk_lpt_sz != chk_lpt_sz) { | 1767 | if (d->chk_lpt_sz != chk_lpt_sz) { |
1767 | dbg_err("LPT wrote %lld but space used was %lld", | 1768 | dbg_err("LPT wrote %lld but space used was %lld", |
1768 | c->chk_lpt_sz, chk_lpt_sz); | 1769 | d->chk_lpt_sz, chk_lpt_sz); |
1769 | err = -EINVAL; | 1770 | err = -EINVAL; |
1770 | } | 1771 | } |
1771 | if (c->chk_lpt_sz > c->lpt_sz) { | 1772 | if (d->chk_lpt_sz > c->lpt_sz) { |
1772 | dbg_err("LPT wrote %lld but lpt_sz is %lld", | 1773 | dbg_err("LPT wrote %lld but lpt_sz is %lld", |
1773 | c->chk_lpt_sz, c->lpt_sz); | 1774 | d->chk_lpt_sz, c->lpt_sz); |
1774 | err = -EINVAL; | 1775 | err = -EINVAL; |
1775 | } | 1776 | } |
1776 | if (c->chk_lpt_sz2 && c->chk_lpt_sz != c->chk_lpt_sz2) { | 1777 | if (d->chk_lpt_sz2 && d->chk_lpt_sz != d->chk_lpt_sz2) { |
1777 | dbg_err("LPT layout size %lld but wrote %lld", | 1778 | dbg_err("LPT layout size %lld but wrote %lld", |
1778 | c->chk_lpt_sz, c->chk_lpt_sz2); | 1779 | d->chk_lpt_sz, d->chk_lpt_sz2); |
1779 | err = -EINVAL; | 1780 | err = -EINVAL; |
1780 | } | 1781 | } |
1781 | if (c->chk_lpt_sz2 && c->new_nhead_offs != len) { | 1782 | if (d->chk_lpt_sz2 && d->new_nhead_offs != len) { |
1782 | dbg_err("LPT new nhead offs: expected %d was %d", | 1783 | dbg_err("LPT new nhead offs: expected %d was %d", |
1783 | c->new_nhead_offs, len); | 1784 | d->new_nhead_offs, len); |
1784 | err = -EINVAL; | 1785 | err = -EINVAL; |
1785 | } | 1786 | } |
1786 | lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; | 1787 | lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; |
@@ -1788,22 +1789,22 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) | |||
1788 | lpt_sz += c->ltab_sz; | 1789 | lpt_sz += c->ltab_sz; |
1789 | if (c->big_lpt) | 1790 | if (c->big_lpt) |
1790 | lpt_sz += c->lsave_sz; | 1791 | lpt_sz += c->lsave_sz; |
1791 | if (c->chk_lpt_sz - c->chk_lpt_wastage > lpt_sz) { | 1792 | if (d->chk_lpt_sz - d->chk_lpt_wastage > lpt_sz) { |
1792 | dbg_err("LPT chk_lpt_sz %lld + waste %lld exceeds %lld", | 1793 | dbg_err("LPT chk_lpt_sz %lld + waste %lld exceeds %lld", |
1793 | c->chk_lpt_sz, c->chk_lpt_wastage, lpt_sz); | 1794 | d->chk_lpt_sz, d->chk_lpt_wastage, lpt_sz); |
1794 | err = -EINVAL; | 1795 | err = -EINVAL; |
1795 | } | 1796 | } |
1796 | if (err) | 1797 | if (err) |
1797 | dbg_dump_lpt_info(c); | 1798 | dbg_dump_lpt_info(c); |
1798 | c->chk_lpt_sz2 = c->chk_lpt_sz; | 1799 | d->chk_lpt_sz2 = d->chk_lpt_sz; |
1799 | c->chk_lpt_sz = 0; | 1800 | d->chk_lpt_sz = 0; |
1800 | c->chk_lpt_wastage = 0; | 1801 | d->chk_lpt_wastage = 0; |
1801 | c->chk_lpt_lebs = 0; | 1802 | d->chk_lpt_lebs = 0; |
1802 | c->new_nhead_offs = len; | 1803 | d->new_nhead_offs = len; |
1803 | return err; | 1804 | return err; |
1804 | case 4: | 1805 | case 4: |
1805 | c->chk_lpt_sz += len; | 1806 | d->chk_lpt_sz += len; |
1806 | c->chk_lpt_wastage += len; | 1807 | d->chk_lpt_wastage += len; |
1807 | return 0; | 1808 | return 0; |
1808 | default: | 1809 | default: |
1809 | return -EINVAL; | 1810 | return -EINVAL; |
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c index 9bd5a43d4526..9e6f403f170e 100644 --- a/fs/ubifs/orphan.c +++ b/fs/ubifs/orphan.c | |||
@@ -899,7 +899,7 @@ static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci) | |||
899 | for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) { | 899 | for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) { |
900 | struct ubifs_scan_leb *sleb; | 900 | struct ubifs_scan_leb *sleb; |
901 | 901 | ||
902 | sleb = ubifs_scan(c, lnum, 0, c->dbg_buf); | 902 | sleb = ubifs_scan(c, lnum, 0, c->dbg->buf); |
903 | if (IS_ERR(sleb)) { | 903 | if (IS_ERR(sleb)) { |
904 | err = PTR_ERR(sleb); | 904 | err = PTR_ERR(sleb); |
905 | break; | 905 | break; |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index fc81022cc26d..ad44822059c7 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -1069,11 +1069,9 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1069 | if (err) | 1069 | if (err) |
1070 | return err; | 1070 | return err; |
1071 | 1071 | ||
1072 | #ifdef CONFIG_UBIFS_FS_DEBUG | 1072 | err = ubifs_debugging_init(c); |
1073 | c->dbg_buf = vmalloc(c->leb_size); | 1073 | if (err) |
1074 | if (!c->dbg_buf) | 1074 | return err; |
1075 | return -ENOMEM; | ||
1076 | #endif | ||
1077 | 1075 | ||
1078 | err = check_volume_empty(c); | 1076 | err = check_volume_empty(c); |
1079 | if (err) | 1077 | if (err) |
@@ -1139,18 +1137,16 @@ static int mount_ubifs(struct ubifs_info *c) | |||
1139 | goto out_free; | 1137 | goto out_free; |
1140 | } | 1138 | } |
1141 | 1139 | ||
1142 | dbg_failure_mode_registration(c); | ||
1143 | |||
1144 | err = init_constants_late(c); | 1140 | err = init_constants_late(c); |
1145 | if (err) | 1141 | if (err) |
1146 | goto out_dereg; | 1142 | goto out_free; |
1147 | 1143 | ||
1148 | sz = ALIGN(c->max_idx_node_sz, c->min_io_size); | 1144 | sz = ALIGN(c->max_idx_node_sz, c->min_io_size); |
1149 | sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size); | 1145 | sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size); |
1150 | c->cbuf = kmalloc(sz, GFP_NOFS); | 1146 | c->cbuf = kmalloc(sz, GFP_NOFS); |
1151 | if (!c->cbuf) { | 1147 | if (!c->cbuf) { |
1152 | err = -ENOMEM; | 1148 | err = -ENOMEM; |
1153 | goto out_dereg; | 1149 | goto out_free; |
1154 | } | 1150 | } |
1155 | 1151 | ||
1156 | sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id); | 1152 | sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id); |
@@ -1350,14 +1346,12 @@ out_wbufs: | |||
1350 | free_wbufs(c); | 1346 | free_wbufs(c); |
1351 | out_cbuf: | 1347 | out_cbuf: |
1352 | kfree(c->cbuf); | 1348 | kfree(c->cbuf); |
1353 | out_dereg: | ||
1354 | dbg_failure_mode_deregistration(c); | ||
1355 | out_free: | 1349 | out_free: |
1356 | kfree(c->bu.buf); | 1350 | kfree(c->bu.buf); |
1357 | vfree(c->ileb_buf); | 1351 | vfree(c->ileb_buf); |
1358 | vfree(c->sbuf); | 1352 | vfree(c->sbuf); |
1359 | kfree(c->bottom_up_buf); | 1353 | kfree(c->bottom_up_buf); |
1360 | UBIFS_DBG(vfree(c->dbg_buf)); | 1354 | ubifs_debugging_exit(c); |
1361 | return err; | 1355 | return err; |
1362 | } | 1356 | } |
1363 | 1357 | ||
@@ -1394,8 +1388,7 @@ static void ubifs_umount(struct ubifs_info *c) | |||
1394 | vfree(c->ileb_buf); | 1388 | vfree(c->ileb_buf); |
1395 | vfree(c->sbuf); | 1389 | vfree(c->sbuf); |
1396 | kfree(c->bottom_up_buf); | 1390 | kfree(c->bottom_up_buf); |
1397 | UBIFS_DBG(vfree(c->dbg_buf)); | 1391 | ubifs_debugging_exit(c); |
1398 | dbg_failure_mode_deregistration(c); | ||
1399 | } | 1392 | } |
1400 | 1393 | ||
1401 | /** | 1394 | /** |
@@ -1879,7 +1872,6 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) | |||
1879 | goto out_iput; | 1872 | goto out_iput; |
1880 | 1873 | ||
1881 | mutex_unlock(&c->umount_mutex); | 1874 | mutex_unlock(&c->umount_mutex); |
1882 | |||
1883 | return 0; | 1875 | return 0; |
1884 | 1876 | ||
1885 | out_iput: | 1877 | out_iput: |
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c index 8ac76b1c2d55..3c0af452887b 100644 --- a/fs/ubifs/tnc_commit.c +++ b/fs/ubifs/tnc_commit.c | |||
@@ -553,8 +553,8 @@ static int layout_in_empty_space(struct ubifs_info *c) | |||
553 | } | 553 | } |
554 | 554 | ||
555 | #ifdef CONFIG_UBIFS_FS_DEBUG | 555 | #ifdef CONFIG_UBIFS_FS_DEBUG |
556 | c->new_ihead_lnum = lnum; | 556 | c->dbg->new_ihead_lnum = lnum; |
557 | c->new_ihead_offs = buf_offs; | 557 | c->dbg->new_ihead_offs = buf_offs; |
558 | #endif | 558 | #endif |
559 | 559 | ||
560 | return 0; | 560 | return 0; |
@@ -1002,7 +1002,8 @@ static int write_index(struct ubifs_info *c) | |||
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | #ifdef CONFIG_UBIFS_FS_DEBUG | 1004 | #ifdef CONFIG_UBIFS_FS_DEBUG |
1005 | if (lnum != c->new_ihead_lnum || buf_offs != c->new_ihead_offs) { | 1005 | if (lnum != c->dbg->new_ihead_lnum || |
1006 | buf_offs != c->dbg->new_ihead_offs) { | ||
1006 | ubifs_err("inconsistent ihead"); | 1007 | ubifs_err("inconsistent ihead"); |
1007 | return -EINVAL; | 1008 | return -EINVAL; |
1008 | } | 1009 | } |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 16840e099eff..7e090a5e2bf6 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
@@ -910,6 +910,8 @@ struct ubifs_mount_opts { | |||
910 | unsigned int compr_type:2; | 910 | unsigned int compr_type:2; |
911 | }; | 911 | }; |
912 | 912 | ||
913 | struct ubifs_debug_info; | ||
914 | |||
913 | /** | 915 | /** |
914 | * struct ubifs_info - UBIFS file-system description data structure | 916 | * struct ubifs_info - UBIFS file-system description data structure |
915 | * (per-superblock). | 917 | * (per-superblock). |
@@ -972,8 +974,6 @@ struct ubifs_mount_opts { | |||
972 | * @ileb_nxt: next pre-allocated index LEBs | 974 | * @ileb_nxt: next pre-allocated index LEBs |
973 | * @old_idx: tree of index nodes obsoleted since the last commit start | 975 | * @old_idx: tree of index nodes obsoleted since the last commit start |
974 | * @bottom_up_buf: a buffer which is used by 'dirty_cow_bottom_up()' in tnc.c | 976 | * @bottom_up_buf: a buffer which is used by 'dirty_cow_bottom_up()' in tnc.c |
975 | * @new_ihead_lnum: used by debugging to check ihead_lnum | ||
976 | * @new_ihead_offs: used by debugging to check ihead_offs | ||
977 | * | 977 | * |
978 | * @mst_node: master node | 978 | * @mst_node: master node |
979 | * @mst_offs: offset of valid master node | 979 | * @mst_offs: offset of valid master node |
@@ -1157,15 +1157,7 @@ struct ubifs_mount_opts { | |||
1157 | * @always_chk_crc: always check CRCs (while mounting and remounting rw) | 1157 | * @always_chk_crc: always check CRCs (while mounting and remounting rw) |
1158 | * @mount_opts: UBIFS-specific mount options | 1158 | * @mount_opts: UBIFS-specific mount options |
1159 | * | 1159 | * |
1160 | * @dbg_buf: a buffer of LEB size used for debugging purposes | 1160 | * @dbg: debugging-related information |
1161 | * @old_zroot: old index root - used by 'dbg_check_old_index()' | ||
1162 | * @old_zroot_level: old index root level - used by 'dbg_check_old_index()' | ||
1163 | * @old_zroot_sqnum: old index root sqnum - used by 'dbg_check_old_index()' | ||
1164 | * @failure_mode: failure mode for recovery testing | ||
1165 | * @fail_delay: 0=>don't delay, 1=>delay a time, 2=>delay a number of calls | ||
1166 | * @fail_timeout: time in jiffies when delay of failure mode expires | ||
1167 | * @fail_cnt: current number of calls to failure mode I/O functions | ||
1168 | * @fail_cnt_max: number of calls by which to delay failure mode | ||
1169 | */ | 1161 | */ |
1170 | struct ubifs_info { | 1162 | struct ubifs_info { |
1171 | struct super_block *vfs_sb; | 1163 | struct super_block *vfs_sb; |
@@ -1221,10 +1213,6 @@ struct ubifs_info { | |||
1221 | int ileb_nxt; | 1213 | int ileb_nxt; |
1222 | struct rb_root old_idx; | 1214 | struct rb_root old_idx; |
1223 | int *bottom_up_buf; | 1215 | int *bottom_up_buf; |
1224 | #ifdef CONFIG_UBIFS_FS_DEBUG | ||
1225 | int new_ihead_lnum; | ||
1226 | int new_ihead_offs; | ||
1227 | #endif | ||
1228 | 1216 | ||
1229 | struct ubifs_mst_node *mst_node; | 1217 | struct ubifs_mst_node *mst_node; |
1230 | int mst_offs; | 1218 | int mst_offs; |
@@ -1399,21 +1387,7 @@ struct ubifs_info { | |||
1399 | struct ubifs_mount_opts mount_opts; | 1387 | struct ubifs_mount_opts mount_opts; |
1400 | 1388 | ||
1401 | #ifdef CONFIG_UBIFS_FS_DEBUG | 1389 | #ifdef CONFIG_UBIFS_FS_DEBUG |
1402 | void *dbg_buf; | 1390 | struct ubifs_debug_info *dbg; |
1403 | struct ubifs_zbranch old_zroot; | ||
1404 | int old_zroot_level; | ||
1405 | unsigned long long old_zroot_sqnum; | ||
1406 | int failure_mode; | ||
1407 | int fail_delay; | ||
1408 | unsigned long fail_timeout; | ||
1409 | unsigned int fail_cnt; | ||
1410 | unsigned int fail_cnt_max; | ||
1411 | long long chk_lpt_sz; | ||
1412 | long long chk_lpt_sz2; | ||
1413 | long long chk_lpt_wastage; | ||
1414 | int chk_lpt_lebs; | ||
1415 | int new_nhead_lnum; | ||
1416 | int new_nhead_offs; | ||
1417 | #endif | 1391 | #endif |
1418 | }; | 1392 | }; |
1419 | 1393 | ||