[NET]: Convert RTNL to mutex.

This patch turns the RTNL from a semaphore to a new 2.6.16 mutex and
gets rid of some of the leftover legacy.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Stephen Hemminger
2006-03-20 22:23:58 -08:00
committed by David S. Miller
parent 253aa11578
commit 6756ae4b4e
8 changed files with 51 additions and 51 deletions

View File

@@ -2466,9 +2466,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
*/
if (cmd == SIOCGIFCONF) {
rtnl_shlock();
rtnl_lock();
ret = dev_ifconf((char __user *) arg);
rtnl_shunlock();
rtnl_unlock();
return ret;
}
if (cmd == SIOCGIFNAME)
@@ -2877,7 +2877,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
rebroadcast_time = warning_time = jiffies;
while (atomic_read(&dev->refcnt) != 0) {
if (time_after(jiffies, rebroadcast_time + 1 * HZ)) {
rtnl_shlock();
rtnl_lock();
/* Rebroadcast unregister notification */
notifier_call_chain(&netdev_chain,
@@ -2894,7 +2894,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
linkwatch_run_queue();
}
rtnl_shunlock();
__rtnl_unlock();
rebroadcast_time = jiffies;
}

View File

@@ -139,9 +139,9 @@ static void linkwatch_event(void *dummy)
linkwatch_nextevent = jiffies + HZ;
clear_bit(LW_RUNNING, &linkwatch_flags);
rtnl_shlock();
rtnl_lock();
linkwatch_run_queue();
rtnl_shunlock();
rtnl_unlock();
}

View File

@@ -669,14 +669,14 @@ int netpoll_setup(struct netpoll *np)
printk(KERN_INFO "%s: device %s not up yet, forcing it\n",
np->name, np->dev_name);
rtnl_shlock();
rtnl_lock();
if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) {
printk(KERN_ERR "%s: failed to open %s\n",
np->name, np->dev_name);
rtnl_shunlock();
rtnl_unlock();
goto release;
}
rtnl_shunlock();
rtnl_unlock();
atleast = jiffies + HZ/10;
atmost = jiffies + 4*HZ;

View File

@@ -35,6 +35,7 @@
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/security.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/system.h>
@@ -51,25 +52,31 @@
#include <net/pkt_sched.h>
#include <net/netlink.h>
DECLARE_MUTEX(rtnl_sem);
static DEFINE_MUTEX(rtnl_mutex);
void rtnl_lock(void)
{
rtnl_shlock();
mutex_lock(&rtnl_mutex);
}
int rtnl_lock_interruptible(void)
void __rtnl_unlock(void)
{
return down_interruptible(&rtnl_sem);
mutex_unlock(&rtnl_mutex);
}
void rtnl_unlock(void)
{
rtnl_shunlock();
mutex_unlock(&rtnl_mutex);
if (rtnl && rtnl->sk_receive_queue.qlen)
rtnl->sk_data_ready(rtnl, 0);
netdev_run_todo();
}
int rtnl_trylock(void)
{
return mutex_trylock(&rtnl_mutex);
}
int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len)
{
memset(tb, 0, sizeof(struct rtattr*)*maxattr);
@@ -625,9 +632,9 @@ static void rtnetlink_rcv(struct sock *sk, int len)
unsigned int qlen = 0;
do {
rtnl_lock();
mutex_lock(&rtnl_mutex);
netlink_run_queue(sk, &qlen, &rtnetlink_rcv_msg);
up(&rtnl_sem);
mutex_unlock(&rtnl_mutex);
netdev_run_todo();
} while (qlen);
@@ -704,6 +711,5 @@ EXPORT_SYMBOL(rtnetlink_links);
EXPORT_SYMBOL(rtnetlink_put_metrics);
EXPORT_SYMBOL(rtnl);
EXPORT_SYMBOL(rtnl_lock);
EXPORT_SYMBOL(rtnl_lock_interruptible);
EXPORT_SYMBOL(rtnl_sem);
EXPORT_SYMBOL(rtnl_trylock);
EXPORT_SYMBOL(rtnl_unlock);