29
29
#include <linux/slab.h>
32
#ifdef CONFIG_UBIFS_FS_DEBUG
33
static int dbg_populate_lsave(struct ubifs_info *c);
35
#define dbg_populate_lsave(c) 0
33
39
* first_dirty_cnode - find first dirty cnode.
34
40
* @c: UBIFS file-system description object
586
592
if (nnode->nbranch[iip].lnum)
589
} while (iip >= UBIFS_LPT_FANOUT);
595
} while (iip >= UBIFS_LPT_FANOUT);
592
598
nnode = ubifs_get_nnode(c, nnode, iip);
815
821
c->lpt_drty_flgs |= LSAVE_DIRTY;
816
822
ubifs_add_lpt_dirt(c, c->lsave_lnum, c->lsave_sz);
825
if (dbg_populate_lsave(c))
818
828
list_for_each_entry(lprops, &c->empty_list, list) {
819
829
c->lsave[cnt++] = lprops->lnum;
820
830
if (cnt >= c->lsave_cnt)
2008
* dbg_populate_lsave - debugging version of 'populate_lsave()'
2009
* @c: UBIFS file-system description object
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.
2016
static int dbg_populate_lsave(struct ubifs_info *c)
2018
struct ubifs_lprops *lprops;
2019
struct ubifs_lpt_heap *heap;
2022
if (!(ubifs_chk_flags & UBIFS_CHK_GEN))
2027
for (i = 0; i < c->lsave_cnt; i++)
2028
c->lsave[i] = c->main_first;
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;
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;
1997
2050
#endif /* CONFIG_UBIFS_FS_DEBUG */