* [PATCH] zonefs: remove unnecessary kobject_del() @ 2023-04-12 3:19 Yangtao Li 2023-04-12 8:04 ` Damien Le Moal 0 siblings, 1 reply; 4+ messages in thread From: Yangtao Li @ 2023-04-12 3:19 UTC (permalink / raw) To: Damien Le Moal, Naohiro Aota, Johannes Thumshirn Cc: Yangtao Li, linux-fsdevel, linux-kernel kobject_put() actually covers kobject removal automatically, which is single stage removal. So kill kobject_del() directly. Signed-off-by: Yangtao Li <frank.li@vivo.com> --- fs/zonefs/sysfs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/zonefs/sysfs.c b/fs/zonefs/sysfs.c index 8ccb65c2b419..a535bdea1097 100644 --- a/fs/zonefs/sysfs.c +++ b/fs/zonefs/sysfs.c @@ -113,7 +113,6 @@ void zonefs_sysfs_unregister(struct super_block *sb) if (!sbi || !sbi->s_sysfs_registered) return; - kobject_del(&sbi->s_kobj); kobject_put(&sbi->s_kobj); wait_for_completion(&sbi->s_kobj_unregister); } -- 2.35.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] zonefs: remove unnecessary kobject_del() 2023-04-12 3:19 [PATCH] zonefs: remove unnecessary kobject_del() Yangtao Li @ 2023-04-12 8:04 ` Damien Le Moal 2023-04-12 8:11 ` Greg KH 0 siblings, 1 reply; 4+ messages in thread From: Damien Le Moal @ 2023-04-12 8:04 UTC (permalink / raw) To: Yangtao Li, Naohiro Aota, Johannes Thumshirn, Greg KH Cc: linux-fsdevel, linux-kernel On 4/12/23 12:19, Yangtao Li wrote: > kobject_put() actually covers kobject removal automatically, which is > single stage removal. So kill kobject_del() directly. > > Signed-off-by: Yangtao Li <frank.li@vivo.com> > --- > fs/zonefs/sysfs.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/fs/zonefs/sysfs.c b/fs/zonefs/sysfs.c > index 8ccb65c2b419..a535bdea1097 100644 > --- a/fs/zonefs/sysfs.c > +++ b/fs/zonefs/sysfs.c > @@ -113,7 +113,6 @@ void zonefs_sysfs_unregister(struct super_block *sb) > if (!sbi || !sbi->s_sysfs_registered) > return; > > - kobject_del(&sbi->s_kobj); > kobject_put(&sbi->s_kobj); > wait_for_completion(&sbi->s_kobj_unregister); > } What I am not sure about here is that if CONFIG_DEBUG_KOBJECT_RELEASE is enabled, the kobj release is delayed, so the kobject will stay in sysfs potentially after the umount() returns. Not exactly nice as that potentially create races in user space... Not 100% sure though. Greg ? Any thoughts on this ? ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] zonefs: remove unnecessary kobject_del() 2023-04-12 8:04 ` Damien Le Moal @ 2023-04-12 8:11 ` Greg KH 2023-04-12 8:18 ` Damien Le Moal 0 siblings, 1 reply; 4+ messages in thread From: Greg KH @ 2023-04-12 8:11 UTC (permalink / raw) To: Damien Le Moal Cc: Yangtao Li, Naohiro Aota, Johannes Thumshirn, linux-fsdevel, linux-kernel On Wed, Apr 12, 2023 at 05:04:16PM +0900, Damien Le Moal wrote: > On 4/12/23 12:19, Yangtao Li wrote: > > kobject_put() actually covers kobject removal automatically, which is > > single stage removal. So kill kobject_del() directly. > > > > Signed-off-by: Yangtao Li <frank.li@vivo.com> > > --- > > fs/zonefs/sysfs.c | 1 - > > 1 file changed, 1 deletion(-) > > > > diff --git a/fs/zonefs/sysfs.c b/fs/zonefs/sysfs.c > > index 8ccb65c2b419..a535bdea1097 100644 > > --- a/fs/zonefs/sysfs.c > > +++ b/fs/zonefs/sysfs.c > > @@ -113,7 +113,6 @@ void zonefs_sysfs_unregister(struct super_block *sb) > > if (!sbi || !sbi->s_sysfs_registered) > > return; > > > > - kobject_del(&sbi->s_kobj); > > kobject_put(&sbi->s_kobj); > > wait_for_completion(&sbi->s_kobj_unregister); > > } > > What I am not sure about here is that if CONFIG_DEBUG_KOBJECT_RELEASE is > enabled, the kobj release is delayed, so the kobject will stay in sysfs > potentially after the umount() returns. Not exactly nice as that potentially > create races in user space... Not 100% sure though. > > Greg ? Any thoughts on this ? Yes, it's all a mess :( See the other messatges in this thread: https://lore.kernel.org/r/20230406120716.80980-1-frank.li@vivo.com Please don't take this patch for now, this all needs to be revisited. We have two reference counted objects with different lifespans trying to be embedded in the same structure, causing a mess. But, if we split them apart, that too has issues. I've been thinking about how to resolve this, but don't have any solid ideas yet, and been swamped with other things... For now, let's just leave this all alone, it's not unique to this one filesystem, they all have the same pattern, and we need to solve them all properly at the same time by moving the common code into the driver core so that filesystems don't have to worry about this mess. thanks, greg k-h ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] zonefs: remove unnecessary kobject_del() 2023-04-12 8:11 ` Greg KH @ 2023-04-12 8:18 ` Damien Le Moal 0 siblings, 0 replies; 4+ messages in thread From: Damien Le Moal @ 2023-04-12 8:18 UTC (permalink / raw) To: Greg KH Cc: Yangtao Li, Naohiro Aota, Johannes Thumshirn, linux-fsdevel, linux-kernel On 4/12/23 17:11, Greg KH wrote: > On Wed, Apr 12, 2023 at 05:04:16PM +0900, Damien Le Moal wrote: >> On 4/12/23 12:19, Yangtao Li wrote: >>> kobject_put() actually covers kobject removal automatically, which is >>> single stage removal. So kill kobject_del() directly. >>> >>> Signed-off-by: Yangtao Li <frank.li@vivo.com> >>> --- >>> fs/zonefs/sysfs.c | 1 - >>> 1 file changed, 1 deletion(-) >>> >>> diff --git a/fs/zonefs/sysfs.c b/fs/zonefs/sysfs.c >>> index 8ccb65c2b419..a535bdea1097 100644 >>> --- a/fs/zonefs/sysfs.c >>> +++ b/fs/zonefs/sysfs.c >>> @@ -113,7 +113,6 @@ void zonefs_sysfs_unregister(struct super_block *sb) >>> if (!sbi || !sbi->s_sysfs_registered) >>> return; >>> >>> - kobject_del(&sbi->s_kobj); >>> kobject_put(&sbi->s_kobj); >>> wait_for_completion(&sbi->s_kobj_unregister); >>> } >> >> What I am not sure about here is that if CONFIG_DEBUG_KOBJECT_RELEASE is >> enabled, the kobj release is delayed, so the kobject will stay in sysfs >> potentially after the umount() returns. Not exactly nice as that potentially >> create races in user space... Not 100% sure though. >> >> Greg ? Any thoughts on this ? > > Yes, it's all a mess :( > > See the other messatges in this thread: > https://lore.kernel.org/r/20230406120716.80980-1-frank.li@vivo.com > > Please don't take this patch for now, this all needs to be revisited. > > We have two reference counted objects with different lifespans trying to > be embedded in the same structure, causing a mess. > > But, if we split them apart, that too has issues. I've been thinking > about how to resolve this, but don't have any solid ideas yet, and been > swamped with other things... > > For now, let's just leave this all alone, it's not unique to this one > filesystem, they all have the same pattern, and we need to solve them > all properly at the same time by moving the common code into the driver > core so that filesystems don't have to worry about this mess. That was my thinking. Will try to think about a solution as well. Likely, some helpers for FSes sysfs attributes somewhere in fs/*.c are needed to not use the kobj directly as part of the fs_info structs. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-12 8:18 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-04-12 3:19 [PATCH] zonefs: remove unnecessary kobject_del() Yangtao Li 2023-04-12 8:04 ` Damien Le Moal 2023-04-12 8:11 ` Greg KH 2023-04-12 8:18 ` Damien Le Moal
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).