]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: use our message helpers instead of pr_err/pr_warn/pr_info
authorDavid Sterba <dsterba@suse.com>
Fri, 20 Jun 2025 16:06:45 +0000 (18:06 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:58:04 +0000 (23:58 +0200)
Our message helpers accept NULL for the fs_info in the context that does
not provide and print the common header of the message. The use of pr_*
helpers is only for special reasons, like module loading, device
scanning or multi-line output (print-tree).

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c
fs/btrfs/disk-io.c
fs/btrfs/extent-io-tree.c
fs/btrfs/extent_io.c
fs/btrfs/print-tree.c
fs/btrfs/sysfs.c
fs/btrfs/volumes.c
fs/btrfs/zstd.c

index 48d07939fee4a0dd3a2e824ecd6ad0913cc0018d..a4934eb1ecdc99382e420a3fd2e1316b1f630d7d 100644 (file)
@@ -789,8 +789,8 @@ static void btrfs_init_workspace_manager(int type)
         */
        workspace = alloc_workspace(type, 0);
        if (IS_ERR(workspace)) {
-               pr_warn(
-       "BTRFS: cannot preallocate compression workspace, will try later\n");
+               btrfs_warn(NULL,
+                          "cannot preallocate compression workspace, will try later");
        } else {
                atomic_set(&wsm->total_ws, 1);
                wsm->free_ws = 1;
@@ -888,9 +888,9 @@ again:
                                        /* once per minute */ 60 * HZ,
                                        /* no burst */ 1);
 
-                       if (__ratelimit(&_rs)) {
-                               pr_warn("BTRFS: no compression workspaces, low memory, retrying\n");
-                       }
+                       if (__ratelimit(&_rs))
+                               btrfs_warn(NULL,
+                               "no compression workspaces, low memory, retrying");
                }
                goto again;
        }
index ee3cdd7035cc237f2ff832c7329e16f5c7e38519..6ac5be02dce7581d1e302b8576c6c8d074c91df8 100644 (file)
@@ -3993,7 +3993,7 @@ int btrfs_get_num_tolerated_disk_barrier_failures(u64 flags)
        }
 
        if (min_tolerated == INT_MAX) {
-               pr_warn("BTRFS: unknown raid flag: %llu", flags);
+               btrfs_warn(NULL, "unknown raid flag: %llu", flags);
                min_tolerated = 0;
        }
 
index 84da01996336c1eb53e947c728848053f78aa97b..66361325f6dceaf65f185218ab74b7960c297c1c 100644 (file)
@@ -43,7 +43,8 @@ static inline void btrfs_extent_state_leak_debug_check(void)
 
        while (!list_empty(&states)) {
                state = list_first_entry(&states, struct extent_state, leak_list);
-               pr_err("BTRFS: state leak: start %llu end %llu state %u in tree %d refs %d\n",
+               btrfs_err(NULL,
+                      "state leak: start %llu end %llu state %u in tree %d refs %d",
                       state->start, state->end, state->state,
                       extent_state_in_tree(state),
                       refcount_read(&state->refs));
index 1a56fb258204dc9f80a390b995762456800667f6..7c171e236fe9cb464a742801e9edbf665036f15c 100644 (file)
@@ -75,8 +75,8 @@ void btrfs_extent_buffer_leak_debug_check(struct btrfs_fs_info *fs_info)
        while (!list_empty(&fs_info->allocated_ebs)) {
                eb = list_first_entry(&fs_info->allocated_ebs,
                                      struct extent_buffer, leak_list);
-               pr_err(
-       "BTRFS: buffer leak start %llu len %u refs %d bflags %lu owner %llu\n",
+               btrfs_err(fs_info,
+                      "buffer leak start %llu len %u refs %d bflags %lu owner %llu",
                       eb->start, eb->len, refcount_read(&eb->refs), eb->bflags,
                       btrfs_header_owner(eb));
                list_del(&eb->leak_list);
index 21605b03f511889591ae88fb9d13724427678ba6..74e38da9bd39cd11aa67ebe75a81307eea7b66e3 100644 (file)
@@ -190,7 +190,7 @@ static void print_uuid_item(const struct extent_buffer *l, unsigned long offset,
                            u32 item_size)
 {
        if (!IS_ALIGNED(item_size, sizeof(u64))) {
-               pr_warn("BTRFS: uuid item with illegal size %lu!\n",
+               btrfs_warn(l->fs_info, "uuid item with illegal size %lu",
                        (unsigned long)item_size);
                return;
        }
index 6471fb53ca2af3ba34b71bbb9fc17dc7d3ee8d39..9d398f7a36addb5ea8974abdd48dbef44b2952cf 100644 (file)
@@ -160,8 +160,7 @@ static int can_modify_feature(struct btrfs_feature_attr *fa)
                clear = BTRFS_FEATURE_INCOMPAT_SAFE_CLEAR;
                break;
        default:
-               pr_warn("btrfs: sysfs: unknown feature set %d\n",
-                               fa->feature_set);
+               btrfs_warn(NULL, "sysfs: unknown feature set %d", fa->feature_set);
                return 0;
        }
 
@@ -2247,7 +2246,7 @@ void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action)
 
        ret = kobject_uevent(&disk_to_dev(bdev->bd_disk)->kobj, action);
        if (ret)
-               pr_warn("BTRFS: Sending event '%d' to kobject: '%s' (%p): failed\n",
+               btrfs_warn(NULL, "sending event %d to kobject: '%s' (%p): failed",
                        action, kobject_name(&disk_to_dev(bdev->bd_disk)->kobj),
                        &disk_to_dev(bdev->bd_disk)->kobj);
 }
index 29282f26336e2d6929812925a662d36c7eb5d0ba..c99aec904e161627ac10ebdcde21dfe0c58502bc 100644 (file)
@@ -675,8 +675,8 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
        if (btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_SEEDING) {
                if (btrfs_super_incompat_flags(disk_super) &
                    BTRFS_FEATURE_INCOMPAT_METADATA_UUID) {
-                       pr_err(
-               "BTRFS: Invalid seeding and uuid-changed device detected\n");
+                       btrfs_err(NULL,
+                                 "invalid seeding and uuid-changed device detected");
                        goto error_free_page;
                }
 
@@ -820,7 +820,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,
                if (same_fsid_diff_dev) {
                        generate_random_uuid(fs_devices->fsid);
                        fs_devices->temp_fsid = true;
-               pr_info("BTRFS: device %s (%d:%d) using temp-fsid %pU\n",
+                       btrfs_info(NULL, "device %s (%d:%d) using temp-fsid %pU",
                                path, MAJOR(path_devt), MINOR(path_devt),
                                fs_devices->fsid);
                }
@@ -1474,7 +1474,7 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags,
 
        devt = file_bdev(bdev_file)->bd_dev;
        if (btrfs_skip_registration(disk_super, path, devt, mount_arg_dev)) {
-               pr_debug("BTRFS: skip registering single non-seed device %s (%d:%d)\n",
+               btrfs_debug(NULL, "skip registering single non-seed device %s (%d:%d)",
                          path, MAJOR(devt), MINOR(devt));
 
                btrfs_free_stale_devices(devt, NULL);
index 4a796a049b5a2473bf8a65869fe452e4b4b5c35e..ff0292615e1f37a2396fd75710a93413af910316 100644 (file)
@@ -200,8 +200,7 @@ void zstd_init_workspace_manager(void)
 
        ws = zstd_alloc_workspace(ZSTD_BTRFS_MAX_LEVEL);
        if (IS_ERR(ws)) {
-               pr_warn(
-               "BTRFS: cannot preallocate zstd compression workspace\n");
+               btrfs_warn(NULL, "cannot preallocate zstd compression workspace");
        } else {
                set_bit(ZSTD_BTRFS_MAX_LEVEL - 1, &wsm.active_map);
                list_add(ws, &wsm.idle_ws[ZSTD_BTRFS_MAX_LEVEL - 1]);