Skip to content

Commit 1c5113c

Browse files
sowminivdavem330
authored andcommitted
RDS: Initialize all RDS_MPATH_WORKERS in __rds_conn_create
Add a for() loop in __rds_conn_create to initialize all the conn_paths, in preparate for MP capable transports. Signed-off-by: Sowmini Varadhan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fb1b3dc commit 1c5113c

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

net/rds/connection.c

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,32 @@ static void rds_conn_reset(struct rds_connection *conn)
111111
* reliability guarantees of RDS. */
112112
}
113113

114+
static void __rds_conn_path_init(struct rds_connection *conn,
115+
struct rds_conn_path *cp, bool is_outgoing)
116+
{
117+
spin_lock_init(&cp->cp_lock);
118+
cp->cp_next_tx_seq = 1;
119+
init_waitqueue_head(&cp->cp_waitq);
120+
INIT_LIST_HEAD(&cp->cp_send_queue);
121+
INIT_LIST_HEAD(&cp->cp_retrans);
122+
123+
cp->cp_conn = conn;
124+
atomic_set(&cp->cp_state, RDS_CONN_DOWN);
125+
cp->cp_send_gen = 0;
126+
/* cp_outgoing is per-path. So we can only set it here
127+
* for the single-path transports.
128+
*/
129+
if (!conn->c_trans->t_mp_capable)
130+
cp->cp_outgoing = (is_outgoing ? 1 : 0);
131+
cp->cp_reconnect_jiffies = 0;
132+
INIT_DELAYED_WORK(&cp->cp_send_w, rds_send_worker);
133+
INIT_DELAYED_WORK(&cp->cp_recv_w, rds_recv_worker);
134+
INIT_DELAYED_WORK(&cp->cp_conn_w, rds_connect_worker);
135+
INIT_WORK(&cp->cp_down_w, rds_shutdown_worker);
136+
mutex_init(&cp->cp_cm_lock);
137+
cp->cp_flags = 0;
138+
}
139+
114140
/*
115141
* There is only every one 'conn' for a given pair of addresses in the
116142
* system at a time. They contain messages to be retransmitted and so
@@ -154,14 +180,8 @@ static struct rds_connection *__rds_conn_create(struct net *net,
154180
INIT_HLIST_NODE(&conn->c_hash_node);
155181
conn->c_laddr = laddr;
156182
conn->c_faddr = faddr;
157-
spin_lock_init(&conn->c_lock);
158-
conn->c_next_tx_seq = 1;
159-
conn->c_path[0].cp_conn = conn;
160-
rds_conn_net_set(conn, net);
161183

162-
init_waitqueue_head(&conn->c_waitq);
163-
INIT_LIST_HEAD(&conn->c_send_queue);
164-
INIT_LIST_HEAD(&conn->c_retrans);
184+
rds_conn_net_set(conn, net);
165185

166186
ret = rds_cong_get_maps(conn);
167187
if (ret) {
@@ -197,17 +217,6 @@ static struct rds_connection *__rds_conn_create(struct net *net,
197217
goto out;
198218
}
199219

200-
atomic_set(&conn->c_state, RDS_CONN_DOWN);
201-
conn->c_send_gen = 0;
202-
conn->c_path[0].cp_outgoing = (is_outgoing ? 1 : 0);
203-
conn->c_reconnect_jiffies = 0;
204-
INIT_DELAYED_WORK(&conn->c_send_w, rds_send_worker);
205-
INIT_DELAYED_WORK(&conn->c_recv_w, rds_recv_worker);
206-
INIT_DELAYED_WORK(&conn->c_conn_w, rds_connect_worker);
207-
INIT_WORK(&conn->c_down_w, rds_shutdown_worker);
208-
mutex_init(&conn->c_cm_lock);
209-
conn->c_flags = 0;
210-
211220
rdsdebug("allocated conn %p for %pI4 -> %pI4 over %s %s\n",
212221
conn, &laddr, &faddr,
213222
trans->t_name ? trans->t_name : "[unknown]",
@@ -224,7 +233,7 @@ static struct rds_connection *__rds_conn_create(struct net *net,
224233
if (parent) {
225234
/* Creating passive conn */
226235
if (parent->c_passive) {
227-
trans->conn_free(conn->c_transport_data);
236+
trans->conn_free(conn->c_path[0].cp_transport_data);
228237
kmem_cache_free(rds_conn_slab, conn);
229238
conn = parent->c_passive;
230239
} else {
@@ -238,10 +247,26 @@ static struct rds_connection *__rds_conn_create(struct net *net,
238247

239248
found = rds_conn_lookup(net, head, laddr, faddr, trans);
240249
if (found) {
241-
trans->conn_free(conn->c_transport_data);
250+
struct rds_conn_path *cp;
251+
int i;
252+
253+
for (i = 0; i < RDS_MPATH_WORKERS; i++) {
254+
cp = &conn->c_path[i];
255+
trans->conn_free(cp->cp_transport_data);
256+
if (!trans->t_mp_capable)
257+
break;
258+
}
242259
kmem_cache_free(rds_conn_slab, conn);
243260
conn = found;
244261
} else {
262+
int i;
263+
264+
for (i = 0; i < RDS_MPATH_WORKERS; i++) {
265+
__rds_conn_path_init(conn, &conn->c_path[i],
266+
is_outgoing);
267+
conn->c_path[i].cp_index = i;
268+
}
269+
245270
hlist_add_head_rcu(&conn->c_hash_node, head);
246271
rds_cong_add_conn(conn);
247272
rds_conn_count++;

0 commit comments

Comments
 (0)