diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-27 11:26:26 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-27 11:26:26 -0400 |
commit | 9773a788681db1f5c2701b7433737fdca61a14ba (patch) | |
tree | 9d5f79f7a0e3b0f5e89509b42a3d8134364bed32 /fs/btrfs | |
parent | f4b9aa8d3b877d0a6044a6d6d9a44b29cab9e265 (diff) |
Btrfs: byte offsets for file keys
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ctree.h | 2 | ||||
-rw-r--r-- | fs/btrfs/file-item.c | 5 | ||||
-rw-r--r-- | fs/btrfs/super.c | 7 |
3 files changed, 9 insertions, 5 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index c3fa12a6b59e..1897f3a65b4f 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -899,5 +899,5 @@ int btrfs_alloc_file_extent(struct btrfs_trans_handle *trans, | |||
899 | int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans, | 899 | int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans, |
900 | struct btrfs_root *root, | 900 | struct btrfs_root *root, |
901 | struct btrfs_path *path, u64 objectid, | 901 | struct btrfs_path *path, u64 objectid, |
902 | u64 blocknr, u64 num_blocks, int mod); | 902 | u64 blocknr, int mod); |
903 | #endif | 903 | #endif |
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index 09de270c5a52..5230a44cb19b 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c | |||
@@ -26,6 +26,7 @@ int btrfs_alloc_file_extent(struct btrfs_trans_handle *trans, | |||
26 | 26 | ||
27 | ret = btrfs_insert_empty_item(trans, root, &path, &file_key, | 27 | ret = btrfs_insert_empty_item(trans, root, &path, &file_key, |
28 | sizeof(*item)); | 28 | sizeof(*item)); |
29 | BUG_ON(ret); | ||
29 | item = btrfs_item_ptr(btrfs_buffer_leaf(path.nodes[0]), path.slots[0], | 30 | item = btrfs_item_ptr(btrfs_buffer_leaf(path.nodes[0]), path.slots[0], |
30 | struct btrfs_file_extent_item); | 31 | struct btrfs_file_extent_item); |
31 | btrfs_set_file_extent_disk_blocknr(item, ins.objectid); | 32 | btrfs_set_file_extent_disk_blocknr(item, ins.objectid); |
@@ -42,7 +43,7 @@ int btrfs_alloc_file_extent(struct btrfs_trans_handle *trans, | |||
42 | int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans, | 43 | int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans, |
43 | struct btrfs_root *root, | 44 | struct btrfs_root *root, |
44 | struct btrfs_path *path, u64 objectid, | 45 | struct btrfs_path *path, u64 objectid, |
45 | u64 blocknr, u64 num_blocks, int mod) | 46 | u64 offset, int mod) |
46 | { | 47 | { |
47 | int ret; | 48 | int ret; |
48 | struct btrfs_key file_key; | 49 | struct btrfs_key file_key; |
@@ -50,7 +51,7 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans, | |||
50 | int cow = mod != 0; | 51 | int cow = mod != 0; |
51 | 52 | ||
52 | file_key.objectid = objectid; | 53 | file_key.objectid = objectid; |
53 | file_key.offset = blocknr; | 54 | file_key.offset = offset; |
54 | file_key.flags = 0; | 55 | file_key.flags = 0; |
55 | btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY); | 56 | btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY); |
56 | ret = btrfs_search_slot(trans, root, &file_key, path, ins_len, cow); | 57 | ret = btrfs_search_slot(trans, root, &file_key, path, ins_len, cow); |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index fd3d9d616ff9..f2f08189903d 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -697,7 +697,8 @@ static int btrfs_get_block(struct inode *inode, sector_t iblock, | |||
697 | 697 | ||
698 | 698 | ||
699 | ret = btrfs_lookup_file_extent(trans, root, &path, | 699 | ret = btrfs_lookup_file_extent(trans, root, &path, |
700 | inode->i_ino, iblock, 1, 0); | 700 | inode->i_ino, |
701 | iblock << inode->i_blkbits, 0); | ||
701 | if (ret < 0) { | 702 | if (ret < 0) { |
702 | btrfs_release_path(root, &path); | 703 | btrfs_release_path(root, &path); |
703 | err = ret; | 704 | err = ret; |
@@ -737,6 +738,7 @@ static int btrfs_get_block(struct inode *inode, sector_t iblock, | |||
737 | } | 738 | } |
738 | 739 | ||
739 | extent_start = btrfs_disk_key_offset(&leaf->items[path.slots[0]].key); | 740 | extent_start = btrfs_disk_key_offset(&leaf->items[path.slots[0]].key); |
741 | extent_start = extent_start >> inode->i_blkbits; | ||
740 | extent_start += btrfs_file_extent_offset(item); | 742 | extent_start += btrfs_file_extent_offset(item); |
741 | extent_end = extent_start + btrfs_file_extent_num_blocks(item); | 743 | extent_end = extent_start + btrfs_file_extent_num_blocks(item); |
742 | btrfs_release_path(root, &path); | 744 | btrfs_release_path(root, &path); |
@@ -751,7 +753,8 @@ allocate: | |||
751 | err = 0; | 753 | err = 0; |
752 | goto out; | 754 | goto out; |
753 | } | 755 | } |
754 | ret = btrfs_alloc_file_extent(trans, root, objectid, iblock, | 756 | ret = btrfs_alloc_file_extent(trans, root, objectid, |
757 | iblock << inode->i_blkbits, | ||
755 | 1, extent_end, &blocknr); | 758 | 1, extent_end, &blocknr); |
756 | if (ret) { | 759 | if (ret) { |
757 | err = ret; | 760 | err = ret; |