Commit e5c140a3 authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

decnet: convert dndev_lock to spinlock

There is no reason for this lock to be reader/writer since
the reader only has lock held for a very brief period.
The overhead of read_lock is more expensive than spinlock.

Compile tested only, I am not a decnet user.
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 41bdecf1
...@@ -68,7 +68,7 @@ extern struct neigh_table dn_neigh_table; ...@@ -68,7 +68,7 @@ extern struct neigh_table dn_neigh_table;
*/ */
__le16 decnet_address = 0; __le16 decnet_address = 0;
static DEFINE_RWLOCK(dndev_lock); static DEFINE_SPINLOCK(dndev_lock);
static struct net_device *decnet_default_device; static struct net_device *decnet_default_device;
static BLOCKING_NOTIFIER_HEAD(dnaddr_chain); static BLOCKING_NOTIFIER_HEAD(dnaddr_chain);
...@@ -557,7 +557,8 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg) ...@@ -557,7 +557,8 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg)
struct net_device *dn_dev_get_default(void) struct net_device *dn_dev_get_default(void)
{ {
struct net_device *dev; struct net_device *dev;
read_lock(&dndev_lock);
spin_lock(&dndev_lock);
dev = decnet_default_device; dev = decnet_default_device;
if (dev) { if (dev) {
if (dev->dn_ptr) if (dev->dn_ptr)
...@@ -565,7 +566,8 @@ struct net_device *dn_dev_get_default(void) ...@@ -565,7 +566,8 @@ struct net_device *dn_dev_get_default(void)
else else
dev = NULL; dev = NULL;
} }
read_unlock(&dndev_lock); spin_unlock(&dndev_lock);
return dev; return dev;
} }
...@@ -575,13 +577,15 @@ int dn_dev_set_default(struct net_device *dev, int force) ...@@ -575,13 +577,15 @@ int dn_dev_set_default(struct net_device *dev, int force)
int rv = -EBUSY; int rv = -EBUSY;
if (!dev->dn_ptr) if (!dev->dn_ptr)
return -ENODEV; return -ENODEV;
write_lock(&dndev_lock);
spin_lock(&dndev_lock);
if (force || decnet_default_device == NULL) { if (force || decnet_default_device == NULL) {
old = decnet_default_device; old = decnet_default_device;
decnet_default_device = dev; decnet_default_device = dev;
rv = 0; rv = 0;
} }
write_unlock(&dndev_lock); spin_unlock(&dndev_lock);
if (old) if (old)
dev_put(old); dev_put(old);
return rv; return rv;
...@@ -589,13 +593,14 @@ int dn_dev_set_default(struct net_device *dev, int force) ...@@ -589,13 +593,14 @@ int dn_dev_set_default(struct net_device *dev, int force)
static void dn_dev_check_default(struct net_device *dev) static void dn_dev_check_default(struct net_device *dev)
{ {
write_lock(&dndev_lock); spin_lock(&dndev_lock);
if (dev == decnet_default_device) { if (dev == decnet_default_device) {
decnet_default_device = NULL; decnet_default_device = NULL;
} else { } else {
dev = NULL; dev = NULL;
} }
write_unlock(&dndev_lock); spin_unlock(&dndev_lock);
if (dev) if (dev)
dev_put(dev); dev_put(dev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment