Skip to content

Commit 31bf37c

Browse files
zhangyi089gregkh
authored andcommitted
ext4: drop extent cache when splitting extent fails
commit 79b592e upstream. When the split extent fails, we might leave some extents still being processed and return an error directly, which will result in stale extent entries remaining in the extent status tree. So drop all of the remaining potentially stale extents if the splitting fails. Signed-off-by: Zhang Yi <yi.zhang@huawei.com> Reviewed-by: Baokun Li <libaokun1@huawei.com> Cc: stable@kernel.org Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> Message-ID: <20251129103247.686136-8-yi.zhang@huaweicloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a1b962a commit 31bf37c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

fs/ext4/extents.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3267,7 +3267,7 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle,
32673267

32683268
err = PTR_ERR(path);
32693269
if (err != -ENOSPC && err != -EDQUOT && err != -ENOMEM)
3270-
return path;
3270+
goto out_path;
32713271

32723272
/*
32733273
* Get a new path to try to zeroout or fix the extent length.
@@ -3281,7 +3281,7 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle,
32813281
if (IS_ERR(path)) {
32823282
EXT4_ERROR_INODE(inode, "Failed split extent on %u, err %ld",
32833283
split, PTR_ERR(path));
3284-
return path;
3284+
goto out_path;
32853285
}
32863286
depth = ext_depth(inode);
32873287
ex = path[depth].p_ext;
@@ -3358,6 +3358,10 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle,
33583358
ext4_free_ext_path(path);
33593359
path = ERR_PTR(err);
33603360
}
3361+
out_path:
3362+
if (IS_ERR(path))
3363+
/* Remove all remaining potentially stale extents. */
3364+
ext4_es_remove_extent(inode, ee_block, ee_len);
33613365
ext4_ext_show_leaf(inode, path);
33623366
return path;
33633367
}

0 commit comments

Comments
 (0)