Skip to contentSkip to conversation

ext4/super.c : Fix a goto label

PATCH In review Haibo Liu 3 participants 4 messages Aug 28, 2023 – Jan 2, 2024 ext4 file system

lore
Share & tools
lore

Haibo Liu

author
#0 lore raw

There are 9 goto labels in ext4_init_fs: out,out05,out1,out2,out3,out4,out5,out6,out7. So I feel that replacing out5 with out0 may be better.

---
 fs/ext4/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/super.c +2 -2
index 03373471131c..115bbbd95a7b 100644
@@ -6696,7 +6696,7 @@ static int __init ext4_init_fs(void)
 
 	err = ext4_fc_init_dentry_cache();
 	if (err)
-		goto out05;
+		goto out0;
 
 	register_as_ext3();
 	register_as_ext2();
@@ -6708,7 +6708,7 @@ static int __init ext4_init_fs(void)
 out:
 	unregister_as_ext2();
 	unregister_as_ext3();
-out05:
+out0:
 	destroy_inodecache();
 out1:
 	ext4_exit_mballoc();
Signature · 1 line
2.34.1
#1 lore raw
Quoted 1 line · Haibo Liu

There are 9 goto labels in ext4_init_fs: out,out05,out1,out2,out3,out4,out5,out6,out7. So I feel that replacing out5 with out0 may be better.

...then why not replace them all with descriptions of what gets released under each label?

	ret = init_inodecache();
	if (ret)
		goto out_unregister_mballoc;
	ret = init_somethingelse();
	if (ret)
		goto out_inodecache;

out_unregister_ext23:

	unregister_as_ext2();
	unregister_as_ext3();
out_inodecache:
	destroy_inodecache();
out_mballoc:
	ext4_exit_mballoc();

Is much more easier to understand than out[0...N], yes?

--D

Quoted 30 lines
---
 fs/ext4/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/super.c +2 -2
index 03373471131c..115bbbd95a7b 100644
@@ -6696,7 +6696,7 @@ static int __init ext4_init_fs(void)
 
 	err = ext4_fc_init_dentry_cache();
 	if (err)
-		goto out05;
+		goto out0;
 
 	register_as_ext3();
 	register_as_ext2();
@@ -6708,7 +6708,7 @@ static int __init ext4_init_fs(void)
 out:
 	unregister_as_ext2();
 	unregister_as_ext3();
-out05:
+out0:
 	destroy_inodecache();
 out1:
 	ext4_exit_mballoc();
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v2 1/1 ext4/super.c : Fix a goto label

In reply to Haibo Liu

Thank you for Darrick J. Wong's suggestions :).
I wrote a new patch and renamed these 9 labels.

Original labels -> New labels:

out -> out_unregister_ext23_and_dentry_cache
out05 -> out_inodecache
out1 -> out_mballoc
out2 -> out_sysfs
out3 -> out_system_zone
out4 -> out_pageio
out5 -> out_post_read_processing
out6 -> out_pending
out7 -> out_es

v1->v2:
Followed Darrick J. Wong's suggestions, renamed these 9 goto labels.

---
 fs/ext4/super.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
fs/ext4/super.c +18 -18
index 91f20afa1d71..11cffb5a05a4 100644
@@ -7347,61 +7347,61 @@ static int __init ext4_init_fs(void)
 
 	err = ext4_init_pending();
 	if (err)
-		goto out7;
+		goto out_es;
 
 	err = ext4_init_post_read_processing();
 	if (err)
-		goto out6;
+		goto out_pending;
 
 	err = ext4_init_pageio();
 	if (err)
-		goto out5;
+		goto out_post_read_processing;
 
 	err = ext4_init_system_zone();
 	if (err)
-		goto out4;
+		goto out_pageio;
 
 	err = ext4_init_sysfs();
 	if (err)
-		goto out3;
+		goto out_system_zone;
 
 	err = ext4_init_mballoc();
 	if (err)
-		goto out2;
+		goto out_sysfs;
 	err = init_inodecache();
 	if (err)
-		goto out1;
+		goto out_mballoc;
 
 	err = ext4_fc_init_dentry_cache();
 	if (err)
-		goto out05;
+		goto out_inodecache;
 
 	register_as_ext3();
 	register_as_ext2();
 	err = register_filesystem(&ext4_fs_type);
 	if (err)
-		goto out;
+		goto out_unregister_ext23_and_dentry_cache;
 
 	return 0;
-out:
+out_unregister_ext23_and_dentry_cache:
 	unregister_as_ext2();
 	unregister_as_ext3();
 	ext4_fc_destroy_dentry_cache();
-out05:
+out_inodecache:
 	destroy_inodecache();
-out1:
+out_mballoc:
 	ext4_exit_mballoc();
-out2:
+out_sysfs:
 	ext4_exit_sysfs();
-out3:
+out_system_zone:
 	ext4_exit_system_zone();
-out4:
+out_pageio:
 	ext4_exit_pageio();
-out5:
+out_post_read_processing:
 	ext4_exit_post_read_processing();
-out6:
+out_pending:
 	ext4_exit_pending();
-out7:
+out_es:
 	ext4_exit_es();
 
 	return err;
Signature · 1 line
2.34.1
reviewer Reviewed-by on v2 1/1
#3 lore raw

This seems to have fallen through the cracks. CCing ext4 maintainer (which is a good idea with any patch BTW)...

Quoted 5 lines · Haibo Liu

Thank you for Darrick J. Wong's suggestions :).
I wrote a new patch and renamed these 9 labels.

Original labels -> New labels:

Quoted 9 lines

out -> out_unregister_ext23_and_dentry_cache
out05 -> out_inodecache
out1 -> out_mballoc
out2 -> out_sysfs
out3 -> out_system_zone
out4 -> out_pageio
out5 -> out_post_read_processing
out6 -> out_pending
out7 -> out_es

I agree this is more standard and probably more future proof.

Quoted 2 lines

v1->v2:
Followed Darrick J. Wong's suggestions, renamed these 9 goto labels.

This versioning belongs below the --- line (probably below diffstat).

Quoted 1 line

Otherwise looks good so feel free to add:

Honza

Quoted 91 lines
---
 fs/ext4/super.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
fs/ext4/super.c +18 -18
index 91f20afa1d71..11cffb5a05a4 100644
@@ -7347,61 +7347,61 @@ static int __init ext4_init_fs(void)
 
 	err = ext4_init_pending();
 	if (err)
-		goto out7;
+		goto out_es;
 
 	err = ext4_init_post_read_processing();
 	if (err)
-		goto out6;
+		goto out_pending;
 
 	err = ext4_init_pageio();
 	if (err)
-		goto out5;
+		goto out_post_read_processing;
 
 	err = ext4_init_system_zone();
 	if (err)
-		goto out4;
+		goto out_pageio;
 
 	err = ext4_init_sysfs();
 	if (err)
-		goto out3;
+		goto out_system_zone;
 
 	err = ext4_init_mballoc();
 	if (err)
-		goto out2;
+		goto out_sysfs;
 	err = init_inodecache();
 	if (err)
-		goto out1;
+		goto out_mballoc;
 
 	err = ext4_fc_init_dentry_cache();
 	if (err)
-		goto out05;
+		goto out_inodecache;
 
 	register_as_ext3();
 	register_as_ext2();
 	err = register_filesystem(&ext4_fs_type);
 	if (err)
-		goto out;
+		goto out_unregister_ext23_and_dentry_cache;
 
 	return 0;
-out:
+out_unregister_ext23_and_dentry_cache:
 	unregister_as_ext2();
 	unregister_as_ext3();
 	ext4_fc_destroy_dentry_cache();
-out05:
+out_inodecache:
 	destroy_inodecache();
-out1:
+out_mballoc:
 	ext4_exit_mballoc();
-out2:
+out_sysfs:
 	ext4_exit_sysfs();
-out3:
+out_system_zone:
 	ext4_exit_system_zone();
-out4:
+out_pageio:
 	ext4_exit_pageio();
-out5:
+out_post_read_processing:
 	ext4_exit_post_read_processing();
-out6:
+out_pending:
 	ext4_exit_pending();
-out7:
+out_es:
 	ext4_exit_es();
 
 	return err;
Signature · 1 line
2.34.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR