Skip to content

Commit e878167

Browse files
ZhangZhenjankara
authored andcommitted
ext2/3: use prandom_u32() instead of get_random_bytes()
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 <zhenzhang.zhang@huawei.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 4ddb987 commit e878167

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎fs/ext2/ialloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
284284
int best_ndir = inodes_per_group;
285285
int best_group = -1;
286286

287-
get_random_bytes(&group, sizeof(group));
287+
group = prandom_u32();
288288
parent_group = (unsigned)group % ngroups;
289289
for (i = 0; i < ngroups; i++) {
290290
group = (parent_group + i) % ngroups;

‎fs/ext3/ialloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
215215
int best_ndir = inodes_per_group;
216216
int best_group = -1;
217217

218-
get_random_bytes(&group, sizeof(group));
218+
group = prandom_u32();
219219
parent_group = (unsigned)group % ngroups;
220220
for (i = 0; i < ngroups; i++) {
221221
group = (parent_group + i) % ngroups;

0 commit comments

Comments
 (0)