diff options
Diffstat (limited to 'fs/configfs')
| -rw-r--r-- | fs/configfs/configfs_internal.h | 6 | ||||
| -rw-r--r-- | fs/configfs/dir.c | 36 | ||||
| -rw-r--r-- | fs/configfs/inode.c | 5 | ||||
| -rw-r--r-- | fs/configfs/item.c | 58 | ||||
| -rw-r--r-- | fs/configfs/mount.c | 4 | 
5 files changed, 57 insertions, 52 deletions
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h index b5f0a3b91f1..bd4a3c16709 100644 --- a/fs/configfs/configfs_internal.h +++ b/fs/configfs/configfs_internal.h @@ -24,6 +24,12 @@   * configfs Copyright (C) 2005 Oracle.  All rights reserved.   */ +#ifdef pr_fmt +#undef pr_fmt +#endif + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +  #include <linux/slab.h>  #include <linux/list.h>  #include <linux/spinlock.h> diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 277bd1be21f..668dcabc569 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -56,29 +56,28 @@ static void configfs_d_iput(struct dentry * dentry,  	struct configfs_dirent *sd = dentry->d_fsdata;  	if (sd) { -		BUG_ON(sd->s_dentry != dentry);  		/* Coordinate with configfs_readdir */  		spin_lock(&configfs_dirent_lock); -		sd->s_dentry = NULL; +		/* Coordinate with configfs_attach_attr where will increase +		 * sd->s_count and update sd->s_dentry to new allocated one. +		 * Only set sd->dentry to null when this dentry is the only +		 * sd owner. +		 * If not do so, configfs_d_iput may run just after +		 * configfs_attach_attr and set sd->s_dentry to null +		 * even it's still in use. +		 */ +		if (atomic_read(&sd->s_count) <= 2) +			sd->s_dentry = NULL; +  		spin_unlock(&configfs_dirent_lock);  		configfs_put(sd);  	}  	iput(inode);  } -/* - * We _must_ delete our dentries on last dput, as the chain-to-parent - * behavior is required to clear the parents of default_groups. - */ -static int configfs_d_delete(const struct dentry *dentry) -{ -	return 1; -} -  const struct dentry_operations configfs_dentry_ops = {  	.d_iput		= configfs_d_iput, -	/* simple_delete_dentry() isn't exported */ -	.d_delete	= configfs_d_delete, +	.d_delete	= always_delete_dentry,  };  #ifdef CONFIG_LOCKDEP @@ -426,8 +425,11 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den  	struct configfs_attribute * attr = sd->s_element;  	int error; +	spin_lock(&configfs_dirent_lock);  	dentry->d_fsdata = configfs_get(sd);  	sd->s_dentry = dentry; +	spin_unlock(&configfs_dirent_lock); +  	error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG,  				configfs_init_file);  	if (error) { @@ -938,9 +940,9 @@ static void client_drop_item(struct config_item *parent_item,  #ifdef DEBUG  static void configfs_dump_one(struct configfs_dirent *sd, int level)  { -	printk(KERN_INFO "%*s\"%s\":\n", level, " ", configfs_get_name(sd)); +	pr_info("%*s\"%s\":\n", level, " ", configfs_get_name(sd)); -#define type_print(_type) if (sd->s_type & _type) printk(KERN_INFO "%*s %s\n", level, " ", #_type); +#define type_print(_type) if (sd->s_type & _type) pr_info("%*s %s\n", level, " ", #_type);  	type_print(CONFIGFS_ROOT);  	type_print(CONFIGFS_DIR);  	type_print(CONFIGFS_ITEM_ATTR); @@ -1697,7 +1699,7 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys)  	struct dentry *root = dentry->d_sb->s_root;  	if (dentry->d_parent != root) { -		printk(KERN_ERR "configfs: Tried to unregister non-subsystem!\n"); +		pr_err("Tried to unregister non-subsystem!\n");  		return;  	} @@ -1707,7 +1709,7 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys)  	mutex_lock(&configfs_symlink_mutex);  	spin_lock(&configfs_dirent_lock);  	if (configfs_detach_prep(dentry, NULL)) { -		printk(KERN_ERR "configfs: Tried to unregister non-empty subsystem!\n"); +		pr_err("Tried to unregister non-empty subsystem!\n");  	}  	spin_unlock(&configfs_dirent_lock);  	mutex_unlock(&configfs_symlink_mutex); diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c index a9d35b0e06c..5946ad98053 100644 --- a/fs/configfs/inode.c +++ b/fs/configfs/inode.c @@ -168,9 +168,8 @@ static void configfs_set_inode_lock_class(struct configfs_dirent *sd,  			 * In practice the maximum level of locking depth is  			 * already reached. Just inform about possible reasons.  			 */ -			printk(KERN_INFO "configfs: Too many levels of inodes" -			       " for the locking correctness validator.\n"); -			printk(KERN_INFO "Spurious warnings may appear.\n"); +			pr_info("Too many levels of inodes for the locking correctness validator.\n"); +			pr_info("Spurious warnings may appear.\n");  		}  	}  } diff --git a/fs/configfs/item.c b/fs/configfs/item.c index 50cee7f9110..e65f9ffbb99 100644 --- a/fs/configfs/item.c +++ b/fs/configfs/item.c @@ -19,7 +19,7 @@   * Boston, MA 021110-1307, USA.   *   * Based on kobject: - * 	kobject is Copyright (c) 2002-2003 Patrick Mochel + *	kobject is Copyright (c) 2002-2003 Patrick Mochel   *   * configfs Copyright (C) 2005 Oracle.  All rights reserved.   * @@ -35,9 +35,9 @@  #include <linux/configfs.h> -static inline struct config_item * to_item(struct list_head * entry) +static inline struct config_item *to_item(struct list_head *entry)  { -	return container_of(entry,struct config_item,ci_entry); +	return container_of(entry, struct config_item, ci_entry);  }  /* Evil kernel */ @@ -47,34 +47,35 @@ static void config_item_release(struct kref *kref);   *	config_item_init - initialize item.   *	@item:	item in question.   */ -void config_item_init(struct config_item * item) +void config_item_init(struct config_item *item)  {  	kref_init(&item->ci_kref);  	INIT_LIST_HEAD(&item->ci_entry);  } +EXPORT_SYMBOL(config_item_init);  /**   *	config_item_set_name - Set the name of an item   *	@item:	item. - *	@name:	name. + *	@fmt:  The vsnprintf()'s format string.   *   *	If strlen(name) >= CONFIGFS_ITEM_NAME_LEN, then use a   *	dynamically allocated string that @item->ci_name points to.   *	Otherwise, use the static @item->ci_namebuf array.   */ -int config_item_set_name(struct config_item * item, const char * fmt, ...) +int config_item_set_name(struct config_item *item, const char *fmt, ...)  {  	int error = 0;  	int limit = CONFIGFS_ITEM_NAME_LEN;  	int need;  	va_list args; -	char * name; +	char *name;  	/*  	 * First, try the static array  	 */ -	va_start(args,fmt); -	need = vsnprintf(item->ci_namebuf,limit,fmt,args); +	va_start(args, fmt); +	need = vsnprintf(item->ci_namebuf, limit, fmt, args);  	va_end(args);  	if (need < limit)  		name = item->ci_namebuf; @@ -83,13 +84,13 @@ int config_item_set_name(struct config_item * item, const char * fmt, ...)  		 * Need more space? Allocate it and try again  		 */  		limit = need + 1; -		name = kmalloc(limit,GFP_KERNEL); +		name = kmalloc(limit, GFP_KERNEL);  		if (!name) {  			error = -ENOMEM;  			goto Done;  		} -		va_start(args,fmt); -		need = vsnprintf(name,limit,fmt,args); +		va_start(args, fmt); +		need = vsnprintf(name, limit, fmt, args);  		va_end(args);  		/* Still? Give up. */ @@ -109,7 +110,6 @@ int config_item_set_name(struct config_item * item, const char * fmt, ...)   Done:  	return error;  } -  EXPORT_SYMBOL(config_item_set_name);  void config_item_init_type_name(struct config_item *item, @@ -131,20 +131,21 @@ void config_group_init_type_name(struct config_group *group, const char *name,  }  EXPORT_SYMBOL(config_group_init_type_name); -struct config_item * config_item_get(struct config_item * item) +struct config_item *config_item_get(struct config_item *item)  {  	if (item)  		kref_get(&item->ci_kref);  	return item;  } +EXPORT_SYMBOL(config_item_get); -static void config_item_cleanup(struct config_item * item) +static void config_item_cleanup(struct config_item *item)  { -	struct config_item_type * t = item->ci_type; -	struct config_group * s = item->ci_group; -	struct config_item * parent = item->ci_parent; +	struct config_item_type *t = item->ci_type; +	struct config_group *s = item->ci_group; +	struct config_item *parent = item->ci_parent; -	pr_debug("config_item %s: cleaning up\n",config_item_name(item)); +	pr_debug("config_item %s: cleaning up\n", config_item_name(item));  	if (item->ci_name != item->ci_namebuf)  		kfree(item->ci_name);  	item->ci_name = NULL; @@ -167,21 +168,23 @@ static void config_item_release(struct kref *kref)   *   *	Decrement the refcount, and if 0, call config_item_cleanup().   */ -void config_item_put(struct config_item * item) +void config_item_put(struct config_item *item)  {  	if (item)  		kref_put(&item->ci_kref, config_item_release);  } +EXPORT_SYMBOL(config_item_put);  /**   *	config_group_init - initialize a group for use - *	@k:	group + *	@group:	config_group   */  void config_group_init(struct config_group *group)  {  	config_item_init(&group->cg_item);  	INIT_LIST_HEAD(&group->cg_children);  } +EXPORT_SYMBOL(config_group_init);  /**   *	config_group_find_item - search for item in group. @@ -195,11 +198,11 @@ void config_group_init(struct config_group *group)  struct config_item *config_group_find_item(struct config_group *group,  					   const char *name)  { -	struct list_head * entry; -	struct config_item * ret = NULL; +	struct list_head *entry; +	struct config_item *ret = NULL; -	list_for_each(entry,&group->cg_children) { -		struct config_item * item = to_item(entry); +	list_for_each(entry, &group->cg_children) { +		struct config_item *item = to_item(entry);  		if (config_item_name(item) &&  		    !strcmp(config_item_name(item), name)) {  			ret = config_item_get(item); @@ -208,9 +211,4 @@ struct config_item *config_group_find_item(struct config_group *group,  	}  	return ret;  } - -EXPORT_SYMBOL(config_item_init); -EXPORT_SYMBOL(config_group_init); -EXPORT_SYMBOL(config_item_get); -EXPORT_SYMBOL(config_item_put);  EXPORT_SYMBOL(config_group_find_item); diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c index 7f26c3cf75a..f6c28583339 100644 --- a/fs/configfs/mount.c +++ b/fs/configfs/mount.c @@ -85,7 +85,7 @@ static int configfs_fill_super(struct super_block *sb, void *data, int silent)  		/* directory inodes start off with i_nlink == 2 (for "." entry) */  		inc_nlink(inode);  	} else { -		pr_debug("configfs: could not get root inode\n"); +		pr_debug("could not get root inode\n");  		return -ENOMEM;  	} @@ -155,7 +155,7 @@ static int __init configfs_init(void)  	return 0;  out4: -	printk(KERN_ERR "configfs: Unable to register filesystem!\n"); +	pr_err("Unable to register filesystem!\n");  	configfs_inode_exit();  out3:  	kobject_put(config_kobj);  | 
