Message ID | 4E1E5F90.50700@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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);
When the end of an extent exceeds the end of the specified range, the extent will be accidentally truncated. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> --- fs/btrfs/free-space-cache.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)