From: Jan Kara <jack@suse.cz>
To: ZhangZhen <zhenzhang.zhang@huawei.com>
Cc: jack@suse.cz, linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext2/3: use prandom_u32() instead of get_random_bytes()
Date: Wed, 26 Feb 2014 12:08:14 +0100 [thread overview]
Message-ID: <20140226110814.GC6989@quack.suse.cz> (raw)
In-Reply-To: <530D5249.4020005@huawei.com>
On Wed 26-02-14 10:32:41, ZhangZhen wrote:
> 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 dd1f723bf56bd96efc9d90e9e60dc511c79de48f has made that for
> ext4, and i did the same for ext2/3.
Thanks. I've merged the patch to my tree.
Honza
>
> Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>
> ---
> fs/ext2/ialloc.c | 2 +-
> fs/ext3/ialloc.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
> index 7cadd82..32f131a 100644
> --- a/fs/ext2/ialloc.c
> +++ b/fs/ext2/ialloc.c
> @@ -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));
> + grp = prandom_u32();
> parent_group = (unsigned)group % ngroups;
> for (i = 0; i < ngroups; i++) {
> group = (parent_group + i) % ngroups;
> diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
> index 082afd7..60e63e3 100644
> --- a/fs/ext3/ialloc.c
> +++ b/fs/ext3/ialloc.c
> @@ -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));
> + grp = prandom_u32();
> parent_group = (unsigned)group % ngroups;
> for (i = 0; i < ngroups; i++) {
> group = (parent_group + i) % ngroups;
> --
> 1.8.1.4
>
>
> .
>
>
>
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
prev parent reply other threads:[~2014-02-26 11:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <530D4BBB.6090600@huawei.com>
2014-02-26 2:32 ` [PATCH] ext2/3: use prandom_u32() instead of get_random_bytes() ZhangZhen
2014-02-26 11:08 ` Jan Kara [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140226110814.GC6989@quack.suse.cz \
--to=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=zhenzhang.zhang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).