aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2014-05-05 14:32:17 -0400
committerPravin B Shelar <pshelar@nicira.com>2014-05-22 19:27:34 -0400
commitbb6f9a708d4067713afae2e9eb2637f6b4c01ecb (patch)
tree2df408598e97bcb98c9204c62addb5b187a48153
parentbe52c9e96a6657d117bb0ec6e11438fb246af5c7 (diff)
openvswitch: Clarify locking.
Remove unnecessary locking from functions that are always called with appropriate locking. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Thomas Graf <tgraf@redhat.com> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
-rw-r--r--net/openvswitch/datapath.c13
-rw-r--r--net/openvswitch/flow.c3
2 files changed, 9 insertions, 7 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 90a1e5e66287..138ea0c9e1b3 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -173,6 +173,7 @@ static struct hlist_head *vport_hash_bucket(const struct datapath *dp,
173 return &dp->ports[port_no & (DP_VPORT_HASH_BUCKETS - 1)]; 173 return &dp->ports[port_no & (DP_VPORT_HASH_BUCKETS - 1)];
174} 174}
175 175
176/* Called with ovs_mutex or RCU read lock. */
176struct vport *ovs_lookup_vport(const struct datapath *dp, u16 port_no) 177struct vport *ovs_lookup_vport(const struct datapath *dp, u16 port_no)
177{ 178{
178 struct vport *vport; 179 struct vport *vport;
@@ -652,7 +653,7 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts)
652 + nla_total_size(acts->actions_len); /* OVS_FLOW_ATTR_ACTIONS */ 653 + nla_total_size(acts->actions_len); /* OVS_FLOW_ATTR_ACTIONS */
653} 654}
654 655
655/* Called with ovs_mutex. */ 656/* Called with ovs_mutex or RCU read lock. */
656static int ovs_flow_cmd_fill_info(struct sw_flow *flow, struct datapath *dp, 657static int ovs_flow_cmd_fill_info(struct sw_flow *flow, struct datapath *dp,
657 struct sk_buff *skb, u32 portid, 658 struct sk_buff *skb, u32 portid,
658 u32 seq, u32 flags, u8 cmd) 659 u32 seq, u32 flags, u8 cmd)
@@ -743,6 +744,7 @@ error:
743 return err; 744 return err;
744} 745}
745 746
747/* Must be called with ovs_mutex. */
746static struct sk_buff *ovs_flow_cmd_alloc_info(struct sw_flow *flow, 748static struct sk_buff *ovs_flow_cmd_alloc_info(struct sw_flow *flow,
747 struct genl_info *info) 749 struct genl_info *info)
748{ 750{
@@ -753,6 +755,7 @@ static struct sk_buff *ovs_flow_cmd_alloc_info(struct sw_flow *flow,
753 return genlmsg_new_unicast(len, info, GFP_KERNEL); 755 return genlmsg_new_unicast(len, info, GFP_KERNEL);
754} 756}
755 757
758/* Must be called with ovs_mutex. */
756static struct sk_buff *ovs_flow_cmd_build_info(struct sw_flow *flow, 759static struct sk_buff *ovs_flow_cmd_build_info(struct sw_flow *flow,
757 struct datapath *dp, 760 struct datapath *dp,
758 struct genl_info *info, 761 struct genl_info *info,
@@ -1094,6 +1097,7 @@ static size_t ovs_dp_cmd_msg_size(void)
1094 return msgsize; 1097 return msgsize;
1095} 1098}
1096 1099
1100/* Called with ovs_mutex or RCU read lock. */
1097static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb, 1101static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb,
1098 u32 portid, u32 seq, u32 flags, u8 cmd) 1102 u32 portid, u32 seq, u32 flags, u8 cmd)
1099{ 1103{
@@ -1109,9 +1113,7 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb,
1109 1113
1110 ovs_header->dp_ifindex = get_dpifindex(dp); 1114 ovs_header->dp_ifindex = get_dpifindex(dp);
1111 1115
1112 rcu_read_lock();
1113 err = nla_put_string(skb, OVS_DP_ATTR_NAME, ovs_dp_name(dp)); 1116 err = nla_put_string(skb, OVS_DP_ATTR_NAME, ovs_dp_name(dp));
1114 rcu_read_unlock();
1115 if (err) 1117 if (err)
1116 goto nla_put_failure; 1118 goto nla_put_failure;
1117 1119
@@ -1136,6 +1138,7 @@ error:
1136 return -EMSGSIZE; 1138 return -EMSGSIZE;
1137} 1139}
1138 1140
1141/* Must be called with ovs_mutex. */
1139static struct sk_buff *ovs_dp_cmd_build_info(struct datapath *dp, 1142static struct sk_buff *ovs_dp_cmd_build_info(struct datapath *dp,
1140 struct genl_info *info, u8 cmd) 1143 struct genl_info *info, u8 cmd)
1141{ 1144{
@@ -1154,7 +1157,7 @@ static struct sk_buff *ovs_dp_cmd_build_info(struct datapath *dp,
1154 return skb; 1157 return skb;
1155} 1158}
1156 1159
1157/* Called with ovs_mutex. */ 1160/* Called with rcu_read_lock or ovs_mutex. */
1158static struct datapath *lookup_datapath(struct net *net, 1161static struct datapath *lookup_datapath(struct net *net,
1159 struct ovs_header *ovs_header, 1162 struct ovs_header *ovs_header,
1160 struct nlattr *a[OVS_DP_ATTR_MAX + 1]) 1163 struct nlattr *a[OVS_DP_ATTR_MAX + 1])
@@ -1166,10 +1169,8 @@ static struct datapath *lookup_datapath(struct net *net,
1166 else { 1169 else {
1167 struct vport *vport; 1170 struct vport *vport;
1168 1171
1169 rcu_read_lock();
1170 vport = ovs_vport_locate(net, nla_data(a[OVS_DP_ATTR_NAME])); 1172 vport = ovs_vport_locate(net, nla_data(a[OVS_DP_ATTR_NAME]));
1171 dp = vport && vport->port_no == OVSP_LOCAL ? vport->dp : NULL; 1173 dp = vport && vport->port_no == OVSP_LOCAL ? vport->dp : NULL;
1172 rcu_read_unlock();
1173 } 1174 }
1174 return dp ? dp : ERR_PTR(-ENODEV); 1175 return dp ? dp : ERR_PTR(-ENODEV);
1175} 1176}
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 6d8d2da0a8ec..1019fc1db06e 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -122,6 +122,7 @@ unlock:
122 spin_unlock(&stats->lock); 122 spin_unlock(&stats->lock);
123} 123}
124 124
125/* Called with ovs_mutex. */
125void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats, 126void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats,
126 unsigned long *used, __be16 *tcp_flags) 127 unsigned long *used, __be16 *tcp_flags)
127{ 128{
@@ -132,7 +133,7 @@ void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats,
132 memset(ovs_stats, 0, sizeof(*ovs_stats)); 133 memset(ovs_stats, 0, sizeof(*ovs_stats));
133 134
134 for_each_node(node) { 135 for_each_node(node) {
135 struct flow_stats *stats = rcu_dereference(flow->stats[node]); 136 struct flow_stats *stats = ovsl_dereference(flow->stats[node]);
136 137
137 if (stats) { 138 if (stats) {
138 /* Local CPU may write on non-local stats, so we must 139 /* Local CPU may write on non-local stats, so we must