aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.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/inode.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/inode.c')
-rw-r--r--fs/btrfs/inode.c173
1 files changed, 86 insertions, 87 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 068bad463387..1b35ea63b6ce 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -124,7 +124,7 @@ int btrfs_check_free_space(struct btrfs_root *root, u64 num_required,
124 * the btree. The caller should have done a btrfs_drop_extents so that 124 * the btree. The caller should have done a btrfs_drop_extents so that
125 * no overlapping inline items exist in the btree 125 * no overlapping inline items exist in the btree
126 */ 126 */
127static int noinline insert_inline_extent(struct btrfs_trans_handle *trans, 127static noinline int insert_inline_extent(struct btrfs_trans_handle *trans,
128 struct btrfs_root *root, struct inode *inode, 128 struct btrfs_root *root, struct inode *inode,
129 u64 start, size_t size, size_t compressed_size, 129 u64 start, size_t size, size_t compressed_size,
130 struct page **compressed_pages) 130 struct page **compressed_pages)
@@ -148,7 +148,8 @@ static int noinline insert_inline_extent(struct btrfs_trans_handle *trans,
148 cur_size = compressed_size; 148 cur_size = compressed_size;
149 } 149 }
150 150
151 path = btrfs_alloc_path(); if (!path) 151 path = btrfs_alloc_path();
152 if (!path)
152 return -ENOMEM; 153 return -ENOMEM;
153 154
154 btrfs_set_trans_block_group(trans, inode); 155 btrfs_set_trans_block_group(trans, inode);
@@ -165,7 +166,6 @@ static int noinline insert_inline_extent(struct btrfs_trans_handle *trans,
165 BUG_ON(ret); 166 BUG_ON(ret);
166 if (ret) { 167 if (ret) {
167 err = ret; 168 err = ret;
168 printk("got bad ret %d\n", ret);
169 goto fail; 169 goto fail;
170 } 170 }
171 leaf = path->nodes[0]; 171 leaf = path->nodes[0];
@@ -181,7 +181,7 @@ static int noinline insert_inline_extent(struct btrfs_trans_handle *trans,
181 if (use_compress) { 181 if (use_compress) {
182 struct page *cpage; 182 struct page *cpage;
183 int i = 0; 183 int i = 0;
184 while(compressed_size > 0) { 184 while (compressed_size > 0) {
185 cpage = compressed_pages[i]; 185 cpage = compressed_pages[i];
186 cur_size = min_t(unsigned long, compressed_size, 186 cur_size = min_t(unsigned long, compressed_size,
187 PAGE_CACHE_SIZE); 187 PAGE_CACHE_SIZE);
@@ -519,8 +519,7 @@ free_pages_out:
519 WARN_ON(pages[i]->mapping); 519 WARN_ON(pages[i]->mapping);
520 page_cache_release(pages[i]); 520 page_cache_release(pages[i]);
521 } 521 }
522 if (pages) 522 kfree(pages);
523 kfree(pages);
524 523
525 goto out; 524 goto out;
526} 525}
@@ -549,7 +548,7 @@ static noinline int submit_compressed_extents(struct inode *inode,
549 548
550 trans = btrfs_join_transaction(root, 1); 549 trans = btrfs_join_transaction(root, 1);
551 550
552 while(!list_empty(&async_cow->extents)) { 551 while (!list_empty(&async_cow->extents)) {
553 async_extent = list_entry(async_cow->extents.next, 552 async_extent = list_entry(async_cow->extents.next,
554 struct async_extent, list); 553 struct async_extent, list);
555 list_del(&async_extent->list); 554 list_del(&async_extent->list);
@@ -562,8 +561,8 @@ static noinline int submit_compressed_extents(struct inode *inode,
562 unsigned long nr_written = 0; 561 unsigned long nr_written = 0;
563 562
564 lock_extent(io_tree, async_extent->start, 563 lock_extent(io_tree, async_extent->start,
565 async_extent->start + async_extent->ram_size - 1, 564 async_extent->start +
566 GFP_NOFS); 565 async_extent->ram_size - 1, GFP_NOFS);
567 566
568 /* allocate blocks */ 567 /* allocate blocks */
569 cow_file_range(inode, async_cow->locked_page, 568 cow_file_range(inode, async_cow->locked_page,
@@ -581,7 +580,7 @@ static noinline int submit_compressed_extents(struct inode *inode,
581 if (!page_started) 580 if (!page_started)
582 extent_write_locked_range(io_tree, 581 extent_write_locked_range(io_tree,
583 inode, async_extent->start, 582 inode, async_extent->start,
584 async_extent->start + 583 async_extent->start +
585 async_extent->ram_size - 1, 584 async_extent->ram_size - 1,
586 btrfs_get_extent, 585 btrfs_get_extent,
587 WB_SYNC_ALL); 586 WB_SYNC_ALL);
@@ -618,7 +617,7 @@ static noinline int submit_compressed_extents(struct inode *inode,
618 set_bit(EXTENT_FLAG_PINNED, &em->flags); 617 set_bit(EXTENT_FLAG_PINNED, &em->flags);
619 set_bit(EXTENT_FLAG_COMPRESSED, &em->flags); 618 set_bit(EXTENT_FLAG_COMPRESSED, &em->flags);
620 619
621 while(1) { 620 while (1) {
622 spin_lock(&em_tree->lock); 621 spin_lock(&em_tree->lock);
623 ret = add_extent_mapping(em_tree, em); 622 ret = add_extent_mapping(em_tree, em);
624 spin_unlock(&em_tree->lock); 623 spin_unlock(&em_tree->lock);
@@ -651,11 +650,11 @@ static noinline int submit_compressed_extents(struct inode *inode,
651 NULL, 1, 1, 0, 1, 1, 0); 650 NULL, 1, 1, 0, 1, 1, 0);
652 651
653 ret = btrfs_submit_compressed_write(inode, 652 ret = btrfs_submit_compressed_write(inode,
654 async_extent->start, 653 async_extent->start,
655 async_extent->ram_size, 654 async_extent->ram_size,
656 ins.objectid, 655 ins.objectid,
657 ins.offset, async_extent->pages, 656 ins.offset, async_extent->pages,
658 async_extent->nr_pages); 657 async_extent->nr_pages);
659 658
660 BUG_ON(ret); 659 BUG_ON(ret);
661 trans = btrfs_join_transaction(root, 1); 660 trans = btrfs_join_transaction(root, 1);
@@ -735,14 +734,13 @@ static noinline int cow_file_range(struct inode *inode,
735 734
736 btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0); 735 btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0);
737 736
738 while(disk_num_bytes > 0) { 737 while (disk_num_bytes > 0) {
739 cur_alloc_size = min(disk_num_bytes, root->fs_info->max_extent); 738 cur_alloc_size = min(disk_num_bytes, root->fs_info->max_extent);
740 ret = btrfs_reserve_extent(trans, root, cur_alloc_size, 739 ret = btrfs_reserve_extent(trans, root, cur_alloc_size,
741 root->sectorsize, 0, alloc_hint, 740 root->sectorsize, 0, alloc_hint,
742 (u64)-1, &ins, 1); 741 (u64)-1, &ins, 1);
743 if (ret) { 742 BUG_ON(ret);
744 BUG(); 743
745 }
746 em = alloc_extent_map(GFP_NOFS); 744 em = alloc_extent_map(GFP_NOFS);
747 em->start = start; 745 em->start = start;
748 em->orig_start = em->start; 746 em->orig_start = em->start;
@@ -755,7 +753,7 @@ static noinline int cow_file_range(struct inode *inode,
755 em->bdev = root->fs_info->fs_devices->latest_bdev; 753 em->bdev = root->fs_info->fs_devices->latest_bdev;
756 set_bit(EXTENT_FLAG_PINNED, &em->flags); 754 set_bit(EXTENT_FLAG_PINNED, &em->flags);
757 755
758 while(1) { 756 while (1) {
759 spin_lock(&em_tree->lock); 757 spin_lock(&em_tree->lock);
760 ret = add_extent_mapping(em_tree, em); 758 ret = add_extent_mapping(em_tree, em);
761 spin_unlock(&em_tree->lock); 759 spin_unlock(&em_tree->lock);
@@ -779,11 +777,9 @@ static noinline int cow_file_range(struct inode *inode,
779 BUG_ON(ret); 777 BUG_ON(ret);
780 } 778 }
781 779
782 if (disk_num_bytes < cur_alloc_size) { 780 if (disk_num_bytes < cur_alloc_size)
783 printk("num_bytes %Lu cur_alloc %Lu\n", disk_num_bytes,
784 cur_alloc_size);
785 break; 781 break;
786 } 782
787 /* we're not doing compressed IO, don't unlock the first 783 /* we're not doing compressed IO, don't unlock the first
788 * page (which the caller expects to stay locked), don't 784 * page (which the caller expects to stay locked), don't
789 * clear any dirty bits and don't set any writeback bits 785 * clear any dirty bits and don't set any writeback bits
@@ -842,9 +838,8 @@ static noinline void async_cow_submit(struct btrfs_work *work)
842 waitqueue_active(&root->fs_info->async_submit_wait)) 838 waitqueue_active(&root->fs_info->async_submit_wait))
843 wake_up(&root->fs_info->async_submit_wait); 839 wake_up(&root->fs_info->async_submit_wait);
844 840
845 if (async_cow->inode) { 841 if (async_cow->inode)
846 submit_compressed_extents(async_cow->inode, async_cow); 842 submit_compressed_extents(async_cow->inode, async_cow);
847 }
848} 843}
849 844
850static noinline void async_cow_free(struct btrfs_work *work) 845static noinline void async_cow_free(struct btrfs_work *work)
@@ -871,7 +866,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
871 866
872 clear_extent_bit(&BTRFS_I(inode)->io_tree, start, end, EXTENT_LOCKED | 867 clear_extent_bit(&BTRFS_I(inode)->io_tree, start, end, EXTENT_LOCKED |
873 EXTENT_DELALLOC, 1, 0, GFP_NOFS); 868 EXTENT_DELALLOC, 1, 0, GFP_NOFS);
874 while(start < end) { 869 while (start < end) {
875 async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS); 870 async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS);
876 async_cow->inode = inode; 871 async_cow->inode = inode;
877 async_cow->root = root; 872 async_cow->root = root;
@@ -904,7 +899,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
904 limit)); 899 limit));
905 } 900 }
906 901
907 while(atomic_read(&root->fs_info->async_submit_draining) && 902 while (atomic_read(&root->fs_info->async_submit_draining) &&
908 atomic_read(&root->fs_info->async_delalloc_pages)) { 903 atomic_read(&root->fs_info->async_delalloc_pages)) {
909 wait_event(root->fs_info->async_submit_wait, 904 wait_event(root->fs_info->async_submit_wait,
910 (atomic_read(&root->fs_info->async_delalloc_pages) == 905 (atomic_read(&root->fs_info->async_delalloc_pages) ==
@@ -918,7 +913,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
918 return 0; 913 return 0;
919} 914}
920 915
921static int noinline csum_exist_in_range(struct btrfs_root *root, 916static noinline int csum_exist_in_range(struct btrfs_root *root,
922 u64 bytenr, u64 num_bytes) 917 u64 bytenr, u64 num_bytes)
923{ 918{
924 int ret; 919 int ret;
@@ -1146,13 +1141,13 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page,
1146 1141
1147 if (btrfs_test_flag(inode, NODATACOW)) 1142 if (btrfs_test_flag(inode, NODATACOW))
1148 ret = run_delalloc_nocow(inode, locked_page, start, end, 1143 ret = run_delalloc_nocow(inode, locked_page, start, end,
1149 page_started, 1, nr_written); 1144 page_started, 1, nr_written);
1150 else if (btrfs_test_flag(inode, PREALLOC)) 1145 else if (btrfs_test_flag(inode, PREALLOC))
1151 ret = run_delalloc_nocow(inode, locked_page, start, end, 1146 ret = run_delalloc_nocow(inode, locked_page, start, end,
1152 page_started, 0, nr_written); 1147 page_started, 0, nr_written);
1153 else 1148 else
1154 ret = cow_file_range_async(inode, locked_page, start, end, 1149 ret = cow_file_range_async(inode, locked_page, start, end,
1155 page_started, nr_written); 1150 page_started, nr_written);
1156 1151
1157 return ret; 1152 return ret;
1158} 1153}
@@ -1200,8 +1195,11 @@ static int btrfs_clear_bit_hook(struct inode *inode, u64 start, u64 end,
1200 1195
1201 spin_lock(&root->fs_info->delalloc_lock); 1196 spin_lock(&root->fs_info->delalloc_lock);
1202 if (end - start + 1 > root->fs_info->delalloc_bytes) { 1197 if (end - start + 1 > root->fs_info->delalloc_bytes) {
1203 printk("warning: delalloc account %Lu %Lu\n", 1198 printk(KERN_INFO "btrfs warning: delalloc account "
1204 end - start + 1, root->fs_info->delalloc_bytes); 1199 "%llu %llu\n",
1200 (unsigned long long)end - start + 1,
1201 (unsigned long long)
1202 root->fs_info->delalloc_bytes);
1205 root->fs_info->delalloc_bytes = 0; 1203 root->fs_info->delalloc_bytes = 0;
1206 BTRFS_I(inode)->delalloc_bytes = 0; 1204 BTRFS_I(inode)->delalloc_bytes = 0;
1207 } else { 1205 } else {
@@ -1241,9 +1239,8 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
1241 ret = btrfs_map_block(map_tree, READ, logical, 1239 ret = btrfs_map_block(map_tree, READ, logical,
1242 &map_length, NULL, 0); 1240 &map_length, NULL, 0);
1243 1241
1244 if (map_length < length + size) { 1242 if (map_length < length + size)
1245 return 1; 1243 return 1;
1246 }
1247 return 0; 1244 return 0;
1248} 1245}
1249 1246
@@ -1255,8 +1252,9 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
1255 * At IO completion time the cums attached on the ordered extent record 1252 * At IO completion time the cums attached on the ordered extent record
1256 * are inserted into the btree 1253 * are inserted into the btree
1257 */ 1254 */
1258static int __btrfs_submit_bio_start(struct inode *inode, int rw, struct bio *bio, 1255static int __btrfs_submit_bio_start(struct inode *inode, int rw,
1259 int mirror_num, unsigned long bio_flags) 1256 struct bio *bio, int mirror_num,
1257 unsigned long bio_flags)
1260{ 1258{
1261 struct btrfs_root *root = BTRFS_I(inode)->root; 1259 struct btrfs_root *root = BTRFS_I(inode)->root;
1262 int ret = 0; 1260 int ret = 0;
@@ -1341,9 +1339,8 @@ static noinline int add_pending_csums(struct btrfs_trans_handle *trans,
1341 1339
1342int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end) 1340int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end)
1343{ 1341{
1344 if ((end & (PAGE_CACHE_SIZE - 1)) == 0) { 1342 if ((end & (PAGE_CACHE_SIZE - 1)) == 0)
1345 WARN_ON(1); 1343 WARN_ON(1);
1346 }
1347 return set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end, 1344 return set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end,
1348 GFP_NOFS); 1345 GFP_NOFS);
1349} 1346}
@@ -1755,14 +1752,14 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
1755 } 1752 }
1756 local_irq_save(flags); 1753 local_irq_save(flags);
1757 kaddr = kmap_atomic(page, KM_IRQ0); 1754 kaddr = kmap_atomic(page, KM_IRQ0);
1758 if (ret) { 1755 if (ret)
1759 goto zeroit; 1756 goto zeroit;
1760 } 1757
1761 csum = btrfs_csum_data(root, kaddr + offset, csum, end - start + 1); 1758 csum = btrfs_csum_data(root, kaddr + offset, csum, end - start + 1);
1762 btrfs_csum_final(csum, (char *)&csum); 1759 btrfs_csum_final(csum, (char *)&csum);
1763 if (csum != private) { 1760 if (csum != private)
1764 goto zeroit; 1761 goto zeroit;
1765 } 1762
1766 kunmap_atomic(kaddr, KM_IRQ0); 1763 kunmap_atomic(kaddr, KM_IRQ0);
1767 local_irq_restore(flags); 1764 local_irq_restore(flags);
1768good: 1765good:
@@ -1773,9 +1770,10 @@ good:
1773 return 0; 1770 return 0;
1774 1771
1775zeroit: 1772zeroit:
1776 printk("btrfs csum failed ino %lu off %llu csum %u private %Lu\n", 1773 printk(KERN_INFO "btrfs csum failed ino %lu off %llu csum %u "
1777 page->mapping->host->i_ino, (unsigned long long)start, csum, 1774 "private %llu\n", page->mapping->host->i_ino,
1778 private); 1775 (unsigned long long)start, csum,
1776 (unsigned long long)private);
1779 memset(kaddr + offset, 1, end - start + 1); 1777 memset(kaddr + offset, 1, end - start + 1);
1780 flush_dcache_page(page); 1778 flush_dcache_page(page);
1781 kunmap_atomic(kaddr, KM_IRQ0); 1779 kunmap_atomic(kaddr, KM_IRQ0);
@@ -2097,9 +2095,8 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
2097/* 2095/*
2098 * copy everything in the in-memory inode into the btree. 2096 * copy everything in the in-memory inode into the btree.
2099 */ 2097 */
2100int noinline btrfs_update_inode(struct btrfs_trans_handle *trans, 2098noinline int btrfs_update_inode(struct btrfs_trans_handle *trans,
2101 struct btrfs_root *root, 2099 struct btrfs_root *root, struct inode *inode)
2102 struct inode *inode)
2103{ 2100{
2104 struct btrfs_inode_item *inode_item; 2101 struct btrfs_inode_item *inode_item;
2105 struct btrfs_path *path; 2102 struct btrfs_path *path;
@@ -2174,7 +2171,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
2174 inode->i_ino, 2171 inode->i_ino,
2175 dir->i_ino, &index); 2172 dir->i_ino, &index);
2176 if (ret) { 2173 if (ret) {
2177 printk("failed to delete reference to %.*s, " 2174 printk(KERN_INFO "btrfs failed to delete reference to %.*s, "
2178 "inode %lu parent %lu\n", name_len, name, 2175 "inode %lu parent %lu\n", name_len, name,
2179 inode->i_ino, dir->i_ino); 2176 inode->i_ino, dir->i_ino);
2180 goto err; 2177 goto err;
@@ -2280,9 +2277,8 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
2280 /* now the directory is empty */ 2277 /* now the directory is empty */
2281 err = btrfs_unlink_inode(trans, root, dir, dentry->d_inode, 2278 err = btrfs_unlink_inode(trans, root, dir, dentry->d_inode,
2282 dentry->d_name.name, dentry->d_name.len); 2279 dentry->d_name.name, dentry->d_name.len);
2283 if (!err) { 2280 if (!err)
2284 btrfs_i_size_write(inode, 0); 2281 btrfs_i_size_write(inode, 0);
2285 }
2286 2282
2287fail_trans: 2283fail_trans:
2288 nr = trans->blocks_used; 2284 nr = trans->blocks_used;
@@ -2516,9 +2512,9 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
2516 2512
2517search_again: 2513search_again:
2518 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); 2514 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
2519 if (ret < 0) { 2515 if (ret < 0)
2520 goto error; 2516 goto error;
2521 } 2517
2522 if (ret > 0) { 2518 if (ret > 0) {
2523 /* there are no items in the tree for us to truncate, we're 2519 /* there are no items in the tree for us to truncate, we're
2524 * done 2520 * done
@@ -2530,7 +2526,7 @@ search_again:
2530 path->slots[0]--; 2526 path->slots[0]--;
2531 } 2527 }
2532 2528
2533 while(1) { 2529 while (1) {
2534 fi = NULL; 2530 fi = NULL;
2535 leaf = path->nodes[0]; 2531 leaf = path->nodes[0];
2536 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); 2532 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
@@ -2562,19 +2558,18 @@ search_again:
2562 item_end--; 2558 item_end--;
2563 } 2559 }
2564 if (item_end < new_size) { 2560 if (item_end < new_size) {
2565 if (found_type == BTRFS_DIR_ITEM_KEY) { 2561 if (found_type == BTRFS_DIR_ITEM_KEY)
2566 found_type = BTRFS_INODE_ITEM_KEY; 2562 found_type = BTRFS_INODE_ITEM_KEY;
2567 } else if (found_type == BTRFS_EXTENT_ITEM_KEY) { 2563 else if (found_type == BTRFS_EXTENT_ITEM_KEY)
2568 found_type = BTRFS_EXTENT_DATA_KEY; 2564 found_type = BTRFS_EXTENT_DATA_KEY;
2569 } else if (found_type == BTRFS_EXTENT_DATA_KEY) { 2565 else if (found_type == BTRFS_EXTENT_DATA_KEY)
2570 found_type = BTRFS_XATTR_ITEM_KEY; 2566 found_type = BTRFS_XATTR_ITEM_KEY;
2571 } else if (found_type == BTRFS_XATTR_ITEM_KEY) { 2567 else if (found_type == BTRFS_XATTR_ITEM_KEY)
2572 found_type = BTRFS_INODE_REF_KEY; 2568 found_type = BTRFS_INODE_REF_KEY;
2573 } else if (found_type) { 2569 else if (found_type)
2574 found_type--; 2570 found_type--;
2575 } else { 2571 else
2576 break; 2572 break;
2577 }
2578 btrfs_set_key_type(&key, found_type); 2573 btrfs_set_key_type(&key, found_type);
2579 goto next; 2574 goto next;
2580 } 2575 }
@@ -2656,7 +2651,7 @@ delete:
2656 pending_del_nr++; 2651 pending_del_nr++;
2657 pending_del_slot = path->slots[0]; 2652 pending_del_slot = path->slots[0];
2658 } else { 2653 } else {
2659 printk("bad pending slot %d pending_del_nr %d pending_del_slot %d\n", path->slots[0], pending_del_nr, pending_del_slot); 2654 BUG();
2660 } 2655 }
2661 } else { 2656 } else {
2662 break; 2657 break;
@@ -2938,9 +2933,10 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
2938 namelen, 0); 2933 namelen, 0);
2939 if (IS_ERR(di)) 2934 if (IS_ERR(di))
2940 ret = PTR_ERR(di); 2935 ret = PTR_ERR(di);
2941 if (!di || IS_ERR(di)) { 2936
2937 if (!di || IS_ERR(di))
2942 goto out_err; 2938 goto out_err;
2943 } 2939
2944 btrfs_dir_item_key_to_cpu(path->nodes[0], di, location); 2940 btrfs_dir_item_key_to_cpu(path->nodes[0], di, location);
2945out: 2941out:
2946 btrfs_free_path(path); 2942 btrfs_free_path(path);
@@ -3020,8 +3016,8 @@ static int btrfs_init_locked_inode(struct inode *inode, void *p)
3020static int btrfs_find_actor(struct inode *inode, void *opaque) 3016static int btrfs_find_actor(struct inode *inode, void *opaque)
3021{ 3017{
3022 struct btrfs_iget_args *args = opaque; 3018 struct btrfs_iget_args *args = opaque;
3023 return (args->ino == inode->i_ino && 3019 return args->ino == inode->i_ino &&
3024 args->root == BTRFS_I(inode)->root); 3020 args->root == BTRFS_I(inode)->root;
3025} 3021}
3026 3022
3027struct inode *btrfs_ilookup(struct super_block *s, u64 objectid, 3023struct inode *btrfs_ilookup(struct super_block *s, u64 objectid,
@@ -3085,7 +3081,7 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
3085 3081
3086struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) 3082struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
3087{ 3083{
3088 struct inode * inode; 3084 struct inode *inode;
3089 struct btrfs_inode *bi = BTRFS_I(dir); 3085 struct btrfs_inode *bi = BTRFS_I(dir);
3090 struct btrfs_root *root = bi->root; 3086 struct btrfs_root *root = bi->root;
3091 struct btrfs_root *sub_root = root; 3087 struct btrfs_root *sub_root = root;
@@ -3385,9 +3381,8 @@ int btrfs_set_inode_index(struct inode *dir, u64 *index)
3385 3381
3386 if (BTRFS_I(dir)->index_cnt == (u64)-1) { 3382 if (BTRFS_I(dir)->index_cnt == (u64)-1) {
3387 ret = btrfs_set_inode_index_count(dir); 3383 ret = btrfs_set_inode_index_count(dir);
3388 if (ret) { 3384 if (ret)
3389 return ret; 3385 return ret;
3390 }
3391 } 3386 }
3392 3387
3393 *index = BTRFS_I(dir)->index_cnt; 3388 *index = BTRFS_I(dir)->index_cnt;
@@ -3879,12 +3874,13 @@ static noinline int uncompress_inline(struct btrfs_path *path,
3879 3874
3880/* 3875/*
3881 * a bit scary, this does extent mapping from logical file offset to the disk. 3876 * a bit scary, this does extent mapping from logical file offset to the disk.
3882 * the ugly parts come from merging extents from the disk with the 3877 * the ugly parts come from merging extents from the disk with the in-ram
3883 * in-ram representation. This gets more complex because of the data=ordered code, 3878 * representation. This gets more complex because of the data=ordered code,
3884 * where the in-ram extents might be locked pending data=ordered completion. 3879 * where the in-ram extents might be locked pending data=ordered completion.
3885 * 3880 *
3886 * This also copies inline extents directly into the page. 3881 * This also copies inline extents directly into the page.
3887 */ 3882 */
3883
3888struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page, 3884struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
3889 size_t pg_offset, u64 start, u64 len, 3885 size_t pg_offset, u64 start, u64 len,
3890 int create) 3886 int create)
@@ -4081,7 +4077,7 @@ again:
4081 extent_map_end(em) - 1, GFP_NOFS); 4077 extent_map_end(em) - 1, GFP_NOFS);
4082 goto insert; 4078 goto insert;
4083 } else { 4079 } else {
4084 printk("unkknown found_type %d\n", found_type); 4080 printk(KERN_ERR "btrfs unknown found_type %d\n", found_type);
4085 WARN_ON(1); 4081 WARN_ON(1);
4086 } 4082 }
4087not_found: 4083not_found:
@@ -4093,7 +4089,11 @@ not_found_em:
4093insert: 4089insert:
4094 btrfs_release_path(root, path); 4090 btrfs_release_path(root, path);
4095 if (em->start > start || extent_map_end(em) <= start) { 4091 if (em->start > start || extent_map_end(em) <= start) {
4096 printk("bad extent! em: [%Lu %Lu] passed [%Lu %Lu]\n", em->start, em->len, start, len); 4092 printk(KERN_ERR "Btrfs: bad extent! em: [%llu %llu] passed "
4093 "[%llu %llu]\n", (unsigned long long)em->start,
4094 (unsigned long long)em->len,
4095 (unsigned long long)start,
4096 (unsigned long long)len);
4097 err = -EIO; 4097 err = -EIO;
4098 goto out; 4098 goto out;
4099 } 4099 }
@@ -4130,8 +4130,6 @@ insert:
4130 } 4130 }
4131 } else { 4131 } else {
4132 err = -EIO; 4132 err = -EIO;
4133 printk("failing to insert %Lu %Lu\n",
4134 start, len);
4135 free_extent_map(em); 4133 free_extent_map(em);
4136 em = NULL; 4134 em = NULL;
4137 } 4135 }
@@ -4147,9 +4145,8 @@ out:
4147 btrfs_free_path(path); 4145 btrfs_free_path(path);
4148 if (trans) { 4146 if (trans) {
4149 ret = btrfs_end_transaction(trans, root); 4147 ret = btrfs_end_transaction(trans, root);
4150 if (!err) { 4148 if (!err)
4151 err = ret; 4149 err = ret;
4152 }
4153 } 4150 }
4154 if (err) { 4151 if (err) {
4155 free_extent_map(em); 4152 free_extent_map(em);
@@ -4482,13 +4479,15 @@ void btrfs_destroy_inode(struct inode *inode)
4482 } 4479 }
4483 spin_unlock(&BTRFS_I(inode)->root->list_lock); 4480 spin_unlock(&BTRFS_I(inode)->root->list_lock);
4484 4481
4485 while(1) { 4482 while (1) {
4486 ordered = btrfs_lookup_first_ordered_extent(inode, (u64)-1); 4483 ordered = btrfs_lookup_first_ordered_extent(inode, (u64)-1);
4487 if (!ordered) 4484 if (!ordered)
4488 break; 4485 break;
4489 else { 4486 else {
4490 printk("found ordered extent %Lu %Lu\n", 4487 printk(KERN_ERR "btrfs found ordered "
4491 ordered->file_offset, ordered->len); 4488 "extent %llu %llu on inode cleanup\n",
4489 (unsigned long long)ordered->file_offset,
4490 (unsigned long long)ordered->len);
4492 btrfs_remove_ordered_extent(inode, ordered); 4491 btrfs_remove_ordered_extent(inode, ordered);
4493 btrfs_put_ordered_extent(ordered); 4492 btrfs_put_ordered_extent(ordered);
4494 btrfs_put_ordered_extent(ordered); 4493 btrfs_put_ordered_extent(ordered);
@@ -4572,8 +4571,8 @@ static int btrfs_getattr(struct vfsmount *mnt,
4572 return 0; 4571 return 0;
4573} 4572}
4574 4573
4575static int btrfs_rename(struct inode * old_dir, struct dentry *old_dentry, 4574static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
4576 struct inode * new_dir,struct dentry *new_dentry) 4575 struct inode *new_dir, struct dentry *new_dentry)
4577{ 4576{
4578 struct btrfs_trans_handle *trans; 4577 struct btrfs_trans_handle *trans;
4579 struct btrfs_root *root = BTRFS_I(old_dir)->root; 4578 struct btrfs_root *root = BTRFS_I(old_dir)->root;
@@ -4663,7 +4662,7 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root)
4663 return -EROFS; 4662 return -EROFS;
4664 4663
4665 spin_lock(&root->fs_info->delalloc_lock); 4664 spin_lock(&root->fs_info->delalloc_lock);
4666 while(!list_empty(head)) { 4665 while (!list_empty(head)) {
4667 binode = list_entry(head->next, struct btrfs_inode, 4666 binode = list_entry(head->next, struct btrfs_inode,
4668 delalloc_inodes); 4667 delalloc_inodes);
4669 inode = igrab(&binode->vfs_inode); 4668 inode = igrab(&binode->vfs_inode);
@@ -4684,7 +4683,7 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root)
4684 * ordered extents get created before we return 4683 * ordered extents get created before we return
4685 */ 4684 */
4686 atomic_inc(&root->fs_info->async_submit_draining); 4685 atomic_inc(&root->fs_info->async_submit_draining);
4687 while(atomic_read(&root->fs_info->nr_async_submits) || 4686 while (atomic_read(&root->fs_info->nr_async_submits) ||
4688 atomic_read(&root->fs_info->async_delalloc_pages)) { 4687 atomic_read(&root->fs_info->async_delalloc_pages)) {
4689 wait_event(root->fs_info->async_submit_wait, 4688 wait_event(root->fs_info->async_submit_wait,
4690 (atomic_read(&root->fs_info->nr_async_submits) == 0 && 4689 (atomic_read(&root->fs_info->nr_async_submits) == 0 &&