From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Nikolay Borisov <nborisov@suse.com>,
Li zeming <zeming@nfschina.com>,
clm@fb.com, josef@toxicpanda.com, dsterba@suse.com
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: volumes: Increase bioc pointer check
Date: Tue, 25 Oct 2022 17:49:55 +0800 [thread overview]
Message-ID: <13035b03-ed27-c36e-da6a-072d882e787f@gmx.com> (raw)
In-Reply-To: <1d9d4d78-073d-fc49-1918-f7c8ab6fe15e@suse.com>
On 2022/10/25 17:29, Nikolay Borisov wrote:
>
>
> On 25.10.22 г. 11:28 ч., Li zeming wrote:
>> If kzalloc fails to allocate the bioc pointer, NULL is returned
>> directly.
>>
>> Signed-off-by: Li zeming <zeming@nfschina.com>
>
> This patch clearly shows you haven't really understood the code. As is
> evident there is __GFP_NOFAIL flag so as per the guarantees for this
> flag we either loop infinitely trying to allocate a bioc or simply
> allocated it. So this check can never be triggered.
I guess what he missed is just to also remove that NOFAIL flag.
NOFAIL will not 100% guarantee the allocation, and I don't see this
location to be so important, especially when the only caller is already
handing allocation failure.
Thanks,
Qu
>
> NAK
>> ---
>> fs/btrfs/volumes.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
>> index 064ab2a79c80..f9cb815fe23d 100644
>> --- a/fs/btrfs/volumes.c
>> +++ b/fs/btrfs/volumes.c
>> @@ -5892,6 +5892,8 @@ static struct btrfs_io_context
>> *alloc_btrfs_io_context(struct btrfs_fs_info *fs_
>> */
>> sizeof(u64) * (total_stripes),
>> GFP_NOFS|__GFP_NOFAIL);
>> + if (!bioc)
>> + return NULL;
>> atomic_set(&bioc->error, 0);
>> refcount_set(&bioc->refs, 1);
next prev parent reply other threads:[~2022-10-25 9:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 8:28 Li zeming
2022-10-25 9:29 ` Nikolay Borisov
2022-10-25 9:49 ` Qu Wenruo [this message]
2022-10-25 9:47 ` Qu Wenruo
2022-10-25 10:38 ` Li zeming
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=13035b03-ed27-c36e-da6a-072d882e787f@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nborisov@suse.com \
--cc=zeming@nfschina.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
all inboxes | Powered by JetHome®