b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH maint] batman-adv: wait for rtnl in batadv_store_mesh_iface instead of failing if it is taken
@ 2013-05-28 15:32 Matthias Schiffer
  2013-05-28 15:42 ` Simon Wunderlich
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Schiffer @ 2013-05-28 15:32 UTC (permalink / raw)
  To: b.a.t.m.a.n

The rtnl_lock in batadv_store_mesh_iface has been converted to a rtnl_trylock
some time ago to avoid a possible deadlock between rtnl and s_active on removal
of the sysfs nodes.

The behaviour introduced by that was quite confusing as it could lead to the
sysfs store to fail, making batman-adv setup scripts unreliable. As recently the
sysfs removal was postponed to a worker not running with the rtnl taken, the
deadlock can't occur any more and it is safe to change the trylock back to a
lock to make the sysfs store reliable again.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
 sysfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/sysfs.c b/sysfs.c
index 15a22ef..929e304 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -582,10 +582,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
 	    (strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0))
 		goto out;
 
-	if (!rtnl_trylock()) {
-		ret = -ERESTARTSYS;
-		goto out;
-	}
+	rtnl_lock();
 
 	if (status_tmp == BATADV_IF_NOT_IN_USE) {
 		batadv_hardif_disable_interface(hard_iface,
-- 
1.8.3


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

* Re: [B.A.T.M.A.N.] [PATCH maint] batman-adv: wait for rtnl in batadv_store_mesh_iface instead of failing if it is taken
  2013-05-28 15:32 [B.A.T.M.A.N.] [PATCH maint] batman-adv: wait for rtnl in batadv_store_mesh_iface instead of failing if it is taken Matthias Schiffer
@ 2013-05-28 15:42 ` Simon Wunderlich
  2013-06-04  9:14   ` Marek Lindner
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Wunderlich @ 2013-05-28 15:42 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]

On Tue, May 28, 2013 at 05:32:32PM +0200, Matthias Schiffer wrote:
> The rtnl_lock in batadv_store_mesh_iface has been converted to a rtnl_trylock
> some time ago to avoid a possible deadlock between rtnl and s_active on removal
> of the sysfs nodes.
> 
> The behaviour introduced by that was quite confusing as it could lead to the
> sysfs store to fail, making batman-adv setup scripts unreliable. As recently the
> sysfs removal was postponed to a worker not running with the rtnl taken, the
> deadlock can't occur any more and it is safe to change the trylock back to a
> lock to make the sysfs store reliable again.
> 
> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>

Reviewed-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>

Thanks for posting,
	Simon

> ---
>  sysfs.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/sysfs.c b/sysfs.c
> index 15a22ef..929e304 100644
> --- a/sysfs.c
> +++ b/sysfs.c
> @@ -582,10 +582,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
>  	    (strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0))
>  		goto out;
>  
> -	if (!rtnl_trylock()) {
> -		ret = -ERESTARTSYS;
> -		goto out;
> -	}
> +	rtnl_lock();
>  
>  	if (status_tmp == BATADV_IF_NOT_IN_USE) {
>  		batadv_hardif_disable_interface(hard_iface,
> -- 
> 1.8.3
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [B.A.T.M.A.N.] [PATCH maint] batman-adv: wait for rtnl in batadv_store_mesh_iface instead of failing if it is taken
  2013-05-28 15:42 ` Simon Wunderlich
@ 2013-06-04  9:14   ` Marek Lindner
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Lindner @ 2013-06-04  9:14 UTC (permalink / raw)
  To: b.a.t.m.a.n

On Tuesday, May 28, 2013 23:42:48 Simon Wunderlich wrote:
>   On Tue, May 28, 2013 at 05:32:32PM +0200, Matthias Schiffer wrote:
> > The rtnl_lock in batadv_store_mesh_iface has been converted to a
> > rtnl_trylock some time ago to avoid a possible deadlock between rtnl and
> > s_active on removal of the sysfs nodes.
> >
> > The behaviour introduced by that was quite confusing as it could lead to
> > the sysfs store to fail, making batman-adv setup scripts unreliable. As
> > recently the sysfs removal was postponed to a worker not running with
> > the rtnl taken, the deadlock can't occur any more and it is safe to
> > change the trylock back to a lock to make the sysfs store reliable
> > again.
> >
> > Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
> 
> Reviewed-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>

Applied in revision 96cd772.

Thanks,
Marek

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

end of thread, other threads:[~2013-06-04  9:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-28 15:32 [B.A.T.M.A.N.] [PATCH maint] batman-adv: wait for rtnl in batadv_store_mesh_iface instead of failing if it is taken Matthias Schiffer
2013-05-28 15:42 ` Simon Wunderlich
2013-06-04  9:14   ` Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).