mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yangtao Li <frank.li@vivo.com>
To: xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com,
	jefflexu@linux.alibaba.com, damien.lemoal@opensource.wdc.com,
	naohiro.aota@wdc.com, jth@kernel.org, gregkh@linuxfoundation.org,
	rafael@kernel.org
Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, Yangtao Li <frank.li@vivo.com>
Subject: [PATCH 3/3] zonefs: convert to use kobject_is_added()
Date: Thu,  6 Apr 2023 17:30:56 +0800	[thread overview]
Message-ID: <20230406093056.33916-3-frank.li@vivo.com> (raw)
In-Reply-To: <20230406093056.33916-1-frank.li@vivo.com>

Use kobject_is_added() instead of local `s_sysfs_registered` variables.
BTW kill kobject_del() directly, because kobject_put() actually covers
kobject removal automatically.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/zonefs/sysfs.c  | 11 +++++------
 fs/zonefs/zonefs.h |  1 -
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/zonefs/sysfs.c b/fs/zonefs/sysfs.c
index 8ccb65c2b419..f0783bf7a25c 100644
--- a/fs/zonefs/sysfs.c
+++ b/fs/zonefs/sysfs.c
@@ -101,8 +101,6 @@ int zonefs_sysfs_register(struct super_block *sb)
 		return ret;
 	}
 
-	sbi->s_sysfs_registered = true;
-
 	return 0;
 }
 
@@ -110,12 +108,13 @@ void zonefs_sysfs_unregister(struct super_block *sb)
 {
 	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
 
-	if (!sbi || !sbi->s_sysfs_registered)
+	if (!sbi)
 		return;
 
-	kobject_del(&sbi->s_kobj);
-	kobject_put(&sbi->s_kobj);
-	wait_for_completion(&sbi->s_kobj_unregister);
+	if (kobject_is_added(&sbi->s_kobj)) {
+		kobject_put(&sbi->s_kobj);
+		wait_for_completion(&sbi->s_kobj_unregister);
+	}
 }
 
 int __init zonefs_sysfs_init(void)
diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h
index 8175652241b5..4db0ea173220 100644
--- a/fs/zonefs/zonefs.h
+++ b/fs/zonefs/zonefs.h
@@ -238,7 +238,6 @@ struct zonefs_sb_info {
 	unsigned int		s_max_active_seq_files;
 	atomic_t		s_active_seq_files;
 
-	bool			s_sysfs_registered;
 	struct kobject		s_kobj;
 	struct completion	s_kobj_unregister;
 };
-- 
2.35.1


  parent reply	other threads:[~2023-04-06  9:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-06  9:30 [PATCH 1/3] kobject: introduce kobject_is_added() Yangtao Li
2023-04-06  9:30 ` [PATCH 2/3] erofs: convert to use kobject_is_added() Yangtao Li
2023-04-06 10:03   ` Greg KH
2023-04-06 10:13     ` Gao Xiang
2023-04-06 10:27       ` Greg KH
2023-04-06 10:55         ` Gao Xiang
2023-04-06 11:19           ` Greg KH
2023-04-06 12:07     ` Yangtao Li
2023-04-06 13:50       ` Yangtao Li
2023-04-06 14:31       ` Greg KH
2023-04-06 17:52         ` Yangtao Li
2023-04-07  6:09         ` Yangtao Li
2023-04-07  7:23         ` Yangtao Li
2023-04-06  9:30 ` Yangtao Li [this message]
2023-04-06 10:05   ` [PATCH 3/3] zonefs: " Greg KH
2023-04-06 10:13     ` Damien Le Moal
2023-04-06 10:26       ` Greg KH
2023-04-06 10:58         ` Damien Le Moal
2023-04-06 11:18           ` Greg KH
2023-04-06 11:23             ` Damien Le Moal
2023-04-06  9:59 ` [PATCH 1/3] kobject: introduce kobject_is_added() Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230406093056.33916-3-frank.li@vivo.com \
    --to=frank.li@vivo.com \
    --cc=chao@kernel.org \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=huyue2@coolpad.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=jth@kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=rafael@kernel.org \
    --cc=xiang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®