Skip to content
/ linux Public

Commit 120c6bd

Browse files
zhangyi089Sasha Levin
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 d8ee559 commit 120c6bd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/ext4/extents.c

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

32663266
err = PTR_ERR(path);
32673267
if (err != -ENOSPC && err != -EDQUOT && err != -ENOMEM)
3268-
return path;
3268+
goto out_path;
32693269

32703270
/*
32713271
* Get a new path to try to zeroout or fix the extent length.
@@ -3279,7 +3279,7 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle,
32793279
if (IS_ERR(path)) {
32803280
EXT4_ERROR_INODE(inode, "Failed split extent on %u, err %ld",
32813281
split, PTR_ERR(path));
3282-
return path;
3282+
goto out_path;
32833283
}
32843284
depth = ext_depth(inode);
32853285
ex = path[depth].p_ext;
@@ -3356,6 +3356,10 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle,
33563356
ext4_free_ext_path(path);
33573357
path = ERR_PTR(err);
33583358
}
3359+
out_path:
3360+
if (IS_ERR(path))
3361+
/* Remove all remaining potentially stale extents. */
3362+
ext4_es_remove_extent(inode, ee_block, ee_len);
33593363
ext4_ext_show_leaf(inode, path);
33603364
return path;
33613365
}

0 commit comments

Comments
 (0)