diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-10-31 12:46:39 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-10-31 12:46:39 -0400 |
commit | 70b99e6959a4c28ae1b314985eca731f3db72f1d (patch) | |
tree | 81578759fe422f7b17a734b8bf16b042aa02a046 /fs/btrfs/file.c | |
parent | d899e05215178fed903ad0e7fc1cb4d8e0cc0a88 (diff) |
Btrfs: Compression corner fixes
Make sure we keep page->mapping NULL on the pages we're getting
via alloc_page. It gets set so a few of the callbacks can do the right
thing, but in general these pages don't have a mapping.
Don't try to truncate compressed inline items in btrfs_drop_extents.
The whole compressed item must be preserved.
Don't try to create multipage inline compressed items. When we try to
overwrite just the first page of the file, we would have to read in and recow
all the pages after it in the same compressed inline items. For now, only
create single page inline items.
Make sure we lock pages in the correct order during delalloc. The
search into the state tree for delalloc bytes can return bytes before
the page we already have locked.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 238a8e215eb9..0c8cc35a8b97 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -368,8 +368,8 @@ int noinline btrfs_drop_extents(struct btrfs_trans_handle *trans, | |||
368 | u64 search_start = start; | 368 | u64 search_start = start; |
369 | u64 leaf_start; | 369 | u64 leaf_start; |
370 | u64 ram_bytes = 0; | 370 | u64 ram_bytes = 0; |
371 | u8 compression = 0; | 371 | u8 compression; |
372 | u8 encryption = 0; | 372 | u8 encryption; |
373 | u16 other_encoding = 0; | 373 | u16 other_encoding = 0; |
374 | u64 root_gen; | 374 | u64 root_gen; |
375 | u64 root_owner; | 375 | u64 root_owner; |
@@ -415,6 +415,8 @@ next_slot: | |||
415 | leaf_start = 0; | 415 | leaf_start = 0; |
416 | root_gen = 0; | 416 | root_gen = 0; |
417 | root_owner = 0; | 417 | root_owner = 0; |
418 | compression = 0; | ||
419 | encryption = 0; | ||
418 | extent = NULL; | 420 | extent = NULL; |
419 | leaf = path->nodes[0]; | 421 | leaf = path->nodes[0]; |
420 | slot = path->slots[0]; | 422 | slot = path->slots[0]; |
@@ -546,8 +548,12 @@ next_slot: | |||
546 | inline_limit - key.offset); | 548 | inline_limit - key.offset); |
547 | inode_sub_bytes(inode, extent_end - | 549 | inode_sub_bytes(inode, extent_end - |
548 | inline_limit); | 550 | inline_limit); |
549 | btrfs_truncate_item(trans, root, path, | 551 | btrfs_set_file_extent_ram_bytes(leaf, extent, |
550 | new_size, 1); | 552 | new_size); |
553 | if (!compression && !encryption) { | ||
554 | btrfs_truncate_item(trans, root, path, | ||
555 | new_size, 1); | ||
556 | } | ||
551 | } | 557 | } |
552 | } | 558 | } |
553 | /* delete the entire extent */ | 559 | /* delete the entire extent */ |
@@ -567,8 +573,11 @@ next_slot: | |||
567 | new_size = btrfs_file_extent_calc_inline_size( | 573 | new_size = btrfs_file_extent_calc_inline_size( |
568 | extent_end - end); | 574 | extent_end - end); |
569 | inode_sub_bytes(inode, end - key.offset); | 575 | inode_sub_bytes(inode, end - key.offset); |
570 | ret = btrfs_truncate_item(trans, root, path, | 576 | btrfs_set_file_extent_ram_bytes(leaf, extent, |
571 | new_size, 0); | 577 | new_size); |
578 | if (!compression && !encryption) | ||
579 | ret = btrfs_truncate_item(trans, root, path, | ||
580 | new_size, 0); | ||
572 | BUG_ON(ret); | 581 | BUG_ON(ret); |
573 | } | 582 | } |
574 | /* create bookend, splitting the extent in two */ | 583 | /* create bookend, splitting the extent in two */ |