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 4/7] ceph: bound the safe-completion wait in ceph_lock_wait_for_completion()
Date: Fri, 20 Nov 2026 09:34:20 +0200	[thread overview]
Message-ID: <20261120073431.53636-5-ionut.nechita@windriver.com> (raw)
In-Reply-To: <20261120073431.53636-1-ionut.nechita@windriver.com>

When a blocking lock request is interrupted,
ceph_lock_wait_for_completion() sends an unlock request to cancel it
and then waits for the original request's r_safe_completion with no
bound.  If the MDS goes away at
that point the task hangs in D state:

  INFO: task flock:12345 blocked for more than 122 seconds.
  Call Trace:
   wait_for_completion_killable
   ceph_lock_wait_for_completion
   ceph_flock

Bound the wait by mount_timeout and return -ETIMEDOUT; the original
request has already been marked CEPH_MDS_R_ABORTED at this point.
mount_timeout=0 keeps waiting forever.

Signed-off-by: Ionut Nechita <ionut.nechita@windriver.com>
---
 fs/ceph/locks.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index 677221bd64e01..b4faf112b3f84 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -158,9 +158,11 @@ static int ceph_lock_wait_for_completion(struct ceph_mds_client *mdsc,
                                          struct ceph_mds_request *req)
 {
 	struct ceph_client *cl = mdsc->fsc->client;
+	unsigned long timeout = ceph_timeout_jiffies(cl->options->mount_timeout);
 	struct ceph_mds_request *intr_req;
 	struct inode *inode = req->r_inode;
 	int err, lock_type;
+	long left;
 
 	BUG_ON(req->r_op != CEPH_MDS_OP_SETFILELOCK);
 	if (req->r_args.filelock_change.rule == CEPH_LOCK_FCNTL)
@@ -219,10 +221,15 @@ static int ceph_lock_wait_for_completion(struct ceph_mds_client *mdsc,
 	if (err && err != -ERESTARTSYS)
 		return err;
 
-	err = wait_for_completion_killable(&req->r_safe_completion);
-	if (err)
-		return err;
-
+	left = wait_for_completion_killable_timeout(&req->r_safe_completion,
+						    timeout);
+	if (left < 0) {
+		return left;
+	} else if (left == 0) {
+		doutc(cl, "request %llu safe completion timed out\n",
+		      req->r_tid);
+		return -ETIMEDOUT;
+	}
 	return 0;
 }
 
-- 
2.56.0


  parent 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 ` [PATCH v2 1/7] libceph: don't back off exponentially on EADDRNOTAVAIL Ionut Nechita
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 ` Ionut Nechita [this message]
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-5-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®