btrfs: switch more printks to our helpers
authorDavid Sterba <dsterba@suse.com>
Thu, 8 Oct 2015 09:37:06 +0000 (11:37 +0200)
committerDavid Sterba <dsterba@suse.com>
Thu, 8 Oct 2015 11:08:03 +0000 (13:08 +0200)
Convert the simple cases, not all functions provide a way to reach the
fs_info. Also skipped debugging messages (print-tree, integrity
checker and pr_debug) and messages that are printed from possibly
unfinished mount.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/ioctl.c
fs/btrfs/root-tree.c
fs/btrfs/send.c
fs/btrfs/volumes.c

index 72553cd9ed141a3ea24699b340d31e747da82e2c..5bc94d2d56993435962b94d20411b5255d4797b4 100644 (file)
@@ -2347,8 +2347,7 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info,
        u64 bytenr = btrfs_super_log_root(disk_super);
 
        if (fs_devices->rw_devices == 0) {
-               printk(KERN_WARNING "BTRFS: log replay required "
-                      "on RO media\n");
+               btrfs_warn(fs_info, "log replay required on RO media");
                return -EIO;
        }
 
@@ -2363,12 +2362,12 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info,
        log_tree_root->node = read_tree_block(tree_root, bytenr,
                        fs_info->generation + 1);
        if (IS_ERR(log_tree_root->node)) {
-               printk(KERN_ERR "BTRFS: failed to read log tree\n");
+               btrfs_warn(fs_info, "failed to read log tree");
                ret = PTR_ERR(log_tree_root->node);
                kfree(log_tree_root);
                return ret;
        } else if (!extent_buffer_uptodate(log_tree_root->node)) {
-               printk(KERN_ERR "BTRFS: failed to read log tree\n");
+               btrfs_err(fs_info, "failed to read log tree");
                free_extent_buffer(log_tree_root->node);
                kfree(log_tree_root);
                return -EIO;
@@ -3294,8 +3293,9 @@ static int write_dev_supers(struct btrfs_device *device,
                        bh = __getblk(device->bdev, bytenr / 4096,
                                      BTRFS_SUPER_INFO_SIZE);
                        if (!bh) {
-                               printk(KERN_ERR "BTRFS: couldn't get super "
-                                      "buffer head for bytenr %Lu\n", bytenr);
+                               btrfs_err(device->dev_root->fs_info,
+                                   "couldn't get super buffer head for bytenr %llu",
+                                   bytenr);
                                errors++;
                                continue;
                        }
index bb318b4e5dd0c47b11780059a7d434c6484a2814..c7a33913188bff5358f898264bcc13fef94f2639 100644 (file)
@@ -5563,13 +5563,15 @@ void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
        unsigned long src_i;
 
        if (src_offset + len > dst->len) {
-               printk(KERN_ERR "BTRFS: memmove bogus src_offset %lu move "
-                      "len %lu dst len %lu\n", src_offset, len, dst->len);
+               btrfs_err(dst->fs_info,
+                       "memmove bogus src_offset %lu move "
+                      "len %lu dst len %lu", src_offset, len, dst->len);
                BUG_ON(1);
        }
        if (dst_offset + len > dst->len) {
-               printk(KERN_ERR "BTRFS: memmove bogus dst_offset %lu move "
-                      "len %lu dst len %lu\n", dst_offset, len, dst->len);
+               btrfs_err(dst->fs_info,
+                       "memmove bogus dst_offset %lu move "
+                      "len %lu dst len %lu", dst_offset, len, dst->len);
                BUG_ON(1);
        }
 
@@ -5609,13 +5611,13 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
        unsigned long src_i;
 
        if (src_offset + len > dst->len) {
-               printk(KERN_ERR "BTRFS: memmove bogus src_offset %lu move "
-                      "len %lu len %lu\n", src_offset, len, dst->len);
+               btrfs_err(dst->fs_info, "memmove bogus src_offset %lu move "
+                      "len %lu len %lu", src_offset, len, dst->len);
                BUG_ON(1);
        }
        if (dst_offset + len > dst->len) {
-               printk(KERN_ERR "BTRFS: memmove bogus dst_offset %lu move "
-                      "len %lu len %lu\n", dst_offset, len, dst->len);
+               btrfs_err(dst->fs_info, "memmove bogus dst_offset %lu move "
+                      "len %lu len %lu", dst_offset, len, dst->len);
                BUG_ON(1);
        }
        if (dst_offset < src_offset) {
index 8e9105af723e7cb0cab4e452bf5eb88822b8e85b..2e520c635709a7500a0087eabbc3b31ddba78186 100644 (file)
@@ -1342,7 +1342,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
                        break;
 
                if (btrfs_defrag_cancelled(root->fs_info)) {
-                       printk(KERN_DEBUG "BTRFS: defrag_file cancelled\n");
+                       btrfs_debug(root->fs_info, "defrag_file cancelled");
                        ret = -EAGAIN;
                        break;
                }
@@ -2081,7 +2081,7 @@ static noinline int search_ioctl(struct inode *inode,
                key.offset = (u64)-1;
                root = btrfs_read_fs_root_no_name(info, &key);
                if (IS_ERR(root)) {
-                       printk(KERN_ERR "BTRFS: could not find root %llu\n",
+                       btrfs_err(info, "could not find root %llu",
                               sk->tree_id);
                        btrfs_free_path(path);
                        return -ENOENT;
@@ -2221,7 +2221,7 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
        key.offset = (u64)-1;
        root = btrfs_read_fs_root_no_name(info, &key);
        if (IS_ERR(root)) {
-               printk(KERN_ERR "BTRFS: could not find root %llu\n", tree_id);
+               btrfs_err(info, "could not find root %llu", tree_id);
                ret = -ENOENT;
                goto out;
        }
index 360a728a639fec403893c6847e1f7859a47dff13..42267d37bb94375ba0cc15cd43260b1e1d8df9c3 100644 (file)
@@ -45,12 +45,13 @@ static void btrfs_read_root_item(struct extent_buffer *eb, int slot,
        if (!need_reset && btrfs_root_generation(item)
                != btrfs_root_generation_v2(item)) {
                if (btrfs_root_generation_v2(item) != 0) {
-                       printk(KERN_WARNING "BTRFS: mismatching "
+                       btrfs_warn(eb->fs_info,
+                                       "mismatching "
                                        "generation and generation_v2 "
                                        "found in root item. This root "
                                        "was probably mounted with an "
                                        "older kernel. Resetting all "
-                                       "new fields.\n");
+                                       "new fields.");
                }
                need_reset = 1;
        }
index aa72bfd28f7dcbd88c73452aafd2a3d9e7f42e00..4ea07c8cd6c25119631aff5bc9ad2e600be9b35e 100644 (file)
@@ -2562,7 +2562,7 @@ verbose_printk("btrfs: send_create_inode %llu\n", ino);
        } else if (S_ISSOCK(mode)) {
                cmd = BTRFS_SEND_C_MKSOCK;
        } else {
-               printk(KERN_WARNING "btrfs: unexpected inode type %o",
+               btrfs_warn(sctx->send_root->fs_info, "unexpected inode type %o",
                                (int)(mode & S_IFMT));
                ret = -ENOTSUPP;
                goto out;
index 4f80986dbf3cf1a039cb2117292e7f3a3cbc85b1..7ad310cc3efbe91e1c9c39d533f7502a4892a83e 100644 (file)
@@ -2352,7 +2352,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
                                                root->fs_info->fsid);
                if (kobject_rename(&root->fs_info->fs_devices->super_kobj,
                                                                fsid_buf))
-                       pr_warn("BTRFS: sysfs: failed to create fsid for sprout\n");
+                       btrfs_warn(root->fs_info,
+                               "sysfs: failed to create fsid for sprout");
        }
 
        root->fs_info->num_tolerated_disk_barrier_failures =