lkml.org 
[lkml]   [2015]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 003/003] Attempt to cope with device changes and delayed kobject deallocation
Avoid issuing duplicate name errors when a kobject's sysfs directory is
scheduled for deletion but has not yet been deleted, and a directory
with the same name is created.

Signed-off-by: Richard Watts <rrw@kynesim.co.uk>
---
fs/sysfs/dir.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 0b45ff4..e85de14 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -49,6 +49,21 @@ int sysfs_create_dir_ns(struct kobject *kobj, const
void *ns)
else
parent = sysfs_root_kn;

+ kn = kernfs_find_and_get_ns(parent, kobject_name(kobj),
+ ns);
+ /* This check is non-atomic, but that is OK - the worst thing
+ * that can happen is a concurrent removal of the sysfs dir,
+ * which is exactly what we want anyway.
+ */
+ if (kn) {
+ struct kobject *kobj_exist = (struct kobject *)kn->priv;
+
+ if (kobject_get_unless_zero(kobj_exist))
+ kobject_put(kobj_exist);
+ else
+ sysfs_remove_dir(kobj_exist);
+ }
+
if (!parent)
return -ENOENT;

--
1.9.1


\
 
 \ /
  Last update: 2015-05-19 18:01    [W:0.052 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site