aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-18 18:28:08 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-18 18:28:08 -0700
commit29e7ee378e2327c808ede66dec4d4d964f4d375f (patch)
tree4f904bfc485acd2ba5f7abdf43f57eeb8ce1dbdb /fs
parentfc15bc817eecd5c13581adab2a182c07edededa0 (diff)
parent967e35dcc9ac194b4a6fad69a5a51f93d69bb0d1 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: sysfs: cosmetic clean up on node creation failure paths sysfs: kill an extra put in sysfs_create_link() failure path Driver core: check return code of sysfs_create_link() HOWTO: Add the knwon_regression URI to the documentation dev_vdbg() documentation dev_vdbg(), available with -DVERBOSE_DEBUG sysfs: make sysfs_init_inode() static sysfs: fix sysfs root inode nlink accounting Documentation fix devres.txt: lib/iomap.c -> lib/devres.c sysfs: avoid kmem_cache_free(NULL) PM: remove deprecated dpm_runtime_* routines PM: Remove deprecated sysfs files Driver core: accept all valid action-strings in uevent-trigger debugfs: remove rmdir() non-empty complaint
Diffstat (limited to 'fs')
-rw-r--r--fs/debugfs/inode.c5
-rw-r--r--fs/sysfs/dir.c25
-rw-r--r--fs/sysfs/file.c9
-rw-r--r--fs/sysfs/inode.c2
-rw-r--r--fs/sysfs/mount.c10
-rw-r--r--fs/sysfs/symlink.c12
-rw-r--r--fs/sysfs/sysfs.h1
7 files changed, 33 insertions, 31 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 1d533a2ec3a..11be8a325e2 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -345,11 +345,6 @@ void debugfs_remove(struct dentry *dentry)
switch (dentry->d_inode->i_mode & S_IFMT) {
case S_IFDIR:
ret = simple_rmdir(parent->d_inode, dentry);
- if (ret)
- printk(KERN_ERR
- "DebugFS rmdir on %s failed : "
- "directory not empty.\n",
- dentry->d_name.name);
break;
case S_IFLNK:
kfree(dentry->d_inode->i_private);
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index aee966c44aa..048e6054c2f 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -361,20 +361,20 @@ static struct dentry_operations sysfs_dentry_ops = {
struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type)
{
char *dup_name = NULL;
- struct sysfs_dirent *sd = NULL;
+ struct sysfs_dirent *sd;
if (type & SYSFS_COPY_NAME) {
name = dup_name = kstrdup(name, GFP_KERNEL);
if (!name)
- goto err_out;
+ return NULL;
}
sd = kmem_cache_zalloc(sysfs_dir_cachep, GFP_KERNEL);
if (!sd)
- goto err_out;
+ goto err_out1;
if (sysfs_alloc_ino(&sd->s_ino))
- goto err_out;
+ goto err_out2;
atomic_set(&sd->s_count, 1);
atomic_set(&sd->s_active, 0);
@@ -386,9 +386,10 @@ struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type)
return sd;
- err_out:
- kfree(dup_name);
+ err_out2:
kmem_cache_free(sysfs_dir_cachep, sd);
+ err_out1:
+ kfree(dup_name);
return NULL;
}
@@ -698,17 +699,19 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
/* link in */
sysfs_addrm_start(&acxt, parent_sd);
+
if (!sysfs_find_dirent(parent_sd, name)) {
sysfs_add_one(&acxt, sd);
sysfs_link_sibling(sd);
}
- if (sysfs_addrm_finish(&acxt)) {
- *p_sd = sd;
- return 0;
+
+ if (!sysfs_addrm_finish(&acxt)) {
+ sysfs_put(sd);
+ return -EEXIST;
}
- sysfs_put(sd);
- return -EEXIST;
+ *p_sd = sd;
+ return 0;
}
int sysfs_create_subdir(struct kobject *kobj, const char *name,
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index cc497994b2a..3e1cc062a74 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -410,11 +410,12 @@ int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr,
sysfs_link_sibling(sd);
}
- if (sysfs_addrm_finish(&acxt))
- return 0;
+ if (!sysfs_addrm_finish(&acxt)) {
+ sysfs_put(sd);
+ return -EEXIST;
+ }
- sysfs_put(sd);
- return -EEXIST;
+ return 0;
}
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 3756e152285..10d1b52899f 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -133,7 +133,7 @@ static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
*/
static struct lock_class_key sysfs_inode_imutex_key;
-void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
+static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
{
inode->i_blocks = 0;
inode->i_mapping->a_ops = &sysfs_aops;
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 402cc356203..60714d075c2 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -43,19 +43,19 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_time_gran = 1;
sysfs_sb = sb;
- inode = new_inode(sysfs_sb);
+ /* get root inode, initialize and unlock it */
+ inode = sysfs_get_inode(&sysfs_root);
if (!inode) {
pr_debug("sysfs: could not get root inode\n");
return -ENOMEM;
}
- sysfs_init_inode(&sysfs_root, inode);
-
inode->i_op = &sysfs_dir_inode_operations;
inode->i_fop = &sysfs_dir_operations;
- /* directory inodes start off with i_nlink == 2 (for "." entry) */
- inc_nlink(inode);
+ inc_nlink(inode); /* directory, account for "." */
+ unlock_new_inode(inode);
+ /* instantiate and link root dentry */
root = d_alloc_root(inode);
if (!root) {
pr_debug("%s: could not get root dentry!\n",__FUNCTION__);
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 2f86e042229..4ce687f0b5d 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -86,7 +86,9 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
sd = sysfs_new_dirent(name, S_IFLNK|S_IRWXUGO, SYSFS_KOBJ_LINK);
if (!sd)
goto out_put;
+
sd->s_elem.symlink.target_sd = target_sd;
+ target_sd = NULL; /* reference is now owned by the symlink */
sysfs_addrm_start(&acxt, parent_sd);
@@ -95,11 +97,13 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
sysfs_link_sibling(sd);
}
- if (sysfs_addrm_finish(&acxt))
- return 0;
+ if (!sysfs_addrm_finish(&acxt)) {
+ error = -EEXIST;
+ goto out_put;
+ }
+
+ return 0;
- error = -EEXIST;
- /* fall through */
out_put:
sysfs_put(target_sd);
sysfs_put(sd);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 6a37f2386a8..6b8c8d76d30 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -71,7 +71,6 @@ extern void sysfs_remove_one(struct sysfs_addrm_cxt *acxt,
extern int sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
extern void sysfs_delete_inode(struct inode *inode);
-extern void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode);
extern struct inode * sysfs_get_inode(struct sysfs_dirent *sd);
extern void sysfs_instantiate(struct dentry *dentry, struct inode *inode);