From: Zhang Zhen <zhenzhang.zhang@huawei.com>
To: Andreas Dilger <adilger@dilger.ca>
Cc: "tytso@mit.edu" <tytso@mit.edu>, Jan Kara <jack@suse.cz>,
<adilger.kernel@dilger.ca>,
"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH] fs/ext4: fix potential endless loop in ext4_mb_discard_group_preallocations()
Date: Tue, 1 Sep 2015 09:16:38 +0800 [thread overview]
Message-ID: <55E4FC76.1090609@huawei.com> (raw)
In-Reply-To: <0E3B5981-84C9-474C-91C2-311CB8B85C24@dilger.ca>
On 2015/9/1 6:34, Andreas Dilger wrote:
> On Aug 31, 2015, at 3:46 AM, Zhang Zhen <zhenzhang.zhang@huawei.com> wrote:
>>
>> In ext4_mb_discard_group_preallocations(), if free is always less
>> than needed, and some PAs are always used in every loop, it will
>> be endless loop.
>>
>> Here we pick a random value to limit the max number of loop.
>>
>> Signed-off-by: Zhang Zhen <zhenzhang.zhang@huawei.com>
>> ---
>> fs/ext4/mballoc.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
>> index 34b610e..553fbde 100644
>> --- a/fs/ext4/mballoc.c
>> +++ b/fs/ext4/mballoc.c
>> @@ -3836,6 +3836,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
>> int err;
>> int busy = 0;
>> int free = 0;
>> + int tried = 0;
>>
>> mb_debug(1, "discard preallocation for group %u\n", group);
>>
>> @@ -3886,9 +3887,11 @@ repeat:
>> list_add(&pa->u.pa_tmp_list, &list);
>> }
>>
>> - /* if we still need more blocks and some PAs were used, try again */
>> - if (free < needed && busy) {
>> + /* if we still need more blocks and some PAs were used, try again,
>> + here 20 is a ramdon value. */
>
> (typo) s/ramdon/random/
>
My mistake, thanks!
>> + if (free < needed && busy && tried < 20) {
>> busy = 0;
>> + tried++;
>> ext4_unlock_group(sb, group);
>> cond_resched();
>> goto repeat;
>
> Looks OK otherwise.
>
> Cheers, Andreas
>
>
>
>
>
>
>
next prev parent reply other threads:[~2015-09-01 1:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1441013790-87948-1-git-send-email-zhenzhang.zhang@huawei.com>
2015-08-31 9:46 ` [PATCH] fs/ext4: fix potential endless loop in ext4_mb_discard_group_preallocations() Zhang Zhen
2015-08-31 22:34 ` Andreas Dilger
2015-09-01 1:16 ` Zhang Zhen [this message]
2015-09-01 6:41 ` [PATCH v2] " Zhang Zhen
2015-09-16 19:45 ` [PATCH] " Jan Kara
2015-09-17 1:27 ` Zhang Zhen
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=55E4FC76.1090609@huawei.com \
--to=zhenzhang.zhang@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=adilger@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.