Commit c3eab85f authored by Liu Bo's avatar Liu Bo Committed by Greg Kroah-Hartman
Browse files

Btrfs: fix truncate down when no_holes feature is enabled

[ Upstream commit 91298eec ]

For such a file mapping,


In NO_HOLES mode, we don't have the [hole] extent any more.
Commit c1aa4575

 ("Btrfs: fix shrinking truncate when the no_holes feature is enabled")
 fixed disk isize not being updated in NO_HOLES mode when data is not flushed.

However, even if data has been flushed, we can still have trouble
in updating disk isize since we updated disk isize to 'start' of
the last evicted extent.
Reviewed-by: default avatarChris Mason <>
Signed-off-by: default avatarLiu Bo <>
Signed-off-by: default avatarDavid Sterba <>
Signed-off-by: default avatarSasha Levin <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent e8b5068b
...@@ -4480,8 +4480,19 @@ search_again: ...@@ -4480,8 +4480,19 @@ search_again:
if (found_type > min_type) { if (found_type > min_type) {
del_item = 1; del_item = 1;
} else { } else {
if (item_end < new_size) if (item_end < new_size) {
* With NO_HOLES mode, for the following mapping
* [0-4k][hole][8k-12k]
* if truncating isize down to 6k, it ends up
* isize being 8k.
if (btrfs_fs_incompat(root->fs_info, NO_HOLES))
last_size = new_size;
break; break;
if (found_key.offset >= new_size) if (found_key.offset >= new_size)
del_item = 1; del_item = 1;
else else
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment