Skip to content

Commit

Permalink
ext2/3: use prandom_u32() instead of get_random_bytes()
Browse files Browse the repository at this point in the history
Many of the uses of get_random_bytes() do not actually need
cryptographically secure random numbers.  Replace those uses with a
call to prandom_u32(), which is faster and which doesn't consume
entropy from the /dev/random driver.

The commit dd1f723 has made that for
ext4, and i did the same for ext2/3.

Signed-off-by: Zhang Zhen <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
ZhangZhen authored and jankara committed Mar 4, 2014
1 parent 4ddb987 commit e878167
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fs/ext2/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
int best_ndir = inodes_per_group;
int best_group = -1;

get_random_bytes(&group, sizeof(group));
group = prandom_u32();
parent_group = (unsigned)group % ngroups;
for (i = 0; i < ngroups; i++) {
group = (parent_group + i) % ngroups;
Expand Down
2 changes: 1 addition & 1 deletion fs/ext3/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
int best_ndir = inodes_per_group;
int best_group = -1;

get_random_bytes(&group, sizeof(group));
group = prandom_u32();
parent_group = (unsigned)group % ngroups;
for (i = 0; i < ngroups; i++) {
group = (parent_group + i) % ngroups;
Expand Down

0 comments on commit e878167

Please sign in to comment.