From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70C8A3A63FB for ; Wed, 8 Jul 2026 00:47:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783471631; cv=none; b=kPA51YrMUlI9oAbfGEIzXXgsNmh+pCE5PIkutFo/RBzxADIirCU6Oq1a53KLLrltNDy+cW1AOGwxJfYdYAZh+OnrcTAUIrPfLMJlLKGeEl5Zk9PmoSkfsywoi1f1V7/ZMEHbgDAu1Q4oUqpvHg96GiWpp2yGMkL40ZwjPl2314I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783471631; c=relaxed/simple; bh=2xUJjcauQaMYHk6lMWTyi/YcPTMRDfLsHDdphhIl0ns=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=skNPJzqvZ2QVnBIa1mJ/7Ud3FbFSMEojEHNBpyDYjn6anVvoLkpMpKUkz28rlCxuyH5ZXuYmfJYaB4fIE1Aqt/TXyCJqZsrEmkC2DHICNywlJhvZ7+KmW8zXy3ReAlUc5bAoYdwI+vpvkUFThuOHJdNjeV3Pssztc609ixwLaXk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b=DxlQgr2f; arc=none smtp.client-ip=209.85.160.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="DxlQgr2f" Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-43b7e186a0cso49014fac.0 for ; Tue, 07 Jul 2026 17:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1783471628; x=1784076428; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=Ip+/gvYquiKGF93LCTTIfFeDQjtucuwYFMW/5/y3fCo=; b=DxlQgr2fm/1+5BVz7oKZXUTXB/pIEj2o/6sppIT3VaeDpI+IIwxcsf/mXF3DXsk6bc iQjDAkh6AVn2W41+OeOZXDZ3ogJOb6O0MAOtk+pNSnaMSR+OP3sHQeGiwg3cro18z7Lp KhmkerE5yYjCctG5e+hbbmcBKCREnYt7yCmGpsEIgMzzpiK7jZKND0QoHOOHKusxfU3Z VG5phTmR+lmzq4oOMEqoV4fw0rxH+jNzjVRVvOpYDHQWQgkeUwPmPtQp2x0rdYE3vum0 Nkiqat4vDgXqswproJr05SXsX3vEULZBvRM/gXRexFPArg9QJl1lwHL7lGEXxTfmYW6n jtEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783471628; x=1784076428; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Ip+/gvYquiKGF93LCTTIfFeDQjtucuwYFMW/5/y3fCo=; b=MV1HQOPYLHQgWwfOTMVDrv6SK/HvhwRVFkR99vjspL1B0/StW4BFOfBbzQSGdgnSS4 Br+7vkomr7z35BSXEeMSTlgujSggMEmrPGNe2FOzayD6sikLFZ4d1hNmO2V139AWzKjI rf7fA8ucexy12QOvNep8Nlt1/DR1rbXgB2XiP3x4zhi0i+8m56Don6nJR9bOiwOnlDji 3zugVW3GJ9b8DYKNNp1PlEXbUto8U+x+m5bSM5pTAffi43O2HN6+DQrbkbXE/pRgNJ9+ MNLfgCK/BpM5gkF6IWAPYAcq+8SnV6/DjdRUsenXZkPQHrhf5LP7IGU82aADzb1rUzcX jThA== X-Forwarded-Encrypted: i=1; AHgh+RrLas7Qm+/5gNb6VaN/dkjKx/UdtpmQ91R4JFzrbgvk2Wx4B7QiEVzNznUNHpP530yM62QThDlbhazc0fk=@vger.kernel.org X-Gm-Message-State: AOJu0YwF4LUS8k2X8FjPWSCgcSTSoC1AjUvl6uD7GqkrJUQnSI6KbEse hpGQoKJpKyEwNud5Oxm2QzLF5cdePUNC7me9GGQPlgZz8zQgCHqNvv8LGYhwEM0JoxWbLExAulr wC0w5uLs= X-Gm-Gg: AfdE7cnRUFBq9YTfcwgKjaH0o4R5c9Vu422b/L67xE9sLVnH5turQL2Ac94IPSEjCIi rr4p7DAor9vkhovAvZBox3t4LaHM0+aYvbOfpEfmq9NM+elm/WrQ0wyxd+nMJbcQDmSONIjl4ey 21rcjyBkFFvc+HfyOHh0wslGCblah3SoZDB3mU7PxcQaxjmkYPDjOjGQ3oTXJY1dbe5S185xYlK x0EW+bzXtTWfdmu4ZgYMWhWF5ohw1/L5ZTOnGiNSjlIr7n/LSypb7AzHcHVelgKKoCCp1UvOkus IJ1vUxxM31n9lzUzHlk68emiDJSkc30cZ90EH3NeMcswJHeqb6KBvDNoV8vP1G0R+ipMPfrrnIo Emsxz4OuXw6uCb+YaJmzYXkasSpaC54No90tITZjx87Nw9MexuLowdvpCdoZF+matz/f1jChN2O JY0QifAm0EuAwA X-Received: by 2002:a05:6870:918b:b0:44c:fb6c:4fe0 with SMTP id 586e51a60fabf-45163a97f1cmr191633fac.21.1783471628241; Tue, 07 Jul 2026 17:47:08 -0700 (PDT) Received: from [127.0.1.1] ([2a09:bac6:bf21:1923::281:22]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-44cfb559559sm15458321fac.9.2026.07.07.17.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2026 17:47:07 -0700 (PDT) From: Chris J Arges Date: Tue, 07 Jul 2026 19:46:42 -0500 Subject: [PATCH] libceph: reset OSD session when keepalive2 acks stop arriving Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260707-fix-rbd-keepalives-v1-1-be888d525d6a@cloudflare.com> X-B4-Tracking: v=1; b=H4sIAPGdTWoC/x2M3QpAQBQGX0Xn2qm1OOJV5MLPhxOh3dqUvLvN5 dTMPOThFJ6a5CGHoF7PI0KWJjSu/bGAdYpM1lgxlal41pvdMPEGXP2uAZ5Fihm1FRnzkmJ4OUT rn7bd+37gA45ZZAAAAA== X-Change-ID: 20260707-fix-rbd-keepalives-664fe9266c35 To: Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko , "Yan, Zheng" Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Andrew DeMaria , Chris J Arges X-Mailer: b4 0.15.2 handle_timeout() in osd_client.c sends CEPH_MSGR2_TAG_KEEPALIVE2 frames to OSDs with stalled requests, but libceph never verifies if the ACKs actually return. Consequently, if an OSD messenger queue wedges while the underlying TCP socket remains ESTABLISHED, the client will block indefinitely in ceph_osdc_wait_request(), causing tasks to hang in D state. Fix this by introducing a watchdog in handle_timeout() that checks ceph_con_keepalive_expired() against a new CEPH_OSD_PING_TIMEOUT (60s). On expiry, reset the sparse-read state, call reopen_osd(), and kick outstanding requests when the session is reopened. Because OSD keepalives are only sent to OSDs with stalled requests, last_keepalive_ack can be stale on an otherwise healthy connection that has simply been idle. Track the start of each slow/probing episode per OSD and require the episode to last CEPH_OSD_PING_TIMEOUT before checking for an expired keepalive ack, so the watchdog only fires after we have been actively pinging. Additionally, seed last_keepalive_ack to the current time in ceph_con_open() to prevent the watchdog from firing spuriously on fresh connections for both OSD and monitor clients. Fixes: 8b9558aab853 ("libceph: use keepalive2 to verify the mon session is alive") Link: https://tracker.ceph.com/issues/76202 Co-developed-by: Andrew DeMaria Signed-off-by: Andrew DeMaria Signed-off-by: Chris J Arges --- This patch fixes an issue where the kernel rbd client and an OSD have an ESTABLISHED TCP connection, but keepalive2 ACKs stop returning from the OSD. When that happens, outstanding OSD requests can remain held by the client and callers can hang in D state. We were able to mitgiate this issue by using ss -K to kill the affected OSD TCP connection which reopened the OSD session. We were able to reproduce this issue in production a few times, and synthetically by dropping OSD to rbd application frames while allowing TCP ACKs through. https://tracker.ceph.com/issues/76202 describes the same situation. The following patch addresses this by creating a watchdog that resets the OSD session if this situation is detected. --- include/linux/ceph/libceph.h | 1 + include/linux/ceph/osd_client.h | 1 + net/ceph/messenger.c | 3 +++ net/ceph/osd_client.c | 23 ++++++++++++++++++++++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h index 63e0e2aa1ce9..1a117c5f1964 100644 --- a/include/linux/ceph/libceph.h +++ b/include/linux/ceph/libceph.h @@ -74,6 +74,7 @@ struct ceph_options { */ #define CEPH_MOUNT_TIMEOUT_DEFAULT msecs_to_jiffies(60 * 1000) #define CEPH_OSD_KEEPALIVE_DEFAULT msecs_to_jiffies(5 * 1000) +#define CEPH_OSD_PING_TIMEOUT msecs_to_jiffies(60 * 1000) #define CEPH_OSD_IDLE_TTL_DEFAULT msecs_to_jiffies(60 * 1000) #define CEPH_OSD_REQUEST_TIMEOUT_DEFAULT 0 /* no timeout */ #define CEPH_READ_FROM_REPLICA_DEFAULT 0 /* read from primary */ diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index 50b14a5661c7..52eb76e9d62a 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h @@ -94,6 +94,7 @@ struct ceph_osd { struct ceph_auth_handshake o_auth; unsigned long lru_ttl; struct list_head o_keepalive_item; + unsigned long o_keepalive_stamp; struct mutex lock; struct ceph_sparse_read o_sparse_read; }; diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 34b3097b4c7b..f7776d83d506 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -610,6 +610,9 @@ void ceph_con_open(struct ceph_connection *con, memcpy(&con->peer_addr, addr, sizeof(*addr)); con->delay = 0; /* reset backoff memory */ + + ktime_get_real_ts64(&con->last_keepalive_ack); + mutex_unlock(&con->mutex); queue_con(con); } diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 2ff00070c181..6d9530beb2e3 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -53,6 +53,7 @@ static void link_linger(struct ceph_osd *osd, static void unlink_linger(struct ceph_osd *osd, struct ceph_osd_linger_request *lreq); static void clear_backoffs(struct ceph_osd *osd); +static void kick_osd_requests(struct ceph_osd *osd); #if 1 static inline bool rwsem_is_wrlocked(struct rw_semaphore *sem) @@ -3480,8 +3481,11 @@ static void handle_timeout(struct work_struct *work) mutex_unlock(&lreq->lock); } - if (found) + if (found) { list_move_tail(&osd->o_keepalive_item, &slow_osds); + } else { + osd->o_keepalive_stamp = 0; + } } if (opts->osd_request_timeout) { @@ -3507,6 +3511,23 @@ static void handle_timeout(struct work_struct *work) struct ceph_osd, o_keepalive_item); list_del_init(&osd->o_keepalive_item); + + /* Record start of ping timeout from the first slow tick. */ + if (!osd->o_keepalive_stamp) { + osd->o_keepalive_stamp = jiffies; + } else if (time_after_eq(jiffies, + osd->o_keepalive_stamp + CEPH_OSD_PING_TIMEOUT) && + ceph_con_keepalive_expired(&osd->o_con, + CEPH_OSD_PING_TIMEOUT)) { + pr_warn_ratelimited("osd%d not responding to keepalives, resetting session\n", + osd->o_osd); + osd->o_sparse_op_idx = -1; + ceph_init_sparse_read(&osd->o_sparse_read); + if (!reopen_osd(osd)) + kick_osd_requests(osd); + continue; + } + ceph_con_keepalive(&osd->o_con); } --- base-commit: 0e35b9b6ec0ffcc5e23cbdec09f5c622ad532b53 change-id: 20260707-fix-rbd-keepalives-664fe9266c35 Best regards, -- Chris J Arges