Skip to content

Commit 05135f5

Browse files
committed
btrfs: switch to common message helpers in open_ctree, adjust messages
Currently we lack the identification of the filesystem in most if not all mount messages, done via printk/pr_* functions. We can use the btrfs_* helpers in open_ctree, as the fs_info <-> sb link is established at the beginning of the function. The messages have been updated at the same time to be more consistent: * dropped sb->s_id, as it's not available via btrfs_* * added %d for return code where appropriate * wording changed * %Lx replaced by %llx Signed-off-by: David Sterba <[email protected]>
1 parent 2355ac8 commit 05135f5

File tree

1 file changed

+50
-52
lines changed

1 file changed

+50
-52
lines changed

fs/btrfs/disk-io.c

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,7 +2713,7 @@ int open_ctree(struct super_block *sb,
27132713
* Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k).
27142714
*/
27152715
if (btrfs_check_super_csum(bh->b_data)) {
2716-
printk(KERN_ERR "BTRFS: superblock checksum mismatch\n");
2716+
btrfs_err(fs_info, "superblock checksum mismatch");
27172717
err = -EINVAL;
27182718
brelse(bh);
27192719
goto fail_alloc;
@@ -2733,7 +2733,7 @@ int open_ctree(struct super_block *sb,
27332733

27342734
ret = btrfs_check_super_valid(fs_info, sb->s_flags & MS_RDONLY);
27352735
if (ret) {
2736-
printk(KERN_ERR "BTRFS: superblock contains fatal errors\n");
2736+
btrfs_err(fs_info, "superblock contains fatal errors");
27372737
err = -EINVAL;
27382738
goto fail_alloc;
27392739
}
@@ -2768,9 +2768,9 @@ int open_ctree(struct super_block *sb,
27682768
features = btrfs_super_incompat_flags(disk_super) &
27692769
~BTRFS_FEATURE_INCOMPAT_SUPP;
27702770
if (features) {
2771-
printk(KERN_ERR "BTRFS: couldn't mount because of "
2772-
"unsupported optional features (%Lx).\n",
2773-
features);
2771+
btrfs_err(fs_info,
2772+
"cannot mount because of unsupported optional features (%llx)",
2773+
features);
27742774
err = -EINVAL;
27752775
goto fail_alloc;
27762776
}
@@ -2781,15 +2781,16 @@ int open_ctree(struct super_block *sb,
27812781
features |= BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO;
27822782

27832783
if (features & BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)
2784-
printk(KERN_INFO "BTRFS: has skinny extents\n");
2784+
btrfs_info(fs_info, "has skinny extents");
27852785

27862786
/*
27872787
* flag our filesystem as having big metadata blocks if
27882788
* they are bigger than the page size
27892789
*/
27902790
if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) {
27912791
if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA))
2792-
printk(KERN_INFO "BTRFS: flagging fs with big metadata feature\n");
2792+
btrfs_info(fs_info,
2793+
"flagging fs with big metadata feature");
27932794
features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA;
27942795
}
27952796

@@ -2805,9 +2806,9 @@ int open_ctree(struct super_block *sb,
28052806
*/
28062807
if ((features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS) &&
28072808
(sectorsize != nodesize)) {
2808-
printk(KERN_ERR "BTRFS: unequal leaf/node/sector sizes "
2809-
"are not allowed for mixed block groups on %s\n",
2810-
sb->s_id);
2809+
btrfs_err(fs_info,
2810+
"unequal nodesize/sectorsize (%u != %u) are not allowed for mixed block groups",
2811+
nodesize, sectorsize);
28112812
goto fail_alloc;
28122813
}
28132814

@@ -2820,8 +2821,8 @@ int open_ctree(struct super_block *sb,
28202821
features = btrfs_super_compat_ro_flags(disk_super) &
28212822
~BTRFS_FEATURE_COMPAT_RO_SUPP;
28222823
if (!(sb->s_flags & MS_RDONLY) && features) {
2823-
printk(KERN_ERR "BTRFS: couldn't mount RDWR because of "
2824-
"unsupported option features (%Lx).\n",
2824+
btrfs_err(fs_info,
2825+
"cannot mount read-write because of unsupported optional features (%llx)",
28252826
features);
28262827
err = -EINVAL;
28272828
goto fail_alloc;
@@ -2850,8 +2851,7 @@ int open_ctree(struct super_block *sb,
28502851
ret = btrfs_read_sys_array(tree_root);
28512852
mutex_unlock(&fs_info->chunk_mutex);
28522853
if (ret) {
2853-
printk(KERN_ERR "BTRFS: failed to read the system "
2854-
"array on %s\n", sb->s_id);
2854+
btrfs_err(fs_info, "failed to read the system array: %d", ret);
28552855
goto fail_sb_buffer;
28562856
}
28572857

@@ -2865,8 +2865,7 @@ int open_ctree(struct super_block *sb,
28652865
generation);
28662866
if (IS_ERR(chunk_root->node) ||
28672867
!extent_buffer_uptodate(chunk_root->node)) {
2868-
printk(KERN_ERR "BTRFS: failed to read chunk root on %s\n",
2869-
sb->s_id);
2868+
btrfs_err(fs_info, "failed to read chunk root");
28702869
if (!IS_ERR(chunk_root->node))
28712870
free_extent_buffer(chunk_root->node);
28722871
chunk_root->node = NULL;
@@ -2880,8 +2879,7 @@ int open_ctree(struct super_block *sb,
28802879

28812880
ret = btrfs_read_chunk_tree(chunk_root);
28822881
if (ret) {
2883-
printk(KERN_ERR "BTRFS: failed to read chunk tree on %s\n",
2884-
sb->s_id);
2882+
btrfs_err(fs_info, "failed to read chunk tree: %d", ret);
28852883
goto fail_tree_roots;
28862884
}
28872885

@@ -2892,8 +2890,7 @@ int open_ctree(struct super_block *sb,
28922890
btrfs_close_extra_devices(fs_devices, 0);
28932891

28942892
if (!fs_devices->latest_bdev) {
2895-
printk(KERN_ERR "BTRFS: failed to read devices on %s\n",
2896-
sb->s_id);
2893+
btrfs_err(fs_info, "failed to read devices");
28972894
goto fail_tree_roots;
28982895
}
28992896

@@ -2905,8 +2902,7 @@ int open_ctree(struct super_block *sb,
29052902
generation);
29062903
if (IS_ERR(tree_root->node) ||
29072904
!extent_buffer_uptodate(tree_root->node)) {
2908-
printk(KERN_WARNING "BTRFS: failed to read tree root on %s\n",
2909-
sb->s_id);
2905+
btrfs_warn(fs_info, "failed to read tree root");
29102906
if (!IS_ERR(tree_root->node))
29112907
free_extent_buffer(tree_root->node);
29122908
tree_root->node = NULL;
@@ -2938,60 +2934,62 @@ int open_ctree(struct super_block *sb,
29382934

29392935
ret = btrfs_recover_balance(fs_info);
29402936
if (ret) {
2941-
printk(KERN_ERR "BTRFS: failed to recover balance\n");
2937+
btrfs_err(fs_info, "failed to recover balance: %d", ret);
29422938
goto fail_block_groups;
29432939
}
29442940

29452941
ret = btrfs_init_dev_stats(fs_info);
29462942
if (ret) {
2947-
printk(KERN_ERR "BTRFS: failed to init dev_stats: %d\n",
2948-
ret);
2943+
btrfs_err(fs_info, "failed to init dev_stats: %d", ret);
29492944
goto fail_block_groups;
29502945
}
29512946

29522947
ret = btrfs_init_dev_replace(fs_info);
29532948
if (ret) {
2954-
pr_err("BTRFS: failed to init dev_replace: %d\n", ret);
2949+
btrfs_err(fs_info, "failed to init dev_replace: %d", ret);
29552950
goto fail_block_groups;
29562951
}
29572952

29582953
btrfs_close_extra_devices(fs_devices, 1);
29592954

29602955
ret = btrfs_sysfs_add_fsid(fs_devices, NULL);
29612956
if (ret) {
2962-
pr_err("BTRFS: failed to init sysfs fsid interface: %d\n", ret);
2957+
btrfs_err(fs_info, "failed to init sysfs fsid interface: %d",
2958+
ret);
29632959
goto fail_block_groups;
29642960
}
29652961

29662962
ret = btrfs_sysfs_add_device(fs_devices);
29672963
if (ret) {
2968-
pr_err("BTRFS: failed to init sysfs device interface: %d\n", ret);
2964+
btrfs_err(fs_info, "failed to init sysfs device interface: %d",
2965+
ret);
29692966
goto fail_fsdev_sysfs;
29702967
}
29712968

29722969
ret = btrfs_sysfs_add_mounted(fs_info);
29732970
if (ret) {
2974-
pr_err("BTRFS: failed to init sysfs interface: %d\n", ret);
2971+
btrfs_err(fs_info, "failed to init sysfs interface: %d", ret);
29752972
goto fail_fsdev_sysfs;
29762973
}
29772974

29782975
ret = btrfs_init_space_info(fs_info);
29792976
if (ret) {
2980-
printk(KERN_ERR "BTRFS: Failed to initial space info: %d\n", ret);
2977+
btrfs_err(fs_info, "failed to initialize space info: %d", ret);
29812978
goto fail_sysfs;
29822979
}
29832980

29842981
ret = btrfs_read_block_groups(fs_info->extent_root);
29852982
if (ret) {
2986-
printk(KERN_ERR "BTRFS: Failed to read block groups: %d\n", ret);
2983+
btrfs_err(fs_info, "failed to read block groups: %d", ret);
29872984
goto fail_sysfs;
29882985
}
29892986
fs_info->num_tolerated_disk_barrier_failures =
29902987
btrfs_calc_num_tolerated_disk_barrier_failures(fs_info);
29912988
if (fs_info->fs_devices->missing_devices >
29922989
fs_info->num_tolerated_disk_barrier_failures &&
29932990
!(sb->s_flags & MS_RDONLY)) {
2994-
pr_warn("BTRFS: missing devices(%llu) exceeds the limit(%d), writeable mount is not allowed\n",
2991+
btrfs_warn(fs_info,
2992+
"missing devices (%llu) exceeds the limit (%d), writeable mount is not allowed",
29952993
fs_info->fs_devices->missing_devices,
29962994
fs_info->num_tolerated_disk_barrier_failures);
29972995
goto fail_sysfs;
@@ -3011,8 +3009,7 @@ int open_ctree(struct super_block *sb,
30113009
if (!btrfs_test_opt(tree_root, SSD) &&
30123010
!btrfs_test_opt(tree_root, NOSSD) &&
30133011
!fs_info->fs_devices->rotating) {
3014-
printk(KERN_INFO "BTRFS: detected SSD devices, enabling SSD "
3015-
"mode\n");
3012+
btrfs_info(fs_info, "detected SSD devices, enabling SSD mode");
30163013
btrfs_set_opt(fs_info->mount_opt, SSD);
30173014
}
30183015

@@ -3030,8 +3027,9 @@ int open_ctree(struct super_block *sb,
30303027
1 : 0,
30313028
fs_info->check_integrity_print_mask);
30323029
if (ret)
3033-
printk(KERN_WARNING "BTRFS: failed to initialize"
3034-
" integrity check module %s\n", sb->s_id);
3030+
btrfs_warn(fs_info,
3031+
"failed to initialize integrity check module: %d",
3032+
ret);
30353033
}
30363034
#endif
30373035
ret = btrfs_read_qgroup_config(fs_info);
@@ -3061,8 +3059,8 @@ int open_ctree(struct super_block *sb,
30613059
ret = btrfs_recover_relocation(tree_root);
30623060
mutex_unlock(&fs_info->cleaner_mutex);
30633061
if (ret < 0) {
3064-
printk(KERN_WARNING
3065-
"BTRFS: failed to recover relocation\n");
3062+
btrfs_warn(fs_info, "failed to recover relocation: %d",
3063+
ret);
30663064
err = -EINVAL;
30673065
goto fail_qgroup;
30683066
}
@@ -3083,11 +3081,11 @@ int open_ctree(struct super_block *sb,
30833081

30843082
if (btrfs_test_opt(tree_root, FREE_SPACE_TREE) &&
30853083
!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) {
3086-
pr_info("BTRFS: creating free space tree\n");
3084+
btrfs_info(fs_info, "creating free space tree");
30873085
ret = btrfs_create_free_space_tree(fs_info);
30883086
if (ret) {
3089-
pr_warn("BTRFS: failed to create free space tree %d\n",
3090-
ret);
3087+
btrfs_warn(fs_info,
3088+
"failed to create free space tree: %d", ret);
30913089
close_ctree(tree_root);
30923090
return ret;
30933091
}
@@ -3104,14 +3102,14 @@ int open_ctree(struct super_block *sb,
31043102

31053103
ret = btrfs_resume_balance_async(fs_info);
31063104
if (ret) {
3107-
printk(KERN_WARNING "BTRFS: failed to resume balance\n");
3105+
btrfs_warn(fs_info, "failed to resume balance: %d", ret);
31083106
close_ctree(tree_root);
31093107
return ret;
31103108
}
31113109

31123110
ret = btrfs_resume_dev_replace_async(fs_info);
31133111
if (ret) {
3114-
pr_warn("BTRFS: failed to resume dev_replace\n");
3112+
btrfs_warn(fs_info, "failed to resume device replace: %d", ret);
31153113
close_ctree(tree_root);
31163114
return ret;
31173115
}
@@ -3120,33 +3118,33 @@ int open_ctree(struct super_block *sb,
31203118

31213119
if (btrfs_test_opt(tree_root, CLEAR_CACHE) &&
31223120
btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) {
3123-
pr_info("BTRFS: clearing free space tree\n");
3121+
btrfs_info(fs_info, "clearing free space tree");
31243122
ret = btrfs_clear_free_space_tree(fs_info);
31253123
if (ret) {
3126-
pr_warn("BTRFS: failed to clear free space tree %d\n",
3127-
ret);
3124+
btrfs_warn(fs_info,
3125+
"failed to clear free space tree: %d", ret);
31283126
close_ctree(tree_root);
31293127
return ret;
31303128
}
31313129
}
31323130

31333131
if (!fs_info->uuid_root) {
3134-
pr_info("BTRFS: creating UUID tree\n");
3132+
btrfs_info(fs_info, "creating UUID tree");
31353133
ret = btrfs_create_uuid_tree(fs_info);
31363134
if (ret) {
3137-
pr_warn("BTRFS: failed to create the UUID tree %d\n",
3138-
ret);
3135+
btrfs_warn(fs_info,
3136+
"failed to create the UUID tree: %d", ret);
31393137
close_ctree(tree_root);
31403138
return ret;
31413139
}
31423140
} else if (btrfs_test_opt(tree_root, RESCAN_UUID_TREE) ||
31433141
fs_info->generation !=
31443142
btrfs_super_uuid_tree_generation(disk_super)) {
3145-
pr_info("BTRFS: checking UUID tree\n");
3143+
btrfs_info(fs_info, "checking UUID tree");
31463144
ret = btrfs_check_uuid_tree(fs_info);
31473145
if (ret) {
3148-
pr_warn("BTRFS: failed to check the UUID tree %d\n",
3149-
ret);
3146+
btrfs_warn(fs_info,
3147+
"failed to check the UUID tree: %d", ret);
31503148
close_ctree(tree_root);
31513149
return ret;
31523150
}

0 commit comments

Comments
 (0)