When the end of an extent exceeds the end of the specified range, the extent will be accidentally truncated.
Signed-off-by: Li Zefan <l...@cn.fujitsu.com> --- fs/btrfs/free-space-cache.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 901585d..cf4bffd 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -2512,8 +2512,15 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group, bytes = min(entry->bytes, end - start); if (bytes < minlen) goto next; + unlink_free_space(ctl, entry); - kmem_cache_free(btrfs_free_space_cachep, entry); + if (bytes < entry->bytes) { + entry->offset = entry->offset + bytes; + entry->bytes = entry->bytes - bytes; + link_free_space(ctl, entry); + } else { + kmem_cache_free(btrfs_free_space_cachep, entry); + } } spin_unlock(&ctl->tree_lock); -- 1.7.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html