diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-27 11:05:53 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-27 11:05:53 -0400 |
commit | f4b9aa8d3b877d0a6044a6d6d9a44b29cab9e265 (patch) | |
tree | 227c83dac6b68407e3396632866f5564391ca15d /fs/btrfs/extent-tree.c | |
parent | 71951f35a6e413f2bfbd41829af8cf10a890aeb6 (diff) |
btrfs_truncate
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 4d4fc48c0a31..176c6dc534ba 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -171,20 +171,21 @@ static int pin_down_block(struct btrfs_root *root, u64 blocknr, int pending) | |||
171 | struct btrfs_header *header; | 171 | struct btrfs_header *header; |
172 | struct buffer_head *bh; | 172 | struct buffer_head *bh; |
173 | 173 | ||
174 | bh = sb_find_get_block(root->fs_info->sb, blocknr); | 174 | if (!pending) { |
175 | if (bh) { | 175 | bh = sb_find_get_block(root->fs_info->sb, blocknr); |
176 | header = btrfs_buffer_header(bh); | 176 | if (bh) { |
177 | if (btrfs_header_generation(header) == | 177 | header = btrfs_buffer_header(bh); |
178 | root->fs_info->running_transaction->transid) { | 178 | if (btrfs_header_generation(header) == |
179 | root->fs_info->running_transaction->transid) { | ||
180 | brelse(bh); | ||
181 | return 0; | ||
182 | } | ||
179 | brelse(bh); | 183 | brelse(bh); |
180 | return 0; | ||
181 | } | 184 | } |
182 | brelse(bh); | ||
183 | } | ||
184 | if (pending) | ||
185 | err = set_radix_bit(&root->fs_info->pending_del_radix, blocknr); | ||
186 | else | ||
187 | err = set_radix_bit(&root->fs_info->pinned_radix, blocknr); | 185 | err = set_radix_bit(&root->fs_info->pinned_radix, blocknr); |
186 | } else { | ||
187 | err = set_radix_bit(&root->fs_info->pending_del_radix, blocknr); | ||
188 | } | ||
188 | BUG_ON(err); | 189 | BUG_ON(err); |
189 | return 0; | 190 | return 0; |
190 | } | 191 | } |
@@ -223,6 +224,7 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root | |||
223 | BUG_ON(ei->refs == 0); | 224 | BUG_ON(ei->refs == 0); |
224 | refs = btrfs_extent_refs(ei) - 1; | 225 | refs = btrfs_extent_refs(ei) - 1; |
225 | btrfs_set_extent_refs(ei, refs); | 226 | btrfs_set_extent_refs(ei, refs); |
227 | mark_buffer_dirty(path.nodes[0]); | ||
226 | if (refs == 0) { | 228 | if (refs == 0) { |
227 | u64 super_blocks_used; | 229 | u64 super_blocks_used; |
228 | 230 | ||
@@ -240,7 +242,6 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root | |||
240 | if (ret) | 242 | if (ret) |
241 | BUG(); | 243 | BUG(); |
242 | } | 244 | } |
243 | mark_buffer_dirty(path.nodes[0]); | ||
244 | btrfs_release_path(extent_root, &path); | 245 | btrfs_release_path(extent_root, &path); |
245 | finish_current_insert(trans, extent_root); | 246 | finish_current_insert(trans, extent_root); |
246 | return ret; | 247 | return ret; |