Skip to contentSkip to conversation

libceph: handle EADDRNOTAVAIL more gracefully

PATCH In review Ionut Nechita (Wind River) 1 participant 2 messages Feb 10 – Feb 13

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libceph: handle EADDRNOTAVAIL more gracefully

From: Ionut Nechita <[email protected]>

When connecting to Ceph monitors/OSDs, kernel_connect() may return -EADDRNOTAVAIL if the source address is unavailable. This occurs during:
- IPv6 Duplicate Address Detection (DAD)
- IPv4/IPv6 interface state changes (link up/down events)
- Address removal or reconfiguration on the interface
- Network namespace transitions in containerized environments
- CNI reconfigurations in Kubernetes/StarlingX rolling upgrades

Currently, libceph treats EADDRNOTAVAIL like any other connection error and enters exponential backoff (BASE_DELAY_INTERVAL 250ms doubling up to MAX_DELAY_INTERVAL 15s). Additionally, the monitor client has its own hunt-level backoff (CEPH_MONC_HUNT_INTERVAL 3s * hunt_mult, where hunt_mult doubles up to 10x = 30s max). These two backoff mechanisms
compound: at steady state each monitor gets ~30 seconds of attempts with connection-level delays up to 15s, and the round-trip through all monitors takes ~60 seconds.

In production on a StarlingX system (6.12.0-1-rt-amd64, Dell PowerEdge R720, IPv6-only Ceph cluster with 2 monitors), the EADDRNOTAVAIL condition persisted for ~36 minutes during a rolling upgrade:

13:20:52 - mon0 session lost, hunting begins, first error -99 13:57:03 - mon0 session finally re-established

~470 failed connect attempts across both monitors
sync task blocked for 983+ seconds, triggering hung task warnings:
"INFO: task sync:514917 blocked for more than 122 seconds" ...repeated at 245s, 368s, 491s, 614s, 737s, 860s, 983s

The duration of EADDRNOTAVAIL varies by environment: it can be brief (simple DAD, 1-2s) or prolonged (complex network reconfiguration during rolling upgrades, minutes). In both cases, the key issue is that exponential backoff up to 15s wastes time once the address becomes available -- the client may sit idle for up to 15 seconds before attempting to reconnect.

This patch bypasses the exponential backoff for EADDRNOTAVAIL by using a fixed short retry interval (ADDRNOTAVAIL_DELAY, HZ/10 = 100ms). This ensures reconnection happens within 100ms of the address becoming available, rather than waiting up to 15 seconds.

Implementation:
- Detect EADDRNOTAVAIL in ceph_tcp_connect() for both IPv4 and IPv6
- Signal the condition to con_fault() via an addr_notavail flag (per-protocol: v1 and v2)
- In con_fault(), use ADDRNOTAVAIL_DELAY instead of exponential backoff when the flag is set
- Clear the flag on successful connection and when reopening
- Use pr_warn_ratelimited() instead of pr_err() for this case

The fast retry is appropriate because each attempt is inexpensive (kernel_connect() fails immediately when the address is unavailable) and quick recovery is critical for storage availability.

Fixes 60bf8bf8815e6 ("libceph: fix msgr backoff")

---
Changes since v1:
- Corrected commit message: removed incorrect "1-2 seconds" claim, added actual production dmesg data showing the 36-minute EADDRNOTAVAIL duration and explained the two compounding backoff mechanisms (connection-level + monitor hunt-level)

 include/linux/ceph/messenger.h | 11 +++++++
 net/ceph/messenger.c           | 55 ++++++++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 3 deletions(-)
include/linux/ceph/messenger.h +11 -0
index 6aa4c6478c9f6..ec08d02a9d4bd 100644
@@ -321,6 +321,13 @@ struct ceph_msg {
 /* ceph connection fault delay defaults, for exponential backoff */
 #define BASE_DELAY_INTERVAL	(HZ / 4)
 #define MAX_DELAY_INTERVAL	(15 * HZ)
+/*
+ * Shorter retry delay for EADDRNOTAVAIL. This error typically indicates
+ * a transient condition (IPv6 DAD in progress, address reconfiguration,
+ * temporary route issue) that resolves in 1-2 seconds. Fast retries
+ * allow quick recovery without exponential backoff delays.
+ */
+#define ADDRNOTAVAIL_DELAY	(HZ / 10)
 
 struct ceph_connection_v1_info {
 	struct kvec out_kvec[8],         /* sending header/footer data */
@@ -361,6 +368,8 @@ struct ceph_connection_v1_info {
 	u32 connect_seq;      /* identify the most recent connection
 				 attempt for this session */
 	u32 peer_global_seq;  /* peer's global seq for this connection */
+
+	bool addr_notavail;  /* address not available (transient) */
 };
 
 #define CEPH_CRC_LEN			4
@@ -432,6 +441,8 @@ struct ceph_connection_v2_info {
 
 	int con_mode;  /* CEPH_CON_MODE_* */
 
+	bool addr_notavail;  /* address not available (transient) */
+
 	void *conn_bufs[16];
 	int conn_buf_cnt;
 	int data_len_remain;
net/ceph/messenger.c +52 -3

91 lines not on this page · raw message

--
2.52.0