aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-04-05 06:52:20 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-05-13 12:23:54 -0400
commitbc3f07f0906e867270fdc2006b0bbcb130a722c1 (patch)
treee290a98b57187896c2e5cefabc55a578f155803c
parentf1bd66afb14c25095cf6ff499c1388db423acc9e (diff)
UBIFS: make force in-the-gaps to be a general self-check
UBIFS can force itself to use the 'in-the-gaps' commit method - the last resort method which is normally invoced very very rarely. Currently this "force int-the-gaps" debugging feature is a separate test mode. But it is a bit saner to make it to be the "general" self-test check instead. This patch is just a clean-up which should make the debugging code look a bit nicer and easier to use - we have way too many debugging options. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r--Documentation/filesystems/ubifs.txt1
-rw-r--r--fs/ubifs/debug.c9
-rw-r--r--fs/ubifs/debug.h19
-rw-r--r--fs/ubifs/tnc_commit.c4
4 files changed, 13 insertions, 20 deletions
diff --git a/Documentation/filesystems/ubifs.txt b/Documentation/filesystems/ubifs.txt
index d7b13b01e98..7d17e5b91ff 100644
--- a/Documentation/filesystems/ubifs.txt
+++ b/Documentation/filesystems/ubifs.txt
@@ -154,7 +154,6 @@ debug_tsts Selects a mode of testing, as follows:
154 154
155 Test mode Flag value 155 Test mode Flag value
156 156
157 Force in-the-gaps method 2
158 Failure mode for recovery testing 4 157 Failure mode for recovery testing 4
159 158
160For example, set debug_msgs to 5 to display General messages and Mount 159For example, set debug_msgs to 5 to display General messages and Mount
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 546ad575b66..06d171cefe4 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -34,7 +34,6 @@
34#include <linux/moduleparam.h> 34#include <linux/moduleparam.h>
35#include <linux/debugfs.h> 35#include <linux/debugfs.h>
36#include <linux/math64.h> 36#include <linux/math64.h>
37#include <linux/slab.h>
38 37
39#ifdef CONFIG_UBIFS_FS_DEBUG 38#ifdef CONFIG_UBIFS_FS_DEBUG
40 39
@@ -2458,14 +2457,12 @@ error_dump:
2458 return 0; 2457 return 0;
2459} 2458}
2460 2459
2461static int invocation_cnt;
2462
2463int dbg_force_in_the_gaps(void) 2460int dbg_force_in_the_gaps(void)
2464{ 2461{
2465 if (!dbg_force_in_the_gaps_enabled) 2462 if (!(ubifs_chk_flags & UBIFS_CHK_GEN))
2466 return 0; 2463 return 0;
2467 /* Force in-the-gaps every 8th commit */ 2464
2468 return !((invocation_cnt++) & 0x7); 2465 return !(random32() & 7);
2469} 2466}
2470 2467
2471/* Failure mode for recovery testing */ 2468/* Failure mode for recovery testing */
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
index 6b5fe7ba029..8934c12f108 100644
--- a/fs/ubifs/debug.h
+++ b/fs/ubifs/debug.h
@@ -31,6 +31,8 @@ typedef int (*dbg_znode_callback)(struct ubifs_info *c,
31 31
32#ifdef CONFIG_UBIFS_FS_DEBUG 32#ifdef CONFIG_UBIFS_FS_DEBUG
33 33
34#include <linux/random.h>
35
34/** 36/**
35 * ubifs_debug_info - per-FS debugging information. 37 * ubifs_debug_info - per-FS debugging information.
36 * @old_zroot: old index root - used by 'dbg_check_old_index()' 38 * @old_zroot: old index root - used by 'dbg_check_old_index()'
@@ -237,11 +239,9 @@ enum {
237/* 239/*
238 * Special testing flags. 240 * Special testing flags.
239 * 241 *
240 * UBIFS_TST_FORCE_IN_THE_GAPS: force the use of in-the-gaps method
241 * UBIFS_TST_RCVRY: failure mode for recovery testing 242 * UBIFS_TST_RCVRY: failure mode for recovery testing
242 */ 243 */
243enum { 244enum {
244 UBIFS_TST_FORCE_IN_THE_GAPS = 0x2,
245 UBIFS_TST_RCVRY = 0x4, 245 UBIFS_TST_RCVRY = 0x4,
246}; 246};
247 247
@@ -308,18 +308,16 @@ int dbg_check_data_nodes_order(struct ubifs_info *c, struct list_head *head);
308int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head); 308int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head);
309 309
310/* Force the use of in-the-gaps method for testing */ 310/* Force the use of in-the-gaps method for testing */
311 311static inline int dbg_force_in_the_gaps_enabled(void)
312#define dbg_force_in_the_gaps_enabled \ 312{
313 (ubifs_tst_flags & UBIFS_TST_FORCE_IN_THE_GAPS) 313 return ubifs_chk_flags & UBIFS_CHK_GEN;
314 314}
315int dbg_force_in_the_gaps(void); 315int dbg_force_in_the_gaps(void);
316 316
317/* Failure mode for recovery testing */ 317/* Failure mode for recovery testing */
318
319#define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY) 318#define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY)
320 319
321#ifndef UBIFS_DBG_PRESERVE_UBI 320#ifndef UBIFS_DBG_PRESERVE_UBI
322
323#define ubi_leb_read dbg_leb_read 321#define ubi_leb_read dbg_leb_read
324#define ubi_leb_write dbg_leb_write 322#define ubi_leb_write dbg_leb_write
325#define ubi_leb_change dbg_leb_change 323#define ubi_leb_change dbg_leb_change
@@ -327,7 +325,6 @@ int dbg_force_in_the_gaps(void);
327#define ubi_leb_unmap dbg_leb_unmap 325#define ubi_leb_unmap dbg_leb_unmap
328#define ubi_is_mapped dbg_is_mapped 326#define ubi_is_mapped dbg_is_mapped
329#define ubi_leb_map dbg_leb_map 327#define ubi_leb_map dbg_leb_map
330
331#endif 328#endif
332 329
333int dbg_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, 330int dbg_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset,
@@ -488,8 +485,8 @@ dbg_check_nondata_nodes_order(struct ubifs_info *c,
488 struct list_head *head) { return 0; } 485 struct list_head *head) { return 0; }
489 486
490static inline int dbg_force_in_the_gaps(void) { return 0; } 487static inline int dbg_force_in_the_gaps(void) { return 0; }
491#define dbg_force_in_the_gaps_enabled 0 488#define dbg_force_in_the_gaps_enabled() 0
492#define dbg_failure_mode 0 489#define dbg_failure_mode 0
493 490
494static inline int dbg_debugfs_init(void) { return 0; } 491static inline int dbg_debugfs_init(void) { return 0; }
495static inline void dbg_debugfs_exit(void) { return; } 492static inline void dbg_debugfs_exit(void) { return; }
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
index c471b06798c..41920f357bb 100644
--- a/fs/ubifs/tnc_commit.c
+++ b/fs/ubifs/tnc_commit.c
@@ -377,12 +377,12 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt)
377 c->gap_lebs = NULL; 377 c->gap_lebs = NULL;
378 return err; 378 return err;
379 } 379 }
380 if (!dbg_force_in_the_gaps_enabled) { 380 if (dbg_force_in_the_gaps_enabled()) {
381 /* 381 /*
382 * Do not print scary warnings if the debugging 382 * Do not print scary warnings if the debugging
383 * option which forces in-the-gaps is enabled. 383 * option which forces in-the-gaps is enabled.
384 */ 384 */
385 ubifs_err("out of space"); 385 ubifs_warn("out of space");
386 dbg_dump_budg(c, &c->bi); 386 dbg_dump_budg(c, &c->bi);
387 dbg_dump_lprops(c); 387 dbg_dump_lprops(c);
388 } 388 }