LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

[patch net-next 2/4] [patch nf-next] IPVS: convert __ip_vs_sched_lock to

To: lvs-devel@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, netfilter-devel@xxxxxxxxxxxxxxx
Subject: [patch net-next 2/4] [patch nf-next] IPVS: convert __ip_vs_sched_lock to a spinlock
Cc: Wensong Zhang <wensong@xxxxxxxxxxxx>, Julian Anastasov <ja@xxxxxx>, Patrick McHardy <kaber@xxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxxxxx>, Stephen Hemminger <shemminger@xxxxxxxxxx>, Eric Dumazet <eric.dumazet@xxxxxxxxx>
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Thu, 26 Aug 2010 21:54:29 +0900
Also rename __ip_vs_sched_lock to ip_vs_sched_lock.

Acked-by: Eric Dumazet <eric.dumazet@xxxxxxxxx>
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

--- 

Compile tested only

Index: nf-next-2.6/net/netfilter/ipvs/ip_vs_sched.c
===================================================================
--- nf-next-2.6.orig/net/netfilter/ipvs/ip_vs_sched.c   2010-08-20 
23:43:29.000000000 +0900
+++ nf-next-2.6/net/netfilter/ipvs/ip_vs_sched.c        2010-08-20 
23:46:02.000000000 +0900
@@ -35,7 +35,7 @@
 static LIST_HEAD(ip_vs_schedulers);
 
 /* lock for service table */
-static DEFINE_RWLOCK(__ip_vs_sched_lock);
+static DEFINE_SPINLOCK(ip_vs_sched_lock);
 
 
 /*
@@ -108,7 +108,7 @@ static struct ip_vs_scheduler *ip_vs_sch
 
        IP_VS_DBG(2, "%s(): sched_name \"%s\"\n", __func__, sched_name);
 
-       read_lock_bh(&__ip_vs_sched_lock);
+       spin_lock_bh(&ip_vs_sched_lock);
 
        list_for_each_entry(sched, &ip_vs_schedulers, n_list) {
                /*
@@ -122,14 +122,14 @@ static struct ip_vs_scheduler *ip_vs_sch
                }
                if (strcmp(sched_name, sched->name)==0) {
                        /* HIT */
-                       read_unlock_bh(&__ip_vs_sched_lock);
+                       spin_unlock_bh(&ip_vs_sched_lock);
                        return sched;
                }
                if (sched->module)
                        module_put(sched->module);
        }
 
-       read_unlock_bh(&__ip_vs_sched_lock);
+       spin_unlock_bh(&ip_vs_sched_lock);
        return NULL;
 }
 
@@ -184,10 +184,10 @@ int register_ip_vs_scheduler(struct ip_v
        /* increase the module use count */
        ip_vs_use_count_inc();
 
-       write_lock_bh(&__ip_vs_sched_lock);
+       spin_lock_bh(&ip_vs_sched_lock);
 
        if (!list_empty(&scheduler->n_list)) {
-               write_unlock_bh(&__ip_vs_sched_lock);
+               spin_unlock_bh(&ip_vs_sched_lock);
                ip_vs_use_count_dec();
                pr_err("%s(): [%s] scheduler already linked\n",
                       __func__, scheduler->name);
@@ -200,7 +200,7 @@ int register_ip_vs_scheduler(struct ip_v
         */
        list_for_each_entry(sched, &ip_vs_schedulers, n_list) {
                if (strcmp(scheduler->name, sched->name) == 0) {
-                       write_unlock_bh(&__ip_vs_sched_lock);
+                       spin_unlock_bh(&ip_vs_sched_lock);
                        ip_vs_use_count_dec();
                        pr_err("%s(): [%s] scheduler already existed "
                               "in the system\n", __func__, scheduler->name);
@@ -211,7 +211,7 @@ int register_ip_vs_scheduler(struct ip_v
         *      Add it into the d-linked scheduler list
         */
        list_add(&scheduler->n_list, &ip_vs_schedulers);
-       write_unlock_bh(&__ip_vs_sched_lock);
+       spin_unlock_bh(&ip_vs_sched_lock);
 
        pr_info("[%s] scheduler registered.\n", scheduler->name);
 
@@ -229,9 +229,9 @@ int unregister_ip_vs_scheduler(struct ip
                return -EINVAL;
        }
 
-       write_lock_bh(&__ip_vs_sched_lock);
+       spin_lock_bh(&ip_vs_sched_lock);
        if (list_empty(&scheduler->n_list)) {
-               write_unlock_bh(&__ip_vs_sched_lock);
+               spin_unlock_bh(&ip_vs_sched_lock);
                pr_err("%s(): [%s] scheduler is not in the list. failed\n",
                       __func__, scheduler->name);
                return -EINVAL;
@@ -241,7 +241,7 @@ int unregister_ip_vs_scheduler(struct ip
         *      Remove it from the d-linked scheduler list
         */
        list_del(&scheduler->n_list);
-       write_unlock_bh(&__ip_vs_sched_lock);
+       spin_unlock_bh(&ip_vs_sched_lock);
 
        /* decrease the module use count */
        ip_vs_use_count_dec();

--
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

<Prev in Thread] Current Thread [Next in Thread>