diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-05-24 13:35:57 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-05-24 13:35:57 -0400 |
commit | 3a686375629da5d2e2ad019265b66ef113c87455 (patch) | |
tree | 1fbbedfcb92aeea38d90955ef11975187ddcc6f3 /fs/btrfs/file-item.c | |
parent | 2b8d99a723a3186a69b5bd941a272dbecae9205b (diff) |
Btrfs: sparse files!
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file-item.c')
-rw-r--r-- | fs/btrfs/file-item.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index a66709e6d036..7990b5742114 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c | |||
@@ -9,7 +9,8 @@ | |||
9 | int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, | 9 | int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, |
10 | struct btrfs_root *root, | 10 | struct btrfs_root *root, |
11 | u64 objectid, u64 pos, | 11 | u64 objectid, u64 pos, |
12 | u64 offset, u64 num_blocks) | 12 | u64 offset, u64 disk_num_blocks, |
13 | u64 num_blocks) | ||
13 | { | 14 | { |
14 | int ret = 0; | 15 | int ret = 0; |
15 | struct btrfs_file_extent_item *item; | 16 | struct btrfs_file_extent_item *item; |
@@ -30,7 +31,7 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, | |||
30 | item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), path->slots[0], | 31 | item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), path->slots[0], |
31 | struct btrfs_file_extent_item); | 32 | struct btrfs_file_extent_item); |
32 | btrfs_set_file_extent_disk_blocknr(item, offset); | 33 | btrfs_set_file_extent_disk_blocknr(item, offset); |
33 | btrfs_set_file_extent_disk_num_blocks(item, num_blocks); | 34 | btrfs_set_file_extent_disk_num_blocks(item, disk_num_blocks); |
34 | btrfs_set_file_extent_offset(item, 0); | 35 | btrfs_set_file_extent_offset(item, 0); |
35 | btrfs_set_file_extent_num_blocks(item, num_blocks); | 36 | btrfs_set_file_extent_num_blocks(item, num_blocks); |
36 | btrfs_set_file_extent_generation(item, trans->transid); | 37 | btrfs_set_file_extent_generation(item, trans->transid); |
@@ -176,14 +177,14 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans, | |||
176 | if (btrfs_key_type(&found_key) != BTRFS_CSUM_ITEM_KEY || | 177 | if (btrfs_key_type(&found_key) != BTRFS_CSUM_ITEM_KEY || |
177 | found_key.objectid != objectid || | 178 | found_key.objectid != objectid || |
178 | csum_offset >= MAX_CSUM_ITEMS(root)) { | 179 | csum_offset >= MAX_CSUM_ITEMS(root)) { |
179 | WARN_ON(1); | ||
180 | goto insert; | 180 | goto insert; |
181 | } | 181 | } |
182 | if (csum_offset >= btrfs_item_size(leaf->items + path->slots[0]) / | 182 | if (csum_offset >= btrfs_item_size(leaf->items + path->slots[0]) / |
183 | BTRFS_CRC32_SIZE) { | 183 | BTRFS_CRC32_SIZE) { |
184 | u32 diff = (csum_offset + 1) * BTRFS_CRC32_SIZE; | 184 | u32 diff = (csum_offset + 1) * BTRFS_CRC32_SIZE; |
185 | diff = diff - btrfs_item_size(leaf->items + path->slots[0]); | 185 | diff = diff - btrfs_item_size(leaf->items + path->slots[0]); |
186 | WARN_ON(diff != BTRFS_CRC32_SIZE); | 186 | if (diff != BTRFS_CRC32_SIZE) |
187 | goto insert; | ||
187 | ret = btrfs_extend_item(trans, root, path, diff); | 188 | ret = btrfs_extend_item(trans, root, path, diff); |
188 | BUG_ON(ret); | 189 | BUG_ON(ret); |
189 | goto csum; | 190 | goto csum; |
@@ -241,7 +242,7 @@ int btrfs_csum_verify_file_block(struct btrfs_root *root, | |||
241 | ret = PTR_ERR(item); | 242 | ret = PTR_ERR(item); |
242 | /* a csum that isn't present is a preallocated region. */ | 243 | /* a csum that isn't present is a preallocated region. */ |
243 | if (ret == -ENOENT || ret == -EFBIG) | 244 | if (ret == -ENOENT || ret == -EFBIG) |
244 | ret = 1; | 245 | ret = -ENOENT; |
245 | goto fail; | 246 | goto fail; |
246 | } | 247 | } |
247 | 248 | ||