aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.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/disk-io.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/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c187
1 files changed, 63 insertions, 124 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index dae25e78a6b7..81a313874ae5 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -23,7 +23,7 @@
23#include <linux/swap.h> 23#include <linux/swap.h>
24#include <linux/radix-tree.h> 24#include <linux/radix-tree.h>
25#include <linux/writeback.h> 25#include <linux/writeback.h>
26#include <linux/buffer_head.h> // for block_sync_page 26#include <linux/buffer_head.h>
27#include <linux/workqueue.h> 27#include <linux/workqueue.h>
28#include <linux/kthread.h> 28#include <linux/kthread.h>
29#include <linux/freezer.h> 29#include <linux/freezer.h>
@@ -40,19 +40,6 @@
40#include "ref-cache.h" 40#include "ref-cache.h"
41#include "tree-log.h" 41#include "tree-log.h"
42 42
43#if 0
44static int check_tree_block(struct btrfs_root *root, struct extent_buffer *buf)
45{
46 if (extent_buffer_blocknr(buf) != btrfs_header_blocknr(buf)) {
47 printk(KERN_CRIT "buf blocknr(buf) is %llu, header is %llu\n",
48 (unsigned long long)extent_buffer_blocknr(buf),
49 (unsigned long long)btrfs_header_blocknr(buf));
50 return 1;
51 }
52 return 0;
53}
54#endif
55
56static struct extent_io_ops btree_extent_io_ops; 43static struct extent_io_ops btree_extent_io_ops;
57static void end_workqueue_fn(struct btrfs_work *work); 44static void end_workqueue_fn(struct btrfs_work *work);
58 45
@@ -128,23 +115,13 @@ static struct extent_map *btree_get_extent(struct inode *inode,
128 u64 failed_start = em->start; 115 u64 failed_start = em->start;
129 u64 failed_len = em->len; 116 u64 failed_len = em->len;
130 117
131 printk("failed to insert %Lu %Lu -> %Lu into tree\n",
132 em->start, em->len, em->block_start);
133 free_extent_map(em); 118 free_extent_map(em);
134 em = lookup_extent_mapping(em_tree, start, len); 119 em = lookup_extent_mapping(em_tree, start, len);
135 if (em) { 120 if (em) {
136 printk("after failing, found %Lu %Lu %Lu\n",
137 em->start, em->len, em->block_start);
138 ret = 0; 121 ret = 0;
139 } else { 122 } else {
140 em = lookup_extent_mapping(em_tree, failed_start, 123 em = lookup_extent_mapping(em_tree, failed_start,
141 failed_len); 124 failed_len);
142 if (em) {
143 printk("double failure lookup gives us "
144 "%Lu %Lu -> %Lu\n", em->start,
145 em->len, em->block_start);
146 free_extent_map(em);
147 }
148 ret = -EIO; 125 ret = -EIO;
149 } 126 }
150 } else if (ret) { 127 } else if (ret) {
@@ -191,15 +168,12 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
191 unsigned long inline_result; 168 unsigned long inline_result;
192 169
193 len = buf->len - offset; 170 len = buf->len - offset;
194 while(len > 0) { 171 while (len > 0) {
195 err = map_private_extent_buffer(buf, offset, 32, 172 err = map_private_extent_buffer(buf, offset, 32,
196 &map_token, &kaddr, 173 &map_token, &kaddr,
197 &map_start, &map_len, KM_USER0); 174 &map_start, &map_len, KM_USER0);
198 if (err) { 175 if (err)
199 printk("failed to map extent buffer! %lu\n",
200 offset);
201 return 1; 176 return 1;
202 }
203 cur_len = min(len, map_len - (offset - map_start)); 177 cur_len = min(len, map_len - (offset - map_start));
204 crc = btrfs_csum_data(root, kaddr + offset - map_start, 178 crc = btrfs_csum_data(root, kaddr + offset - map_start,
205 crc, cur_len); 179 crc, cur_len);
@@ -218,15 +192,14 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
218 btrfs_csum_final(crc, result); 192 btrfs_csum_final(crc, result);
219 193
220 if (verify) { 194 if (verify) {
221 /* FIXME, this is not good */
222 if (memcmp_extent_buffer(buf, result, 0, csum_size)) { 195 if (memcmp_extent_buffer(buf, result, 0, csum_size)) {
223 u32 val; 196 u32 val;
224 u32 found = 0; 197 u32 found = 0;
225 memcpy(&found, result, csum_size); 198 memcpy(&found, result, csum_size);
226 199
227 read_extent_buffer(buf, &val, 0, csum_size); 200 read_extent_buffer(buf, &val, 0, csum_size);
228 printk("btrfs: %s checksum verify failed on %llu " 201 printk(KERN_INFO "btrfs: %s checksum verify failed "
229 "wanted %X found %X level %d\n", 202 "on %llu wanted %X found %X level %d\n",
230 root->fs_info->sb->s_id, 203 root->fs_info->sb->s_id,
231 buf->start, val, found, btrfs_header_level(buf)); 204 buf->start, val, found, btrfs_header_level(buf));
232 if (result != (char *)&inline_result) 205 if (result != (char *)&inline_result)
@@ -293,7 +266,7 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
293 if (!ret && 266 if (!ret &&
294 !verify_parent_transid(io_tree, eb, parent_transid)) 267 !verify_parent_transid(io_tree, eb, parent_transid))
295 return ret; 268 return ret;
296printk("read extent buffer pages failed with ret %d mirror no %d\n", ret, mirror_num); 269
297 num_copies = btrfs_num_copies(&root->fs_info->mapping_tree, 270 num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
298 eb->start, eb->len); 271 eb->start, eb->len);
299 if (num_copies == 1) 272 if (num_copies == 1)
@@ -307,9 +280,10 @@ printk("read extent buffer pages failed with ret %d mirror no %d\n", ret, mirror
307} 280}
308 281
309/* 282/*
310 * checksum a dirty tree block before IO. This has extra checks to make 283 * checksum a dirty tree block before IO. This has extra checks to make sure
311 * sure we only fill in the checksum field in the first page of a multi-page block 284 * we only fill in the checksum field in the first page of a multi-page block
312 */ 285 */
286
313static int csum_dirty_buffer(struct btrfs_root *root, struct page *page) 287static int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
314{ 288{
315 struct extent_io_tree *tree; 289 struct extent_io_tree *tree;
@@ -327,28 +301,22 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
327 if (!page->private) 301 if (!page->private)
328 goto out; 302 goto out;
329 len = page->private >> 2; 303 len = page->private >> 2;
330 if (len == 0) { 304 WARN_ON(len == 0);
331 WARN_ON(1); 305
332 }
333 eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS); 306 eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS);
334 ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE, 307 ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE,
335 btrfs_header_generation(eb)); 308 btrfs_header_generation(eb));
336 BUG_ON(ret); 309 BUG_ON(ret);
337 found_start = btrfs_header_bytenr(eb); 310 found_start = btrfs_header_bytenr(eb);
338 if (found_start != start) { 311 if (found_start != start) {
339 printk("warning: eb start incorrect %Lu buffer %Lu len %lu\n",
340 start, found_start, len);
341 WARN_ON(1); 312 WARN_ON(1);
342 goto err; 313 goto err;
343 } 314 }
344 if (eb->first_page != page) { 315 if (eb->first_page != page) {
345 printk("bad first page %lu %lu\n", eb->first_page->index,
346 page->index);
347 WARN_ON(1); 316 WARN_ON(1);
348 goto err; 317 goto err;
349 } 318 }
350 if (!PageUptodate(page)) { 319 if (!PageUptodate(page)) {
351 printk("csum not up to date page %lu\n", page->index);
352 WARN_ON(1); 320 WARN_ON(1);
353 goto err; 321 goto err;
354 } 322 }
@@ -396,29 +364,30 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
396 goto out; 364 goto out;
397 if (!page->private) 365 if (!page->private)
398 goto out; 366 goto out;
367
399 len = page->private >> 2; 368 len = page->private >> 2;
400 if (len == 0) { 369 WARN_ON(len == 0);
401 WARN_ON(1); 370
402 }
403 eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS); 371 eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS);
404 372
405 found_start = btrfs_header_bytenr(eb); 373 found_start = btrfs_header_bytenr(eb);
406 if (found_start != start) { 374 if (found_start != start) {
407 printk("bad tree block start %llu %llu\n", 375 printk(KERN_INFO "btrfs bad tree block start %llu %llu\n",
408 (unsigned long long)found_start, 376 (unsigned long long)found_start,
409 (unsigned long long)eb->start); 377 (unsigned long long)eb->start);
410 ret = -EIO; 378 ret = -EIO;
411 goto err; 379 goto err;
412 } 380 }
413 if (eb->first_page != page) { 381 if (eb->first_page != page) {
414 printk("bad first page %lu %lu\n", eb->first_page->index, 382 printk(KERN_INFO "btrfs bad first page %lu %lu\n",
415 page->index); 383 eb->first_page->index, page->index);
416 WARN_ON(1); 384 WARN_ON(1);
417 ret = -EIO; 385 ret = -EIO;
418 goto err; 386 goto err;
419 } 387 }
420 if (check_tree_block_fsid(root, eb)) { 388 if (check_tree_block_fsid(root, eb)) {
421 printk("bad fsid on block %Lu\n", eb->start); 389 printk(KERN_INFO "btrfs bad fsid on block %llu\n",
390 (unsigned long long)eb->start);
422 ret = -EIO; 391 ret = -EIO;
423 goto err; 392 goto err;
424 } 393 }
@@ -578,7 +547,7 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
578 HZ/10); 547 HZ/10);
579 } 548 }
580#endif 549#endif
581 while(atomic_read(&fs_info->async_submit_draining) && 550 while (atomic_read(&fs_info->async_submit_draining) &&
582 atomic_read(&fs_info->nr_async_submits)) { 551 atomic_read(&fs_info->nr_async_submits)) {
583 wait_event(fs_info->async_submit_wait, 552 wait_event(fs_info->async_submit_wait,
584 (atomic_read(&fs_info->nr_async_submits) == 0)); 553 (atomic_read(&fs_info->nr_async_submits) == 0));
@@ -594,7 +563,7 @@ static int btree_csum_one_bio(struct bio *bio)
594 struct btrfs_root *root; 563 struct btrfs_root *root;
595 564
596 WARN_ON(bio->bi_vcnt <= 0); 565 WARN_ON(bio->bi_vcnt <= 0);
597 while(bio_index < bio->bi_vcnt) { 566 while (bio_index < bio->bi_vcnt) {
598 root = BTRFS_I(bvec->bv_page->mapping->host)->root; 567 root = BTRFS_I(bvec->bv_page->mapping->host)->root;
599 csum_dirty_buffer(root, bvec->bv_page); 568 csum_dirty_buffer(root, bvec->bv_page);
600 bio_index++; 569 bio_index++;
@@ -680,9 +649,8 @@ static int btree_writepages(struct address_space *mapping,
680 649
681 num_dirty = count_range_bits(tree, &start, (u64)-1, 650 num_dirty = count_range_bits(tree, &start, (u64)-1,
682 thresh, EXTENT_DIRTY); 651 thresh, EXTENT_DIRTY);
683 if (num_dirty < thresh) { 652 if (num_dirty < thresh)
684 return 0; 653 return 0;
685 }
686 } 654 }
687 return extent_writepages(tree, mapping, btree_get_extent, wbc); 655 return extent_writepages(tree, mapping, btree_get_extent, wbc);
688} 656}
@@ -701,15 +669,14 @@ static int btree_releasepage(struct page *page, gfp_t gfp_flags)
701 int ret; 669 int ret;
702 670
703 if (PageWriteback(page) || PageDirty(page)) 671 if (PageWriteback(page) || PageDirty(page))
704 return 0; 672 return 0;
705 673
706 tree = &BTRFS_I(page->mapping->host)->io_tree; 674 tree = &BTRFS_I(page->mapping->host)->io_tree;
707 map = &BTRFS_I(page->mapping->host)->extent_tree; 675 map = &BTRFS_I(page->mapping->host)->extent_tree;
708 676
709 ret = try_release_extent_state(map, tree, page, gfp_flags); 677 ret = try_release_extent_state(map, tree, page, gfp_flags);
710 if (!ret) { 678 if (!ret)
711 return 0; 679 return 0;
712 }
713 680
714 ret = try_release_extent_buffer(tree, page); 681 ret = try_release_extent_buffer(tree, page);
715 if (ret == 1) { 682 if (ret == 1) {
@@ -728,8 +695,8 @@ static void btree_invalidatepage(struct page *page, unsigned long offset)
728 extent_invalidatepage(tree, page, offset); 695 extent_invalidatepage(tree, page, offset);
729 btree_releasepage(page, GFP_NOFS); 696 btree_releasepage(page, GFP_NOFS);
730 if (PagePrivate(page)) { 697 if (PagePrivate(page)) {
731 printk("warning page private not zero on page %Lu\n", 698 printk(KERN_WARNING "btrfs warning page private not zero "
732 page_offset(page)); 699 "on page %llu\n", (unsigned long long)page_offset(page));
733 ClearPagePrivate(page); 700 ClearPagePrivate(page);
734 set_page_private(page, 0); 701 set_page_private(page, 0);
735 page_cache_release(page); 702 page_cache_release(page);
@@ -813,7 +780,7 @@ int btrfs_write_tree_block(struct extent_buffer *buf)
813int btrfs_wait_tree_block_writeback(struct extent_buffer *buf) 780int btrfs_wait_tree_block_writeback(struct extent_buffer *buf)
814{ 781{
815 return btrfs_wait_on_page_writeback_range(buf->first_page->mapping, 782 return btrfs_wait_on_page_writeback_range(buf->first_page->mapping,
816 buf->start, buf->start + buf->len -1); 783 buf->start, buf->start + buf->len - 1);
817} 784}
818 785
819struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, 786struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
@@ -832,11 +799,10 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
832 799
833 ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid); 800 ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid);
834 801
835 if (ret == 0) { 802 if (ret == 0)
836 buf->flags |= EXTENT_UPTODATE; 803 buf->flags |= EXTENT_UPTODATE;
837 } else { 804 else
838 WARN_ON(1); 805 WARN_ON(1);
839 }
840 return buf; 806 return buf;
841 807
842} 808}
@@ -944,7 +910,7 @@ int btrfs_free_log_root_tree(struct btrfs_trans_handle *trans,
944 if (!log_root_tree) 910 if (!log_root_tree)
945 return 0; 911 return 0;
946 912
947 while(1) { 913 while (1) {
948 ret = find_first_extent_bit(&log_root_tree->dirty_log_pages, 914 ret = find_first_extent_bit(&log_root_tree->dirty_log_pages,
949 0, &start, &end, EXTENT_DIRTY); 915 0, &start, &end, EXTENT_DIRTY);
950 if (ret) 916 if (ret)
@@ -1165,24 +1131,6 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
1165 root->in_sysfs = 1; 1131 root->in_sysfs = 1;
1166 return root; 1132 return root;
1167} 1133}
1168#if 0
1169static int add_hasher(struct btrfs_fs_info *info, char *type) {
1170 struct btrfs_hasher *hasher;
1171
1172 hasher = kmalloc(sizeof(*hasher), GFP_NOFS);
1173 if (!hasher)
1174 return -ENOMEM;
1175 hasher->hash_tfm = crypto_alloc_hash(type, 0, CRYPTO_ALG_ASYNC);
1176 if (!hasher->hash_tfm) {
1177 kfree(hasher);
1178 return -EINVAL;
1179 }
1180 spin_lock(&info->hash_lock);
1181 list_add(&hasher->list, &info->hashers);
1182 spin_unlock(&info->hash_lock);
1183 return 0;
1184}
1185#endif
1186 1134
1187static int btrfs_congested_fn(void *congested_data, int bdi_bits) 1135static int btrfs_congested_fn(void *congested_data, int bdi_bits)
1188{ 1136{
@@ -1226,9 +1174,8 @@ static void __unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
1226 continue; 1174 continue;
1227 1175
1228 bdi = blk_get_backing_dev_info(device->bdev); 1176 bdi = blk_get_backing_dev_info(device->bdev);
1229 if (bdi->unplug_io_fn) { 1177 if (bdi->unplug_io_fn)
1230 bdi->unplug_io_fn(bdi, page); 1178 bdi->unplug_io_fn(bdi, page);
1231 }
1232 } 1179 }
1233} 1180}
1234 1181
@@ -1420,8 +1367,9 @@ static int transaction_kthread(void *arg)
1420 mutex_lock(&root->fs_info->transaction_kthread_mutex); 1367 mutex_lock(&root->fs_info->transaction_kthread_mutex);
1421 1368
1422 if (root->fs_info->total_ref_cache_size > 20 * 1024 * 1024) { 1369 if (root->fs_info->total_ref_cache_size > 20 * 1024 * 1024) {
1423 printk("btrfs: total reference cache size %Lu\n", 1370 printk(KERN_INFO "btrfs: total reference cache "
1424 root->fs_info->total_ref_cache_size); 1371 "size %llu\n",
1372 root->fs_info->total_ref_cache_size);
1425 } 1373 }
1426 1374
1427 mutex_lock(&root->fs_info->trans_mutex); 1375 mutex_lock(&root->fs_info->trans_mutex);
@@ -1592,14 +1540,6 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1592 atomic_set(&fs_info->tree_log_writers, 0); 1540 atomic_set(&fs_info->tree_log_writers, 0);
1593 fs_info->tree_log_transid = 0; 1541 fs_info->tree_log_transid = 0;
1594 1542
1595#if 0
1596 ret = add_hasher(fs_info, "crc32c");
1597 if (ret) {
1598 printk("btrfs: failed hash setup, modprobe cryptomgr?\n");
1599 err = -ENOMEM;
1600 goto fail_iput;
1601 }
1602#endif
1603 __setup_root(4096, 4096, 4096, 4096, tree_root, 1543 __setup_root(4096, 4096, 4096, 4096, tree_root,
1604 fs_info, BTRFS_ROOT_TREE_OBJECTID); 1544 fs_info, BTRFS_ROOT_TREE_OBJECTID);
1605 1545
@@ -1720,7 +1660,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1720 1660
1721 if (strncmp((char *)(&disk_super->magic), BTRFS_MAGIC, 1661 if (strncmp((char *)(&disk_super->magic), BTRFS_MAGIC,
1722 sizeof(disk_super->magic))) { 1662 sizeof(disk_super->magic))) {
1723 printk("btrfs: valid FS not found on %s\n", sb->s_id); 1663 printk(KERN_INFO "btrfs: valid FS not found on %s\n", sb->s_id);
1724 goto fail_sb_buffer; 1664 goto fail_sb_buffer;
1725 } 1665 }
1726 1666
@@ -1728,8 +1668,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1728 ret = btrfs_read_sys_array(tree_root); 1668 ret = btrfs_read_sys_array(tree_root);
1729 mutex_unlock(&fs_info->chunk_mutex); 1669 mutex_unlock(&fs_info->chunk_mutex);
1730 if (ret) { 1670 if (ret) {
1731 printk("btrfs: failed to read the system array on %s\n", 1671 printk(KERN_WARNING "btrfs: failed to read the system "
1732 sb->s_id); 1672 "array on %s\n", sb->s_id);
1733 goto fail_sys_array; 1673 goto fail_sys_array;
1734 } 1674 }
1735 1675
@@ -1746,14 +1686,15 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1746 BUG_ON(!chunk_root->node); 1686 BUG_ON(!chunk_root->node);
1747 1687
1748 read_extent_buffer(chunk_root->node, fs_info->chunk_tree_uuid, 1688 read_extent_buffer(chunk_root->node, fs_info->chunk_tree_uuid,
1749 (unsigned long)btrfs_header_chunk_tree_uuid(chunk_root->node), 1689 (unsigned long)btrfs_header_chunk_tree_uuid(chunk_root->node),
1750 BTRFS_UUID_SIZE); 1690 BTRFS_UUID_SIZE);
1751 1691
1752 mutex_lock(&fs_info->chunk_mutex); 1692 mutex_lock(&fs_info->chunk_mutex);
1753 ret = btrfs_read_chunk_tree(chunk_root); 1693 ret = btrfs_read_chunk_tree(chunk_root);
1754 mutex_unlock(&fs_info->chunk_mutex); 1694 mutex_unlock(&fs_info->chunk_mutex);
1755 if (ret) { 1695 if (ret) {
1756 printk("btrfs: failed to read chunk tree on %s\n", sb->s_id); 1696 printk(KERN_WARNING "btrfs: failed to read chunk tree on %s\n",
1697 sb->s_id);
1757 goto fail_chunk_root; 1698 goto fail_chunk_root;
1758 } 1699 }
1759 1700
@@ -1812,7 +1753,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1812 u64 bytenr = btrfs_super_log_root(disk_super); 1753 u64 bytenr = btrfs_super_log_root(disk_super);
1813 1754
1814 if (fs_devices->rw_devices == 0) { 1755 if (fs_devices->rw_devices == 0) {
1815 printk("Btrfs log replay required on RO media\n"); 1756 printk(KERN_WARNING "Btrfs log replay required "
1757 "on RO media\n");
1816 err = -EIO; 1758 err = -EIO;
1817 goto fail_trans_kthread; 1759 goto fail_trans_kthread;
1818 } 1760 }
@@ -2097,7 +2039,8 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)
2097 total_errors++; 2039 total_errors++;
2098 } 2040 }
2099 if (total_errors > max_errors) { 2041 if (total_errors > max_errors) {
2100 printk("btrfs: %d errors while writing supers\n", total_errors); 2042 printk(KERN_ERR "btrfs: %d errors while writing supers\n",
2043 total_errors);
2101 BUG(); 2044 BUG();
2102 } 2045 }
2103 2046
@@ -2114,7 +2057,8 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)
2114 total_errors++; 2057 total_errors++;
2115 } 2058 }
2116 if (total_errors > max_errors) { 2059 if (total_errors > max_errors) {
2117 printk("btrfs: %d errors while writing supers\n", total_errors); 2060 printk(KERN_ERR "btrfs: %d errors while writing supers\n",
2061 total_errors);
2118 BUG(); 2062 BUG();
2119 } 2063 }
2120 return 0; 2064 return 0;
@@ -2137,16 +2081,11 @@ int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
2137 down_write(&root->anon_super.s_umount); 2081 down_write(&root->anon_super.s_umount);
2138 kill_anon_super(&root->anon_super); 2082 kill_anon_super(&root->anon_super);
2139 } 2083 }
2140#if 0
2141 if (root->in_sysfs)
2142 btrfs_sysfs_del_root(root);
2143#endif
2144 if (root->node) 2084 if (root->node)
2145 free_extent_buffer(root->node); 2085 free_extent_buffer(root->node);
2146 if (root->commit_root) 2086 if (root->commit_root)
2147 free_extent_buffer(root->commit_root); 2087 free_extent_buffer(root->commit_root);
2148 if (root->name) 2088 kfree(root->name);
2149 kfree(root->name);
2150 kfree(root); 2089 kfree(root);
2151 return 0; 2090 return 0;
2152} 2091}
@@ -2157,7 +2096,7 @@ static int del_fs_roots(struct btrfs_fs_info *fs_info)
2157 struct btrfs_root *gang[8]; 2096 struct btrfs_root *gang[8];
2158 int i; 2097 int i;
2159 2098
2160 while(1) { 2099 while (1) {
2161 ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix, 2100 ret = radix_tree_gang_lookup(&fs_info->fs_roots_radix,
2162 (void **)gang, 0, 2101 (void **)gang, 0,
2163 ARRAY_SIZE(gang)); 2102 ARRAY_SIZE(gang));
@@ -2228,18 +2167,17 @@ int close_ctree(struct btrfs_root *root)
2228 2167
2229 if (!(fs_info->sb->s_flags & MS_RDONLY)) { 2168 if (!(fs_info->sb->s_flags & MS_RDONLY)) {
2230 ret = btrfs_commit_super(root); 2169 ret = btrfs_commit_super(root);
2231 if (ret) { 2170 if (ret)
2232 printk("btrfs: commit super returns %d\n", ret); 2171 printk(KERN_ERR "btrfs: commit super ret %d\n", ret);
2233 }
2234 } 2172 }
2235 2173
2236 if (fs_info->delalloc_bytes) { 2174 if (fs_info->delalloc_bytes) {
2237 printk("btrfs: at unmount delalloc count %Lu\n", 2175 printk(KERN_INFO "btrfs: at unmount delalloc count %llu\n",
2238 fs_info->delalloc_bytes); 2176 fs_info->delalloc_bytes);
2239 } 2177 }
2240 if (fs_info->total_ref_cache_size) { 2178 if (fs_info->total_ref_cache_size) {
2241 printk("btrfs: at umount reference cache size %Lu\n", 2179 printk(KERN_INFO "btrfs: at umount reference cache size %llu\n",
2242 fs_info->total_ref_cache_size); 2180 (unsigned long long)fs_info->total_ref_cache_size);
2243 } 2181 }
2244 2182
2245 if (fs_info->extent_root->node) 2183 if (fs_info->extent_root->node)
@@ -2248,13 +2186,13 @@ int close_ctree(struct btrfs_root *root)
2248 if (fs_info->tree_root->node) 2186 if (fs_info->tree_root->node)
2249 free_extent_buffer(fs_info->tree_root->node); 2187 free_extent_buffer(fs_info->tree_root->node);
2250 2188
2251 if (root->fs_info->chunk_root->node); 2189 if (root->fs_info->chunk_root->node)
2252 free_extent_buffer(root->fs_info->chunk_root->node); 2190 free_extent_buffer(root->fs_info->chunk_root->node);
2253 2191
2254 if (root->fs_info->dev_root->node); 2192 if (root->fs_info->dev_root->node)
2255 free_extent_buffer(root->fs_info->dev_root->node); 2193 free_extent_buffer(root->fs_info->dev_root->node);
2256 2194
2257 if (root->fs_info->csum_root->node); 2195 if (root->fs_info->csum_root->node)
2258 free_extent_buffer(root->fs_info->csum_root->node); 2196 free_extent_buffer(root->fs_info->csum_root->node);
2259 2197
2260 btrfs_free_block_groups(root->fs_info); 2198 btrfs_free_block_groups(root->fs_info);
@@ -2273,7 +2211,7 @@ int close_ctree(struct btrfs_root *root)
2273 btrfs_stop_workers(&fs_info->submit_workers); 2211 btrfs_stop_workers(&fs_info->submit_workers);
2274 2212
2275#if 0 2213#if 0
2276 while(!list_empty(&fs_info->hashers)) { 2214 while (!list_empty(&fs_info->hashers)) {
2277 struct btrfs_hasher *hasher; 2215 struct btrfs_hasher *hasher;
2278 hasher = list_entry(fs_info->hashers.next, struct btrfs_hasher, 2216 hasher = list_entry(fs_info->hashers.next, struct btrfs_hasher,
2279 hashers); 2217 hashers);
@@ -2324,9 +2262,11 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
2324 2262
2325 WARN_ON(!btrfs_tree_locked(buf)); 2263 WARN_ON(!btrfs_tree_locked(buf));
2326 if (transid != root->fs_info->generation) { 2264 if (transid != root->fs_info->generation) {
2327 printk(KERN_CRIT "transid mismatch buffer %llu, found %Lu running %Lu\n", 2265 printk(KERN_CRIT "btrfs transid mismatch buffer %llu, "
2266 "found %llu running %llu\n",
2328 (unsigned long long)buf->start, 2267 (unsigned long long)buf->start,
2329 transid, root->fs_info->generation); 2268 (unsigned long long)transid,
2269 (unsigned long long)root->fs_info->generation);
2330 WARN_ON(1); 2270 WARN_ON(1);
2331 } 2271 }
2332 set_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, buf); 2272 set_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, buf);
@@ -2361,9 +2301,8 @@ int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid)
2361 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; 2301 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
2362 int ret; 2302 int ret;
2363 ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid); 2303 ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid);
2364 if (ret == 0) { 2304 if (ret == 0)
2365 buf->flags |= EXTENT_UPTODATE; 2305 buf->flags |= EXTENT_UPTODATE;
2366 }
2367 return ret; 2306 return ret;
2368} 2307}
2369 2308