aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-01-05 21:25:51 -0500
committerChris Mason <chris.mason@oracle.com>2009-01-05 21:25:51 -0500
commitd397712bcc6a759a560fd247e6053ecae091f958 (patch)
tree9da8daebb870d8b8b1843507c4621715e23dd31a /fs/btrfs/ctree.c
parent1f3c79a28c8837e8572b98f6d14142d9a6133c56 (diff)
Btrfs: Fix checkpatch.pl warnings
There were many, most are fixed now. struct-funcs.c generates some warnings but these are bogus. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r--fs/btrfs/ctree.c217
1 files changed, 78 insertions, 139 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 7fad2e3ad6ff..9e46c0776816 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -67,7 +67,7 @@ void btrfs_free_path(struct btrfs_path *p)
67 * 67 *
68 * It is safe to call this on paths that no locks or extent buffers held. 68 * It is safe to call this on paths that no locks or extent buffers held.
69 */ 69 */
70void noinline btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p) 70noinline void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p)
71{ 71{
72 int i; 72 int i;
73 73
@@ -112,7 +112,7 @@ struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root)
112{ 112{
113 struct extent_buffer *eb; 113 struct extent_buffer *eb;
114 114
115 while(1) { 115 while (1) {
116 eb = btrfs_root_node(root); 116 eb = btrfs_root_node(root);
117 btrfs_tree_lock(eb); 117 btrfs_tree_lock(eb);
118 118
@@ -202,22 +202,22 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
202} 202}
203 203
204/* 204/*
205 * does the dirty work in cow of a single block. The parent block 205 * does the dirty work in cow of a single block. The parent block (if
206 * (if supplied) is updated to point to the new cow copy. The new 206 * supplied) is updated to point to the new cow copy. The new buffer is marked
207 * buffer is marked dirty and returned locked. If you modify the block 207 * dirty and returned locked. If you modify the block it needs to be marked
208 * it needs to be marked dirty again. 208 * dirty again.
209 * 209 *
210 * search_start -- an allocation hint for the new block 210 * search_start -- an allocation hint for the new block
211 * 211 *
212 * empty_size -- a hint that you plan on doing more cow. This is the size in bytes 212 * empty_size -- a hint that you plan on doing more cow. This is the size in
213 * the allocator should try to find free next to the block it returns. This is 213 * bytes the allocator should try to find free next to the block it returns.
214 * just a hint and may be ignored by the allocator. 214 * This is just a hint and may be ignored by the allocator.
215 * 215 *
216 * prealloc_dest -- if you have already reserved a destination for the cow, 216 * prealloc_dest -- if you have already reserved a destination for the cow,
217 * this uses that block instead of allocating a new one. btrfs_alloc_reserved_extent 217 * this uses that block instead of allocating a new one.
218 * is used to finish the allocation. 218 * btrfs_alloc_reserved_extent is used to finish the allocation.
219 */ 219 */
220static int noinline __btrfs_cow_block(struct btrfs_trans_handle *trans, 220static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
221 struct btrfs_root *root, 221 struct btrfs_root *root,
222 struct extent_buffer *buf, 222 struct extent_buffer *buf,
223 struct extent_buffer *parent, int parent_slot, 223 struct extent_buffer *parent, int parent_slot,
@@ -366,7 +366,7 @@ static int noinline __btrfs_cow_block(struct btrfs_trans_handle *trans,
366 * This version of it has extra checks so that a block isn't cow'd more than 366 * This version of it has extra checks so that a block isn't cow'd more than
367 * once per transaction, as long as it hasn't been written yet 367 * once per transaction, as long as it hasn't been written yet
368 */ 368 */
369int noinline btrfs_cow_block(struct btrfs_trans_handle *trans, 369noinline int btrfs_cow_block(struct btrfs_trans_handle *trans,
370 struct btrfs_root *root, struct extent_buffer *buf, 370 struct btrfs_root *root, struct extent_buffer *buf,
371 struct extent_buffer *parent, int parent_slot, 371 struct extent_buffer *parent, int parent_slot,
372 struct extent_buffer **cow_ret, u64 prealloc_dest) 372 struct extent_buffer **cow_ret, u64 prealloc_dest)
@@ -375,13 +375,16 @@ int noinline btrfs_cow_block(struct btrfs_trans_handle *trans,
375 int ret; 375 int ret;
376 376
377 if (trans->transaction != root->fs_info->running_transaction) { 377 if (trans->transaction != root->fs_info->running_transaction) {
378 printk(KERN_CRIT "trans %Lu running %Lu\n", trans->transid, 378 printk(KERN_CRIT "trans %llu running %llu\n",
379 (unsigned long long)trans->transid,
380 (unsigned long long)
379 root->fs_info->running_transaction->transid); 381 root->fs_info->running_transaction->transid);
380 WARN_ON(1); 382 WARN_ON(1);
381 } 383 }
382 if (trans->transid != root->fs_info->generation) { 384 if (trans->transid != root->fs_info->generation) {
383 printk(KERN_CRIT "trans %Lu running %Lu\n", trans->transid, 385 printk(KERN_CRIT "trans %llu running %llu\n",
384 root->fs_info->generation); 386 (unsigned long long)trans->transid,
387 (unsigned long long)root->fs_info->generation);
385 WARN_ON(1); 388 WARN_ON(1);
386 } 389 }
387 390
@@ -489,16 +492,10 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
489 if (cache_only && parent_level != 1) 492 if (cache_only && parent_level != 1)
490 return 0; 493 return 0;
491 494
492 if (trans->transaction != root->fs_info->running_transaction) { 495 if (trans->transaction != root->fs_info->running_transaction)
493 printk(KERN_CRIT "trans %Lu running %Lu\n", trans->transid,
494 root->fs_info->running_transaction->transid);
495 WARN_ON(1); 496 WARN_ON(1);
496 } 497 if (trans->transid != root->fs_info->generation)
497 if (trans->transid != root->fs_info->generation) {
498 printk(KERN_CRIT "trans %Lu running %Lu\n", trans->transid,
499 root->fs_info->generation);
500 WARN_ON(1); 498 WARN_ON(1);
501 }
502 499
503 parent_nritems = btrfs_header_nritems(parent); 500 parent_nritems = btrfs_header_nritems(parent);
504 blocksize = btrfs_level_size(root, parent_level - 1); 501 blocksize = btrfs_level_size(root, parent_level - 1);
@@ -681,51 +678,18 @@ static int check_leaf(struct btrfs_root *root, struct btrfs_path *path,
681 BUG_ON(btrfs_node_blockptr(parent, parent_slot) != 678 BUG_ON(btrfs_node_blockptr(parent, parent_slot) !=
682 btrfs_header_bytenr(leaf)); 679 btrfs_header_bytenr(leaf));
683 } 680 }
684#if 0
685 for (i = 0; nritems > 1 && i < nritems - 2; i++) {
686 btrfs_item_key_to_cpu(leaf, &cpukey, i + 1);
687 btrfs_item_key(leaf, &leaf_key, i);
688 if (comp_keys(&leaf_key, &cpukey) >= 0) {
689 btrfs_print_leaf(root, leaf);
690 printk("slot %d offset bad key\n", i);
691 BUG_ON(1);
692 }
693 if (btrfs_item_offset_nr(leaf, i) !=
694 btrfs_item_end_nr(leaf, i + 1)) {
695 btrfs_print_leaf(root, leaf);
696 printk("slot %d offset bad\n", i);
697 BUG_ON(1);
698 }
699 if (i == 0) {
700 if (btrfs_item_offset_nr(leaf, i) +
701 btrfs_item_size_nr(leaf, i) !=
702 BTRFS_LEAF_DATA_SIZE(root)) {
703 btrfs_print_leaf(root, leaf);
704 printk("slot %d first offset bad\n", i);
705 BUG_ON(1);
706 }
707 }
708 }
709 if (nritems > 0) {
710 if (btrfs_item_size_nr(leaf, nritems - 1) > 4096) {
711 btrfs_print_leaf(root, leaf);
712 printk("slot %d bad size \n", nritems - 1);
713 BUG_ON(1);
714 }
715 }
716#endif
717 if (slot != 0 && slot < nritems - 1) { 681 if (slot != 0 && slot < nritems - 1) {
718 btrfs_item_key(leaf, &leaf_key, slot); 682 btrfs_item_key(leaf, &leaf_key, slot);
719 btrfs_item_key_to_cpu(leaf, &cpukey, slot - 1); 683 btrfs_item_key_to_cpu(leaf, &cpukey, slot - 1);
720 if (comp_keys(&leaf_key, &cpukey) <= 0) { 684 if (comp_keys(&leaf_key, &cpukey) <= 0) {
721 btrfs_print_leaf(root, leaf); 685 btrfs_print_leaf(root, leaf);
722 printk("slot %d offset bad key\n", slot); 686 printk(KERN_CRIT "slot %d offset bad key\n", slot);
723 BUG_ON(1); 687 BUG_ON(1);
724 } 688 }
725 if (btrfs_item_offset_nr(leaf, slot - 1) != 689 if (btrfs_item_offset_nr(leaf, slot - 1) !=
726 btrfs_item_end_nr(leaf, slot)) { 690 btrfs_item_end_nr(leaf, slot)) {
727 btrfs_print_leaf(root, leaf); 691 btrfs_print_leaf(root, leaf);
728 printk("slot %d offset bad\n", slot); 692 printk(KERN_CRIT "slot %d offset bad\n", slot);
729 BUG_ON(1); 693 BUG_ON(1);
730 } 694 }
731 } 695 }
@@ -736,7 +700,7 @@ static int check_leaf(struct btrfs_root *root, struct btrfs_path *path,
736 if (btrfs_item_offset_nr(leaf, slot) != 700 if (btrfs_item_offset_nr(leaf, slot) !=
737 btrfs_item_end_nr(leaf, slot + 1)) { 701 btrfs_item_end_nr(leaf, slot + 1)) {
738 btrfs_print_leaf(root, leaf); 702 btrfs_print_leaf(root, leaf);
739 printk("slot %d offset bad\n", slot); 703 printk(KERN_CRIT "slot %d offset bad\n", slot);
740 BUG_ON(1); 704 BUG_ON(1);
741 } 705 }
742 } 706 }
@@ -745,30 +709,10 @@ static int check_leaf(struct btrfs_root *root, struct btrfs_path *path,
745 return 0; 709 return 0;
746} 710}
747 711
748static int noinline check_block(struct btrfs_root *root, 712static noinline int check_block(struct btrfs_root *root,
749 struct btrfs_path *path, int level) 713 struct btrfs_path *path, int level)
750{ 714{
751 u64 found_start;
752 return 0; 715 return 0;
753 if (btrfs_header_level(path->nodes[level]) != level)
754 printk("warning: bad level %Lu wanted %d found %d\n",
755 path->nodes[level]->start, level,
756 btrfs_header_level(path->nodes[level]));
757 found_start = btrfs_header_bytenr(path->nodes[level]);
758 if (found_start != path->nodes[level]->start) {
759 printk("warning: bad bytentr %Lu found %Lu\n",
760 path->nodes[level]->start, found_start);
761 }
762#if 0
763 struct extent_buffer *buf = path->nodes[level];
764
765 if (memcmp_extent_buffer(buf, root->fs_info->fsid,
766 (unsigned long)btrfs_header_fsid(buf),
767 BTRFS_FSID_SIZE)) {
768 printk("warning bad block %Lu\n", buf->start);
769 return 1;
770 }
771#endif
772 if (level == 0) 716 if (level == 0)
773 return check_leaf(root, path, level); 717 return check_leaf(root, path, level);
774 return check_node(root, path, level); 718 return check_node(root, path, level);
@@ -802,7 +746,7 @@ static noinline int generic_bin_search(struct extent_buffer *eb,
802 unsigned long map_len = 0; 746 unsigned long map_len = 0;
803 int err; 747 int err;
804 748
805 while(low < high) { 749 while (low < high) {
806 mid = (low + high) / 2; 750 mid = (low + high) / 2;
807 offset = p + mid * item_size; 751 offset = p + mid * item_size;
808 752
@@ -1130,7 +1074,7 @@ enospc:
1130 * when they are completely full. This is also done top down, so we 1074 * when they are completely full. This is also done top down, so we
1131 * have to be pessimistic. 1075 * have to be pessimistic.
1132 */ 1076 */
1133static int noinline push_nodes_for_insert(struct btrfs_trans_handle *trans, 1077static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
1134 struct btrfs_root *root, 1078 struct btrfs_root *root,
1135 struct btrfs_path *path, int level) 1079 struct btrfs_path *path, int level)
1136{ 1080{
@@ -1296,7 +1240,7 @@ static noinline void reada_for_search(struct btrfs_root *root,
1296 1240
1297 nritems = btrfs_header_nritems(node); 1241 nritems = btrfs_header_nritems(node);
1298 nr = slot; 1242 nr = slot;
1299 while(1) { 1243 while (1) {
1300 if (direction < 0) { 1244 if (direction < 0) {
1301 if (nr == 0) 1245 if (nr == 0)
1302 break; 1246 break;
@@ -1322,7 +1266,8 @@ static noinline void reada_for_search(struct btrfs_root *root,
1322 nscan++; 1266 nscan++;
1323 if (path->reada < 2 && (nread > (64 * 1024) || nscan > 32)) 1267 if (path->reada < 2 && (nread > (64 * 1024) || nscan > 32))
1324 break; 1268 break;
1325 if(nread > (256 * 1024) || nscan > 128) 1269
1270 if (nread > (256 * 1024) || nscan > 128)
1326 break; 1271 break;
1327 1272
1328 if (search < lowest_read) 1273 if (search < lowest_read)
@@ -1333,17 +1278,17 @@ static noinline void reada_for_search(struct btrfs_root *root,
1333} 1278}
1334 1279
1335/* 1280/*
1336 * when we walk down the tree, it is usually safe to unlock the higher layers in 1281 * when we walk down the tree, it is usually safe to unlock the higher layers
1337 * the tree. The exceptions are when our path goes through slot 0, because operations 1282 * in the tree. The exceptions are when our path goes through slot 0, because
1338 * on the tree might require changing key pointers higher up in the tree. 1283 * operations on the tree might require changing key pointers higher up in the
1284 * tree.
1339 * 1285 *
1340 * callers might also have set path->keep_locks, which tells this code to 1286 * callers might also have set path->keep_locks, which tells this code to keep
1341 * keep the lock if the path points to the last slot in the block. This is 1287 * the lock if the path points to the last slot in the block. This is part of
1342 * part of walking through the tree, and selecting the next slot in the higher 1288 * walking through the tree, and selecting the next slot in the higher block.
1343 * block.
1344 * 1289 *
1345 * lowest_unlock sets the lowest level in the tree we're allowed to unlock. 1290 * lowest_unlock sets the lowest level in the tree we're allowed to unlock. so
1346 * so if lowest_unlock is 1, level 0 won't be unlocked 1291 * if lowest_unlock is 1, level 0 won't be unlocked
1347 */ 1292 */
1348static noinline void unlock_up(struct btrfs_path *path, int level, 1293static noinline void unlock_up(struct btrfs_path *path, int level,
1349 int lowest_unlock) 1294 int lowest_unlock)
@@ -1832,9 +1777,8 @@ static int push_node_left(struct btrfs_trans_handle *trans,
1832 if (!empty && src_nritems <= 8) 1777 if (!empty && src_nritems <= 8)
1833 return 1; 1778 return 1;
1834 1779
1835 if (push_items <= 0) { 1780 if (push_items <= 0)
1836 return 1; 1781 return 1;
1837 }
1838 1782
1839 if (empty) { 1783 if (empty) {
1840 push_items = min(src_nritems, push_items); 1784 push_items = min(src_nritems, push_items);
@@ -1854,7 +1798,7 @@ static int push_node_left(struct btrfs_trans_handle *trans,
1854 copy_extent_buffer(dst, src, 1798 copy_extent_buffer(dst, src,
1855 btrfs_node_key_ptr_offset(dst_nritems), 1799 btrfs_node_key_ptr_offset(dst_nritems),
1856 btrfs_node_key_ptr_offset(0), 1800 btrfs_node_key_ptr_offset(0),
1857 push_items * sizeof(struct btrfs_key_ptr)); 1801 push_items * sizeof(struct btrfs_key_ptr));
1858 1802
1859 if (push_items < src_nritems) { 1803 if (push_items < src_nritems) {
1860 memmove_extent_buffer(src, btrfs_node_key_ptr_offset(0), 1804 memmove_extent_buffer(src, btrfs_node_key_ptr_offset(0),
@@ -1899,19 +1843,16 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
1899 src_nritems = btrfs_header_nritems(src); 1843 src_nritems = btrfs_header_nritems(src);
1900 dst_nritems = btrfs_header_nritems(dst); 1844 dst_nritems = btrfs_header_nritems(dst);
1901 push_items = BTRFS_NODEPTRS_PER_BLOCK(root) - dst_nritems; 1845 push_items = BTRFS_NODEPTRS_PER_BLOCK(root) - dst_nritems;
1902 if (push_items <= 0) { 1846 if (push_items <= 0)
1903 return 1; 1847 return 1;
1904 }
1905 1848
1906 if (src_nritems < 4) { 1849 if (src_nritems < 4)
1907 return 1; 1850 return 1;
1908 }
1909 1851
1910 max_push = src_nritems / 2 + 1; 1852 max_push = src_nritems / 2 + 1;
1911 /* don't try to empty the node */ 1853 /* don't try to empty the node */
1912 if (max_push >= src_nritems) { 1854 if (max_push >= src_nritems)
1913 return 1; 1855 return 1;
1914 }
1915 1856
1916 if (max_push < push_items) 1857 if (max_push < push_items)
1917 push_items = max_push; 1858 push_items = max_push;
@@ -1924,7 +1865,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
1924 copy_extent_buffer(dst, src, 1865 copy_extent_buffer(dst, src,
1925 btrfs_node_key_ptr_offset(0), 1866 btrfs_node_key_ptr_offset(0),
1926 btrfs_node_key_ptr_offset(src_nritems - push_items), 1867 btrfs_node_key_ptr_offset(src_nritems - push_items),
1927 push_items * sizeof(struct btrfs_key_ptr)); 1868 push_items * sizeof(struct btrfs_key_ptr));
1928 1869
1929 btrfs_set_header_nritems(src, src_nritems - push_items); 1870 btrfs_set_header_nritems(src, src_nritems - push_items);
1930 btrfs_set_header_nritems(dst, dst_nritems + push_items); 1871 btrfs_set_header_nritems(dst, dst_nritems + push_items);
@@ -1945,7 +1886,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
1945 * 1886 *
1946 * returns zero on success or < 0 on failure. 1887 * returns zero on success or < 0 on failure.
1947 */ 1888 */
1948static int noinline insert_new_root(struct btrfs_trans_handle *trans, 1889static noinline int insert_new_root(struct btrfs_trans_handle *trans,
1949 struct btrfs_root *root, 1890 struct btrfs_root *root,
1950 struct btrfs_path *path, int level) 1891 struct btrfs_path *path, int level)
1951{ 1892{
@@ -2176,14 +2117,15 @@ static int leaf_space_used(struct extent_buffer *l, int start, int nr)
2176 * the start of the leaf data. IOW, how much room 2117 * the start of the leaf data. IOW, how much room
2177 * the leaf has left for both items and data 2118 * the leaf has left for both items and data
2178 */ 2119 */
2179int noinline btrfs_leaf_free_space(struct btrfs_root *root, 2120noinline int btrfs_leaf_free_space(struct btrfs_root *root,
2180 struct extent_buffer *leaf) 2121 struct extent_buffer *leaf)
2181{ 2122{
2182 int nritems = btrfs_header_nritems(leaf); 2123 int nritems = btrfs_header_nritems(leaf);
2183 int ret; 2124 int ret;
2184 ret = BTRFS_LEAF_DATA_SIZE(root) - leaf_space_used(leaf, 0, nritems); 2125 ret = BTRFS_LEAF_DATA_SIZE(root) - leaf_space_used(leaf, 0, nritems);
2185 if (ret < 0) { 2126 if (ret < 0) {
2186 printk("leaf free space ret %d, leaf data size %lu, used %d nritems %d\n", 2127 printk(KERN_CRIT "leaf free space ret %d, leaf data size %lu, "
2128 "used %d nritems %d\n",
2187 ret, (unsigned long) BTRFS_LEAF_DATA_SIZE(root), 2129 ret, (unsigned long) BTRFS_LEAF_DATA_SIZE(root),
2188 leaf_space_used(leaf, 0, nritems), nritems); 2130 leaf_space_used(leaf, 0, nritems), nritems);
2189 } 2131 }
@@ -2219,9 +2161,9 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
2219 int ret; 2161 int ret;
2220 2162
2221 slot = path->slots[1]; 2163 slot = path->slots[1];
2222 if (!path->nodes[1]) { 2164 if (!path->nodes[1])
2223 return 1; 2165 return 1;
2224 } 2166
2225 upper = path->nodes[1]; 2167 upper = path->nodes[1];
2226 if (slot >= btrfs_header_nritems(upper) - 1) 2168 if (slot >= btrfs_header_nritems(upper) - 1)
2227 return 1; 2169 return 1;
@@ -2418,9 +2360,8 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
2418 return 1; 2360 return 1;
2419 2361
2420 right_nritems = btrfs_header_nritems(right); 2362 right_nritems = btrfs_header_nritems(right);
2421 if (right_nritems == 0) { 2363 if (right_nritems == 0)
2422 return 1; 2364 return 1;
2423 }
2424 2365
2425 WARN_ON(!btrfs_tree_locked(path->nodes[1])); 2366 WARN_ON(!btrfs_tree_locked(path->nodes[1]));
2426 2367
@@ -2502,7 +2443,7 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
2502 push_items * sizeof(struct btrfs_item)); 2443 push_items * sizeof(struct btrfs_item));
2503 2444
2504 push_space = BTRFS_LEAF_DATA_SIZE(root) - 2445 push_space = BTRFS_LEAF_DATA_SIZE(root) -
2505 btrfs_item_offset_nr(right, push_items -1); 2446 btrfs_item_offset_nr(right, push_items - 1);
2506 2447
2507 copy_extent_buffer(left, right, btrfs_leaf_data(left) + 2448 copy_extent_buffer(left, right, btrfs_leaf_data(left) +
2508 leaf_data_end(root, left) - push_space, 2449 leaf_data_end(root, left) - push_space,
@@ -2537,7 +2478,8 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
2537 2478
2538 /* fixup right node */ 2479 /* fixup right node */
2539 if (push_items > right_nritems) { 2480 if (push_items > right_nritems) {
2540 printk("push items %d nr %u\n", push_items, right_nritems); 2481 printk(KERN_CRIT "push items %d nr %u\n", push_items,
2482 right_nritems);
2541 WARN_ON(1); 2483 WARN_ON(1);
2542 } 2484 }
2543 2485
@@ -2640,9 +2582,8 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans,
2640 /* first try to make some room by pushing left and right */ 2582 /* first try to make some room by pushing left and right */
2641 if (data_size && ins_key->type != BTRFS_DIR_ITEM_KEY) { 2583 if (data_size && ins_key->type != BTRFS_DIR_ITEM_KEY) {
2642 wret = push_leaf_right(trans, root, path, data_size, 0); 2584 wret = push_leaf_right(trans, root, path, data_size, 0);
2643 if (wret < 0) { 2585 if (wret < 0)
2644 return wret; 2586 return wret;
2645 }
2646 if (wret) { 2587 if (wret) {
2647 wret = push_leaf_left(trans, root, path, data_size, 0); 2588 wret = push_leaf_left(trans, root, path, data_size, 0);
2648 if (wret < 0) 2589 if (wret < 0)
@@ -2665,7 +2606,7 @@ again:
2665 l = path->nodes[0]; 2606 l = path->nodes[0];
2666 slot = path->slots[0]; 2607 slot = path->slots[0];
2667 nritems = btrfs_header_nritems(l); 2608 nritems = btrfs_header_nritems(l);
2668 mid = (nritems + 1)/ 2; 2609 mid = (nritems + 1) / 2;
2669 2610
2670 right = btrfs_alloc_free_block(trans, root, root->leafsize, 2611 right = btrfs_alloc_free_block(trans, root, root->leafsize,
2671 path->nodes[1]->start, 2612 path->nodes[1]->start,
@@ -2734,7 +2675,7 @@ again:
2734 path->slots[0] = 0; 2675 path->slots[0] = 0;
2735 if (path->slots[1] == 0) { 2676 if (path->slots[1] == 0) {
2736 wret = fixup_low_keys(trans, root, 2677 wret = fixup_low_keys(trans, root,
2737 path, &disk_key, 1); 2678 path, &disk_key, 1);
2738 if (wret) 2679 if (wret)
2739 ret = wret; 2680 ret = wret;
2740 } 2681 }
@@ -3033,8 +2974,8 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
3033 BTRFS_FILE_EXTENT_INLINE) { 2974 BTRFS_FILE_EXTENT_INLINE) {
3034 ptr = btrfs_item_ptr_offset(leaf, slot); 2975 ptr = btrfs_item_ptr_offset(leaf, slot);
3035 memmove_extent_buffer(leaf, ptr, 2976 memmove_extent_buffer(leaf, ptr,
3036 (unsigned long)fi, 2977 (unsigned long)fi,
3037 offsetof(struct btrfs_file_extent_item, 2978 offsetof(struct btrfs_file_extent_item,
3038 disk_bytenr)); 2979 disk_bytenr));
3039 } 2980 }
3040 } 2981 }
@@ -3096,7 +3037,8 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans,
3096 BUG_ON(slot < 0); 3037 BUG_ON(slot < 0);
3097 if (slot >= nritems) { 3038 if (slot >= nritems) {
3098 btrfs_print_leaf(root, leaf); 3039 btrfs_print_leaf(root, leaf);
3099 printk("slot %d too large, nritems %d\n", slot, nritems); 3040 printk(KERN_CRIT "slot %d too large, nritems %d\n",
3041 slot, nritems);
3100 BUG_ON(1); 3042 BUG_ON(1);
3101 } 3043 }
3102 3044
@@ -3218,7 +3160,7 @@ int btrfs_insert_some_items(struct btrfs_trans_handle *trans,
3218 3160
3219 if (old_data < data_end) { 3161 if (old_data < data_end) {
3220 btrfs_print_leaf(root, leaf); 3162 btrfs_print_leaf(root, leaf);
3221 printk("slot %d old_data %d data_end %d\n", 3163 printk(KERN_CRIT "slot %d old_data %d data_end %d\n",
3222 slot, old_data, data_end); 3164 slot, old_data, data_end);
3223 BUG_ON(1); 3165 BUG_ON(1);
3224 } 3166 }
@@ -3317,9 +3259,8 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
3317 unsigned int data_end; 3259 unsigned int data_end;
3318 struct btrfs_disk_key disk_key; 3260 struct btrfs_disk_key disk_key;
3319 3261
3320 for (i = 0; i < nr; i++) { 3262 for (i = 0; i < nr; i++)
3321 total_data += data_size[i]; 3263 total_data += data_size[i];
3322 }
3323 3264
3324 total_size = total_data + (nr * sizeof(struct btrfs_item)); 3265 total_size = total_data + (nr * sizeof(struct btrfs_item));
3325 ret = btrfs_search_slot(trans, root, cpu_key, path, total_size, 1); 3266 ret = btrfs_search_slot(trans, root, cpu_key, path, total_size, 1);
@@ -3336,7 +3277,7 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
3336 3277
3337 if (btrfs_leaf_free_space(root, leaf) < total_size) { 3278 if (btrfs_leaf_free_space(root, leaf) < total_size) {
3338 btrfs_print_leaf(root, leaf); 3279 btrfs_print_leaf(root, leaf);
3339 printk("not enough freespace need %u have %d\n", 3280 printk(KERN_CRIT "not enough freespace need %u have %d\n",
3340 total_size, btrfs_leaf_free_space(root, leaf)); 3281 total_size, btrfs_leaf_free_space(root, leaf));
3341 BUG(); 3282 BUG();
3342 } 3283 }
@@ -3349,7 +3290,7 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
3349 3290
3350 if (old_data < data_end) { 3291 if (old_data < data_end) {
3351 btrfs_print_leaf(root, leaf); 3292 btrfs_print_leaf(root, leaf);
3352 printk("slot %d old_data %d data_end %d\n", 3293 printk(KERN_CRIT "slot %d old_data %d data_end %d\n",
3353 slot, old_data, data_end); 3294 slot, old_data, data_end);
3354 BUG_ON(1); 3295 BUG_ON(1);
3355 } 3296 }
@@ -3457,7 +3398,7 @@ static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3457 int wret; 3398 int wret;
3458 3399
3459 nritems = btrfs_header_nritems(parent); 3400 nritems = btrfs_header_nritems(parent);
3460 if (slot != nritems -1) { 3401 if (slot != nritems - 1) {
3461 memmove_extent_buffer(parent, 3402 memmove_extent_buffer(parent,
3462 btrfs_node_key_ptr_offset(slot), 3403 btrfs_node_key_ptr_offset(slot),
3463 btrfs_node_key_ptr_offset(slot + 1), 3404 btrfs_node_key_ptr_offset(slot + 1),
@@ -3614,7 +3555,8 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3614 3555
3615 if (btrfs_header_nritems(leaf) == 0) { 3556 if (btrfs_header_nritems(leaf) == 0) {
3616 path->slots[1] = slot; 3557 path->slots[1] = slot;
3617 ret = btrfs_del_leaf(trans, root, path, leaf->start); 3558 ret = btrfs_del_leaf(trans, root, path,
3559 leaf->start);
3618 BUG_ON(ret); 3560 BUG_ON(ret);
3619 free_extent_buffer(leaf); 3561 free_extent_buffer(leaf);
3620 } else { 3562 } else {
@@ -3717,7 +3659,7 @@ again:
3717 ret = 1; 3659 ret = 1;
3718 goto out; 3660 goto out;
3719 } 3661 }
3720 while(1) { 3662 while (1) {
3721 nritems = btrfs_header_nritems(cur); 3663 nritems = btrfs_header_nritems(cur);
3722 level = btrfs_header_level(cur); 3664 level = btrfs_header_level(cur);
3723 sret = bin_search(cur, min_key, level, &slot); 3665 sret = bin_search(cur, min_key, level, &slot);
@@ -3738,7 +3680,7 @@ again:
3738 * min_trans parameters. If it isn't in cache or is too 3680 * min_trans parameters. If it isn't in cache or is too
3739 * old, skip to the next one. 3681 * old, skip to the next one.
3740 */ 3682 */
3741 while(slot < nritems) { 3683 while (slot < nritems) {
3742 u64 blockptr; 3684 u64 blockptr;
3743 u64 gen; 3685 u64 gen;
3744 struct extent_buffer *tmp; 3686 struct extent_buffer *tmp;
@@ -3830,7 +3772,7 @@ int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path,
3830 struct extent_buffer *c; 3772 struct extent_buffer *c;
3831 3773
3832 WARN_ON(!path->keep_locks); 3774 WARN_ON(!path->keep_locks);
3833 while(level < BTRFS_MAX_LEVEL) { 3775 while (level < BTRFS_MAX_LEVEL) {
3834 if (!path->nodes[level]) 3776 if (!path->nodes[level])
3835 return 1; 3777 return 1;
3836 3778
@@ -3839,9 +3781,8 @@ int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path,
3839next: 3781next:
3840 if (slot >= btrfs_header_nritems(c)) { 3782 if (slot >= btrfs_header_nritems(c)) {
3841 level++; 3783 level++;
3842 if (level == BTRFS_MAX_LEVEL) { 3784 if (level == BTRFS_MAX_LEVEL)
3843 return 1; 3785 return 1;
3844 }
3845 continue; 3786 continue;
3846 } 3787 }
3847 if (level == 0) 3788 if (level == 0)
@@ -3889,9 +3830,8 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
3889 int ret; 3830 int ret;
3890 3831
3891 nritems = btrfs_header_nritems(path->nodes[0]); 3832 nritems = btrfs_header_nritems(path->nodes[0]);
3892 if (nritems == 0) { 3833 if (nritems == 0)
3893 return 1; 3834 return 1;
3894 }
3895 3835
3896 btrfs_item_key_to_cpu(path->nodes[0], &key, nritems - 1); 3836 btrfs_item_key_to_cpu(path->nodes[0], &key, nritems - 1);
3897 3837
@@ -3915,7 +3855,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
3915 goto done; 3855 goto done;
3916 } 3856 }
3917 3857
3918 while(level < BTRFS_MAX_LEVEL) { 3858 while (level < BTRFS_MAX_LEVEL) {
3919 if (!path->nodes[level]) 3859 if (!path->nodes[level])
3920 return 1; 3860 return 1;
3921 3861
@@ -3923,9 +3863,8 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
3923 c = path->nodes[level]; 3863 c = path->nodes[level];
3924 if (slot >= btrfs_header_nritems(c)) { 3864 if (slot >= btrfs_header_nritems(c)) {
3925 level++; 3865 level++;
3926 if (level == BTRFS_MAX_LEVEL) { 3866 if (level == BTRFS_MAX_LEVEL)
3927 return 1; 3867 return 1;
3928 }
3929 continue; 3868 continue;
3930 } 3869 }
3931 3870
@@ -3946,7 +3885,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
3946 break; 3885 break;
3947 } 3886 }
3948 path->slots[level] = slot; 3887 path->slots[level] = slot;
3949 while(1) { 3888 while (1) {
3950 level--; 3889 level--;
3951 c = path->nodes[level]; 3890 c = path->nodes[level];
3952 if (path->locks[level]) 3891 if (path->locks[level])
@@ -3986,7 +3925,7 @@ int btrfs_previous_item(struct btrfs_root *root,
3986 u32 nritems; 3925 u32 nritems;
3987 int ret; 3926 int ret;
3988 3927
3989 while(1) { 3928 while (1) {
3990 if (path->slots[0] == 0) { 3929 if (path->slots[0] == 0) {
3991 ret = btrfs_prev_leaf(root, path); 3930 ret = btrfs_prev_leaf(root, path);
3992 if (ret != 0) 3931 if (ret != 0)