aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAneesh <aneesh.kumar@linux.vnet.ibm.com>2007-06-13 16:18:26 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-06-13 16:18:26 -0400
commitf1ace244c8c1e16eaa5c8b3b5339849651e31ede (patch)
treef1a84930a17a6803072f390bab28eb43f6e95f5b
parentb79ab950f57c3260ee609ba41779019d21b8eb88 (diff)
btrfs: Code cleanup
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>
-rw-r--r--fs/btrfs/btrfs_inode.h1
-rw-r--r--fs/btrfs/ctree.c1
-rw-r--r--fs/btrfs/dir-item.c1
-rw-r--r--fs/btrfs/extent-tree.c4
-rw-r--r--fs/btrfs/file-item.c2
-rw-r--r--fs/btrfs/inode-item.c1
-rw-r--r--fs/btrfs/inode.c10
-rw-r--r--fs/btrfs/root-tree.c3
8 files changed, 2 insertions, 21 deletions
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 783f06b63259..6bce46be49ff 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -19,6 +19,7 @@
19#ifndef __BTRFS_I__ 19#ifndef __BTRFS_I__
20#define __BTRFS_I__ 20#define __BTRFS_I__
21 21
22/* in memory btrfs inode */
22struct btrfs_inode { 23struct btrfs_inode {
23 struct btrfs_root *root; 24 struct btrfs_root *root;
24 struct btrfs_block_group_cache *block_group; 25 struct btrfs_block_group_cache *block_group;
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 4736155af419..498dea0854c1 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1647,7 +1647,6 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
1647 1647
1648 path = btrfs_alloc_path(); 1648 path = btrfs_alloc_path();
1649 BUG_ON(!path); 1649 BUG_ON(!path);
1650 btrfs_init_path(path);
1651 ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size); 1650 ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size);
1652 if (!ret) { 1651 if (!ret) {
1653 ptr = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), 1652 ptr = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]),
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index 0d179a44ebf4..ff10cf5a8422 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -74,7 +74,6 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
74 ret = btrfs_name_hash(name, name_len, &key.offset); 74 ret = btrfs_name_hash(name, name_len, &key.offset);
75 BUG_ON(ret); 75 BUG_ON(ret);
76 path = btrfs_alloc_path(); 76 path = btrfs_alloc_path();
77 btrfs_init_path(path);
78 data_size = sizeof(*dir_item) + name_len; 77 data_size = sizeof(*dir_item) + name_len;
79 dir_item = insert_with_overflow(trans, root, path, &key, data_size, 78 dir_item = insert_with_overflow(trans, root, path, &key, data_size,
80 name, name_len); 79 name, name_len);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 975a0eb9241b..5f4eaba8b85f 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -402,7 +402,6 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
402 &ins, 0); 402 &ins, 0);
403 path = btrfs_alloc_path(); 403 path = btrfs_alloc_path();
404 BUG_ON(!path); 404 BUG_ON(!path);
405 btrfs_init_path(path);
406 key.objectid = blocknr; 405 key.objectid = blocknr;
407 key.flags = 0; 406 key.flags = 0;
408 btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); 407 btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
@@ -437,7 +436,6 @@ static int lookup_extent_ref(struct btrfs_trans_handle *trans,
437 struct btrfs_extent_item *item; 436 struct btrfs_extent_item *item;
438 437
439 path = btrfs_alloc_path(); 438 path = btrfs_alloc_path();
440 btrfs_init_path(path);
441 key.objectid = blocknr; 439 key.objectid = blocknr;
442 key.offset = num_blocks; 440 key.offset = num_blocks;
443 key.flags = 0; 441 key.flags = 0;
@@ -807,7 +805,6 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
807 find_free_extent(trans, root, 0, 0, (u64)-1, 0, &ins, 0); 805 find_free_extent(trans, root, 0, 0, (u64)-1, 0, &ins, 0);
808 path = btrfs_alloc_path(); 806 path = btrfs_alloc_path();
809 BUG_ON(!path); 807 BUG_ON(!path);
810 btrfs_init_path(path);
811 808
812 ret = btrfs_search_slot(trans, extent_root, &key, path, -1, 1); 809 ret = btrfs_search_slot(trans, extent_root, &key, path, -1, 1);
813 if (ret) { 810 if (ret) {
@@ -1463,7 +1460,6 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
1463 1460
1464 path = btrfs_alloc_path(); 1461 path = btrfs_alloc_path();
1465 BUG_ON(!path); 1462 BUG_ON(!path);
1466 btrfs_init_path(path);
1467 1463
1468 level = btrfs_header_level(btrfs_buffer_header(snap)); 1464 level = btrfs_header_level(btrfs_buffer_header(snap));
1469 orig_level = level; 1465 orig_level = level;
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 37dd3801a107..3c140cc1dd05 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -38,7 +38,6 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
38 38
39 path = btrfs_alloc_path(); 39 path = btrfs_alloc_path();
40 BUG_ON(!path); 40 BUG_ON(!path);
41 btrfs_init_path(path);
42 file_key.objectid = objectid; 41 file_key.objectid = objectid;
43 file_key.offset = pos; 42 file_key.offset = pos;
44 file_key.flags = 0; 43 file_key.flags = 0;
@@ -274,7 +273,6 @@ int btrfs_csum_verify_file_block(struct btrfs_root *root,
274 273
275 path = btrfs_alloc_path(); 274 path = btrfs_alloc_path();
276 BUG_ON(!path); 275 BUG_ON(!path);
277 btrfs_init_path(path);
278 file_key.objectid = objectid; 276 file_key.objectid = objectid;
279 file_key.offset = offset; 277 file_key.offset = offset;
280 file_key.flags = 0; 278 file_key.flags = 0;
diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c
index 449e9dbdf957..e8b5a9f7c0c2 100644
--- a/fs/btrfs/inode-item.c
+++ b/fs/btrfs/inode-item.c
@@ -35,7 +35,6 @@ int btrfs_insert_inode(struct btrfs_trans_handle *trans, struct btrfs_root
35 35
36 path = btrfs_alloc_path(); 36 path = btrfs_alloc_path();
37 BUG_ON(!path); 37 BUG_ON(!path);
38 btrfs_init_path(path);
39 ret = btrfs_insert_item(trans, root, &key, inode_item, 38 ret = btrfs_insert_item(trans, root, &key, inode_item,
40 sizeof(*inode_item)); 39 sizeof(*inode_item));
41 btrfs_release_path(root, path); 40 btrfs_release_path(root, path);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d3d5a4cdb6af..e639cc9e089f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -79,7 +79,6 @@ void btrfs_read_locked_inode(struct inode *inode)
79 79
80 path = btrfs_alloc_path(); 80 path = btrfs_alloc_path();
81 BUG_ON(!path); 81 BUG_ON(!path);
82 btrfs_init_path(path);
83 mutex_lock(&root->fs_info->fs_mutex); 82 mutex_lock(&root->fs_info->fs_mutex);
84 83
85 memcpy(&location, &BTRFS_I(inode)->location, sizeof(location)); 84 memcpy(&location, &BTRFS_I(inode)->location, sizeof(location));
@@ -177,7 +176,6 @@ static int btrfs_update_inode(struct btrfs_trans_handle *trans,
177 176
178 path = btrfs_alloc_path(); 177 path = btrfs_alloc_path();
179 BUG_ON(!path); 178 BUG_ON(!path);
180 btrfs_init_path(path);
181 ret = btrfs_lookup_inode(trans, root, path, 179 ret = btrfs_lookup_inode(trans, root, path,
182 &BTRFS_I(inode)->location, 1); 180 &BTRFS_I(inode)->location, 1);
183 if (ret) { 181 if (ret) {
@@ -214,7 +212,6 @@ static int btrfs_unlink_trans(struct btrfs_trans_handle *trans,
214 212
215 path = btrfs_alloc_path(); 213 path = btrfs_alloc_path();
216 BUG_ON(!path); 214 BUG_ON(!path);
217 btrfs_init_path(path);
218 di = btrfs_lookup_dir_item(trans, root, path, dir->i_ino, 215 di = btrfs_lookup_dir_item(trans, root, path, dir->i_ino,
219 name, name_len, -1); 216 name, name_len, -1);
220 if (IS_ERR(di)) { 217 if (IS_ERR(di)) {
@@ -289,7 +286,6 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
289 286
290 path = btrfs_alloc_path(); 287 path = btrfs_alloc_path();
291 BUG_ON(!path); 288 BUG_ON(!path);
292 btrfs_init_path(path);
293 mutex_lock(&root->fs_info->fs_mutex); 289 mutex_lock(&root->fs_info->fs_mutex);
294 trans = btrfs_start_transaction(root, 1); 290 trans = btrfs_start_transaction(root, 1);
295 btrfs_set_trans_block_group(trans, dir); 291 btrfs_set_trans_block_group(trans, dir);
@@ -360,7 +356,6 @@ static int btrfs_free_inode(struct btrfs_trans_handle *trans,
360 356
361 path = btrfs_alloc_path(); 357 path = btrfs_alloc_path();
362 BUG_ON(!path); 358 BUG_ON(!path);
363 btrfs_init_path(path);
364 ret = btrfs_lookup_inode(trans, root, path, 359 ret = btrfs_lookup_inode(trans, root, path,
365 &BTRFS_I(inode)->location, -1); 360 &BTRFS_I(inode)->location, -1);
366 BUG_ON(ret); 361 BUG_ON(ret);
@@ -687,7 +682,6 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
687 682
688 path = btrfs_alloc_path(); 683 path = btrfs_alloc_path();
689 BUG_ON(!path); 684 BUG_ON(!path);
690 btrfs_init_path(path);
691 di = btrfs_lookup_dir_item(NULL, root, path, dir->i_ino, name, 685 di = btrfs_lookup_dir_item(NULL, root, path, dir->i_ino, name,
692 namelen, 0); 686 namelen, 0);
693 if (!di || IS_ERR(di)) { 687 if (!di || IS_ERR(di)) {
@@ -874,7 +868,6 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
874 btrfs_set_key_type(&key, key_type); 868 btrfs_set_key_type(&key, key_type);
875 key.offset = filp->f_pos; 869 key.offset = filp->f_pos;
876 path = btrfs_alloc_path(); 870 path = btrfs_alloc_path();
877 btrfs_init_path(path);
878 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 871 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
879 if (ret < 0) 872 if (ret < 0)
880 goto err; 873 goto err;
@@ -1263,7 +1256,6 @@ static int btrfs_get_block_lock(struct inode *inode, sector_t iblock,
1263 1256
1264 path = btrfs_alloc_path(); 1257 path = btrfs_alloc_path();
1265 BUG_ON(!path); 1258 BUG_ON(!path);
1266 btrfs_init_path(path);
1267 if (create & BTRFS_GET_BLOCK_CREATE) { 1259 if (create & BTRFS_GET_BLOCK_CREATE) {
1268 WARN_ON(1); 1260 WARN_ON(1);
1269 /* this almost but not quite works */ 1261 /* this almost but not quite works */
@@ -1280,7 +1272,7 @@ static int btrfs_get_block_lock(struct inode *inode, sector_t iblock,
1280 } 1272 }
1281 1273
1282 ret = btrfs_lookup_file_extent(NULL, root, path, 1274 ret = btrfs_lookup_file_extent(NULL, root, path,
1283 inode->i_ino, 1275 objectid,
1284 iblock << inode->i_blkbits, 0); 1276 iblock << inode->i_blkbits, 0);
1285 if (ret < 0) { 1277 if (ret < 0) {
1286 err = ret; 1278 err = ret;
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index 7a2d63c1ee80..8e1b9046d5ec 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -36,7 +36,6 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
36 36
37 path = btrfs_alloc_path(); 37 path = btrfs_alloc_path();
38 BUG_ON(!path); 38 BUG_ON(!path);
39 btrfs_init_path(path);
40 ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0); 39 ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
41 if (ret < 0) 40 if (ret < 0)
42 goto out; 41 goto out;
@@ -70,7 +69,6 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
70 69
71 path = btrfs_alloc_path(); 70 path = btrfs_alloc_path();
72 BUG_ON(!path); 71 BUG_ON(!path);
73 btrfs_init_path(path);
74 ret = btrfs_search_slot(trans, root, key, path, 0, 1); 72 ret = btrfs_search_slot(trans, root, key, path, 0, 1);
75 if (ret < 0) 73 if (ret < 0)
76 goto out; 74 goto out;
@@ -106,7 +104,6 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
106 104
107 path = btrfs_alloc_path(); 105 path = btrfs_alloc_path();
108 BUG_ON(!path); 106 BUG_ON(!path);
109 btrfs_init_path(path);
110 ret = btrfs_search_slot(trans, root, key, path, -1, 1); 107 ret = btrfs_search_slot(trans, root, key, path, -1, 1);
111 if (ret < 0) 108 if (ret < 0)
112 goto out; 109 goto out;