Btrfs: byte offsets for file keys
authorChris Mason <chris.mason@oracle.com>
Tue, 27 Mar 2007 15:26:26 +0000 (11:26 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Tue, 27 Mar 2007 15:26:26 +0000 (11:26 -0400)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/ctree.h
fs/btrfs/file-item.c
fs/btrfs/super.c

index c3fa12a6b59e604d6324d85fef68c9173e26a656..1897f3a65b4fd5846c0bd55212bc1a5069e48eea 100644 (file)
@@ -899,5 +899,5 @@ int btrfs_alloc_file_extent(struct btrfs_trans_handle *trans,
 int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
                             struct btrfs_root *root,
                             struct btrfs_path *path, u64 objectid,
-                            u64 blocknr, u64 num_blocks, int mod);
+                            u64 blocknr, int mod);
 #endif
index 09de270c5a521ec5d8b7fbc4e880a77584653430..5230a44cb19b9eed44ec5e9a82d248454c9e1630 100644 (file)
@@ -26,6 +26,7 @@ int btrfs_alloc_file_extent(struct btrfs_trans_handle *trans,
 
        ret = btrfs_insert_empty_item(trans, root, &path, &file_key,
                                      sizeof(*item));
+       BUG_ON(ret);
        item = btrfs_item_ptr(btrfs_buffer_leaf(path.nodes[0]), path.slots[0],
                              struct btrfs_file_extent_item);
        btrfs_set_file_extent_disk_blocknr(item, ins.objectid);
@@ -42,7 +43,7 @@ int btrfs_alloc_file_extent(struct btrfs_trans_handle *trans,
 int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
                             struct btrfs_root *root,
                             struct btrfs_path *path, u64 objectid,
-                            u64 blocknr, u64 num_blocks, int mod)
+                            u64 offset, int mod)
 {
        int ret;
        struct btrfs_key file_key;
@@ -50,7 +51,7 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
        int cow = mod != 0;
 
        file_key.objectid = objectid;
-       file_key.offset = blocknr;
+       file_key.offset = offset;
        file_key.flags = 0;
        btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY);
        ret = btrfs_search_slot(trans, root, &file_key, path, ins_len, cow);
index fd3d9d616ff9a65d34d71e1a12d89d25d98020b4..f2f08189903d33c16d7121da1b737cf7580a3398 100644 (file)
@@ -697,7 +697,8 @@ static int btrfs_get_block(struct inode *inode, sector_t iblock,
 
 
        ret = btrfs_lookup_file_extent(trans, root, &path,
-                                      inode->i_ino, iblock, 1, 0);
+                                      inode->i_ino,
+                                      iblock << inode->i_blkbits, 0);
        if (ret < 0) {
                btrfs_release_path(root, &path);
                err = ret;
@@ -737,6 +738,7 @@ static int btrfs_get_block(struct inode *inode, sector_t iblock,
        }
 
        extent_start = btrfs_disk_key_offset(&leaf->items[path.slots[0]].key);
+       extent_start = extent_start >> inode->i_blkbits;
        extent_start += btrfs_file_extent_offset(item);
        extent_end = extent_start + btrfs_file_extent_num_blocks(item);
        btrfs_release_path(root, &path);
@@ -751,7 +753,8 @@ allocate:
                err = 0;
                goto out;
        }
-       ret = btrfs_alloc_file_extent(trans, root, objectid, iblock,
+       ret = btrfs_alloc_file_extent(trans, root, objectid,
+                                     iblock << inode->i_blkbits,
                                      1, extent_end, &blocknr);
        if (ret) {
                err = ret;