Skip to content

Commit bc3f07f

Browse files
Artem BityutskiyArtem Bityutskiy
authored andcommitted
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>
1 parent f1bd66a commit bc3f07f

4 files changed

Lines changed: 13 additions & 20 deletions

File tree

‎Documentation/filesystems/ubifs.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ debug_tsts Selects a mode of testing, as follows:
154154

155155
Test mode Flag value
156156

157-
Force in-the-gaps method 2
158157
Failure mode for recovery testing 4
159158

160159
For example, set debug_msgs to 5 to display General messages and Mount

‎fs/ubifs/debug.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <linux/moduleparam.h>
3535
#include <linux/debugfs.h>
3636
#include <linux/math64.h>
37-
#include <linux/slab.h>
3837

3938
#ifdef CONFIG_UBIFS_FS_DEBUG
4039

@@ -2458,14 +2457,12 @@ int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head)
24582457
return 0;
24592458
}
24602459

2461-
static int invocation_cnt;
2462-
24632460
int dbg_force_in_the_gaps(void)
24642461
{
2465-
if (!dbg_force_in_the_gaps_enabled)
2462+
if (!(ubifs_chk_flags & UBIFS_CHK_GEN))
24662463
return 0;
2467-
/* Force in-the-gaps every 8th commit */
2468-
return !((invocation_cnt++) & 0x7);
2464+
2465+
return !(random32() & 7);
24692466
}
24702467

24712468
/* Failure mode for recovery testing */

‎fs/ubifs/debug.h‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ typedef int (*dbg_znode_callback)(struct ubifs_info *c,
3131

3232
#ifdef CONFIG_UBIFS_FS_DEBUG
3333

34+
#include <linux/random.h>
35+
3436
/**
3537
* ubifs_debug_info - per-FS debugging information.
3638
* @old_zroot: old index root - used by 'dbg_check_old_index()'
@@ -237,11 +239,9 @@ enum {
237239
/*
238240
* Special testing flags.
239241
*
240-
* UBIFS_TST_FORCE_IN_THE_GAPS: force the use of in-the-gaps method
241242
* UBIFS_TST_RCVRY: failure mode for recovery testing
242243
*/
243244
enum {
244-
UBIFS_TST_FORCE_IN_THE_GAPS = 0x2,
245245
UBIFS_TST_RCVRY = 0x4,
246246
};
247247

@@ -308,26 +308,23 @@ int dbg_check_data_nodes_order(struct ubifs_info *c, struct list_head *head);
308308
int dbg_check_nondata_nodes_order(struct ubifs_info *c, struct list_head *head);
309309

310310
/* Force the use of in-the-gaps method for testing */
311-
312-
#define dbg_force_in_the_gaps_enabled \
313-
(ubifs_tst_flags & UBIFS_TST_FORCE_IN_THE_GAPS)
314-
311+
static inline int dbg_force_in_the_gaps_enabled(void)
312+
{
313+
return ubifs_chk_flags & UBIFS_CHK_GEN;
314+
}
315315
int dbg_force_in_the_gaps(void);
316316

317317
/* Failure mode for recovery testing */
318-
319318
#define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY)
320319

321320
#ifndef UBIFS_DBG_PRESERVE_UBI
322-
323321
#define ubi_leb_read dbg_leb_read
324322
#define ubi_leb_write dbg_leb_write
325323
#define ubi_leb_change dbg_leb_change
326324
#define ubi_leb_erase dbg_leb_erase
327325
#define ubi_leb_unmap dbg_leb_unmap
328326
#define ubi_is_mapped dbg_is_mapped
329327
#define ubi_leb_map dbg_leb_map
330-
331328
#endif
332329

333330
int 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,
488485
struct list_head *head) { return 0; }
489486

490487
static inline int dbg_force_in_the_gaps(void) { return 0; }
491-
#define dbg_force_in_the_gaps_enabled 0
492-
#define dbg_failure_mode 0
488+
#define dbg_force_in_the_gaps_enabled() 0
489+
#define dbg_failure_mode 0
493490

494491
static inline int dbg_debugfs_init(void) { return 0; }
495492
static inline void dbg_debugfs_exit(void) { return; }

‎fs/ubifs/tnc_commit.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,12 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt)
377377
c->gap_lebs = NULL;
378378
return err;
379379
}
380-
if (!dbg_force_in_the_gaps_enabled) {
380+
if (dbg_force_in_the_gaps_enabled()) {
381381
/*
382382
* Do not print scary warnings if the debugging
383383
* option which forces in-the-gaps is enabled.
384384
*/
385-
ubifs_err("out of space");
385+
ubifs_warn("out of space");
386386
dbg_dump_budg(c, &c->bi);
387387
dbg_dump_lprops(c);
388388
}

0 commit comments

Comments
 (0)