From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 1DBAE26158B for ; Wed, 8 Jul 2026 20:40:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783543230; cv=none; b=NRKTS/3ch1+FJ1AKDFzDeT1rJmUPQAx0ZSVakvmvgyRFdlXvUSEMCDQ1Lf9R3s8u06XOQJDosXZUVtGGLvfkMzpnYxVj08xDde7USQjR3o8KcweggHPIFWn8CMPjelSv/G9uCQMnStqCalRxta79lwyLQm1FwTG00o6l/104xUI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783543230; c=relaxed/simple; bh=kaPZErsK3KYzi0e3RLe7W7LF9YGVqnv7yq+SFX4ufLg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=K+xEAinARHM7duLKi7fAKBptdZ/Y4bGQgi0fTPRCuoQuB8DV/3QxHA5bbZ9uC7WJoYFxZlIU4X9nyUFfP+CPblvmYR+Na66WncpjhvjhmEWIAzVG5N362Xqojbo6g2QDn0y1LneEPW6rodIad933MH/u0txtNroAhYW4uIxTmL0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=JrAdci/E; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="JrAdci/E" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-47d70879764so808032f8f.2 for ; Wed, 08 Jul 2026 13:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1783543227; x=1784148027; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=V7x8+X06pvsKgsbhNKOh2cLRprWp7S1kFPDrLN1+nS8=; b=JrAdci/ES0cT4TfTF/9BpXKgP/Urg2tUmHIUOgVnukKHeASg8G15TfzYdIg+kUAFTl AAIe2PmSVdTIby8UCeWXoAo6XZv46qVPTEHH7yBKBYotYHNg2vi92acaKn7WTzLBsptv sD/RkIyHObi6OE+/8SVqiaudy2meETgTc6Tfb/2/O2KKmbWP+Ag/jwy86K1v4YheupxO Dh7hOZHVAOGS1d5WFe0pyrVEOW9s5izUMIUn/znVuVmiSlGwP2mfepvUXLyBCT2UkVIS 7V12oJX/l6E/73g7isRwcS3HpVW5UBeDbuJF83twPMuLFo8ltKn96Tcpd6RL/twwQkb+ NoCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783543227; x=1784148027; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=V7x8+X06pvsKgsbhNKOh2cLRprWp7S1kFPDrLN1+nS8=; b=Tu4Sv0gpNl6GJCZZ8y46lxLe4HZD8UodT4H8VRoNwbgsw1+jom+Mnb8K4FC26w/H1r ecb0G088+3l5lEf+diDfF+qsbPuo87THmKo/6T1YRVK9QLnys2C7Yhy8nZDQY6nn2kO0 /YlX7CaYgB/X84mGlI1/8jEHC6xfI8FMp6Dgkpso9cieZEzWCzoXiDU4Vst7z2eePYLD 76hCRPRu2GUMMoTIvq2QFhx2CzuM5nEJHvg2ANQOQx2pHZQzuJv3Lpb00maQrrmT4HGV ro5Mk+YqXKSixk/zUhh9QtEAhwxJ/OuJRQ5lbSKzwM8frGdCb/yO9n6zp5Wzz9u79pR+ KKEg== X-Forwarded-Encrypted: i=1; AHgh+RrA61AKy+5z758L7xSgDezyfG9S2CIeCwEI6GbqrEAjBMS6yK9pk3Ygb/uOPAty6IrNgt/CSBkSJn4QKxk=@vger.kernel.org X-Gm-Message-State: AOJu0YwCtn31QD9Iug+8cs3PbbV/BeYsSZG9p4Z1Au0Hc7GvSeR0Enw5 t7OJesLu7DoUEKgUml9ML/67SSqRy1ubkp/GwbwtPhleJijYSxinh/hyFLcIouVLjsM= X-Gm-Gg: AfdE7cm0tJ3b4flUbMKMH7QcGVqpauXvfVOrjUlbYVkj6Zfpz80TyaGbY4ZKhfLD3JA EAmUfN3EdR2M5rh+T93WCoTKLbeWbMBU1plp9sRYEi7XGiPeoHdR5devF76yyjAA3goOsuZmCbs spXu63z1E/YwWzXRrCv/bf1eRFUEYvwa48gxSWQMMXlX73aatvjl+4LiJgMIRfWn6WIEHWohW2D STgcpLDAbvrqMFQ228sluF6qfDK729xFPokr1JB4OF9w9f1g7pLVUaWgOz9mduxuCa3Ig60iBH1 NMcFcSknYE5AUvcN2M/62Zuy8LQJt1BEk+t64ThbF0ilhSq2qKXeP6kI/hcLSE5uOduDnnJvRXR uz/J928gRRblebtBIrpAMgR5GI4XTvM3l8lfL4VGpyu3IOC+eeK/NyBbAYkdC2kwMWvXMxrGoZf ZKHwsNsSe/DAKvTP0Vf19zEYzZQHgSXBSz2X6Wwo7y3bTx1A0BzZIUrSgQRMNOIz9FWOiMS5T8U Am7xxOLJglC9Aro X-Received: by 2002:a05:6000:2f86:b0:475:f100:360d with SMTP id ffacd0b85a97d-47df0824681mr4713745f8f.60.1783543227502; Wed, 08 Jul 2026 13:40:27 -0700 (PDT) Received: from raven.intern.cm-ag (p200300dc6f45eb00023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f45:eb00:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47a9b4d850dsm46784459f8f.0.2026.07.08.13.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 13:40:27 -0700 (PDT) From: Max Kellermann To: idryomov@gmail.com, amarkuze@redhat.com, ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH] fs/ceph/mds_client: drop mdsc->mutex before decoding the MDS reply Date: Wed, 8 Jul 2026 22:40:22 +0200 Message-ID: <20260708204022.263578-1-max.kellermann@ionos.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit handle_reply() held `mdsc->mutex` across parse_reply_info(), i.e. across the full decode of the reply message. For large replies (a big readdir allocates and parses many dir_entries), this can take a while and blocks ceph_mdsc_submit_request() calls meanwhile. The decode does not need `mdsc->mutex`: parse_reply_info() mostly fills the request's `r_reply_info`. Create replies may also add delegated inode numbers to the session xarray, but that xarray is protected by its own lock and is not serialized by `mdsc->mutex` today. By the time we reach parse_reply_info(), all `mdsc->mutex`-protected state has already been updated under the lock (the request has either been unregistered (safe reply) or added to the session's unsafe list (unsafe reply)) and the request is pinned by the reference taken in lookup_get_request(). Drop `mdsc->mutex` before calling parse_reply_info() so reply decoding no longer blocks request submission. This only widens the existing unlocked window that already covers the heavier ceph_fill_trace() / ceph_readdir_prepopulate() processing, so no new races are introduced. Signed-off-by: Max Kellermann --- fs/ceph/mds_client.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 853bf698b356..bb8570d31208 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -4089,13 +4089,19 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg) list_add_tail(&req->r_unsafe_item, &req->r_session->s_unsafe); } + /* + * Now that all mutex-protected state has been updated above + * (the request has been unregistered or added to the + * session's unsafe list), we can unlock it. + */ + mutex_unlock(&mdsc->mutex); + doutc(cl, "tid %lld result %d\n", tid, result); if (test_bit(CEPHFS_FEATURE_REPLY_ENCODING, &session->s_features)) err = parse_reply_info(session, msg, req, (u64)-1); else err = parse_reply_info(session, msg, req, session->s_con.peer_features); - mutex_unlock(&mdsc->mutex); /* Must find target inode outside of mutexes to avoid deadlocks */ rinfo = &req->r_reply_info; -- 2.47.3