From: Baokun Li <libaokun1@huawei.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Li Zetao <lizetao1@huawei.com>, <adilger.kernel@dilger.ca>,
<linux-ext4@vger.kernel.org>, Baokun Li <libaokun1@huawei.com>,
Yang Erkun <yangerkun@huawei.com>
Subject: Re: [PATCH -next] ext4: Remove redundant null pointer check
Date: Tue, 3 Sep 2024 21:39:57 +0800 [thread overview]
Message-ID: <7480a81b-4b95-45cc-bf4e-da34ff148790@huawei.com> (raw)
In-Reply-To: <20240903125022.GF424729@mit.edu>
Hi Theodore,
Unfortunately it is possible that the regression was introduced
precisely by the mishandling of conflicts here.
On 2024/9/3 20:50, Theodore Ts'o wrote:
> On Tue, Sep 03, 2024 at 03:52:01PM +0800, Baokun Li wrote:
>> Thanks for the cleanup patch.
>>
>> But the change is already included in the patch:
>>
>> https://lore.kernel.org/all/20240710040654.1714672-21-libaokun@huaweicloud.com/
> Yeah, I noticed. I had already applied Zetao's patch when I processed
> yours, so I just ended up manually handling the patch conflict.
>
> (I haven't set out the patch acks yet, because the current state of
> the ext4/dev branch is apparently causing a test regression which I'm
> trying to root cause. They will be in tomorrow's fs-next and
> linux-next branch, though unless I end up figuring out the problematic
> patch or patch series, and end up dropping them from the ext4 dev
> branch today. Still, feel free to take a look and let me know if I
> screwed up anything.)
>
> - Ted
>
[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git/commit/?h=dev&id=92bbb922166cd7a829bf60d168372ffa1c54e81d
The changes after resolving the conflict in ext4_ext_clear_bb() are
as follows:
---------------------------------------------------------------------------
@@ -6128,12 +6122,9 @@ int ext4_ext_clear_bb(struct inode *inode)
if (IS_ERR(path))
return PTR_ERR(path);
ex = path[path->p_depth].p_ext;
- if (!ex) {
- ext4_free_ext_path(path);
- return 0;
- }
+ if (!ex)
+ goto out;
end = le32_to_cpu(ex->ee_block) + ext4_ext_get_actual_len(ex);
- ext4_free_ext_path(path);
cur = 0;
while (cur < end) {
@@ -6146,7 +6137,6 @@ int ext4_ext_clear_bb(struct inode *inode)
path = ext4_find_extent(inode, map.m_lblk,
NULL, 0);
if (!IS_ERR(path)) {
for (j = 0; j < path->p_depth; j++) {
-
ext4_mb_mark_bb(inode->i_sb,
path[j].p_block, 1, false);
ext4_fc_record_regions(inode->i_sb, inode->i_ino,
@@ -6161,5 +6151,7 @@ int ext4_ext_clear_bb(struct inode *inode)
cur = cur + map.m_len;
}
+out:
+ ext4_free_ext_path(path);
return 0;
}
---------------------------------------------------------------------------
This can cause path leaks and path double free.
----------------------------------------
path_A = ext4_find_extent
while (cur < end) {
path_B = ext4_find_extent(inode, map.m_lblk, NULL, 0);
// path_A leak
ext4_free_ext_path(path_B);
}
out:
ext4_free_ext_path(path_B); // path_B double free
----------------------------------------
I think it's best to drop Zetao's patch
b2e662cb86ca ("ext4: remove redundant null pointer check")
and then reapply the conflicting patch
92bbb922166c ("ext4: make some fast commit functions reuse extents path")
Or apply the following modifications to conflicting patch in the tree:
---------------------------------------------------------------------------
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 789316f22f97..34e25eee6521 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -6132,7 +6132,7 @@ int ext4_ext_clear_bb(struct inode *inode)
if (ret < 0)
break;
if (ret > 0) {
- path = ext4_find_extent(inode, map.m_lblk, NULL, 0);
+ path = ext4_find_extent(inode, map.m_lblk, path, 0);
if (!IS_ERR(path)) {
for (j = 0; j < path->p_depth; j++) {
ext4_mb_mark_bb(inode->i_sb,
@@ -6140,7 +6140,8 @@ int ext4_ext_clear_bb(struct inode *inode)
ext4_fc_record_regions(inode->i_sb, inode->i_ino,
0,
path[j].p_block, 1, 1);
}
- ext4_free_ext_path(path);
+ } else {
+ path = NULL;
}
ext4_mb_mark_bb(inode->i_sb, map.m_pblk,
map.m_len, false);
ext4_fc_record_regions(inode->i_sb, inode->i_ino,
---------------------------------------------------------------------------
Cheers,
Baokun
prev parent reply other threads:[~2024-09-03 13:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 1:32 [PATCH -next] ext4: Remove redundant null pointer check Li Zetao
2024-09-03 7:52 ` Baokun Li
2024-09-03 12:50 ` Theodore Ts'o
2024-09-03 13:39 ` Baokun Li [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=7480a81b-4b95-45cc-bf4e-da34ff148790@huawei.com \
--to=libaokun1@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=lizetao1@huawei.com \
--cc=tytso@mit.edu \
--cc=yangerkun@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