aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSimon Kirby <sim@hostway.ca>2013-03-19 18:41:23 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-05-06 15:54:23 -0400
commitc2cf52eb71aeb902682e0c1fa29e4e9e4a7f4ffc (patch)
tree6c62e02e87bc92eb8eb66bf4c0fbebc00b64a1e5 /fs
parentaa8259145ecb8d432685c1167a194094559647a1 (diff)
Btrfs: Include the device in most error printk()s
With more than one btrfs volume mounted, it can be very difficult to find out which volume is hitting an error. btrfs_error() will print this, but it is currently rigged as more of a fatal error handler, while many of the printk()s are currently for debugging and yet-unhandled cases. This patch just changes the functions where the device information is already available. Some cases remain where the root or fs_info is not passed to the function emitting the error. This may introduce some confusion with volumes backed by multiple devices emitting errors referring to the primary device in the set instead of the one on which the error occurred. Use btrfs_printk(fs_info, format, ...) rather than writing the device string every time, and introduce macro wrappers ala XFS for brevity. Since the function already cannot be used for continuations, print a newline as part of the btrfs_printk() message rather than at each caller. Signed-off-by: Simon Kirby <sim@hostway.ca> Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ctree.h21
-rw-r--r--fs/btrfs/extent-tree.c67
-rw-r--r--fs/btrfs/free-space-cache.c43
-rw-r--r--fs/btrfs/inode.c70
-rw-r--r--fs/btrfs/print-tree.c9
-rw-r--r--fs/btrfs/super.c12
-rw-r--r--fs/btrfs/transaction.c2
-rw-r--r--fs/btrfs/volumes.c18
8 files changed, 133 insertions, 109 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index efb2feb7cd4a..5060990336a8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3643,14 +3643,31 @@ int btrfs_sync_fs(struct super_block *sb, int wait);
3643 3643
3644#ifdef CONFIG_PRINTK 3644#ifdef CONFIG_PRINTK
3645__printf(2, 3) 3645__printf(2, 3)
3646void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...); 3646void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
3647#else 3647#else
3648static inline __printf(2, 3) 3648static inline __printf(2, 3)
3649void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...) 3649void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
3650{ 3650{
3651} 3651}
3652#endif 3652#endif
3653 3653
3654#define btrfs_emerg(fs_info, fmt, args...) \
3655 btrfs_printk(fs_info, KERN_EMERG fmt, ##args)
3656#define btrfs_alert(fs_info, fmt, args...) \
3657 btrfs_printk(fs_info, KERN_ALERT fmt, ##args)
3658#define btrfs_crit(fs_info, fmt, args...) \
3659 btrfs_printk(fs_info, KERN_CRIT fmt, ##args)
3660#define btrfs_err(fs_info, fmt, args...) \
3661 btrfs_printk(fs_info, KERN_ERR fmt, ##args)
3662#define btrfs_warn(fs_info, fmt, args...) \
3663 btrfs_printk(fs_info, KERN_WARNING fmt, ##args)
3664#define btrfs_notice(fs_info, fmt, args...) \
3665 btrfs_printk(fs_info, KERN_NOTICE fmt, ##args)
3666#define btrfs_info(fs_info, fmt, args...) \
3667 btrfs_printk(fs_info, KERN_INFO fmt, ##args)
3668#define btrfs_debug(fs_info, fmt, args...) \
3669 btrfs_printk(fs_info, KERN_DEBUG fmt, ##args)
3670
3654__printf(5, 6) 3671__printf(5, 6)
3655void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, 3672void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
3656 unsigned int line, int errno, const char *fmt, ...); 3673 unsigned int line, int errno, const char *fmt, ...);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index be09157ff91b..171f8d676d9c 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2403,9 +2403,7 @@ static noinline int run_clustered_refs(struct btrfs_trans_handle *trans,
2403 btrfs_free_delayed_extent_op(extent_op); 2403 btrfs_free_delayed_extent_op(extent_op);
2404 2404
2405 if (ret) { 2405 if (ret) {
2406 printk(KERN_DEBUG 2406 btrfs_debug(fs_info, "run_delayed_extent_op returned %d", ret);
2407 "btrfs: run_delayed_extent_op "
2408 "returned %d\n", ret);
2409 spin_lock(&delayed_refs->lock); 2407 spin_lock(&delayed_refs->lock);
2410 btrfs_delayed_ref_unlock(locked_ref); 2408 btrfs_delayed_ref_unlock(locked_ref);
2411 return ret; 2409 return ret;
@@ -2444,8 +2442,7 @@ static noinline int run_clustered_refs(struct btrfs_trans_handle *trans,
2444 if (ret) { 2442 if (ret) {
2445 btrfs_delayed_ref_unlock(locked_ref); 2443 btrfs_delayed_ref_unlock(locked_ref);
2446 btrfs_put_delayed_ref(ref); 2444 btrfs_put_delayed_ref(ref);
2447 printk(KERN_DEBUG 2445 btrfs_debug(fs_info, "run_one_delayed_ref returned %d", ret);
2448 "btrfs: run_one_delayed_ref returned %d\n", ret);
2449 spin_lock(&delayed_refs->lock); 2446 spin_lock(&delayed_refs->lock);
2450 return ret; 2447 return ret;
2451 } 2448 }
@@ -2522,7 +2519,8 @@ int btrfs_delayed_refs_qgroup_accounting(struct btrfs_trans_handle *trans,
2522 if (list_empty(&trans->qgroup_ref_list) != 2519 if (list_empty(&trans->qgroup_ref_list) !=
2523 !trans->delayed_ref_elem.seq) { 2520 !trans->delayed_ref_elem.seq) {
2524 /* list without seq or seq without list */ 2521 /* list without seq or seq without list */
2525 printk(KERN_ERR "btrfs: qgroup accounting update error, list is%s empty, seq is %llu\n", 2522 btrfs_err(fs_info,
2523 "qgroup accounting update error, list is%s empty, seq is %llu",
2526 list_empty(&trans->qgroup_ref_list) ? "" : " not", 2524 list_empty(&trans->qgroup_ref_list) ? "" : " not",
2527 trans->delayed_ref_elem.seq); 2525 trans->delayed_ref_elem.seq);
2528 BUG(); 2526 BUG();
@@ -3723,8 +3721,8 @@ static void check_system_chunk(struct btrfs_trans_handle *trans,
3723 3721
3724 thresh = get_system_chunk_thresh(root, type); 3722 thresh = get_system_chunk_thresh(root, type);
3725 if (left < thresh && btrfs_test_opt(root, ENOSPC_DEBUG)) { 3723 if (left < thresh && btrfs_test_opt(root, ENOSPC_DEBUG)) {
3726 printk(KERN_INFO "left=%llu, need=%llu, flags=%llu\n", 3724 btrfs_info(root->fs_info, "left=%llu, need=%llu, flags=%llu",
3727 left, thresh, type); 3725 left, thresh, type);
3728 dump_space_info(info, 0, 0); 3726 dump_space_info(info, 0, 0);
3729 } 3727 }
3730 3728
@@ -5501,9 +5499,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
5501 } 5499 }
5502 5500
5503 if (ret) { 5501 if (ret) {
5504 printk(KERN_ERR "umm, got %d back from search" 5502 btrfs_err(info, "umm, got %d back from search, was looking for %llu",
5505 ", was looking for %llu\n", ret, 5503 ret, (unsigned long long)bytenr);
5506 (unsigned long long)bytenr);
5507 if (ret > 0) 5504 if (ret > 0)
5508 btrfs_print_leaf(extent_root, 5505 btrfs_print_leaf(extent_root,
5509 path->nodes[0]); 5506 path->nodes[0]);
@@ -5517,13 +5514,13 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
5517 } else if (ret == -ENOENT) { 5514 } else if (ret == -ENOENT) {
5518 btrfs_print_leaf(extent_root, path->nodes[0]); 5515 btrfs_print_leaf(extent_root, path->nodes[0]);
5519 WARN_ON(1); 5516 WARN_ON(1);
5520 printk(KERN_ERR "btrfs unable to find ref byte nr %llu " 5517 btrfs_err(info,
5521 "parent %llu root %llu owner %llu offset %llu\n", 5518 "unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu",
5522 (unsigned long long)bytenr, 5519 (unsigned long long)bytenr,
5523 (unsigned long long)parent, 5520 (unsigned long long)parent,
5524 (unsigned long long)root_objectid, 5521 (unsigned long long)root_objectid,
5525 (unsigned long long)owner_objectid, 5522 (unsigned long long)owner_objectid,
5526 (unsigned long long)owner_offset); 5523 (unsigned long long)owner_offset);
5527 } else { 5524 } else {
5528 btrfs_abort_transaction(trans, extent_root, ret); 5525 btrfs_abort_transaction(trans, extent_root, ret);
5529 goto out; 5526 goto out;
@@ -5551,9 +5548,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
5551 ret = btrfs_search_slot(trans, extent_root, &key, path, 5548 ret = btrfs_search_slot(trans, extent_root, &key, path,
5552 -1, 1); 5549 -1, 1);
5553 if (ret) { 5550 if (ret) {
5554 printk(KERN_ERR "umm, got %d back from search" 5551 btrfs_err(info, "umm, got %d back from search, was looking for %llu",
5555 ", was looking for %llu\n", ret, 5552 ret, (unsigned long long)bytenr);
5556 (unsigned long long)bytenr);
5557 btrfs_print_leaf(extent_root, path->nodes[0]); 5553 btrfs_print_leaf(extent_root, path->nodes[0]);
5558 } 5554 }
5559 if (ret < 0) { 5555 if (ret < 0) {
@@ -5922,7 +5918,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
5922 5918
5923 space_info = __find_space_info(root->fs_info, data); 5919 space_info = __find_space_info(root->fs_info, data);
5924 if (!space_info) { 5920 if (!space_info) {
5925 printk(KERN_ERR "No space info for %llu\n", data); 5921 btrfs_err(root->fs_info, "No space info for %llu", data);
5926 return -ENOSPC; 5922 return -ENOSPC;
5927 } 5923 }
5928 5924
@@ -6346,9 +6342,9 @@ again:
6346 struct btrfs_space_info *sinfo; 6342 struct btrfs_space_info *sinfo;
6347 6343
6348 sinfo = __find_space_info(root->fs_info, data); 6344 sinfo = __find_space_info(root->fs_info, data);
6349 printk(KERN_ERR "btrfs allocation failed flags %llu, " 6345 btrfs_err(root->fs_info, "allocation failed flags %llu, wanted %llu",
6350 "wanted %llu\n", (unsigned long long)data, 6346 (unsigned long long)data,
6351 (unsigned long long)num_bytes); 6347 (unsigned long long)num_bytes);
6352 if (sinfo) 6348 if (sinfo)
6353 dump_space_info(sinfo, num_bytes, 1); 6349 dump_space_info(sinfo, num_bytes, 1);
6354 } 6350 }
@@ -6367,8 +6363,8 @@ static int __btrfs_free_reserved_extent(struct btrfs_root *root,
6367 6363
6368 cache = btrfs_lookup_block_group(root->fs_info, start); 6364 cache = btrfs_lookup_block_group(root->fs_info, start);
6369 if (!cache) { 6365 if (!cache) {
6370 printk(KERN_ERR "Unable to find block group for %llu\n", 6366 btrfs_err(root->fs_info, "Unable to find block group for %llu",
6371 (unsigned long long)start); 6367 (unsigned long long)start);
6372 return -ENOSPC; 6368 return -ENOSPC;
6373 } 6369 }
6374 6370
@@ -6463,9 +6459,9 @@ static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
6463 6459
6464 ret = update_block_group(root, ins->objectid, ins->offset, 1); 6460 ret = update_block_group(root, ins->objectid, ins->offset, 1);
6465 if (ret) { /* -ENOENT, logic error */ 6461 if (ret) { /* -ENOENT, logic error */
6466 printk(KERN_ERR "btrfs update block group failed for %llu " 6462 btrfs_err(fs_info, "update block group failed for %llu %llu",
6467 "%llu\n", (unsigned long long)ins->objectid, 6463 (unsigned long long)ins->objectid,
6468 (unsigned long long)ins->offset); 6464 (unsigned long long)ins->offset);
6469 BUG(); 6465 BUG();
6470 } 6466 }
6471 return ret; 6467 return ret;
@@ -6536,9 +6532,9 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
6536 6532
6537 ret = update_block_group(root, ins->objectid, root->leafsize, 1); 6533 ret = update_block_group(root, ins->objectid, root->leafsize, 1);
6538 if (ret) { /* -ENOENT, logic error */ 6534 if (ret) { /* -ENOENT, logic error */
6539 printk(KERN_ERR "btrfs update block group failed for %llu " 6535 btrfs_err(fs_info, "update block group failed for %llu %llu",
6540 "%llu\n", (unsigned long long)ins->objectid, 6536 (unsigned long long)ins->objectid,
6541 (unsigned long long)ins->offset); 6537 (unsigned long long)ins->offset);
6542 BUG(); 6538 BUG();
6543 } 6539 }
6544 return ret; 6540 return ret;
@@ -7027,7 +7023,10 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
7027 return ret; 7023 return ret;
7028 } 7024 }
7029 7025
7030 BUG_ON(wc->refs[level - 1] == 0); 7026 if (unlikely(wc->refs[level - 1] == 0)) {
7027 btrfs_err(root->fs_info, "Missing references.");
7028 BUG();
7029 }
7031 *lookup_info = 0; 7030 *lookup_info = 0;
7032 7031
7033 if (wc->stage == DROP_REFERENCE) { 7032 if (wc->stage == DROP_REFERENCE) {
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 6be083b6433e..fa1a8140bfb5 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -104,7 +104,8 @@ struct inode *lookup_free_space_inode(struct btrfs_root *root,
104 104
105 spin_lock(&block_group->lock); 105 spin_lock(&block_group->lock);
106 if (!((BTRFS_I(inode)->flags & flags) == flags)) { 106 if (!((BTRFS_I(inode)->flags & flags) == flags)) {
107 printk(KERN_INFO "Old style space inode found, converting.\n"); 107 btrfs_info(root->fs_info,
108 "Old style space inode found, converting.");
108 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM | 109 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM |
109 BTRFS_INODE_NODATACOW; 110 BTRFS_INODE_NODATACOW;
110 block_group->disk_cache_state = BTRFS_DC_CLEAR; 111 block_group->disk_cache_state = BTRFS_DC_CLEAR;
@@ -669,10 +670,11 @@ int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
669 btrfs_release_path(path); 670 btrfs_release_path(path);
670 671
671 if (BTRFS_I(inode)->generation != generation) { 672 if (BTRFS_I(inode)->generation != generation) {
672 printk(KERN_ERR "btrfs: free space inode generation (%llu) did" 673 btrfs_err(root->fs_info,
673 " not match free space cache generation (%llu)\n", 674 "free space inode generation (%llu) "
674 (unsigned long long)BTRFS_I(inode)->generation, 675 "did not match free space cache generation (%llu)",
675 (unsigned long long)generation); 676 (unsigned long long)BTRFS_I(inode)->generation,
677 (unsigned long long)generation);
676 return 0; 678 return 0;
677 } 679 }
678 680
@@ -721,8 +723,8 @@ int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
721 ret = link_free_space(ctl, e); 723 ret = link_free_space(ctl, e);
722 spin_unlock(&ctl->tree_lock); 724 spin_unlock(&ctl->tree_lock);
723 if (ret) { 725 if (ret) {
724 printk(KERN_ERR "Duplicate entries in " 726 btrfs_err(root->fs_info,
725 "free space cache, dumping\n"); 727 "Duplicate entries in free space cache, dumping");
726 kmem_cache_free(btrfs_free_space_cachep, e); 728 kmem_cache_free(btrfs_free_space_cachep, e);
727 goto free_cache; 729 goto free_cache;
728 } 730 }
@@ -741,8 +743,8 @@ int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
741 ctl->op->recalc_thresholds(ctl); 743 ctl->op->recalc_thresholds(ctl);
742 spin_unlock(&ctl->tree_lock); 744 spin_unlock(&ctl->tree_lock);
743 if (ret) { 745 if (ret) {
744 printk(KERN_ERR "Duplicate entries in " 746 btrfs_err(root->fs_info,
745 "free space cache, dumping\n"); 747 "Duplicate entries in free space cache, dumping");
746 kmem_cache_free(btrfs_free_space_cachep, e); 748 kmem_cache_free(btrfs_free_space_cachep, e);
747 goto free_cache; 749 goto free_cache;
748 } 750 }
@@ -833,8 +835,8 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
833 835
834 if (!matched) { 836 if (!matched) {
835 __btrfs_remove_free_space_cache(ctl); 837 __btrfs_remove_free_space_cache(ctl);
836 printk(KERN_ERR "block group %llu has an wrong amount of free " 838 btrfs_err(fs_info, "block group %llu has wrong amount of free space",
837 "space\n", block_group->key.objectid); 839 block_group->key.objectid);
838 ret = -1; 840 ret = -1;
839 } 841 }
840out: 842out:
@@ -845,8 +847,8 @@ out:
845 spin_unlock(&block_group->lock); 847 spin_unlock(&block_group->lock);
846 ret = 0; 848 ret = 0;
847 849
848 printk(KERN_ERR "btrfs: failed to load free space cache " 850 btrfs_err(fs_info, "failed to load free space cache for block group %llu",
849 "for block group %llu\n", block_group->key.objectid); 851 block_group->key.objectid);
850 } 852 }
851 853
852 iput(inode); 854 iput(inode);
@@ -1104,8 +1106,9 @@ int btrfs_write_out_cache(struct btrfs_root *root,
1104 spin_unlock(&block_group->lock); 1106 spin_unlock(&block_group->lock);
1105 ret = 0; 1107 ret = 0;
1106#ifdef DEBUG 1108#ifdef DEBUG
1107 printk(KERN_ERR "btrfs: failed to write free space cache " 1109 btrfs_err(root->fs_info,
1108 "for block group %llu\n", block_group->key.objectid); 1110 "failed to write free space cache for block group %llu",
1111 block_group->key.objectid);
1109#endif 1112#endif
1110 } 1113 }
1111 1114
@@ -2931,8 +2934,9 @@ int load_free_ino_cache(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
2931 ret = __load_free_space_cache(root, inode, ctl, path, 0); 2934 ret = __load_free_space_cache(root, inode, ctl, path, 0);
2932 2935
2933 if (ret < 0) 2936 if (ret < 0)
2934 printk(KERN_ERR "btrfs: failed to load free ino cache for " 2937 btrfs_err(fs_info,
2935 "root %llu\n", root->root_key.objectid); 2938 "failed to load free ino cache for root %llu",
2939 root->root_key.objectid);
2936out_put: 2940out_put:
2937 iput(inode); 2941 iput(inode);
2938out: 2942out:
@@ -2959,8 +2963,9 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root,
2959 if (ret) { 2963 if (ret) {
2960 btrfs_delalloc_release_metadata(inode, inode->i_size); 2964 btrfs_delalloc_release_metadata(inode, inode->i_size);
2961#ifdef DEBUG 2965#ifdef DEBUG
2962 printk(KERN_ERR "btrfs: failed to write free ino cache " 2966 btrfs_err(root->fs_info,
2963 "for root %llu\n", root->root_key.objectid); 2967 "failed to write free ino cache for root %llu",
2968 root->root_key.objectid);
2964#endif 2969#endif
2965 } 2970 }
2966 2971
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c69145b66ea4..84f056e5d3db 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2793,6 +2793,8 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
2793 int ret; 2793 int ret;
2794 struct btrfs_root *root = BTRFS_I(inode)->root; 2794 struct btrfs_root *root = BTRFS_I(inode)->root;
2795 u32 csum = ~(u32)0; 2795 u32 csum = ~(u32)0;
2796 static DEFINE_RATELIMIT_STATE(_rs, DEFAULT_RATELIMIT_INTERVAL,
2797 DEFAULT_RATELIMIT_BURST);
2796 2798
2797 if (PageChecked(page)) { 2799 if (PageChecked(page)) {
2798 ClearPageChecked(page); 2800 ClearPageChecked(page);
@@ -2829,11 +2831,11 @@ good:
2829 return 0; 2831 return 0;
2830 2832
2831zeroit: 2833zeroit:
2832 printk_ratelimited(KERN_INFO "btrfs csum failed ino %llu off %llu csum %u " 2834 if (__ratelimit(&_rs))
2833 "private %llu\n", 2835 btrfs_info(root->fs_info, "csum failed ino %llu off %llu csum %u private %llu",
2834 (unsigned long long)btrfs_ino(page->mapping->host), 2836 (unsigned long long)btrfs_ino(page->mapping->host),
2835 (unsigned long long)start, csum, 2837 (unsigned long long)start, csum,
2836 (unsigned long long)private); 2838 (unsigned long long)private);
2837 memset(kaddr + offset, 1, end - start + 1); 2839 memset(kaddr + offset, 1, end - start + 1);
2838 flush_dcache_page(page); 2840 flush_dcache_page(page);
2839 kunmap_atomic(kaddr); 2841 kunmap_atomic(kaddr);
@@ -3114,8 +3116,8 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
3114 */ 3116 */
3115 3117
3116 if (found_key.offset == last_objectid) { 3118 if (found_key.offset == last_objectid) {
3117 printk(KERN_ERR "btrfs: Error removing orphan entry, " 3119 btrfs_err(root->fs_info,
3118 "stopping orphan cleanup\n"); 3120 "Error removing orphan entry, stopping orphan cleanup");
3119 ret = -EINVAL; 3121 ret = -EINVAL;
3120 goto out; 3122 goto out;
3121 } 3123 }
@@ -3172,8 +3174,8 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
3172 ret = PTR_ERR(trans); 3174 ret = PTR_ERR(trans);
3173 goto out; 3175 goto out;
3174 } 3176 }
3175 printk(KERN_ERR "auto deleting %Lu\n", 3177 btrfs_debug(root->fs_info, "auto deleting %Lu",
3176 found_key.objectid); 3178 found_key.objectid);
3177 ret = btrfs_del_orphan_item(trans, root, 3179 ret = btrfs_del_orphan_item(trans, root,
3178 found_key.objectid); 3180 found_key.objectid);
3179 BUG_ON(ret); /* -ENOMEM or corruption (JDM: Recheck) */ 3181 BUG_ON(ret); /* -ENOMEM or corruption (JDM: Recheck) */
@@ -3237,13 +3239,14 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
3237 } 3239 }
3238 3240
3239 if (nr_unlink) 3241 if (nr_unlink)
3240 printk(KERN_INFO "btrfs: unlinked %d orphans\n", nr_unlink); 3242 btrfs_info(root->fs_info, "unlinked %d orphans", nr_unlink);
3241 if (nr_truncate) 3243 if (nr_truncate)
3242 printk(KERN_INFO "btrfs: truncated %d orphans\n", nr_truncate); 3244 btrfs_info(root->fs_info, "truncated %d orphans", nr_truncate);
3243 3245
3244out: 3246out:
3245 if (ret) 3247 if (ret)
3246 printk(KERN_CRIT "btrfs: could not do orphan cleanup %d\n", ret); 3248 btrfs_crit(root->fs_info,
3249 "could not do orphan cleanup %d", ret);
3247 btrfs_free_path(path); 3250 btrfs_free_path(path);
3248 return ret; 3251 return ret;
3249} 3252}
@@ -3591,9 +3594,10 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
3591 ret = btrfs_del_inode_ref(trans, root, name, name_len, ino, 3594 ret = btrfs_del_inode_ref(trans, root, name, name_len, ino,
3592 dir_ino, &index); 3595 dir_ino, &index);
3593 if (ret) { 3596 if (ret) {
3594 printk(KERN_INFO "btrfs failed to delete reference to %.*s, " 3597 btrfs_info(root->fs_info,
3595 "inode %llu parent %llu\n", name_len, name, 3598 "failed to delete reference to %.*s, inode %llu parent %llu",
3596 (unsigned long long)ino, (unsigned long long)dir_ino); 3599 name_len, name,
3600 (unsigned long long)ino, (unsigned long long)dir_ino);
3597 btrfs_abort_transaction(trans, root, ret); 3601 btrfs_abort_transaction(trans, root, ret);
3598 goto err; 3602 goto err;
3599 } 3603 }
@@ -4670,8 +4674,9 @@ void btrfs_evict_inode(struct inode *inode)
4670 ret = btrfs_block_rsv_migrate(global_rsv, rsv, min_size); 4674 ret = btrfs_block_rsv_migrate(global_rsv, rsv, min_size);
4671 4675
4672 if (ret) { 4676 if (ret) {
4673 printk(KERN_WARNING "Could not get space for a " 4677 btrfs_warn(root->fs_info,
4674 "delete, will truncate on mount %d\n", ret); 4678 "Could not get space for a delete, will truncate on mount %d",
4679 ret);
4675 btrfs_orphan_del(NULL, inode); 4680 btrfs_orphan_del(NULL, inode);
4676 btrfs_free_block_rsv(root, rsv); 4681 btrfs_free_block_rsv(root, rsv);
4677 goto no_delete; 4682 goto no_delete;
@@ -6259,11 +6264,11 @@ not_found_em:
6259insert: 6264insert:
6260 btrfs_release_path(path); 6265 btrfs_release_path(path);
6261 if (em->start > start || extent_map_end(em) <= start) { 6266 if (em->start > start || extent_map_end(em) <= start) {
6262 printk(KERN_ERR "Btrfs: bad extent! em: [%llu %llu] passed " 6267 btrfs_err(root->fs_info, "bad extent! em: [%llu %llu] passed [%llu %llu]",
6263 "[%llu %llu]\n", (unsigned long long)em->start, 6268 (unsigned long long)em->start,
6264 (unsigned long long)em->len, 6269 (unsigned long long)em->len,
6265 (unsigned long long)start, 6270 (unsigned long long)start,
6266 (unsigned long long)len); 6271 (unsigned long long)len);
6267 err = -EIO; 6272 err = -EIO;
6268 goto out; 6273 goto out;
6269 } 6274 }
@@ -6919,6 +6924,7 @@ static void btrfs_endio_direct_read(struct bio *bio, int err)
6919 struct bio_vec *bvec_end = bio->bi_io_vec + bio->bi_vcnt - 1; 6924 struct bio_vec *bvec_end = bio->bi_io_vec + bio->bi_vcnt - 1;
6920 struct bio_vec *bvec = bio->bi_io_vec; 6925 struct bio_vec *bvec = bio->bi_io_vec;
6921 struct inode *inode = dip->inode; 6926 struct inode *inode = dip->inode;
6927 struct btrfs_root *root = BTRFS_I(inode)->root;
6922 u64 start; 6928 u64 start;
6923 6929
6924 start = dip->logical_offset; 6930 start = dip->logical_offset;
@@ -6944,11 +6950,10 @@ static void btrfs_endio_direct_read(struct bio *bio, int err)
6944 flush_dcache_page(bvec->bv_page); 6950 flush_dcache_page(bvec->bv_page);
6945 if (csum != private) { 6951 if (csum != private) {
6946failed: 6952failed:
6947 printk(KERN_ERR "btrfs csum failed ino %llu off" 6953 btrfs_err(root->fs_info, "csum failed ino %llu off %llu csum %u private %u",
6948 " %llu csum %u private %u\n", 6954 (unsigned long long)btrfs_ino(inode),
6949 (unsigned long long)btrfs_ino(inode), 6955 (unsigned long long)start,
6950 (unsigned long long)start, 6956 csum, (unsigned)private);
6951 csum, (unsigned)private);
6952 err = -EIO; 6957 err = -EIO;
6953 } 6958 }
6954 } 6959 }
@@ -7940,8 +7945,8 @@ void btrfs_destroy_inode(struct inode *inode)
7940 7945
7941 if (test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, 7946 if (test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
7942 &BTRFS_I(inode)->runtime_flags)) { 7947 &BTRFS_I(inode)->runtime_flags)) {
7943 printk(KERN_INFO "BTRFS: inode %llu still on the orphan list\n", 7948 btrfs_info(root->fs_info, "inode %llu still on the orphan list",
7944 (unsigned long long)btrfs_ino(inode)); 7949 (unsigned long long)btrfs_ino(inode));
7945 atomic_dec(&root->orphan_inodes); 7950 atomic_dec(&root->orphan_inodes);
7946 } 7951 }
7947 7952
@@ -7950,10 +7955,9 @@ void btrfs_destroy_inode(struct inode *inode)
7950 if (!ordered) 7955 if (!ordered)
7951 break; 7956 break;
7952 else { 7957 else {
7953 printk(KERN_ERR "btrfs found ordered " 7958 btrfs_err(root->fs_info, "found ordered extent %llu %llu on inode cleanup",
7954 "extent %llu %llu on inode cleanup\n", 7959 (unsigned long long)ordered->file_offset,
7955 (unsigned long long)ordered->file_offset, 7960 (unsigned long long)ordered->len);
7956 (unsigned long long)ordered->len);
7957 btrfs_remove_ordered_extent(inode, ordered); 7961 btrfs_remove_ordered_extent(inode, ordered);
7958 btrfs_put_ordered_extent(ordered); 7962 btrfs_put_ordered_extent(ordered);
7959 btrfs_put_ordered_extent(ordered); 7963 btrfs_put_ordered_extent(ordered);
diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index 920957ecb27e..dc0024f17c1f 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -176,7 +176,7 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
176 176
177 nr = btrfs_header_nritems(l); 177 nr = btrfs_header_nritems(l);
178 178
179 printk(KERN_INFO "leaf %llu total ptrs %d free space %d\n", 179 btrfs_info(root->fs_info, "leaf %llu total ptrs %d free space %d",
180 (unsigned long long)btrfs_header_bytenr(l), nr, 180 (unsigned long long)btrfs_header_bytenr(l), nr,
181 btrfs_leaf_free_space(root, l)); 181 btrfs_leaf_free_space(root, l));
182 for (i = 0 ; i < nr ; i++) { 182 for (i = 0 ; i < nr ; i++) {
@@ -319,10 +319,9 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
319 btrfs_print_leaf(root, c); 319 btrfs_print_leaf(root, c);
320 return; 320 return;
321 } 321 }
322 printk(KERN_INFO "node %llu level %d total ptrs %d free spc %u\n", 322 btrfs_info(root->fs_info, "node %llu level %d total ptrs %d free spc %u",
323 (unsigned long long)btrfs_header_bytenr(c), 323 (unsigned long long)btrfs_header_bytenr(c),
324 level, nr, 324 level, nr, (u32)BTRFS_NODEPTRS_PER_BLOCK(root) - nr);
325 (u32)BTRFS_NODEPTRS_PER_BLOCK(root) - nr);
326 for (i = 0; i < nr; i++) { 325 for (i = 0; i < nr; i++) {
327 btrfs_node_key_to_cpu(c, &key, i); 326 btrfs_node_key_to_cpu(c, &key, i);
328 printk(KERN_INFO "\tkey %d (%llu %u %llu) block %llu\n", 327 printk(KERN_INFO "\tkey %d (%llu %u %llu) block %llu\n",
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 7f00a91ccc10..3fd4f2c3d529 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -105,7 +105,7 @@ static void btrfs_handle_error(struct btrfs_fs_info *fs_info)
105 105
106 if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) { 106 if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) {
107 sb->s_flags |= MS_RDONLY; 107 sb->s_flags |= MS_RDONLY;
108 printk(KERN_INFO "btrfs is forced readonly\n"); 108 btrfs_info(fs_info, "forced readonly");
109 /* 109 /*
110 * Note that a running device replace operation is not 110 * Note that a running device replace operation is not
111 * canceled here although there is no way to update 111 * canceled here although there is no way to update
@@ -172,7 +172,7 @@ static const char * const logtypes[] = {
172 "debug", 172 "debug",
173}; 173};
174 174
175void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...) 175void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
176{ 176{
177 struct super_block *sb = fs_info->sb; 177 struct super_block *sb = fs_info->sb;
178 char lvl[4]; 178 char lvl[4];
@@ -196,7 +196,7 @@ void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...)
196 vaf.fmt = fmt; 196 vaf.fmt = fmt;
197 vaf.va = &args; 197 vaf.va = &args;
198 198
199 printk("%sBTRFS %s (device %s): %pV", lvl, type, sb->s_id, &vaf); 199 printk("%sBTRFS %s (device %s): %pV\n", lvl, type, sb->s_id, &vaf);
200 200
201 va_end(args); 201 va_end(args);
202} 202}
@@ -255,9 +255,9 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
255 const char *errstr; 255 const char *errstr;
256 256
257 errstr = btrfs_decode_error(errno); 257 errstr = btrfs_decode_error(errno);
258 btrfs_printk(root->fs_info, 258 btrfs_warn(root->fs_info,
259 "%s:%d: Aborting unused transaction (%s)\n", 259 "%s:%d: Aborting unused transaction(%s).",
260 function, line, errstr); 260 function, line, errstr);
261 return; 261 return;
262 } 262 }
263 ACCESS_ONCE(trans->transaction->aborted) = errno; 263 ACCESS_ONCE(trans->transaction->aborted) = errno;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 5a5ea99f29ed..9940fd90a958 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1864,7 +1864,7 @@ cleanup_transaction:
1864 btrfs_qgroup_free(root, trans->qgroup_reserved); 1864 btrfs_qgroup_free(root, trans->qgroup_reserved);
1865 trans->qgroup_reserved = 0; 1865 trans->qgroup_reserved = 0;
1866 } 1866 }
1867 btrfs_printk(root->fs_info, "Skipping commit of aborted transaction\n"); 1867 btrfs_warn(root->fs_info, "Skipping commit of aborted transaction.");
1868 if (current->journal_info == trans) 1868 if (current->journal_info == trans)
1869 current->journal_info = NULL; 1869 current->journal_info = NULL;
1870 cleanup_transaction(trans, root, ret); 1870 cleanup_transaction(trans, root, ret);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 2854c824ab64..3994767ece4d 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -4411,9 +4411,9 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
4411 read_unlock(&em_tree->lock); 4411 read_unlock(&em_tree->lock);
4412 4412
4413 if (!em) { 4413 if (!em) {
4414 printk(KERN_CRIT "btrfs: unable to find logical %llu len %llu\n", 4414 btrfs_crit(fs_info, "unable to find logical %llu len %llu",
4415 (unsigned long long)logical, 4415 (unsigned long long)logical,
4416 (unsigned long long)*length); 4416 (unsigned long long)*length);
4417 BUG(); 4417 BUG();
4418 } 4418 }
4419 4419
@@ -5308,10 +5308,10 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,
5308 } 5308 }
5309 5309
5310 if (map_length < length) { 5310 if (map_length < length) {
5311 printk(KERN_CRIT "btrfs: mapping failed logical %llu bio len %llu " 5311 btrfs_crit(root->fs_info, "mapping failed logical %llu bio len %llu len %llu",
5312 "len %llu\n", (unsigned long long)logical, 5312 (unsigned long long)logical,
5313 (unsigned long long)length, 5313 (unsigned long long)length,
5314 (unsigned long long)map_length); 5314 (unsigned long long)map_length);
5315 BUG(); 5315 BUG();
5316 } 5316 }
5317 5317
@@ -5583,8 +5583,8 @@ static int read_one_dev(struct btrfs_root *root,
5583 return -EIO; 5583 return -EIO;
5584 5584
5585 if (!device) { 5585 if (!device) {
5586 printk(KERN_WARNING "warning devid %llu missing\n", 5586 btrfs_warn(root->fs_info, "devid %llu missing",
5587 (unsigned long long)devid); 5587 (unsigned long long)devid);
5588 device = add_missing_dev(root, devid, dev_uuid); 5588 device = add_missing_dev(root, devid, dev_uuid);
5589 if (!device) 5589 if (!device)
5590 return -ENOMEM; 5590 return -ENOMEM;