From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11B272DF138 for ; Sun, 6 Sep 2026 15:46:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788709568; cv=none; b=spUbqWrgqPOhpXjabCRwKd9PYP2VocKGf8edUmrFPCc2oXJNiCC8QFNh84Ni56yoznk8X0I09N4Pj/5pn5+bX4EPbryEleyZBLKrwKIk/D7vzdhHwkmnsaCC388Pm7kg9MlSwi3575ajdQ/qEtoZSKnC6PUB3px4JUpHK6P3JYI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788709568; c=relaxed/simple; bh=qy3fNLpE0d7LcwSdSmCiVzRrjW2ivGqmeuhAsp5Owmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dhl7pbCseWNT+oLaGmBQtNCon0PVCFJdNXkxo2z5rz5DCw3aQXK5lo/DdToJ1beoT99jjVC9U/+cqjFYB9eYYdtjnDvFs0nnD3adsK8SgdeSImjf5EL3TxmAKYCqHKqwWGdkd6RZ0LJJGEqSfJaOFWdvOK1GqroJE2pfmj0V8Is= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=deUoX8rn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="deUoX8rn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01E681F00A3A; Sun, 6 Sep 2026 15:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788709566; bh=XbX2+KiunDXpl9+ITvPNm8PhPXm9m7S6sg01VrNNrKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=deUoX8rnJqhm6VJURo4uxyezkCYm9B6CA2f2/X19LToSYSatrc7ZIT2WgbwJNF+8G 97GqzJ08EFokQ8lAO3o6ciqyN36L727w6Gvr1g+xPcAFIN8TA68aoN7HarSuBDzj3J 3OE9ILxriF3EfDRxlk/toxWRXTk8t7iga5Y4rkxloWFbuJkBvEesqu/ga2ydfEqudw Z8a5TjvLmh+Hn42HkCOk26/K+CU1/ELXaZ9MIJHt/W/T4hD+sSg/C/kvpTAu1dba1Z KyJTY4+nCuTScSzcLpOrAnUYH/L1sWzgjRyRiV61jhif4ReEOP+TyE4zmXNuKyKO/W eNIZ/sKRfzr3A== From: Sasha Levin To: stable@vger.kernel.org Cc: =?UTF-8?q?Lu=C3=ADs=20Henriques?= , Dan Carpenter , Xiubo Li , Ilya Dryomov , Sasha Levin Subject: [PATCH 6.1.y 1/3] ceph: remove unnecessary check for NULL in parse_longname() Date: Sun, 6 Sep 2026 11:46:02 -0400 Message-ID: <20260906154604.1504928-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026090355-tradition-although-cffd@gregkh> References: <2026090355-tradition-although-cffd@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Luís Henriques [ Upstream commit 2816a09678f50fc6a69e742e90cb1fd7a9f1f9ff ] Function ceph_get_inode() never returns NULL; instead it returns an ERR_PTR() if something fails. Thus, the check for NULL in parse_longname() is useless and can be dropped. Instead, move there the debug code that does the error checking so that it's only executed if ceph_get_inode() is called. Fixes: dd66df0053ef ("ceph: add support for encrypted snapshot names") Reported-by: Dan Carpenter Signed-off-by: Luís Henriques Reviewed-by: Xiubo Li Signed-off-by: Ilya Dryomov Stable-dependency adaptation: fs/ceph/crypto.c is not present in 6.1, so drop the original hunk. Instead, carry the minimal existing-code context needed by the follow-up: use client-aware logging in the delegated-inode parser, serialize the delegated-inode xarray teardown, and reject reconnects for terminal sessions. This gives the follow-up's counter reset a clean and correct insertion point. [ sashal: Reduced backport -- upstream 2816a09678f50 touches 1 file(s), this backport carries 1. Not backported here: fs/ceph/crypto.c This note is generated from the file lists only; see the resolution record for the reasoning. ] Stable-dep-of: 4bd3158bd624 ("ceph: cap delegated inode count in ceph_parse_deleg_inos()") Signed-off-by: Sasha Levin --- fs/ceph/mds_client.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 939f9e870de0a..4893545b930c3 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -433,6 +433,7 @@ static int parse_reply_info_filelock(void **p, void *end, static int ceph_parse_deleg_inos(void **p, void *end, struct ceph_mds_session *s) { + struct ceph_client *cl = s->s_mdsc->fsc->client; u32 sets; ceph_decode_32_safe(p, end, sets, bad); @@ -445,8 +446,9 @@ static int ceph_parse_deleg_inos(void **p, void *end, /* Don't accept a delegation of system inodes */ if (start < CEPH_INO_SYSTEM_BASE) { - pr_warn_ratelimited("ceph: ignoring reserved inode range delegation (start=0x%llx len=0x%llx)\n", - start, len); + pr_warn_ratelimited_client(cl, + "ignoring reserved inode range delegation (start=0x%llx len=0x%llx)\n", + start, len); continue; } while (len--) { @@ -454,10 +456,10 @@ static int ceph_parse_deleg_inos(void **p, void *end, DELEGATED_INO_AVAILABLE, GFP_KERNEL); if (!err) { - dout("added delegated inode 0x%llx\n", - start - 1); + doutc(cl, "added delegated inode 0x%llx\n", start - 1); } else if (err == -EBUSY) { - pr_warn("MDS delegated inode 0x%llx more than once.\n", + pr_warn_client(cl, + "MDS delegated inode 0x%llx more than once.\n", start - 1); } else { return err; @@ -4200,6 +4202,7 @@ static int encode_snap_realms(struct ceph_mds_client *mdsc, static void send_mds_reconnect(struct ceph_mds_client *mdsc, struct ceph_mds_session *session) { + struct ceph_client *cl = mdsc->fsc->client; struct ceph_msg *reply; int mds = session->s_mds; int err = -ENOMEM; @@ -4218,9 +4221,21 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc, if (!reply) goto fail_nomsg; + mutex_lock(&session->s_mutex); + + /* Serialized by s_mutex against concurrent ceph_get_deleg_ino(). */ xa_destroy(&session->s_delegated_inos); + if (session->s_state == CEPH_MDS_SESSION_CLOSED || + session->s_state == CEPH_MDS_SESSION_REJECTED) { + pr_info_client(cl, "mds%d skipping reconnect, session %s\n", + mds, + ceph_session_state_name(session->s_state)); + mutex_unlock(&session->s_mutex); + ceph_msg_put(reply); + err = -ESTALE; + goto fail_return; + } - mutex_lock(&session->s_mutex); session->s_state = CEPH_MDS_SESSION_RECONNECTING; session->s_seq = 0; @@ -4361,6 +4376,10 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc, fail_nopagelist: pr_err("error %d preparing reconnect for mds%d\n", err, mds); return; + +fail_return: + ceph_pagelist_release(recon_state.pagelist); + return; } -- 2.53.0