summaryrefslogtreecommitdiff
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-10-31 12:46:39 -0400
committerChris Mason <chris.mason@oracle.com>2008-10-31 12:46:39 -0400
commit70b99e6959a4c28ae1b314985eca731f3db72f1d (patch)
tree81578759fe422f7b17a734b8bf16b042aa02a046 /fs/btrfs/file.c
parentd899e05215178fed903ad0e7fc1cb4d8e0cc0a88 (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.c21
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,
u64 search_start = start;
u64 leaf_start;
u64 ram_bytes = 0;
- u8 compression = 0;
- u8 encryption = 0;
+ u8 compression;
+ u8 encryption;
u16 other_encoding = 0;
u64 root_gen;
u64 root_owner;
@@ -415,6 +415,8 @@ next_slot:
leaf_start = 0;
root_gen = 0;
root_owner = 0;
+ compression = 0;
+ encryption = 0;
extent = NULL;
leaf = path->nodes[0];
slot = path->slots[0];
@@ -546,8 +548,12 @@ next_slot:
inline_limit - key.offset);
inode_sub_bytes(inode, extent_end -
inline_limit);
- btrfs_truncate_item(trans, root, path,
- new_size, 1);
+ btrfs_set_file_extent_ram_bytes(leaf, extent,
+ new_size);
+ if (!compression && !encryption) {
+ btrfs_truncate_item(trans, root, path,
+ new_size, 1);
+ }
}
}
/* delete the entire extent */
@@ -567,8 +573,11 @@ next_slot:
new_size = btrfs_file_extent_calc_inline_size(
extent_end - end);
inode_sub_bytes(inode, end - key.offset);
- ret = btrfs_truncate_item(trans, root, path,
- new_size, 0);
+ btrfs_set_file_extent_ram_bytes(leaf, extent,
+ new_size);
+ if (!compression && !encryption)
+ ret = btrfs_truncate_item(trans, root, path,
+ new_size, 0);
BUG_ON(ret);
}
/* create bookend, splitting the extent in two */