]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
btrfs: Code cleanup
authorAneesh <aneesh.kumar@linux.vnet.ibm.com>
Wed, 13 Jun 2007 20:18:26 +0000 (16:18 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Wed, 13 Jun 2007 20:18:26 +0000 (16:18 -0400)
Attaching below is some of the code cleanups that i came across while
reading the code.

a) alloc_path already calls init_path.
b) Mention that btrfs_inode is the in memory copy.Ext4 have ext4_inode_info as
the in memory copy ext4_inode as the disk copy

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/btrfs_inode.h
fs/btrfs/ctree.c
fs/btrfs/dir-item.c
fs/btrfs/extent-tree.c
fs/btrfs/file-item.c
fs/btrfs/inode-item.c
fs/btrfs/inode.c
fs/btrfs/root-tree.c

index 783f06b6325934926a5aa86a63f5c2398d3659ee..6bce46be49ffb0dbc5a50630287a7f39d808bca8 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef __BTRFS_I__
 #define __BTRFS_I__
 
+/* in memory btrfs inode */
 struct btrfs_inode {
        struct btrfs_root *root;
        struct btrfs_block_group_cache *block_group;
index 4736155af41978d5214b4587157547a6f7adfd8d..498dea0854c1525902f81ffa498e18ce05b23f01 100644 (file)
@@ -1647,7 +1647,6 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size);
        if (!ret) {
                ptr = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]),
index 0d179a44ebf4b6488276c76b5c92a914f5836079..ff10cf5a84226d6cefcd014e5e3a366121570338 100644 (file)
@@ -74,7 +74,6 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
        ret = btrfs_name_hash(name, name_len, &key.offset);
        BUG_ON(ret);
        path = btrfs_alloc_path();
-       btrfs_init_path(path);
        data_size = sizeof(*dir_item) + name_len;
        dir_item = insert_with_overflow(trans, root, path, &key, data_size,
                                        name, name_len);
index 975a0eb9241b989e95b10e650b5964aeaf066c8d..5f4eaba8b85f27de6cb798f01cadc898d6b6b0b9 100644 (file)
@@ -402,7 +402,6 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
                         &ins, 0);
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        key.objectid = blocknr;
        key.flags = 0;
        btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
@@ -437,7 +436,6 @@ static int lookup_extent_ref(struct btrfs_trans_handle *trans,
        struct btrfs_extent_item *item;
 
        path = btrfs_alloc_path();
-       btrfs_init_path(path);
        key.objectid = blocknr;
        key.offset = num_blocks;
        key.flags = 0;
@@ -807,7 +805,6 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
        find_free_extent(trans, root, 0, 0, (u64)-1, 0, &ins, 0);
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
 
        ret = btrfs_search_slot(trans, extent_root, &key, path, -1, 1);
        if (ret) {
@@ -1463,7 +1460,6 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
 
        level = btrfs_header_level(btrfs_buffer_header(snap));
        orig_level = level;
index 37dd3801a107084a22ac0f73a155006255db628a..3c140cc1dd0514730309a98b12146e076cde5f47 100644 (file)
@@ -38,7 +38,6 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        file_key.objectid = objectid;
        file_key.offset = pos;
        file_key.flags = 0;
@@ -274,7 +273,6 @@ int btrfs_csum_verify_file_block(struct btrfs_root *root,
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        file_key.objectid = objectid;
        file_key.offset = offset;
        file_key.flags = 0;
index 449e9dbdf9574eda533f65552d21c78215e175a4..e8b5a9f7c0c24956de75c1717c380a191ef46456 100644 (file)
@@ -35,7 +35,6 @@ int btrfs_insert_inode(struct btrfs_trans_handle *trans, struct btrfs_root
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        ret = btrfs_insert_item(trans, root, &key, inode_item,
                                sizeof(*inode_item));
        btrfs_release_path(root, path);
index d3d5a4cdb6af4898634bb72b8285c701f0db2864..e639cc9e089f01d02595be343f582b99463936c7 100644 (file)
@@ -79,7 +79,6 @@ void btrfs_read_locked_inode(struct inode *inode)
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        mutex_lock(&root->fs_info->fs_mutex);
 
        memcpy(&location, &BTRFS_I(inode)->location, sizeof(location));
@@ -177,7 +176,6 @@ static int btrfs_update_inode(struct btrfs_trans_handle *trans,
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        ret = btrfs_lookup_inode(trans, root, path,
                                 &BTRFS_I(inode)->location, 1);
        if (ret) {
@@ -214,7 +212,6 @@ static int btrfs_unlink_trans(struct btrfs_trans_handle *trans,
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        di = btrfs_lookup_dir_item(trans, root, path, dir->i_ino,
                                    name, name_len, -1);
        if (IS_ERR(di)) {
@@ -289,7 +286,6 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        mutex_lock(&root->fs_info->fs_mutex);
        trans = btrfs_start_transaction(root, 1);
        btrfs_set_trans_block_group(trans, dir);
@@ -360,7 +356,6 @@ static int btrfs_free_inode(struct btrfs_trans_handle *trans,
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        ret = btrfs_lookup_inode(trans, root, path,
                                 &BTRFS_I(inode)->location, -1);
        BUG_ON(ret);
@@ -687,7 +682,6 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        di = btrfs_lookup_dir_item(NULL, root, path, dir->i_ino, name,
                                    namelen, 0);
        if (!di || IS_ERR(di)) {
@@ -874,7 +868,6 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
        btrfs_set_key_type(&key, key_type);
        key.offset = filp->f_pos;
        path = btrfs_alloc_path();
-       btrfs_init_path(path);
        ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
        if (ret < 0)
                goto err;
@@ -1263,7 +1256,6 @@ static int btrfs_get_block_lock(struct inode *inode, sector_t iblock,
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        if (create & BTRFS_GET_BLOCK_CREATE) {
                WARN_ON(1);
                /* this almost but not quite works */
@@ -1280,7 +1272,7 @@ static int btrfs_get_block_lock(struct inode *inode, sector_t iblock,
        }
 
        ret = btrfs_lookup_file_extent(NULL, root, path,
-                                      inode->i_ino,
+                                      objectid,
                                       iblock << inode->i_blkbits, 0);
        if (ret < 0) {
                err = ret;
index 7a2d63c1ee809d19e00242f22a69adb7f20c9d66..8e1b9046d5ec2fbc63f3e2115878c6cd1b3c5d1e 100644 (file)
@@ -36,7 +36,6 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
        if (ret < 0)
                goto out;
@@ -70,7 +69,6 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        ret = btrfs_search_slot(trans, root, key, path, 0, 1);
        if (ret < 0)
                goto out;
@@ -106,7 +104,6 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
-       btrfs_init_path(path);
        ret = btrfs_search_slot(trans, root, key, path, -1, 1);
        if (ret < 0)
                goto out;