Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e878167a authored by ZhangZhen's avatar ZhangZhen Committed by Jan Kara
Browse files

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 dd1f723b has made that for
ext4, and i did the same for ext2/3.

Signed-off-by: default avatarZhang Zhen <zhenzhang.zhang@huawei.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 4ddb987a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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;