Yan Zheng
2007-Nov-02 00:07 UTC
[Btrfs-devel][PATCH]Properly update free space cache in __free_extent
Hello, When 'pin_down_bytes' decides against pinning a extent, '__free_extent' should update the free space cache by itself. Regards YZ --- diff -r bc6bfcf7a158 extent-tree.c --- a/extent-tree.c Tue Oct 30 16:56:53 2007 -0400 +++ b/extent-tree.c Fri Nov 02 15:04:33 2007 +0800 @@ -715,7 +715,7 @@ static int pin_down_bytes(struct btrfs_r root->fs_info->running_transaction->transid; if (btrfs_header_generation(buf) == transid) { free_extent_buffer(buf); - return 0; + return 1; } } free_extent_buffer(buf); @@ -775,7 +775,12 @@ static int __free_extent(struct btrfs_tr if (pin) { ret = pin_down_bytes(root, bytenr, num_bytes, 0); - BUG_ON(ret); + if (ret > 0) { + set_extent_dirty(&info->free_space_cache, + bytenr, bytenr + num_bytes - 1, + GFP_NOFS); + } + BUG_ON(ret < 0); } /* block accounting for super block */
Yan Zheng
2007-Nov-02 01:07 UTC
[Btrfs-devel][PATCH]Properly update free space cache in __free_extent
Hello, Please consider this patch, it's more compact. --- diff -r bc6bfcf7a158 extent-tree.c --- a/extent-tree.c Tue Oct 30 16:56:53 2007 -0400 +++ b/extent-tree.c Fri Nov 02 16:04:34 2007 +0800 @@ -715,7 +715,7 @@ static int pin_down_bytes(struct btrfs_r root->fs_info->running_transaction->transid; if (btrfs_header_generation(buf) == transid) { free_extent_buffer(buf); - return 0; + return 1; } } free_extent_buffer(buf); @@ -775,7 +775,9 @@ static int __free_extent(struct btrfs_tr if (pin) { ret = pin_down_bytes(root, bytenr, num_bytes, 0); - BUG_ON(ret); + if (ret > 0) + mark_free = 1; + BUG_ON(ret < 0); } /* block accounting for super block */