kobject: introduce kobject_del_and_put()
Subsystems (14)
PATCH v2 1/10 kobject: introduce kobject_del_and_put()
There are plenty of using kobject_del() and kobject_put() together in the kernel tree. This patch wraps these two calls in a single helper.
---
v2:
-add kobject_del_and_put() users
include/linux/kobject.h | 1 + lib/kobject.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-)
include/linux/kobject.h +1 -0
@@ -111,6 +111,7 @@ extern struct kobject *kobject_get(struct kobject *kobj);extern struct kobject *__must_check kobject_get_unless_zero (struct kobject *kobj);extern void kobject_put (struct kobject *kobj); +extern void kobject_del_and_put (struct kobject *kobj);extern const void *kobject_namespace (const struct kobject *kobj); extern void kobject_get_ownership(const struct kobject *kobj,
lib/kobject.c +15 -2
@@ -731,6 +731,20 @@ void kobject_put(struct kobject *kobj) }EXPORT_SYMBOL (kobject_put); +/** +* kobject_del_and_put() - Delete kobject. +* @kobj: object. +* +* Unlink kobject from hierarchy and decrement the refcount. +* If refcount is 0, call kobject_cleanup(). +*/ +void kobject_del_and_put (struct kobject *kobj) +{ +kobject_del (kobj); +kobject_put (kobj); +} +EXPORT_SYMBOL_GPL (kobject_del_and_put); +static void dynamic_kobj_release (struct kobject *kobj) {pr_debug ("kobject: (%p): %s\n" , kobj, __func__);
@@ -874,8 +888,7 @@ void kset_unregister(struct kset *k) {if (!k)return ; -kobject_del (&k->kobj); -kobject_put (&k->kobj); +kobject_del_and_put (&k->kobj); }EXPORT_SYMBOL (kset_unregister);
Signature · 1 line
2.35.1
PATCH v2 2/10 f2fs: convert to kobject_del_and_put()
Use kobject_del_and_put() to simplify code.
--- fs/f2fs/sysfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
fs/f2fs/sysfs.c +3 -6
@@ -1478,14 +1478,11 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)remove_proc_entry (sbi->sb->s_id, f2fs_proc_root); } -kobject_del (&sbi->s_stat_kobj); -kobject_put (&sbi->s_stat_kobj); +kobject_del_and_put (&sbi->s_stat_kobj);wait_for_completion (&sbi->s_stat_kobj_unregister); -kobject_del (&sbi->s_feature_list_kobj); -kobject_put (&sbi->s_feature_list_kobj); +kobject_del_and_put (&sbi->s_feature_list_kobj);wait_for_completion (&sbi->s_feature_list_kobj_unregister); -kobject_del (&sbi->s_kobj); -kobject_put (&sbi->s_kobj); +kobject_del_and_put (&sbi->s_kobj);wait_for_completion (&sbi->s_kobj_unregister); }
Signature · 1 line
2.35.1
PATCH v2 3/10 erofs: convert to kobject_del_and_put()
In reply to Yangtao LiUse kobject_del_and_put() to simplify code.
--- fs/erofs/sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/erofs/sysfs.c +1 -2
@@ -241,8 +241,7 @@ void erofs_unregister_sysfs(struct super_block *sb)struct erofs_sb_info *sbi =EROFS_SB (sb);if (sbi->s_kobj.state_in_sysfs) { -kobject_del (&sbi->s_kobj); -kobject_put (&sbi->s_kobj); +kobject_del_and_put (&sbi->s_kobj);wait_for_completion (&sbi->s_kobj_unregister); } }
Signature · 1 line
2.35.1
PATCH v2 4/10 zonefs: convert to kobject_del_and_put()
In reply to Yangtao LiUse kobject_del_and_put() to simplify code.
--- fs/zonefs/sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/zonefs/sysfs.c +1 -2
@@ -113,8 +113,7 @@ 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); +kobject_del_and_put (&sbi->s_kobj);wait_for_completion (&sbi->s_kobj_unregister); }
Signature · 1 line
2.35.1
PATCH v2 5/10 ubifs: convert to kobject_del_and_put()
In reply to Yangtao LiUse kobject_del_and_put() to simplify code.
--- fs/ubifs/sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ubifs/sysfs.c +1 -2
@@ -130,8 +130,7 @@ int ubifs_sysfs_register(struct ubifs_info *c)void ubifs_sysfs_unregister (struct ubifs_info *c) { -kobject_del (&c->kobj); -kobject_put (&c->kobj); +kobject_del_and_put (&c->kobj);wait_for_completion (&c->kobj_unregister);kfree (c->stats);
Signature · 1 line
2.35.1
PATCH v2 6/10 btrfs: convert to kobject_del_and_put()
In reply to Yangtao LiUse kobject_del_and_put() to simplify code.
--- fs/btrfs/block-group.c | 5 +---- fs/btrfs/sysfs.c | 38 ++++++++++++-------------------------- 2 files changed, 13 insertions(+), 30 deletions(-)
fs/btrfs/block-group.c +1 -4
@@ -1125,10 +1125,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, }up_write (&block_group->space_info->groups_sem);clear_incompat_bg_bits (fs_info, block_group->flags); -if (kobj) { -kobject_del (kobj); -kobject_put (kobj); - } +kobject_del_and_put (kobj);if (block_group->cached ==BTRFS_CACHE_STARTED )btrfs_wait_block_group_cache_done (block_group);
fs/btrfs/sysfs.c +12 -26
@@ -1390,20 +1390,17 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)static void __btrfs_sysfs_remove_fsid (struct btrfs_fs_devices *fs_devs) {if (fs_devs->devinfo_kobj) { -kobject_del (fs_devs->devinfo_kobj); -kobject_put (fs_devs->devinfo_kobj); +kobject_del_and_put (fs_devs->devinfo_kobj); fs_devs->devinfo_kobj =NULL ; }if (fs_devs->devices_kobj) { -kobject_del (fs_devs->devices_kobj); -kobject_put (fs_devs->devices_kobj); +kobject_del_and_put (fs_devs->devices_kobj); fs_devs->devices_kobj =NULL ; }if (fs_devs->fsid_kobj.state_initialized) { -kobject_del (&fs_devs->fsid_kobj); -kobject_put (&fs_devs->fsid_kobj); +kobject_del_and_put (&fs_devs->fsid_kobj);wait_for_completion (&fs_devs->kobj_unregister); } }
@@ -1445,19 +1442,16 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)if (fs_info->space_info_kobj) {sysfs_remove_files (fs_info->space_info_kobj, allocation_attrs); -kobject_del (fs_info->space_info_kobj); -kobject_put (fs_info->space_info_kobj); +kobject_del_and_put (fs_info->space_info_kobj); }if (fs_info->discard_kobj) {sysfs_remove_files (fs_info->discard_kobj, discard_attrs); -kobject_del (fs_info->discard_kobj); -kobject_put (fs_info->discard_kobj); +kobject_del_and_put (fs_info->discard_kobj); }#ifdef CONFIG_BTRFS_DEBUG if (fs_info->debug_kobj) {sysfs_remove_files (fs_info->debug_kobj, btrfs_debug_mount_attrs); -kobject_del (fs_info->debug_kobj); -kobject_put (fs_info->debug_kobj); +kobject_del_and_put (fs_info->debug_kobj); }#endif addrm_unknown_feature_attrs (fs_info, false);
@@ -1620,13 +1614,9 @@ void btrfs_sysfs_remove_space_info(struct btrfs_space_info *space_info) kobj = space_info->block_group_kobjs[i]; space_info->block_group_kobjs[i] =NULL ; -if (kobj) { -kobject_del (kobj); -kobject_put (kobj); - } +kobject_del_and_put (kobj); } -kobject_del (&space_info->kobj); -kobject_put (&space_info->kobj); +kobject_del_and_put (&space_info->kobj); }static const char *alloc_name (u64 flags)
@@ -1681,8 +1671,7 @@ void btrfs_sysfs_remove_device(struct btrfs_device *device)sysfs_remove_link (devices_kobj,bdev_kobj (device->bdev)->name);if (device->devid_kobj.state_initialized) { -kobject_del (&device->devid_kobj); -kobject_put (&device->devid_kobj); +kobject_del_and_put (&device->devid_kobj);wait_for_completion (&device->kobj_unregister); } }
@@ -2255,8 +2244,7 @@ void btrfs_sysfs_del_qgroups(struct btrfs_fs_info *fs_info) &fs_info->qgroup_tree, node)btrfs_sysfs_del_one_qgroup (fs_info, qgroup);if (fs_info->qgroups_kobj) { -kobject_del (fs_info->qgroups_kobj); -kobject_put (fs_info->qgroups_kobj); +kobject_del_and_put (fs_info->qgroups_kobj); fs_info->qgroups_kobj =NULL ; } }
@@ -2304,10 +2292,8 @@ void btrfs_sysfs_del_one_qgroup(struct btrfs_fs_info *fs_info,if (test_bit (BTRFS_FS_STATE_DUMMY_FS_INFO , &fs_info->fs_state))return ; -if (qgroup->kobj.state_initialized) { -kobject_del (&qgroup->kobj); -kobject_put (&qgroup->kobj); - } +if (qgroup->kobj.state_initialized) +kobject_del_and_put (&qgroup->kobj); }/*
Signature · 1 line
2.35.1
PATCH v2 7/10 xfs: convert to kobject_del_and_put()
In reply to Yangtao LiUse kobject_del_and_put() to simplify code.
--- fs/xfs/xfs_sysfs.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/xfs/xfs_sysfs.h +1 -2
@@ -48,8 +48,7 @@ static inline voidxfs_sysfs_del ( struct xfs_kobj *kobj) { -kobject_del (&kobj->kobject); -kobject_put (&kobj->kobject); +kobject_del_and_put (&kobj->kobject);wait_for_completion (&kobj->complete); }
Signature · 1 line
2.35.1
PATCH v2 8/10 ocfs2: convert to kobject_del_and_put()
In reply to Yangtao LiUse kobject_del_and_put() to simplify code.
--- fs/ocfs2/filecheck.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ocfs2/filecheck.c +1 -2
@@ -198,8 +198,7 @@ void ocfs2_filecheck_remove_sysfs(struct ocfs2_super *osb)if (!osb->osb_fc_ent.fs_fcheck)return ; -kobject_del (&osb->osb_fc_ent.fs_kobj); -kobject_put (&osb->osb_fc_ent.fs_kobj); +kobject_del_and_put (&osb->osb_fc_ent.fs_kobj);wait_for_completion (&osb->osb_fc_ent.fs_kobj_unregister);ocfs2_filecheck_sysfs_free (&osb->osb_fc_ent); }
Signature · 1 line
2.35.1
PATCH v2 9/10 nfs: convert to kobject_del_and_put()
In reply to Yangtao LiUse kobject_del_and_put() to simplify code.
--- fs/nfs/sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfs/sysfs.c +1 -2
@@ -185,8 +185,7 @@ void nfs_netns_sysfs_destroy(struct nfs_net *netns)if (clp) {kobject_uevent (&clp->kobject,KOBJ_REMOVE ); -kobject_del (&clp->kobject); -kobject_put (&clp->kobject); +kobject_del_and_put (&clp->kobject); netns->nfs_client =NULL ; } }
Signature · 1 line
2.35.1
PATCH v2 10/10 nilfs2: convert to kobject_del_and_put()
In reply to Yangtao LiUse kobject_del_and_put() to simplify code.
--- fs/nilfs2/sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nilfs2/sysfs.c +1 -2
@@ -1042,8 +1042,7 @@ void nilfs_sysfs_delete_device_group(struct the_nilfs *nilfs)nilfs_sysfs_delete_segments_group (nilfs);nilfs_sysfs_delete_superblock_group (nilfs);nilfs_sysfs_delete_segctor_group (nilfs); -kobject_del (&nilfs->ns_dev_kobj); -kobject_put (&nilfs->ns_dev_kobj); +kobject_del_and_put (&nilfs->ns_dev_kobj);kfree (nilfs->ns_dev_subgroups); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerQuoted 10 lines · Yangtao Li
There are plenty of using
kobject_del()andkobject_put()together in the kernel tree. This patch wraps these two calls in a single helper.Signed-off-by Yangtao Li <[email protected]>---
v2:
-addkobject_del_and_put()usersinclude/linux/kobject.h | 1 + lib/kobject.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-)
Any reason you only sent me one patch? I guess you don't want me to review them? :(
Quoted 2 lines
Any reason you only sent me one patch? I guess you don't want me to review them? :(
Sorry, I used the following git configuration to send emails, so it was not sent to you.
[sendemail]
tocmd ="`pwd`/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nol"
cccmd ="`pwd`/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nom"I amended the resent patch, the patch body states cc to you and Rafael.
Thx,
Yangtao
Greg KH
maintainerQuoted 11 lines · Yangtao Li
Quoted 2 lines
Any reason you only sent me one patch? I guess you don't want me to review them? :(
Sorry, I used the following git configuration to send emails, so it was not sent to you.
[sendemail]
tocmd ="`pwd`/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nol" cccmd ="`pwd`/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nom"I amended the resent patch, the patch body states cc to you and Rafael.
Great, thanks, I got them now, I'll queue them up later next week if there's no complaints.
greg k-h