diff options
author | Stephen Hemminger <shemminger@osdl.org> | 2006-08-29 19:48:09 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-22 17:54:13 -0400 |
commit | 832b4c5e184391773e462653aa862a8cab71f38d (patch) | |
tree | 46eb431ae2f0e2b58a4929bbf3363f64633f10b0 /net/ipv4/fib_semantics.c | |
parent | b14295532421c40f82ee099fdbd3d011f022e756 (diff) |
[IPV4] fib: convert reader/writer to spinlock
Ther is no point in using a more expensive reader/writer lock
for a low contention lock like the fib_info_lock. The only
reader case is in handling route redirects.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_semantics.c')
-rw-r--r-- | net/ipv4/fib_semantics.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 51738000f3dc..38bca473c7e2 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -49,7 +49,7 @@ | |||
49 | 49 | ||
50 | #define FSprintk(a...) | 50 | #define FSprintk(a...) |
51 | 51 | ||
52 | static DEFINE_RWLOCK(fib_info_lock); | 52 | static DEFINE_SPINLOCK(fib_info_lock); |
53 | static struct hlist_head *fib_info_hash; | 53 | static struct hlist_head *fib_info_hash; |
54 | static struct hlist_head *fib_info_laddrhash; | 54 | static struct hlist_head *fib_info_laddrhash; |
55 | static unsigned int fib_hash_size; | 55 | static unsigned int fib_hash_size; |
@@ -159,7 +159,7 @@ void free_fib_info(struct fib_info *fi) | |||
159 | 159 | ||
160 | void fib_release_info(struct fib_info *fi) | 160 | void fib_release_info(struct fib_info *fi) |
161 | { | 161 | { |
162 | write_lock_bh(&fib_info_lock); | 162 | spin_lock_bh(&fib_info_lock); |
163 | if (fi && --fi->fib_treeref == 0) { | 163 | if (fi && --fi->fib_treeref == 0) { |
164 | hlist_del(&fi->fib_hash); | 164 | hlist_del(&fi->fib_hash); |
165 | if (fi->fib_prefsrc) | 165 | if (fi->fib_prefsrc) |
@@ -172,7 +172,7 @@ void fib_release_info(struct fib_info *fi) | |||
172 | fi->fib_dead = 1; | 172 | fi->fib_dead = 1; |
173 | fib_info_put(fi); | 173 | fib_info_put(fi); |
174 | } | 174 | } |
175 | write_unlock_bh(&fib_info_lock); | 175 | spin_unlock_bh(&fib_info_lock); |
176 | } | 176 | } |
177 | 177 | ||
178 | static __inline__ int nh_comp(const struct fib_info *fi, const struct fib_info *ofi) | 178 | static __inline__ int nh_comp(const struct fib_info *fi, const struct fib_info *ofi) |
@@ -254,7 +254,7 @@ int ip_fib_check_default(u32 gw, struct net_device *dev) | |||
254 | struct fib_nh *nh; | 254 | struct fib_nh *nh; |
255 | unsigned int hash; | 255 | unsigned int hash; |
256 | 256 | ||
257 | read_lock(&fib_info_lock); | 257 | spin_lock(&fib_info_lock); |
258 | 258 | ||
259 | hash = fib_devindex_hashfn(dev->ifindex); | 259 | hash = fib_devindex_hashfn(dev->ifindex); |
260 | head = &fib_info_devhash[hash]; | 260 | head = &fib_info_devhash[hash]; |
@@ -262,12 +262,12 @@ int ip_fib_check_default(u32 gw, struct net_device *dev) | |||
262 | if (nh->nh_dev == dev && | 262 | if (nh->nh_dev == dev && |
263 | nh->nh_gw == gw && | 263 | nh->nh_gw == gw && |
264 | !(nh->nh_flags&RTNH_F_DEAD)) { | 264 | !(nh->nh_flags&RTNH_F_DEAD)) { |
265 | read_unlock(&fib_info_lock); | 265 | spin_unlock(&fib_info_lock); |
266 | return 0; | 266 | return 0; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | read_unlock(&fib_info_lock); | 270 | spin_unlock(&fib_info_lock); |
271 | 271 | ||
272 | return -1; | 272 | return -1; |
273 | } | 273 | } |
@@ -598,7 +598,7 @@ static void fib_hash_move(struct hlist_head *new_info_hash, | |||
598 | unsigned int old_size = fib_hash_size; | 598 | unsigned int old_size = fib_hash_size; |
599 | unsigned int i, bytes; | 599 | unsigned int i, bytes; |
600 | 600 | ||
601 | write_lock_bh(&fib_info_lock); | 601 | spin_lock_bh(&fib_info_lock); |
602 | old_info_hash = fib_info_hash; | 602 | old_info_hash = fib_info_hash; |
603 | old_laddrhash = fib_info_laddrhash; | 603 | old_laddrhash = fib_info_laddrhash; |
604 | fib_hash_size = new_size; | 604 | fib_hash_size = new_size; |
@@ -639,7 +639,7 @@ static void fib_hash_move(struct hlist_head *new_info_hash, | |||
639 | } | 639 | } |
640 | fib_info_laddrhash = new_laddrhash; | 640 | fib_info_laddrhash = new_laddrhash; |
641 | 641 | ||
642 | write_unlock_bh(&fib_info_lock); | 642 | spin_unlock_bh(&fib_info_lock); |
643 | 643 | ||
644 | bytes = old_size * sizeof(struct hlist_head *); | 644 | bytes = old_size * sizeof(struct hlist_head *); |
645 | fib_hash_free(old_info_hash, bytes); | 645 | fib_hash_free(old_info_hash, bytes); |
@@ -820,7 +820,7 @@ link_it: | |||
820 | 820 | ||
821 | fi->fib_treeref++; | 821 | fi->fib_treeref++; |
822 | atomic_inc(&fi->fib_clntref); | 822 | atomic_inc(&fi->fib_clntref); |
823 | write_lock_bh(&fib_info_lock); | 823 | spin_lock_bh(&fib_info_lock); |
824 | hlist_add_head(&fi->fib_hash, | 824 | hlist_add_head(&fi->fib_hash, |
825 | &fib_info_hash[fib_info_hashfn(fi)]); | 825 | &fib_info_hash[fib_info_hashfn(fi)]); |
826 | if (fi->fib_prefsrc) { | 826 | if (fi->fib_prefsrc) { |
@@ -839,7 +839,7 @@ link_it: | |||
839 | head = &fib_info_devhash[hash]; | 839 | head = &fib_info_devhash[hash]; |
840 | hlist_add_head(&nh->nh_hash, head); | 840 | hlist_add_head(&nh->nh_hash, head); |
841 | } endfor_nexthops(fi) | 841 | } endfor_nexthops(fi) |
842 | write_unlock_bh(&fib_info_lock); | 842 | spin_unlock_bh(&fib_info_lock); |
843 | return fi; | 843 | return fi; |
844 | 844 | ||
845 | err_inval: | 845 | err_inval: |