aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
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/btrfs/inode.c
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/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c70
1 files changed, 37 insertions, 33 deletions
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);