diff options
author | Stephen Hemminger <shemminger@osdl.org> | 2006-03-21 01:23:58 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-21 01:23:58 -0500 |
commit | 6756ae4b4e97aba48c042b4aa6b77a18f507d2cb (patch) | |
tree | 05bf37711d782fb0089d474716026c44a454f89b /net/core | |
parent | 253aa11578c1b89757282430891bb66ae5300092 (diff) |
[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>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 8 | ||||
-rw-r--r-- | net/core/link_watch.c | 4 | ||||
-rw-r--r-- | net/core/netpoll.c | 6 | ||||
-rw-r--r-- | net/core/rtnetlink.c | 28 |
4 files changed, 26 insertions, 20 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 8763c99fcb84..be1d896cc5b9 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -2466,9 +2466,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg) | |||
2466 | */ | 2466 | */ |
2467 | 2467 | ||
2468 | if (cmd == SIOCGIFCONF) { | 2468 | if (cmd == SIOCGIFCONF) { |
2469 | rtnl_shlock(); | 2469 | rtnl_lock(); |
2470 | ret = dev_ifconf((char __user *) arg); | 2470 | ret = dev_ifconf((char __user *) arg); |
2471 | rtnl_shunlock(); | 2471 | rtnl_unlock(); |
2472 | return ret; | 2472 | return ret; |
2473 | } | 2473 | } |
2474 | if (cmd == SIOCGIFNAME) | 2474 | if (cmd == SIOCGIFNAME) |
@@ -2877,7 +2877,7 @@ static void netdev_wait_allrefs(struct net_device *dev) | |||
2877 | rebroadcast_time = warning_time = jiffies; | 2877 | rebroadcast_time = warning_time = jiffies; |
2878 | while (atomic_read(&dev->refcnt) != 0) { | 2878 | while (atomic_read(&dev->refcnt) != 0) { |
2879 | if (time_after(jiffies, rebroadcast_time + 1 * HZ)) { | 2879 | if (time_after(jiffies, rebroadcast_time + 1 * HZ)) { |
2880 | rtnl_shlock(); | 2880 | rtnl_lock(); |
2881 | 2881 | ||
2882 | /* Rebroadcast unregister notification */ | 2882 | /* Rebroadcast unregister notification */ |
2883 | notifier_call_chain(&netdev_chain, | 2883 | notifier_call_chain(&netdev_chain, |
@@ -2894,7 +2894,7 @@ static void netdev_wait_allrefs(struct net_device *dev) | |||
2894 | linkwatch_run_queue(); | 2894 | linkwatch_run_queue(); |
2895 | } | 2895 | } |
2896 | 2896 | ||
2897 | rtnl_shunlock(); | 2897 | __rtnl_unlock(); |
2898 | 2898 | ||
2899 | rebroadcast_time = jiffies; | 2899 | rebroadcast_time = jiffies; |
2900 | } | 2900 | } |
diff --git a/net/core/link_watch.c b/net/core/link_watch.c index e82a451d330b..341de44c7ed1 100644 --- a/net/core/link_watch.c +++ b/net/core/link_watch.c | |||
@@ -139,9 +139,9 @@ static void linkwatch_event(void *dummy) | |||
139 | linkwatch_nextevent = jiffies + HZ; | 139 | linkwatch_nextevent = jiffies + HZ; |
140 | clear_bit(LW_RUNNING, &linkwatch_flags); | 140 | clear_bit(LW_RUNNING, &linkwatch_flags); |
141 | 141 | ||
142 | rtnl_shlock(); | 142 | rtnl_lock(); |
143 | linkwatch_run_queue(); | 143 | linkwatch_run_queue(); |
144 | rtnl_shunlock(); | 144 | rtnl_unlock(); |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index ea51f8d02eb8..e8e05cebd95a 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -669,14 +669,14 @@ int netpoll_setup(struct netpoll *np) | |||
669 | printk(KERN_INFO "%s: device %s not up yet, forcing it\n", | 669 | printk(KERN_INFO "%s: device %s not up yet, forcing it\n", |
670 | np->name, np->dev_name); | 670 | np->name, np->dev_name); |
671 | 671 | ||
672 | rtnl_shlock(); | 672 | rtnl_lock(); |
673 | if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) { | 673 | if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) { |
674 | printk(KERN_ERR "%s: failed to open %s\n", | 674 | printk(KERN_ERR "%s: failed to open %s\n", |
675 | np->name, np->dev_name); | 675 | np->name, np->dev_name); |
676 | rtnl_shunlock(); | 676 | rtnl_unlock(); |
677 | goto release; | 677 | goto release; |
678 | } | 678 | } |
679 | rtnl_shunlock(); | 679 | rtnl_unlock(); |
680 | 680 | ||
681 | atleast = jiffies + HZ/10; | 681 | atleast = jiffies + HZ/10; |
682 | atmost = jiffies + 4*HZ; | 682 | atmost = jiffies + 4*HZ; |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 1c15a907066f..ae10d3740faa 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/skbuff.h> | 35 | #include <linux/skbuff.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/security.h> | 37 | #include <linux/security.h> |
38 | #include <linux/mutex.h> | ||
38 | 39 | ||
39 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
40 | #include <asm/system.h> | 41 | #include <asm/system.h> |
@@ -51,25 +52,31 @@ | |||
51 | #include <net/pkt_sched.h> | 52 | #include <net/pkt_sched.h> |
52 | #include <net/netlink.h> | 53 | #include <net/netlink.h> |
53 | 54 | ||
54 | DECLARE_MUTEX(rtnl_sem); | 55 | static DEFINE_MUTEX(rtnl_mutex); |
55 | 56 | ||
56 | void rtnl_lock(void) | 57 | void rtnl_lock(void) |
57 | { | 58 | { |
58 | rtnl_shlock(); | 59 | mutex_lock(&rtnl_mutex); |
59 | } | 60 | } |
60 | 61 | ||
61 | int rtnl_lock_interruptible(void) | 62 | void __rtnl_unlock(void) |
62 | { | 63 | { |
63 | return down_interruptible(&rtnl_sem); | 64 | mutex_unlock(&rtnl_mutex); |
64 | } | 65 | } |
65 | 66 | ||
66 | void rtnl_unlock(void) | 67 | void rtnl_unlock(void) |
67 | { | 68 | { |
68 | rtnl_shunlock(); | 69 | mutex_unlock(&rtnl_mutex); |
69 | 70 | if (rtnl && rtnl->sk_receive_queue.qlen) | |
71 | rtnl->sk_data_ready(rtnl, 0); | ||
70 | netdev_run_todo(); | 72 | netdev_run_todo(); |
71 | } | 73 | } |
72 | 74 | ||
75 | int rtnl_trylock(void) | ||
76 | { | ||
77 | return mutex_trylock(&rtnl_mutex); | ||
78 | } | ||
79 | |||
73 | int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len) | 80 | int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len) |
74 | { | 81 | { |
75 | memset(tb, 0, sizeof(struct rtattr*)*maxattr); | 82 | memset(tb, 0, sizeof(struct rtattr*)*maxattr); |
@@ -625,9 +632,9 @@ static void rtnetlink_rcv(struct sock *sk, int len) | |||
625 | unsigned int qlen = 0; | 632 | unsigned int qlen = 0; |
626 | 633 | ||
627 | do { | 634 | do { |
628 | rtnl_lock(); | 635 | mutex_lock(&rtnl_mutex); |
629 | netlink_run_queue(sk, &qlen, &rtnetlink_rcv_msg); | 636 | netlink_run_queue(sk, &qlen, &rtnetlink_rcv_msg); |
630 | up(&rtnl_sem); | 637 | mutex_unlock(&rtnl_mutex); |
631 | 638 | ||
632 | netdev_run_todo(); | 639 | netdev_run_todo(); |
633 | } while (qlen); | 640 | } while (qlen); |
@@ -704,6 +711,5 @@ EXPORT_SYMBOL(rtnetlink_links); | |||
704 | EXPORT_SYMBOL(rtnetlink_put_metrics); | 711 | EXPORT_SYMBOL(rtnetlink_put_metrics); |
705 | EXPORT_SYMBOL(rtnl); | 712 | EXPORT_SYMBOL(rtnl); |
706 | EXPORT_SYMBOL(rtnl_lock); | 713 | EXPORT_SYMBOL(rtnl_lock); |
707 | EXPORT_SYMBOL(rtnl_lock_interruptible); | 714 | EXPORT_SYMBOL(rtnl_trylock); |
708 | EXPORT_SYMBOL(rtnl_sem); | ||
709 | EXPORT_SYMBOL(rtnl_unlock); | 715 | EXPORT_SYMBOL(rtnl_unlock); |