Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128511
b: refs/heads/master
c: 18f16f7
h: refs/heads/master
i:
  128509: d90f6ea
  128507: 648a90c
  128503: 94f5f6e
  128495: 93c8db5
  128479: 5a0651e
  128447: 7c56bb8
  128383: fe58e78
  128255: ad8077d
  127999: c3235cf
v: v3
  • Loading branch information
Yan authored and Chris Mason committed Sep 25, 2008
1 parent 6781810 commit 6650f35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cc0c55384796b422133ff1f21646835b31590f88
refs/heads/master: 18f16f7ba62a01c29e09b40ac6ad6d92a8955859
21 changes: 12 additions & 9 deletions trunk/fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
key.objectid = inode->i_ino;
key.offset = offset;
btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY);
datasize = btrfs_file_extent_calc_inline_size(offset + size);

ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
if (ret < 0) {
Expand All @@ -130,7 +129,7 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
}
if (ret == 0) {
u32 found_size;
u64 found_start;
u64 found_end;

leaf = path->nodes[0];
ei = btrfs_item_ptr(leaf, path->slots[0],
Expand All @@ -144,19 +143,17 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
offset, inode->i_ino);
goto fail;
}
found_start = key.offset;
found_size = btrfs_file_extent_inline_len(leaf,
btrfs_item_nr(leaf, path->slots[0]));
found_end = key.offset + found_size;

if (found_size < offset + size) {
if (found_end < offset + size) {
btrfs_release_path(root, path);
ret = btrfs_search_slot(trans, root, &key, path,
offset + size - found_size -
found_start, 1);
offset + size - found_end, 1);
BUG_ON(ret != 0);
ret = btrfs_extend_item(trans, root, path,
offset + size - found_size -
found_start);
offset + size - found_end);
if (ret) {
err = ret;
goto fail;
Expand All @@ -165,9 +162,15 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
ei = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_file_extent_item);
}
if (found_end < offset) {
ptr = btrfs_file_extent_inline_start(ei) + found_size;
memset_extent_buffer(leaf, 0, ptr, offset - found_end);
}
} else {
insert:
btrfs_release_path(root, path);
datasize = offset + size - key.offset;
datasize = btrfs_file_extent_calc_inline_size(datasize);
ret = btrfs_insert_empty_item(trans, root, path, &key,
datasize);
if (ret) {
Expand All @@ -181,7 +184,7 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
btrfs_set_file_extent_generation(leaf, ei, trans->transid);
btrfs_set_file_extent_type(leaf, ei, BTRFS_FILE_EXTENT_INLINE);
}
ptr = btrfs_file_extent_inline_start(ei) + offset;
ptr = btrfs_file_extent_inline_start(ei) + offset - key.offset;

cur_size = size;
i = 0;
Expand Down

0 comments on commit 6650f35

Please sign in to comment.