* [PATCH v2] btrfs: normalize the error handling branch in btrfs_init_sysfs()
@ 2022-11-22 11:50 Zhen Lei
2022-11-22 11:59 ` Qu Wenruo
2022-11-22 15:25 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Zhen Lei @ 2022-11-22 11:50 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, linux-kernel
Cc: Zhen Lei, Qu Wenruo
Although kset_unregister() can eventually remove all attribute files,
explicitly rolling back with the matching function makes the code logic
look clearer.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
fs/btrfs/sysfs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
v1 --> v2:
1. Add sysfs_unmerge_group() to unmerge group first.
2. Update subject and commit message, no resource leaks.
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 699b54b3acaae0b..74fef1f49c358cd 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -2321,8 +2321,11 @@ int __init btrfs_init_sysfs(void)
#ifdef CONFIG_BTRFS_DEBUG
ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_debug_feature_attr_group);
- if (ret)
- goto out2;
+ if (ret) {
+ sysfs_unmerge_group(&btrfs_kset->kobj,
+ &btrfs_static_feature_attr_group);
+ goto out_remove_group;
+ }
#endif
return 0;
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] btrfs: normalize the error handling branch in btrfs_init_sysfs()
2022-11-22 11:50 [PATCH v2] btrfs: normalize the error handling branch in btrfs_init_sysfs() Zhen Lei
@ 2022-11-22 11:59 ` Qu Wenruo
2022-11-22 15:25 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2022-11-22 11:59 UTC (permalink / raw)
To: Zhen Lei, Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
linux-kernel
On 2022/11/22 19:50, Zhen Lei wrote:
> Although kset_unregister() can eventually remove all attribute files,
> explicitly rolling back with the matching function makes the code logic
> look clearer.
>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/sysfs.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> v1 --> v2:
> 1. Add sysfs_unmerge_group() to unmerge group first.
> 2. Update subject and commit message, no resource leaks.
>
> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
> index 699b54b3acaae0b..74fef1f49c358cd 100644
> --- a/fs/btrfs/sysfs.c
> +++ b/fs/btrfs/sysfs.c
> @@ -2321,8 +2321,11 @@ int __init btrfs_init_sysfs(void)
>
> #ifdef CONFIG_BTRFS_DEBUG
> ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_debug_feature_attr_group);
> - if (ret)
> - goto out2;
> + if (ret) {
> + sysfs_unmerge_group(&btrfs_kset->kobj,
> + &btrfs_static_feature_attr_group);
> + goto out_remove_group;
> + }
> #endif
>
> return 0;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] btrfs: normalize the error handling branch in btrfs_init_sysfs()
2022-11-22 11:50 [PATCH v2] btrfs: normalize the error handling branch in btrfs_init_sysfs() Zhen Lei
2022-11-22 11:59 ` Qu Wenruo
@ 2022-11-22 15:25 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2022-11-22 15:25 UTC (permalink / raw)
To: Zhen Lei
Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
linux-kernel, Qu Wenruo
On Tue, Nov 22, 2022 at 07:50:02PM +0800, Zhen Lei wrote:
> Although kset_unregister() can eventually remove all attribute files,
> explicitly rolling back with the matching function makes the code logic
> look clearer.
>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-22 15:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 11:50 [PATCH v2] btrfs: normalize the error handling branch in btrfs_init_sysfs() Zhen Lei
2022-11-22 11:59 ` Qu Wenruo
2022-11-22 15:25 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®