mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ionut Nechita <ionut.nechita@windriver.com>
To: ceph-devel@vger.kernel.org
Cc: Ilya Dryomov <idryomov@gmail.com>,
	Alex Markuze <amarkuze@redhat.com>,
	Viacheslav Dubeyko <slava@dubeyko.com>,
	Xiubo Li <xiubo.li@clyso.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/7] libceph: don't back off exponentially on EADDRNOTAVAIL
Date: Fri, 20 Nov 2026 09:34:17 +0200	[thread overview]
Message-ID: <20261120073431.53636-2-ionut.nechita@windriver.com> (raw)
In-Reply-To: <20261120073431.53636-1-ionut.nechita@windriver.com>

When kernel_connect() fails with EADDRNOTAVAIL, the error is local:
no route or no usable source address for the peer, and nothing was
sent on the wire.  con_fault() nevertheless treats it like any other
failure and doubles con->delay up to MAX_DELAY_INTERVAL (15s), so once
the local condition clears the client may sit idle for up to 15s
before trying again.

Since a failed attempt costs nothing and never reaches the peer,
retry at a fixed 100ms instead.  Track the condition in struct
ceph_connection so that it doesn't depend on which protocol (msgr1 or
msgr2) is in use, and rate-limit the message.

Signed-off-by: Ionut Nechita <ionut.nechita@windriver.com>
---
 include/linux/ceph/messenger.h |  7 +++++++
 net/ceph/messenger.c           | 15 ++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
index 6aa4c6478c9f6..344496967b5c5 100644
--- a/include/linux/ceph/messenger.h
+++ b/include/linux/ceph/messenger.h
@@ -321,6 +321,12 @@ struct ceph_msg {
 /* ceph connection fault delay defaults, for exponential backoff */
 #define BASE_DELAY_INTERVAL	(HZ / 4)
 #define MAX_DELAY_INTERVAL	(15 * HZ)
+/*
+ * Fixed retry delay used instead of exponential backoff when connect()
+ * fails locally with EADDRNOTAVAIL.  Such an attempt never reaches the
+ * peer, so backing off protects nobody and only delays recovery.
+ */
+#define ADDRNOTAVAIL_DELAY	msecs_to_jiffies(100)
 
 struct ceph_connection_v1_info {
 	struct kvec out_kvec[8],         /* sending header/footer data */
@@ -507,6 +513,7 @@ struct ceph_connection {
 
 	struct delayed_work work;	    /* send|recv work */
 	unsigned long       delay;          /* current delay interval */
+	bool addr_notavail;  /* last connect() failed with EADDRNOTAVAIL */
 
 	union {
 		struct ceph_connection_v1_info v1;
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index cc7db8c61db37..3c893bc0f7d8b 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -467,8 +467,13 @@ int ceph_tcp_connect(struct ceph_connection *con)
 		     ceph_pr_addr(&con->peer_addr),
 		     sock->sk->sk_state);
 	} else if (ret < 0) {
-		pr_err("connect %s error %d\n",
-		       ceph_pr_addr(&con->peer_addr), ret);
+		if (ret == -EADDRNOTAVAIL)
+			pr_warn_ratelimited("connect %s: address not available, will retry\n",
+					    ceph_pr_addr(&con->peer_addr));
+		else
+			pr_err("connect %s error %d\n",
+			       ceph_pr_addr(&con->peer_addr), ret);
+		con->addr_notavail = ret == -EADDRNOTAVAIL;
 		sock_release(sock);
 		return ret;
 	}
@@ -477,6 +482,7 @@ int ceph_tcp_connect(struct ceph_connection *con)
 		tcp_sock_set_nodelay(sock->sk);
 
 	con->sock = sock;
+	con->addr_notavail = false;
 	return 0;
 }
 
@@ -610,6 +616,7 @@ void ceph_con_open(struct ceph_connection *con,
 
 	memcpy(&con->peer_addr, addr, sizeof(*addr));
 	con->delay = 0;      /* reset backoff memory */
+	con->addr_notavail = false;
 	mutex_unlock(&con->mutex);
 	queue_con(con);
 }
@@ -1644,7 +1651,9 @@ static void con_fault(struct ceph_connection *con)
 	} else {
 		/* retry after a delay. */
 		con->state = CEPH_CON_S_PREOPEN;
-		if (!con->delay) {
+		if (con->addr_notavail) {
+			con->delay = ADDRNOTAVAIL_DELAY;
+		} else if (!con->delay) {
 			con->delay = BASE_DELAY_INTERVAL;
 		} else if (con->delay < MAX_DELAY_INTERVAL) {
 			con->delay *= 2;
-- 
2.56.0


  reply	other threads:[~2026-11-20  7:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  7:34 [PATCH v2 0/7] ceph/libceph: bound sync waits and speed up recovery after network disruption Ionut Nechita
2026-11-20  7:34 ` Ionut Nechita [this message]
2026-11-20  7:34 ` [PATCH v2 2/7] ceph: bound the ceph_mdsc_sync() wait by mount_timeout Ionut Nechita
2026-11-20  7:34 ` [PATCH v2 3/7] ceph: bound the ceph_osdc_sync() " Ionut Nechita
2026-11-20  7:34 ` [PATCH v2 4/7] ceph: bound the safe-completion wait in ceph_lock_wait_for_completion() Ionut Nechita
2026-11-20  7:34 ` [PATCH v2 5/7] ceph: set default timeout for MDS requests Ionut Nechita
2026-11-20  7:34 ` [PATCH v2 6/7] ceph: request a full mdsmap when an MDS stays unreachable Ionut Nechita
2026-11-20  7:34 ` [PATCH v2 7/7] libceph: don't escalate monitor hunt backoff on EADDRNOTAVAIL Ionut Nechita

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261120073431.53636-2-ionut.nechita@windriver.com \
    --to=ionut.nechita@windriver.com \
    --cc=amarkuze@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=slava@dubeyko.com \
    --cc=xiubo.li@clyso.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®