public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH 0/3] configfs: Miscellaneous fixes
@ 2008-06-12 15:26 Louis Rilling
  2008-06-12 15:26 ` [RFC][PATCH 1/3] configfs: Report errors in config_*_init_type_name() Louis Rilling
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Louis Rilling @ 2008-06-12 15:26 UTC (permalink / raw)
  To: Joel.Becker; +Cc: Louis.Rilling, ocfs2-devel, linux-kernel

Hi,

The following patches fix few bugs/APIs in configfs. The third one depends on
the patch introducing configfs_dirent_lock previously submitted in 
http://lkml.org/lkml/2008/6/12/232

Louis

-- 
Dr Louis Rilling			Kerlabs
Skype: louis.rilling			Batiment Germanium
Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
http://www.kerlabs.com/			35700 Rennes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFC][PATCH 1/3] configfs: Report errors in config_*_init_type_name()
  2008-06-12 15:26 [RFC][PATCH 0/3] configfs: Miscellaneous fixes Louis Rilling
@ 2008-06-12 15:26 ` Louis Rilling
  2008-06-12 18:42   ` Joel Becker
  2008-06-12 15:26 ` [RFC][PATCH 2/3] configfs: call drop_link() to cleanup after create_link() failure Louis Rilling
  2008-06-12 15:26 ` [RFC][PATCH 3/3] configfs: Protect configfs_dirent s_links list mutations Louis Rilling
  2 siblings, 1 reply; 6+ messages in thread
From: Louis Rilling @ 2008-06-12 15:26 UTC (permalink / raw)
  To: Joel.Becker; +Cc: Louis.Rilling, ocfs2-devel, linux-kernel

[-- Attachment #1: configfs-make-set-name-functions-return-errors.patch --]
[-- Type: text/plain, Size: 2838 bytes --]

config_item_set_name() may fail but its error code is not checked in
config_*init_type_name().

This patch adds the missing error checking and make config_*_init_type_name()
report errors.

Signed-off-by: Louis Rilling <Louis.Rilling@kerlabs.com>
---
 fs/configfs/item.c       |   18 ++++++++++++++----
 include/linux/configfs.h |    8 ++++----
 2 files changed, 18 insertions(+), 8 deletions(-)

Index: b/fs/configfs/item.c
===================================================================
--- a/fs/configfs/item.c	2008-06-12 17:13:32.000000000 +0200
+++ b/fs/configfs/item.c	2008-06-12 17:13:35.000000000 +0200
@@ -112,22 +112,32 @@ int config_item_set_name(struct config_i
 
 EXPORT_SYMBOL(config_item_set_name);
 
-void config_item_init_type_name(struct config_item *item,
+int config_item_init_type_name(struct config_item *item,
 				const char *name,
 				struct config_item_type *type)
 {
-	config_item_set_name(item, name);
+	int error;
+
+	error = config_item_set_name(item, name);
+	if (error)
+		return error;
 	item->ci_type = type;
 	config_item_init(item);
+	return 0;
 }
 EXPORT_SYMBOL(config_item_init_type_name);
 
-void config_group_init_type_name(struct config_group *group, const char *name,
+int config_group_init_type_name(struct config_group *group, const char *name,
 			 struct config_item_type *type)
 {
-	config_item_set_name(&group->cg_item, name);
+	int error;
+
+	error = config_item_set_name(&group->cg_item, name);
+	if (error)
+		return error;
 	group->cg_item.ci_type = type;
 	config_group_init(group);
+	return 0;
 }
 EXPORT_SYMBOL(config_group_init_type_name);
 
Index: b/include/linux/configfs.h
===================================================================
--- a/include/linux/configfs.h	2008-06-12 17:13:32.000000000 +0200
+++ b/include/linux/configfs.h	2008-06-12 17:13:35.000000000 +0200
@@ -71,9 +71,9 @@ static inline char *config_item_name(str
 }
 
 extern void config_item_init(struct config_item *);
-extern void config_item_init_type_name(struct config_item *item,
-				       const char *name,
-				       struct config_item_type *type);
+extern int config_item_init_type_name(struct config_item *item,
+				      const char *name,
+				      struct config_item_type *type);
 
 extern struct config_item * config_item_get(struct config_item *);
 extern void config_item_put(struct config_item *);
@@ -97,7 +97,7 @@ struct config_group {
 };
 
 extern void config_group_init(struct config_group *group);
-extern void config_group_init_type_name(struct config_group *group,
+extern int config_group_init_type_name(struct config_group *group,
 					const char *name,
 					struct config_item_type *type);
 

-- 
Dr Louis Rilling			Kerlabs
Skype: louis.rilling			Batiment Germanium
Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
http://www.kerlabs.com/			35700 Rennes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFC][PATCH 2/3] configfs: call drop_link() to cleanup after create_link() failure
  2008-06-12 15:26 [RFC][PATCH 0/3] configfs: Miscellaneous fixes Louis Rilling
  2008-06-12 15:26 ` [RFC][PATCH 1/3] configfs: Report errors in config_*_init_type_name() Louis Rilling
@ 2008-06-12 15:26 ` Louis Rilling
  2008-06-12 18:45   ` Joel Becker
  2008-06-12 15:26 ` [RFC][PATCH 3/3] configfs: Protect configfs_dirent s_links list mutations Louis Rilling
  2 siblings, 1 reply; 6+ messages in thread
From: Louis Rilling @ 2008-06-12 15:26 UTC (permalink / raw)
  To: Joel.Becker; +Cc: Louis.Rilling, ocfs2-devel, linux-kernel

[-- Attachment #1: configfs-drop_link-if-create_link-fails.patch --]
[-- Type: text/plain, Size: 1126 bytes --]

When allow_link() succeeds but create_link() fails, the subsystem is not
informed of the failure.

This patch fixes this by calling drop_link() on create_link() failures.

Signed-off-by: Louis Rilling <Louis.Rilling@kerlabs.com>
---
 fs/configfs/symlink.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: b/fs/configfs/symlink.c
===================================================================
--- a/fs/configfs/symlink.c	2008-06-12 17:13:27.000000000 +0200
+++ b/fs/configfs/symlink.c	2008-06-12 17:13:38.000000000 +0200
@@ -137,8 +137,12 @@ int configfs_symlink(struct inode *dir, 
 		goto out_put;
 
 	ret = type->ct_item_ops->allow_link(parent_item, target_item);
-	if (!ret)
+	if (!ret) {
 		ret = create_link(parent_item, target_item, dentry);
+		if (ret && type->ct_item_ops->drop_link)
+			type->ct_item_ops->drop_link(parent_item,
+						     target_item);
+	}
 
 	config_item_put(target_item);
 	path_put(&nd.path);

-- 
Dr Louis Rilling			Kerlabs
Skype: louis.rilling			Batiment Germanium
Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
http://www.kerlabs.com/			35700 Rennes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFC][PATCH 3/3] configfs: Protect configfs_dirent s_links list mutations
  2008-06-12 15:26 [RFC][PATCH 0/3] configfs: Miscellaneous fixes Louis Rilling
  2008-06-12 15:26 ` [RFC][PATCH 1/3] configfs: Report errors in config_*_init_type_name() Louis Rilling
  2008-06-12 15:26 ` [RFC][PATCH 2/3] configfs: call drop_link() to cleanup after create_link() failure Louis Rilling
@ 2008-06-12 15:26 ` Louis Rilling
  2 siblings, 0 replies; 6+ messages in thread
From: Louis Rilling @ 2008-06-12 15:26 UTC (permalink / raw)
  To: Joel.Becker; +Cc: Louis.Rilling, ocfs2-devel, linux-kernel

[-- Attachment #1: configfs-fix-symlink-dirent-linkage-locking.patch --]
[-- Type: text/plain, Size: 2020 bytes --]

Symlinks to a config_item are listed under its configfs_dirent s_links, but the
list mutations are not protected by any common lock.

This patch uses the configfs_dirent_lock spinlock to add the necessary
protection.

Note: we should also protect the list_empty() test in configfs_detach_prep() but
1/ the lock should not be released immediately because nothing would prevent the
list from being filled after a successful list_empty() test, making the problem
tricky,
2/ this will be solved by the rmdir() vs rename() deadlock bugfix.

Signed-off-by: Louis Rilling <Louis.Rilling@kerlabs.com>
---
 fs/configfs/symlink.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: b/fs/configfs/symlink.c
===================================================================
--- a/fs/configfs/symlink.c	2008-06-12 16:50:40.000000000 +0200
+++ b/fs/configfs/symlink.c	2008-06-12 16:52:43.000000000 +0200
@@ -77,12 +77,15 @@ static int create_link(struct config_ite
 	sl = kmalloc(sizeof(struct configfs_symlink), GFP_KERNEL);
 	if (sl) {
 		sl->sl_target = config_item_get(item);
-		/* FIXME: needs a lock, I'd bet */
+		spin_lock(&configfs_dirent_lock);
 		list_add(&sl->sl_list, &target_sd->s_links);
+		spin_unlock(&configfs_dirent_lock);
 		ret = configfs_create_link(sl, parent_item->ci_dentry,
 					   dentry);
 		if (ret) {
+			spin_lock(&configfs_dirent_lock);
 			list_del_init(&sl->sl_list);
+			spin_unlock(&configfs_dirent_lock);
 			config_item_put(item);
 			kfree(sl);
 		}
@@ -190,8 +193,9 @@ int configfs_unlink(struct inode *dir, s
 		type->ct_item_ops->drop_link(parent_item,
 					       sl->sl_target);
 
-	/* FIXME: Needs lock */
+	spin_lock(&configfs_dirent_lock);
 	list_del_init(&sl->sl_list);
+	spin_unlock(&configfs_dirent_lock);
 
 	/* Put reference from create_link() */
 	config_item_put(sl->sl_target);

-- 
Dr Louis Rilling			Kerlabs
Skype: louis.rilling			Batiment Germanium
Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
http://www.kerlabs.com/			35700 Rennes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH 1/3] configfs: Report errors in config_*_init_type_name()
  2008-06-12 15:26 ` [RFC][PATCH 1/3] configfs: Report errors in config_*_init_type_name() Louis Rilling
@ 2008-06-12 18:42   ` Joel Becker
  0 siblings, 0 replies; 6+ messages in thread
From: Joel Becker @ 2008-06-12 18:42 UTC (permalink / raw)
  To: Louis Rilling; +Cc: ocfs2-devel, linux-kernel

On Thu, Jun 12, 2008 at 05:26:46PM +0200, Louis Rilling wrote:
> config_item_set_name() may fail but its error code is not checked in
> config_*init_type_name().
> 
> This patch adds the missing error checking and make config_*_init_type_name()
> report errors.

	This patch needs to modify the callers of
config_*_init_type_name(), including fs/dlm/config.c and
fs/ocfs2/cluster/nodemanager.c

Joel

> 
> Signed-off-by: Louis Rilling <Louis.Rilling@kerlabs.com>
> ---
>  fs/configfs/item.c       |   18 ++++++++++++++----
>  include/linux/configfs.h |    8 ++++----
>  2 files changed, 18 insertions(+), 8 deletions(-)
> 
> Index: b/fs/configfs/item.c
> ===================================================================
> --- a/fs/configfs/item.c	2008-06-12 17:13:32.000000000 +0200
> +++ b/fs/configfs/item.c	2008-06-12 17:13:35.000000000 +0200
> @@ -112,22 +112,32 @@ int config_item_set_name(struct config_i
>  
>  EXPORT_SYMBOL(config_item_set_name);
>  
> -void config_item_init_type_name(struct config_item *item,
> +int config_item_init_type_name(struct config_item *item,
>  				const char *name,
>  				struct config_item_type *type)
>  {
> -	config_item_set_name(item, name);
> +	int error;
> +
> +	error = config_item_set_name(item, name);
> +	if (error)
> +		return error;
>  	item->ci_type = type;
>  	config_item_init(item);
> +	return 0;
>  }
>  EXPORT_SYMBOL(config_item_init_type_name);
>  
> -void config_group_init_type_name(struct config_group *group, const char *name,
> +int config_group_init_type_name(struct config_group *group, const char *name,
>  			 struct config_item_type *type)
>  {
> -	config_item_set_name(&group->cg_item, name);
> +	int error;
> +
> +	error = config_item_set_name(&group->cg_item, name);
> +	if (error)
> +		return error;
>  	group->cg_item.ci_type = type;
>  	config_group_init(group);
> +	return 0;
>  }
>  EXPORT_SYMBOL(config_group_init_type_name);
>  
> Index: b/include/linux/configfs.h
> ===================================================================
> --- a/include/linux/configfs.h	2008-06-12 17:13:32.000000000 +0200
> +++ b/include/linux/configfs.h	2008-06-12 17:13:35.000000000 +0200
> @@ -71,9 +71,9 @@ static inline char *config_item_name(str
>  }
>  
>  extern void config_item_init(struct config_item *);
> -extern void config_item_init_type_name(struct config_item *item,
> -				       const char *name,
> -				       struct config_item_type *type);
> +extern int config_item_init_type_name(struct config_item *item,
> +				      const char *name,
> +				      struct config_item_type *type);
>  
>  extern struct config_item * config_item_get(struct config_item *);
>  extern void config_item_put(struct config_item *);
> @@ -97,7 +97,7 @@ struct config_group {
>  };
>  
>  extern void config_group_init(struct config_group *group);
> -extern void config_group_init_type_name(struct config_group *group,
> +extern int config_group_init_type_name(struct config_group *group,
>  					const char *name,
>  					struct config_item_type *type);
>  
> 
> -- 
> Dr Louis Rilling			Kerlabs
> Skype: louis.rilling			Batiment Germanium
> Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
> http://www.kerlabs.com/			35700 Rennes
> 

-- 

 There are morethings in heaven and earth, Horatio,
 Than are dreamt of in your philosophy.

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH 2/3] configfs: call drop_link() to cleanup after create_link() failure
  2008-06-12 15:26 ` [RFC][PATCH 2/3] configfs: call drop_link() to cleanup after create_link() failure Louis Rilling
@ 2008-06-12 18:45   ` Joel Becker
  0 siblings, 0 replies; 6+ messages in thread
From: Joel Becker @ 2008-06-12 18:45 UTC (permalink / raw)
  To: Louis Rilling; +Cc: ocfs2-devel, linux-kernel

On Thu, Jun 12, 2008 at 05:26:47PM +0200, Louis Rilling wrote:
> When allow_link() succeeds but create_link() fails, the subsystem is not
> informed of the failure.
> 
> This patch fixes this by calling drop_link() on create_link() failures.
> 
> Signed-off-by: Louis Rilling <Louis.Rilling@kerlabs.com>

This looks good.

Joel

-- 

"Friends may come and go, but enemies accumulate." 
        - Thomas Jones

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-06-12 18:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-12 15:26 [RFC][PATCH 0/3] configfs: Miscellaneous fixes Louis Rilling
2008-06-12 15:26 ` [RFC][PATCH 1/3] configfs: Report errors in config_*_init_type_name() Louis Rilling
2008-06-12 18:42   ` Joel Becker
2008-06-12 15:26 ` [RFC][PATCH 2/3] configfs: call drop_link() to cleanup after create_link() failure Louis Rilling
2008-06-12 18:45   ` Joel Becker
2008-06-12 15:26 ` [RFC][PATCH 3/3] configfs: Protect configfs_dirent s_links list mutations Louis Rilling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox