diff options
Diffstat (limited to 'fs/ubifs/lpt_commit.c')
-rw-r--r-- | fs/ubifs/lpt_commit.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index 0c9c69bd983a..dfcb5748a7dc 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c | |||
@@ -29,6 +29,12 @@ | |||
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include "ubifs.h" | 30 | #include "ubifs.h" |
31 | 31 | ||
32 | #ifdef CONFIG_UBIFS_FS_DEBUG | ||
33 | static int dbg_populate_lsave(struct ubifs_info *c); | ||
34 | #else | ||
35 | #define dbg_populate_lsave(c) 0 | ||
36 | #endif | ||
37 | |||
32 | /** | 38 | /** |
33 | * first_dirty_cnode - find first dirty cnode. | 39 | * first_dirty_cnode - find first dirty cnode. |
34 | * @c: UBIFS file-system description object | 40 | * @c: UBIFS file-system description object |
@@ -586,7 +592,7 @@ static struct ubifs_pnode *next_pnode_to_dirty(struct ubifs_info *c, | |||
586 | if (nnode->nbranch[iip].lnum) | 592 | if (nnode->nbranch[iip].lnum) |
587 | break; | 593 | break; |
588 | } | 594 | } |
589 | } while (iip >= UBIFS_LPT_FANOUT); | 595 | } while (iip >= UBIFS_LPT_FANOUT); |
590 | 596 | ||
591 | /* Go right */ | 597 | /* Go right */ |
592 | nnode = ubifs_get_nnode(c, nnode, iip); | 598 | nnode = ubifs_get_nnode(c, nnode, iip); |
@@ -815,6 +821,10 @@ static void populate_lsave(struct ubifs_info *c) | |||
815 | c->lpt_drty_flgs |= LSAVE_DIRTY; | 821 | c->lpt_drty_flgs |= LSAVE_DIRTY; |
816 | ubifs_add_lpt_dirt(c, c->lsave_lnum, c->lsave_sz); | 822 | ubifs_add_lpt_dirt(c, c->lsave_lnum, c->lsave_sz); |
817 | } | 823 | } |
824 | |||
825 | if (dbg_populate_lsave(c)) | ||
826 | return; | ||
827 | |||
818 | list_for_each_entry(lprops, &c->empty_list, list) { | 828 | list_for_each_entry(lprops, &c->empty_list, list) { |
819 | c->lsave[cnt++] = lprops->lnum; | 829 | c->lsave[cnt++] = lprops->lnum; |
820 | if (cnt >= c->lsave_cnt) | 830 | if (cnt >= c->lsave_cnt) |
@@ -1994,4 +2004,47 @@ void dbg_dump_lpt_lebs(const struct ubifs_info *c) | |||
1994 | current->pid); | 2004 | current->pid); |
1995 | } | 2005 | } |
1996 | 2006 | ||
2007 | /** | ||
2008 | * dbg_populate_lsave - debugging version of 'populate_lsave()' | ||
2009 | * @c: UBIFS file-system description object | ||
2010 | * | ||
2011 | * This is a debugging version for 'populate_lsave()' which populates lsave | ||
2012 | * with random LEBs instead of useful LEBs, which is good for test coverage. | ||
2013 | * Returns zero if lsave has not been populated (this debugging feature is | ||
2014 | * disabled) an non-zero if lsave has been populated. | ||
2015 | */ | ||
2016 | static int dbg_populate_lsave(struct ubifs_info *c) | ||
2017 | { | ||
2018 | struct ubifs_lprops *lprops; | ||
2019 | struct ubifs_lpt_heap *heap; | ||
2020 | int i; | ||
2021 | |||
2022 | if (!(ubifs_chk_flags & UBIFS_CHK_GEN)) | ||
2023 | return 0; | ||
2024 | if (random32() & 3) | ||
2025 | return 0; | ||
2026 | |||
2027 | for (i = 0; i < c->lsave_cnt; i++) | ||
2028 | c->lsave[i] = c->main_first; | ||
2029 | |||
2030 | list_for_each_entry(lprops, &c->empty_list, list) | ||
2031 | c->lsave[random32() % c->lsave_cnt] = lprops->lnum; | ||
2032 | list_for_each_entry(lprops, &c->freeable_list, list) | ||
2033 | c->lsave[random32() % c->lsave_cnt] = lprops->lnum; | ||
2034 | list_for_each_entry(lprops, &c->frdi_idx_list, list) | ||
2035 | c->lsave[random32() % c->lsave_cnt] = lprops->lnum; | ||
2036 | |||
2037 | heap = &c->lpt_heap[LPROPS_DIRTY_IDX - 1]; | ||
2038 | for (i = 0; i < heap->cnt; i++) | ||
2039 | c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum; | ||
2040 | heap = &c->lpt_heap[LPROPS_DIRTY - 1]; | ||
2041 | for (i = 0; i < heap->cnt; i++) | ||
2042 | c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum; | ||
2043 | heap = &c->lpt_heap[LPROPS_FREE - 1]; | ||
2044 | for (i = 0; i < heap->cnt; i++) | ||
2045 | c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum; | ||
2046 | |||
2047 | return 1; | ||
2048 | } | ||
2049 | |||
1997 | #endif /* CONFIG_UBIFS_FS_DEBUG */ | 2050 | #endif /* CONFIG_UBIFS_FS_DEBUG */ |