[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241003151435.3753959-4-aahringo@redhat.com>
Date: Thu, 3 Oct 2024 11:14:34 -0400
From: Alexander Aring <aahringo@...hat.com>
To: trondmy@...nel.org
Cc: anna@...nel.org,
bcodding@...hat.com,
gregkh@...uxfoundation.org,
rafael@...nel.org,
akpm@...ux-foundation.org,
linux-nfs@...r.kernel.org,
gfs2@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [PATCH 3/4] nfs: sysfs: use kset_type_create_and_add()
Since we have the new udev helper kset_type_create_and_add() helper we
can use it as it allows to have an own kobj_type ktype that is necessary
for nfs for the nfs_netns_object_child_ns_type() kset type callback.
We lose some errno information related to kset_register() in probably
non-existing cases. We return always -ENOMEM as other uses of
kset_create_and_add() does.
The nfs_kset_release() can be replaced by the default udev helper
kset_release() as it does the same functionality.
Signed-off-by: Alexander Aring <aahringo@...hat.com>
---
fs/nfs/sysfs.c | 29 +++--------------------------
1 file changed, 3 insertions(+), 26 deletions(-)
diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
index bf378ecd5d9f..a6584203b7ff 100644
--- a/fs/nfs/sysfs.c
+++ b/fs/nfs/sysfs.c
@@ -20,12 +20,6 @@
static struct kset *nfs_kset;
-static void nfs_kset_release(struct kobject *kobj)
-{
- struct kset *kset = container_of(kobj, struct kset, kobj);
- kfree(kset);
-}
-
static const struct kobj_ns_type_operations *nfs_netns_object_child_ns_type(
const struct kobject *kobj)
{
@@ -33,35 +27,18 @@ static const struct kobj_ns_type_operations *nfs_netns_object_child_ns_type(
}
static struct kobj_type nfs_kset_type = {
- .release = nfs_kset_release,
+ .release = kset_release,
.sysfs_ops = &kobj_sysfs_ops,
.child_ns_type = nfs_netns_object_child_ns_type,
};
int nfs_sysfs_init(void)
{
- int ret;
-
- nfs_kset = kzalloc(sizeof(*nfs_kset), GFP_KERNEL);
+ nfs_kset = kset_type_create_and_add("nfs", NULL, fs_kobj,
+ &nfs_kset_type);
if (!nfs_kset)
return -ENOMEM;
- ret = kobject_set_name(&nfs_kset->kobj, "nfs");
- if (ret) {
- kfree(nfs_kset);
- return ret;
- }
-
- nfs_kset->kobj.parent = fs_kobj;
- nfs_kset->kobj.ktype = &nfs_kset_type;
- nfs_kset->kobj.kset = NULL;
-
- ret = kset_register(nfs_kset);
- if (ret) {
- kfree(nfs_kset);
- return ret;
- }
-
return 0;
}
--
2.43.0
Powered by blists - more mailing lists