threads.c (552c69b36ebd966186573b9c7a286b390935cce1) | threads.c (eee2fa6ab3225192d6d894c54a6fb02ac9efdff6) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2006 Oracle. All rights reserved. | 2 * Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved. |
3 * 4 * This software is available to you under a choice of one of two 5 * licenses. You may choose to be licensed under the terms of the GNU 6 * General Public License (GPL) Version 2, available from the file 7 * COPYING in the main directory of this source tree, or the 8 * OpenIB.org BSD license below: 9 * 10 * Redistribution and use in source and binary forms, with or --- 66 unchanged lines hidden (view full) --- 77 printk(KERN_WARNING "%s: Cannot transition to state UP, " 78 "current state is %d\n", 79 __func__, 80 atomic_read(&cp->cp_state)); 81 rds_conn_path_drop(cp, false); 82 return; 83 } 84 | 3 * 4 * This software is available to you under a choice of one of two 5 * licenses. You may choose to be licensed under the terms of the GNU 6 * General Public License (GPL) Version 2, available from the file 7 * COPYING in the main directory of this source tree, or the 8 * OpenIB.org BSD license below: 9 * 10 * Redistribution and use in source and binary forms, with or --- 66 unchanged lines hidden (view full) --- 77 printk(KERN_WARNING "%s: Cannot transition to state UP, " 78 "current state is %d\n", 79 __func__, 80 atomic_read(&cp->cp_state)); 81 rds_conn_path_drop(cp, false); 82 return; 83 } 84 |
85 rdsdebug("conn %p for %pI4 to %pI4 complete\n", 86 cp->cp_conn, &cp->cp_conn->c_laddr, &cp->cp_conn->c_faddr); | 85 rdsdebug("conn %p for %pI6c to %pI6c complete\n", 86 cp->cp_conn, &cp->cp_conn->c_laddr, &cp->cp_conn->c_faddr); |
87 88 cp->cp_reconnect_jiffies = 0; 89 set_bit(0, &cp->cp_conn->c_map_queued); 90 rcu_read_lock(); 91 if (!rds_destroy_pending(cp->cp_conn)) { 92 queue_delayed_work(rds_wq, &cp->cp_send_w, 0); 93 queue_delayed_work(rds_wq, &cp->cp_recv_w, 0); 94 } --- 25 unchanged lines hidden (view full) --- 120 * We should *always* start with a random backoff; otherwise a broken connection 121 * will always take several iterations to be re-established. 122 */ 123void rds_queue_reconnect(struct rds_conn_path *cp) 124{ 125 unsigned long rand; 126 struct rds_connection *conn = cp->cp_conn; 127 | 87 88 cp->cp_reconnect_jiffies = 0; 89 set_bit(0, &cp->cp_conn->c_map_queued); 90 rcu_read_lock(); 91 if (!rds_destroy_pending(cp->cp_conn)) { 92 queue_delayed_work(rds_wq, &cp->cp_send_w, 0); 93 queue_delayed_work(rds_wq, &cp->cp_recv_w, 0); 94 } --- 25 unchanged lines hidden (view full) --- 120 * We should *always* start with a random backoff; otherwise a broken connection 121 * will always take several iterations to be re-established. 122 */ 123void rds_queue_reconnect(struct rds_conn_path *cp) 124{ 125 unsigned long rand; 126 struct rds_connection *conn = cp->cp_conn; 127 |
128 rdsdebug("conn %p for %pI4 to %pI4 reconnect jiffies %lu\n", 129 conn, &conn->c_laddr, &conn->c_faddr, 130 cp->cp_reconnect_jiffies); | 128 rdsdebug("conn %p for %pI6c to %pI6c reconnect jiffies %lu\n", 129 conn, &conn->c_laddr, &conn->c_faddr, 130 cp->cp_reconnect_jiffies); |
131 132 /* let peer with smaller addr initiate reconnect, to avoid duels */ 133 if (conn->c_trans->t_type == RDS_TRANS_TCP && | 131 132 /* let peer with smaller addr initiate reconnect, to avoid duels */ 133 if (conn->c_trans->t_type == RDS_TRANS_TCP && |
134 !IS_CANONICAL(conn->c_laddr, conn->c_faddr)) | 134 rds_addr_cmp(&conn->c_laddr, &conn->c_faddr) >= 0) |
135 return; 136 137 set_bit(RDS_RECONNECT_PENDING, &cp->cp_flags); 138 if (cp->cp_reconnect_jiffies == 0) { 139 cp->cp_reconnect_jiffies = rds_sysctl_reconnect_min_jiffies; 140 rcu_read_lock(); 141 if (!rds_destroy_pending(cp->cp_conn)) 142 queue_delayed_work(rds_wq, &cp->cp_conn_w, 0); 143 rcu_read_unlock(); 144 return; 145 } 146 147 get_random_bytes(&rand, sizeof(rand)); | 135 return; 136 137 set_bit(RDS_RECONNECT_PENDING, &cp->cp_flags); 138 if (cp->cp_reconnect_jiffies == 0) { 139 cp->cp_reconnect_jiffies = rds_sysctl_reconnect_min_jiffies; 140 rcu_read_lock(); 141 if (!rds_destroy_pending(cp->cp_conn)) 142 queue_delayed_work(rds_wq, &cp->cp_conn_w, 0); 143 rcu_read_unlock(); 144 return; 145 } 146 147 get_random_bytes(&rand, sizeof(rand)); |
148 rdsdebug("%lu delay %lu ceil conn %p for %pI4 -> %pI4\n", | 148 rdsdebug("%lu delay %lu ceil conn %p for %pI6c -> %pI6c\n", |
149 rand % cp->cp_reconnect_jiffies, cp->cp_reconnect_jiffies, 150 conn, &conn->c_laddr, &conn->c_faddr); 151 rcu_read_lock(); 152 if (!rds_destroy_pending(cp->cp_conn)) 153 queue_delayed_work(rds_wq, &cp->cp_conn_w, 154 rand % cp->cp_reconnect_jiffies); 155 rcu_read_unlock(); 156 --- 5 unchanged lines hidden (view full) --- 162{ 163 struct rds_conn_path *cp = container_of(work, 164 struct rds_conn_path, 165 cp_conn_w.work); 166 struct rds_connection *conn = cp->cp_conn; 167 int ret; 168 169 if (cp->cp_index > 0 && | 149 rand % cp->cp_reconnect_jiffies, cp->cp_reconnect_jiffies, 150 conn, &conn->c_laddr, &conn->c_faddr); 151 rcu_read_lock(); 152 if (!rds_destroy_pending(cp->cp_conn)) 153 queue_delayed_work(rds_wq, &cp->cp_conn_w, 154 rand % cp->cp_reconnect_jiffies); 155 rcu_read_unlock(); 156 --- 5 unchanged lines hidden (view full) --- 162{ 163 struct rds_conn_path *cp = container_of(work, 164 struct rds_conn_path, 165 cp_conn_w.work); 166 struct rds_connection *conn = cp->cp_conn; 167 int ret; 168 169 if (cp->cp_index > 0 && |
170 !IS_CANONICAL(cp->cp_conn->c_laddr, cp->cp_conn->c_faddr)) | 170 rds_addr_cmp(&cp->cp_conn->c_laddr, &cp->cp_conn->c_faddr) >= 0) |
171 return; 172 clear_bit(RDS_RECONNECT_PENDING, &cp->cp_flags); 173 ret = rds_conn_path_transition(cp, RDS_CONN_DOWN, RDS_CONN_CONNECTING); 174 if (ret) { 175 ret = conn->c_trans->conn_path_connect(cp); | 171 return; 172 clear_bit(RDS_RECONNECT_PENDING, &cp->cp_flags); 173 ret = rds_conn_path_transition(cp, RDS_CONN_DOWN, RDS_CONN_CONNECTING); 174 if (ret) { 175 ret = conn->c_trans->conn_path_connect(cp); |
176 rdsdebug("conn %p for %pI4 to %pI4 dispatched, ret %d\n", 177 conn, &conn->c_laddr, &conn->c_faddr, ret); | 176 rdsdebug("conn %p for %pI6c to %pI6c dispatched, ret %d\n", 177 conn, &conn->c_laddr, &conn->c_faddr, ret); |
178 179 if (ret) { 180 if (rds_conn_path_transition(cp, 181 RDS_CONN_CONNECTING, 182 RDS_CONN_DOWN)) 183 rds_queue_reconnect(cp); 184 else 185 rds_conn_path_error(cp, "connect failed\n"); --- 68 unchanged lines hidden (view full) --- 254int rds_threads_init(void) 255{ 256 rds_wq = create_singlethread_workqueue("krdsd"); 257 if (!rds_wq) 258 return -ENOMEM; 259 260 return 0; 261} | 178 179 if (ret) { 180 if (rds_conn_path_transition(cp, 181 RDS_CONN_CONNECTING, 182 RDS_CONN_DOWN)) 183 rds_queue_reconnect(cp); 184 else 185 rds_conn_path_error(cp, "connect failed\n"); --- 68 unchanged lines hidden (view full) --- 254int rds_threads_init(void) 255{ 256 rds_wq = create_singlethread_workqueue("krdsd"); 257 if (!rds_wq) 258 return -ENOMEM; 259 260 return 0; 261} |
262 263/* Compare two IPv6 addresses. Return 0 if the two addresses are equal. 264 * Return 1 if the first is greater. Return -1 if the second is greater. 265 */ 266int rds_addr_cmp(const struct in6_addr *addr1, 267 const struct in6_addr *addr2) 268{ 269#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 270 const __be64 *a1, *a2; 271 u64 x, y; 272 273 a1 = (__be64 *)addr1; 274 a2 = (__be64 *)addr2; 275 276 if (*a1 != *a2) { 277 if (be64_to_cpu(*a1) < be64_to_cpu(*a2)) 278 return -1; 279 else 280 return 1; 281 } else { 282 x = be64_to_cpu(*++a1); 283 y = be64_to_cpu(*++a2); 284 if (x < y) 285 return -1; 286 else if (x > y) 287 return 1; 288 else 289 return 0; 290 } 291#else 292 u32 a, b; 293 int i; 294 295 for (i = 0; i < 4; i++) { 296 if (addr1->s6_addr32[i] != addr2->s6_addr32[i]) { 297 a = ntohl(addr1->s6_addr32[i]); 298 b = ntohl(addr2->s6_addr32[i]); 299 if (a < b) 300 return -1; 301 else if (a > b) 302 return 1; 303 } 304 } 305 return 0; 306#endif 307} 308EXPORT_SYMBOL_GPL(rds_addr_cmp); |
|