Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128952
b: refs/heads/master
c: 9b49c9b
h: refs/heads/master
v: v3
  • Loading branch information
Chris Mason committed Sep 25, 2008
1 parent f1d6070 commit cae76de
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 60582d1e933649f14f46f816bb75049058679e01
refs/heads/master: 9b49c9b9f93e148815f2544d0c91f43b6d72eea9
34 changes: 34 additions & 0 deletions trunk/fs/btrfs/free-space-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,45 @@ int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,

ret = link_free_space(block_group, info);
BUG_ON(ret);
} else if (info && info->offset < offset &&
info->offset + info->bytes >= offset + bytes) {
u64 old_start = info->offset;
/*
* we're freeing space in the middle of the info,
* this can happen during tree log replay
*
* first unlink the old info and then
* insert it again after the hole we're creating
*/
unlink_free_space(block_group, info);
if (offset + bytes < info->offset + info->bytes) {
u64 old_end = info->offset + info->bytes;

info->offset = offset + bytes;
info->bytes = old_end - info->offset;
ret = link_free_space(block_group, info);
BUG_ON(ret);
} else {
/* the hole we're creating ends at the end
* of the info struct, just free the info
*/
kfree(info);
}

/* step two, insert a new info struct to cover anything
* before the hole
*/
spin_unlock(&block_group->lock);
ret = btrfs_add_free_space(block_group, old_start,
offset - old_start);
BUG_ON(ret);
goto out_nolock;
} else {
WARN_ON(1);
}
out:
spin_unlock(&block_group->lock);
out_nolock:
return ret;
}

Expand Down

0 comments on commit cae76de

Please sign in to comment.