aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2013-01-03 07:19:09 -0500
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-01-15 08:45:27 -0500
commit3d251a5b9e2f09edcf25bbffe1fa308d0f648bf1 (patch)
treeb50e9be66c5b0f0c3e7cbbf321cb737f7d999bdf /fs/ubifs
parent9931faca02c604c22335f5a935a501bb2ace6e20 (diff)
UBIFS: rename random32() to prandom_u32()
Use more preferable function name which implies using a pseudo-random number generator. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/debug.c8
-rw-r--r--fs/ubifs/lpt_commit.c14
-rw-r--r--fs/ubifs/tnc_commit.c2
3 files changed, 12 insertions, 12 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 12817ffc7345..7f60e900edff 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2459,7 +2459,7 @@ error_dump:
2459 2459
2460static inline int chance(unsigned int n, unsigned int out_of) 2460static inline int chance(unsigned int n, unsigned int out_of)
2461{ 2461{
2462 return !!((random32() % out_of) + 1 <= n); 2462 return !!((prandom_u32() % out_of) + 1 <= n);
2463 2463
2464} 2464}
2465 2465
@@ -2477,13 +2477,13 @@ static int power_cut_emulated(struct ubifs_info *c, int lnum, int write)
2477 if (chance(1, 2)) { 2477 if (chance(1, 2)) {
2478 d->pc_delay = 1; 2478 d->pc_delay = 1;
2479 /* Fail withing 1 minute */ 2479 /* Fail withing 1 minute */
2480 delay = random32() % 60000; 2480 delay = prandom_u32() % 60000;
2481 d->pc_timeout = jiffies; 2481 d->pc_timeout = jiffies;
2482 d->pc_timeout += msecs_to_jiffies(delay); 2482 d->pc_timeout += msecs_to_jiffies(delay);
2483 ubifs_warn("failing after %lums", delay); 2483 ubifs_warn("failing after %lums", delay);
2484 } else { 2484 } else {
2485 d->pc_delay = 2; 2485 d->pc_delay = 2;
2486 delay = random32() % 10000; 2486 delay = prandom_u32() % 10000;
2487 /* Fail within 10000 operations */ 2487 /* Fail within 10000 operations */
2488 d->pc_cnt_max = delay; 2488 d->pc_cnt_max = delay;
2489 ubifs_warn("failing after %lu calls", delay); 2489 ubifs_warn("failing after %lu calls", delay);
@@ -2563,7 +2563,7 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf,
2563 unsigned int from, to, ffs = chance(1, 2); 2563 unsigned int from, to, ffs = chance(1, 2);
2564 unsigned char *p = (void *)buf; 2564 unsigned char *p = (void *)buf;
2565 2565
2566 from = random32() % (len + 1); 2566 from = prandom_u32() % (len + 1);
2567 /* Corruption may only span one max. write unit */ 2567 /* Corruption may only span one max. write unit */
2568 to = min(len, ALIGN(from, c->max_write_size)); 2568 to = min(len, ALIGN(from, c->max_write_size));
2569 2569
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index 9daaeef675dd..4b826abb1528 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -2007,28 +2007,28 @@ static int dbg_populate_lsave(struct ubifs_info *c)
2007 2007
2008 if (!dbg_is_chk_gen(c)) 2008 if (!dbg_is_chk_gen(c))
2009 return 0; 2009 return 0;
2010 if (random32() & 3) 2010 if (prandom_u32() & 3)
2011 return 0; 2011 return 0;
2012 2012
2013 for (i = 0; i < c->lsave_cnt; i++) 2013 for (i = 0; i < c->lsave_cnt; i++)
2014 c->lsave[i] = c->main_first; 2014 c->lsave[i] = c->main_first;
2015 2015
2016 list_for_each_entry(lprops, &c->empty_list, list) 2016 list_for_each_entry(lprops, &c->empty_list, list)
2017 c->lsave[random32() % c->lsave_cnt] = lprops->lnum; 2017 c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum;
2018 list_for_each_entry(lprops, &c->freeable_list, list) 2018 list_for_each_entry(lprops, &c->freeable_list, list)
2019 c->lsave[random32() % c->lsave_cnt] = lprops->lnum; 2019 c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum;
2020 list_for_each_entry(lprops, &c->frdi_idx_list, list) 2020 list_for_each_entry(lprops, &c->frdi_idx_list, list)
2021 c->lsave[random32() % c->lsave_cnt] = lprops->lnum; 2021 c->lsave[prandom_u32() % c->lsave_cnt] = lprops->lnum;
2022 2022
2023 heap = &c->lpt_heap[LPROPS_DIRTY_IDX - 1]; 2023 heap = &c->lpt_heap[LPROPS_DIRTY_IDX - 1];
2024 for (i = 0; i < heap->cnt; i++) 2024 for (i = 0; i < heap->cnt; i++)
2025 c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum; 2025 c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum;
2026 heap = &c->lpt_heap[LPROPS_DIRTY - 1]; 2026 heap = &c->lpt_heap[LPROPS_DIRTY - 1];
2027 for (i = 0; i < heap->cnt; i++) 2027 for (i = 0; i < heap->cnt; i++)
2028 c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum; 2028 c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum;
2029 heap = &c->lpt_heap[LPROPS_FREE - 1]; 2029 heap = &c->lpt_heap[LPROPS_FREE - 1];
2030 for (i = 0; i < heap->cnt; i++) 2030 for (i = 0; i < heap->cnt; i++)
2031 c->lsave[random32() % c->lsave_cnt] = heap->arr[i]->lnum; 2031 c->lsave[prandom_u32() % c->lsave_cnt] = heap->arr[i]->lnum;
2032 2032
2033 return 1; 2033 return 1;
2034} 2034}
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
index 523bbad69c0c..52a6559275c4 100644
--- a/fs/ubifs/tnc_commit.c
+++ b/fs/ubifs/tnc_commit.c
@@ -683,7 +683,7 @@ static int alloc_idx_lebs(struct ubifs_info *c, int cnt)
683 c->ilebs[c->ileb_cnt++] = lnum; 683 c->ilebs[c->ileb_cnt++] = lnum;
684 dbg_cmt("LEB %d", lnum); 684 dbg_cmt("LEB %d", lnum);
685 } 685 }
686 if (dbg_is_chk_index(c) && !(random32() & 7)) 686 if (dbg_is_chk_index(c) && !(prandom_u32() & 7))
687 return -ENOSPC; 687 return -ENOSPC;
688 return 0; 688 return 0;
689} 689}