aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d3d39e4a2797..07b121d4bd93 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -186,8 +186,16 @@ static int dirty_and_release_pages(struct btrfs_trans_handle *trans,
186 u64 mask = root->blocksize - 1; 186 u64 mask = root->blocksize - 1;
187 last_pos_in_file = (isize + mask) & ~mask; 187 last_pos_in_file = (isize + mask) & ~mask;
188 hole_size = (start_pos - last_pos_in_file + mask) & ~mask; 188 hole_size = (start_pos - last_pos_in_file + mask) & ~mask;
189 hole_size >>= inode->i_blkbits; 189
190 if (last_pos_in_file < start_pos) { 190 if (last_pos_in_file < start_pos) {
191 err = btrfs_drop_extents(trans, root, inode,
192 last_pos_in_file,
193 last_pos_in_file + hole_size,
194 &hint_block);
195 if (err)
196 goto failed;
197
198 hole_size >>= inode->i_blkbits;
191 err = btrfs_insert_file_extent(trans, root, 199 err = btrfs_insert_file_extent(trans, root,
192 inode->i_ino, 200 inode->i_ino,
193 last_pos_in_file, 201 last_pos_in_file,
@@ -217,13 +225,11 @@ static int dirty_and_release_pages(struct btrfs_trans_handle *trans,
217 struct page *p = pages[0]; 225 struct page *p = pages[0];
218 /* step one, delete the existing extents in this range */ 226 /* step one, delete the existing extents in this range */
219 /* FIXME blocksize != pagesize */ 227 /* FIXME blocksize != pagesize */
220 if (start_pos < inode->i_size) { 228 err = btrfs_drop_extents(trans, root, inode, start_pos,
221 err = btrfs_drop_extents(trans, root, inode, start_pos, 229 (pos + write_bytes + root->blocksize -1) &
222 (pos + write_bytes + root->blocksize -1) & 230 ~((u64)root->blocksize - 1), &hint_block);
223 ~((u64)root->blocksize - 1), &hint_block); 231 if (err)
224 if (err) 232 goto failed;
225 goto failed;
226 }
227 233
228 err = insert_inline_extent(trans, root, inode, start_pos, 234 err = insert_inline_extent(trans, root, inode, start_pos,
229 end_pos - start_pos, p, 0); 235 end_pos - start_pos, p, 0);
@@ -400,6 +406,8 @@ next_slot:
400 keep = 1; 406 keep = 1;
401 WARN_ON(start & (root->blocksize - 1)); 407 WARN_ON(start & (root->blocksize - 1));
402 if (found_extent) { 408 if (found_extent) {
409 btrfs_drop_extent_cache(inode, key.offset,
410 start - 1 );
403 new_num = (start - key.offset) >> 411 new_num = (start - key.offset) >>
404 inode->i_blkbits; 412 inode->i_blkbits;
405 old_num = btrfs_file_extent_num_blocks(extent); 413 old_num = btrfs_file_extent_num_blocks(extent);
@@ -464,7 +472,7 @@ next_slot:
464 472
465 if (ret) { 473 if (ret) {
466 btrfs_print_leaf(root, btrfs_buffer_leaf(path->nodes[0])); 474 btrfs_print_leaf(root, btrfs_buffer_leaf(path->nodes[0]));
467 printk("got %d on inserting %Lu %u %Lu start %Lu end %Lu found %Lu %Lu\n", ret , ins.objectid, ins.flags, ins.offset, start, end, key.offset, extent_end); 475 printk("got %d on inserting %Lu %u %Lu start %Lu end %Lu found %Lu %Lu keep was %d\n", ret , ins.objectid, ins.flags, ins.offset, start, end, key.offset, extent_end, keep);
468 } 476 }
469 BUG_ON(ret); 477 BUG_ON(ret);
470 extent = btrfs_item_ptr( 478 extent = btrfs_item_ptr(