Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

NFS: Open-code the nfs_kset kset_create_and_add()

In preparation to make objects below /sys/fs/nfs namespace aware, we need
to define our own kobj_type for the nfs kset so that we can add the
.child_ns_type member in a following patch. No functional change here, only
the unrolling of kset_create_and_add().

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

authored by

Benjamin Coddington and committed by
Trond Myklebust
943aef2d d5082ace

+32 -2
+32 -2
fs/nfs/sysfs.c
··· 25 25 kfree(kobj); 26 26 } 27 27 28 + static void nfs_kset_release(struct kobject *kobj) 29 + { 30 + struct kset *kset = container_of(kobj, struct kset, kobj); 31 + kfree(kset); 32 + } 33 + 28 34 static const struct kobj_ns_type_operations *nfs_netns_object_child_ns_type( 29 35 const struct kobject *kobj) 30 36 { 31 37 return &net_ns_type_operations; 32 38 } 39 + 40 + static struct kobj_type nfs_kset_type = { 41 + .release = nfs_kset_release, 42 + .sysfs_ops = &kobj_sysfs_ops, 43 + }; 33 44 34 45 static struct kobj_type nfs_netns_object_type = { 35 46 .release = nfs_netns_object_release, ··· 66 55 67 56 int nfs_sysfs_init(void) 68 57 { 69 - nfs_kset = kset_create_and_add("nfs", NULL, fs_kobj); 58 + int ret; 59 + 60 + nfs_kset = kzalloc(sizeof(*nfs_kset), GFP_KERNEL); 70 61 if (!nfs_kset) 71 62 return -ENOMEM; 63 + 64 + ret = kobject_set_name(&nfs_kset->kobj, "nfs"); 65 + if (ret) { 66 + kfree(nfs_kset); 67 + return ret; 68 + } 69 + 70 + nfs_kset->kobj.parent = fs_kobj; 71 + nfs_kset->kobj.ktype = &nfs_kset_type; 72 + nfs_kset->kobj.kset = NULL; 73 + 74 + ret = kset_register(nfs_kset); 75 + if (ret) { 76 + kfree(nfs_kset); 77 + return ret; 78 + } 79 + 72 80 nfs_net_kobj = nfs_netns_object_alloc("net", nfs_kset, NULL); 73 81 if (!nfs_net_kobj) { 74 82 kset_unregister(nfs_kset); 75 - nfs_kset = NULL; 83 + kfree(nfs_kset); 76 84 return -ENOMEM; 77 85 } 78 86 return 0;