{"id":2222821,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2222821/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260413191110.1508848-1-henrique.carvalho@suse.com/","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.2/projects/12/?format=json","name":"Linux CIFS Client","link_name":"linux-cifs-client","list_id":"linux-cifs.vger.kernel.org","list_email":"linux-cifs@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260413191110.1508848-1-henrique.carvalho@suse.com>","list_archive_url":null,"date":"2026-04-13T19:11:09","name":"[1/2] smb: client: serialize channel scaling path","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0c9ef3e747730e20d3c1e275b8649d3d403ef93c","submitter":{"id":89563,"url":"http://patchwork.ozlabs.org/api/1.2/people/89563/?format=json","name":"Henrique Carvalho","email":"henrique.carvalho@suse.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260413191110.1508848-1-henrique.carvalho@suse.com/mbox/","series":[{"id":499742,"url":"http://patchwork.ozlabs.org/api/1.2/series/499742/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=499742","date":"2026-04-13T19:11:10","name":"[1/2] smb: client: serialize channel scaling path","version":1,"mbox":"http://patchwork.ozlabs.org/series/499742/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222821/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222821/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-cifs+bounces-10783-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-cifs@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256\n header.s=google header.b=OUXumIF8;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10783-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com\n header.b=\"OUXumIF8\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.128.49","smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=suse.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=suse.com"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvcWb50Rtz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 05:13:31 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 19EA9304EA51\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 19:11:42 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 037D03BAD92;\n\tMon, 13 Apr 2026 19:11:24 +0000 (UTC)","from mail-wm1-f49.google.com (mail-wm1-f49.google.com\n [209.85.128.49])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 533CA3B6BE8\n\tfor <linux-cifs@vger.kernel.org>; Mon, 13 Apr 2026 19:11:22 +0000 (UTC)","by mail-wm1-f49.google.com with SMTP id\n 5b1f17b1804b1-488afb0427eso59687455e9.1\n        for <linux-cifs@vger.kernel.org>;\n Mon, 13 Apr 2026 12:11:22 -0700 (PDT)","from precision ([2804:7f0:6401:5290:433e:afae:f475:c9f7])\n        by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2d55f5c6afdsm17508032eec.4.2026.04.13.12.11.16\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Mon, 13 Apr 2026 12:11:19 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776107483; cv=none;\n b=pazH79GaMGW77WmsLrCKfQvflVE+1u3fNVJou1cRalfP4H83b+XNyFTYObUfJckPd4reG6zUxqUTPduLEbpfA6Y8FpJ4QcotL2BGg2MDeu6GPlIrpwnxbQ3Hoyl8dRYqD/T4ztr3Q8AUV7DXoz0GGwxvrQ4vpDdABcUn0+hyEXw=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776107483; c=relaxed/simple;\n\tbh=E2hjxYStm3aD6IMH0x56H1eA9O7MIAYApbvv/cTbWNs=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=bTNHMnUIvS1XuYT8dSC3joY1i4sLBCfsukO3Qb7AgNYp0R+qnI332Dpgp6y3J8VVH2Pxq8j6bKaGq4S8fR5phrRGZRheWaxjlfVEhN35Y4jOJDbKIfCkjicHMlhZO8NL5cTxpF/nxKljy/mjWUD3a76W/x4Y69yq/GfCMaiVxqc=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=suse.com;\n spf=pass smtp.mailfrom=suse.com;\n dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com\n header.b=OUXumIF8; arc=none smtp.client-ip=209.85.128.49","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=suse.com; s=google; t=1776107481; x=1776712281;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:from:to:cc:subject:date:message-id:reply-to;\n        bh=fXWGSvkFU16FgOFRkCaaPZi61w++nh88NCvP7Zfs+t0=;\n        b=OUXumIF8AX3lCnvtPOWN1pLHMorUFBkYKEcjLV69DTQNZDtECiiWfMJ6MRk3VLpqYE\n         0ojH3vi4S6K7VUX4R3B8rwKUQQs4HMuHUvp9Em6QRI4SO0zth1JEmdTUhsU60XZgVW7f\n         ZVRD5HNHreH+NKT9pfq2kKnIrUylru0MCIi3tZfOuyhL3GFK3glTZfxh2Qtl3GLv/wfK\n         7qfTX6Fh7/6vXCDAf/0Xaz1G1KDmAjnhN6AMsTDJWe43PXOo/C5NDU5XG//sgV5NxCwj\n         EV1jiOPWDAywFgskNDhDJDmarPU9N3Eef0Mfe1YME4LMPRMa0yNurpow/Hv4B7PgEF9H\n         A8Rg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776107481; x=1776712281;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=fXWGSvkFU16FgOFRkCaaPZi61w++nh88NCvP7Zfs+t0=;\n        b=Ltu6vlavJRmCfymR47CuvKf60Y9b0dLxUf7oa6jOrDzPTmqTpbeVR1ljgy2nhZNpZF\n         tFkDf3DsEEHd1akIIHCykyXOWGGTiHM0JSimZ785WL2moXzikPYiTQsB5LeKWPlIxaSw\n         5rSOmoGgv3mOBe+2/q5aQMbUV1C2d9KDvpDczRU5p9spAvx4zbO8SXRW/qShX1WuWWjN\n         /xAqhC0pEld90tlEOrVuZCe5n/zmBlrA5rktbPQB6u1MEujtngY7wSzokavli4Gkmr56\n         3b4u7EJN9opcM5wIWu4vm4HNAnzd7hCs+M8oqcLcNVJXiNmrUZd6SxRqZFiWKzrNDyAj\n         QPnw==","X-Forwarded-Encrypted":"i=1;\n AFNElJ98pryrZgGO+JDPjTvcQy7wKxGh6H01AtBo5hpDKfbCqpqvIS27gR9+7JRC9fp3ZnZ5xWJjhIytKf9I@vger.kernel.org","X-Gm-Message-State":"AOJu0YyokaggVbZQ+NiTb0x+LI72nCx0VMHHkAXUjHj4pgE0SczBFM4S\n\trAgcYnhuh37B/74FQjrrrRID1UDYiVxVIk7FGeDTHKayvzEbTSzBRALoDCucIiLmPk70A4hvVNP\n\th35MwzkY=","X-Gm-Gg":"AeBDiev574L/EFm3Vxy047IbgTpuDOL4ltCcNPbUVW31Qy3/Gdy3q6GWjrSYqUlbpAk\n\tsOEwyJJDecMkVxWlOURk1fd/M+jlPAo8X5GyVYYxjgBwe5chqrhknZZIZug4rOKTtsIlRqhi7LQ\n\tV1YjYNW9iY3ZLiLytg9TREuIpmJOXt98o4gb3P3Bt61OAzXXgAxIWbWwiSmwTGo+zwGD2kKiTFR\n\tc40xGu7SAHn6+pwiNOC5OEcU4/gqpy5T2icEBA6IL/AOkK9d7IrFzo65SLGi96RqROUXHDK/JZv\n\tz8qGLoVMTcjlrrekTZh27eber/7reXHe9+xsAAKphzZyGQoFkuFLd/pStcW9HEZQFkQNDC6n+8n\n\tsq1+vPFPVmqXG9o4vF5dC17KNsaGJsxpoN6NzT2f5DZs7VHMtLoI9MaojIEVkdj/KxUtR/4B+NR\n\tvy7fNTCNouWFb74iM0GyDqg1+y7bdL3eg=","X-Received":"by 2002:a05:600c:3f0d:b0:485:40fd:8390 with SMTP id\n 5b1f17b1804b1-488d68769f9mr181491475e9.26.1776107480576;\n        Mon, 13 Apr 2026 12:11:20 -0700 (PDT)","From":"Henrique Carvalho <henrique.carvalho@suse.com>","To":"sfrench@samba.org","Cc":"pc@manguebit.org,\n\tronniesahlberg@gmail.com,\n\tsprasad@microsoft.com,\n\ttom@talpey.com,\n\tbharathsm@microsoft.com,\n\tematsumiya@suse.de,\n\tlinux-cifs@vger.kernel.org,\n\tstable@vger.kernel.org","Subject":"[PATCH 1/2] smb: client: serialize channel scaling path","Date":"Mon, 13 Apr 2026 16:11:09 -0300","Message-ID":"<20260413191110.1508848-1-henrique.carvalho@suse.com>","X-Mailer":"git-send-email 2.53.0","Precedence":"bulk","X-Mailing-List":"linux-cifs@vger.kernel.org","List-Id":"<linux-cifs.vger.kernel.org>","List-Subscribe":"<mailto:linux-cifs+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-cifs+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"Channel scaling serialization was coded at several call sites with plain\nflag values in ses->flags, which duplicated the same bookkeeping in\nreconnect and remount paths, and was missing in the mount path.\n\nMove the CIFS_SES_FLAG_SCALE_CHANNELS acquisition and release inside\nsmb3_update_ses_channels(), and convert the session flags to bit indices\nand their operations to bitops.\n\nMake smb3_update_ses_channels return -EBUSY if there is already an\nongoing channel scaling operation.\n\nFixes: 556bb341f9f2e (\"smb: client: introduce multichannel async work during mount\")\nCc: stable@vger.kernel.org\nSigned-off-by: Henrique Carvalho <henrique.carvalho@suse.com>\n---\n fs/smb/client/cifsglob.h   |  6 +++---\n fs/smb/client/fs_context.c | 15 ---------------\n fs/smb/client/smb2pdu.c    | 24 ++++++++----------------\n 3 files changed, 11 insertions(+), 34 deletions(-)","diff":"diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h\nindex 709e96e07791..7b1323927711 100644\n--- a/fs/smb/client/cifsglob.h\n+++ b/fs/smb/client/cifsglob.h\n@@ -1049,8 +1049,8 @@ struct cifs_chan {\n \t__u8 signkey[SMB3_SIGN_KEY_SIZE];\n };\n \n-#define CIFS_SES_FLAG_SCALE_CHANNELS (0x1)\n-#define CIFS_SES_FLAGS_PENDING_QUERY_INTERFACES (0x2)\n+#define CIFS_SES_FLAG_SCALE_CHANNELS 0\n+#define CIFS_SES_FLAGS_PENDING_QUERY_INTERFACES 1\n \n /*\n  * Session structure.  One of these for each uid session with a particular host\n@@ -1089,7 +1089,7 @@ struct cifs_ses {\n \tbool domainAuto:1;\n \tbool expired_pwd;  /* track if access denied or expired pwd so can know if need to update */\n \tint unicode;\n-\tunsigned int flags;\n+\tunsigned long flags;\n \t__u16 session_flags;\n \t__u8 smb3signingkey[SMB3_SIGN_KEY_SIZE];\n \t__u8 smb3encryptionkey[SMB3_ENC_DEC_KEY_SIZE];\ndiff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c\nindex a46764c24710..e0e13c22e159 100644\n--- a/fs/smb/client/fs_context.c\n+++ b/fs/smb/client/fs_context.c\n@@ -1166,27 +1166,12 @@ static int smb3_reconfigure(struct fs_context *fc)\n \n \t\t/* Synchronize ses->chan_max with the new mount context */\n \t\tsmb3_sync_ses_chan_max(ses, ctx->max_channels);\n-\t\t/* Now update the session's channels to match the new configuration */\n-\t\t/* Prevent concurrent scaling operations */\n-\t\tspin_lock(&ses->ses_lock);\n-\t\tif (ses->flags & CIFS_SES_FLAG_SCALE_CHANNELS) {\n-\t\t\tspin_unlock(&ses->ses_lock);\n-\t\t\tmutex_unlock(&ses->session_mutex);\n-\t\t\treturn -EINVAL;\n-\t\t}\n-\t\tses->flags |= CIFS_SES_FLAG_SCALE_CHANNELS;\n-\t\tspin_unlock(&ses->ses_lock);\n \n \t\tmutex_unlock(&ses->session_mutex);\n \n \t\trc = smb3_update_ses_channels(ses, ses->server,\n \t\t\t\t\t       false /* from_reconnect */,\n \t\t\t\t\t       false /* disable_mchan */);\n-\n-\t\t/* Clear scaling flag after operation */\n-\t\tspin_lock(&ses->ses_lock);\n-\t\tses->flags &= ~CIFS_SES_FLAG_SCALE_CHANNELS;\n-\t\tspin_unlock(&ses->ses_lock);\n \t} else {\n \t\tmutex_unlock(&ses->session_mutex);\n \t}\ndiff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c\nindex 5188218c25be..2eb13b2665a4 100644\n--- a/fs/smb/client/smb2pdu.c\n+++ b/fs/smb/client/smb2pdu.c\n@@ -228,6 +228,10 @@ int smb3_update_ses_channels(struct cifs_ses *ses, struct TCP_Server_Info *serve\n \t\t\tbool from_reconnect, bool disable_mchan)\n {\n \tint rc = 0;\n+\n+\tif (test_and_set_bit(CIFS_SES_FLAG_SCALE_CHANNELS, &ses->flags))\n+\t\treturn -EBUSY;\n+\n \t/*\n \t * Manage session channels based on current count vs max:\n \t * - If disable requested, skip or disable the channel\n@@ -243,6 +247,7 @@ int smb3_update_ses_channels(struct cifs_ses *ses, struct TCP_Server_Info *serve\n \t\t\trc = cifs_chan_skip_or_disable(ses, server, from_reconnect, disable_mchan);\n \t}\n \n+\tclear_bit(CIFS_SES_FLAG_SCALE_CHANNELS, &ses->flags);\n \treturn rc;\n }\n \n@@ -432,15 +437,6 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,\n \t\tgoto out;\n \t}\n \n-\tspin_lock(&ses->ses_lock);\n-\tif (ses->flags & CIFS_SES_FLAG_SCALE_CHANNELS) {\n-\t\tspin_unlock(&ses->ses_lock);\n-\t\tmutex_unlock(&ses->session_mutex);\n-\t\tgoto skip_add_channels;\n-\t}\n-\tses->flags |= CIFS_SES_FLAG_SCALE_CHANNELS;\n-\tspin_unlock(&ses->ses_lock);\n-\n \tif (!rc &&\n \t    (server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL) &&\n \t    server->ops->query_server_interfaces) {\n@@ -450,11 +446,11 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,\n \t\t * is in progress. This will be used to avoid calling\n \t\t * smb2_reconnect recursively.\n \t\t */\n-\t\tses->flags |= CIFS_SES_FLAGS_PENDING_QUERY_INTERFACES;\n+\t\tset_bit(CIFS_SES_FLAGS_PENDING_QUERY_INTERFACES, &ses->flags);\n \t\txid = get_xid();\n \t\trc = server->ops->query_server_interfaces(xid, tcon, false);\n \t\tfree_xid(xid);\n-\t\tses->flags &= ~CIFS_SES_FLAGS_PENDING_QUERY_INTERFACES;\n+\t\tclear_bit(CIFS_SES_FLAGS_PENDING_QUERY_INTERFACES, &ses->flags);\n \n \t\tif (!tcon->ipc && !tcon->dummy)\n \t\t\tqueue_delayed_work(cifsiod_wq, &tcon->query_interfaces,\n@@ -492,10 +488,6 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,\n \t}\n \n skip_add_channels:\n-\tspin_lock(&ses->ses_lock);\n-\tses->flags &= ~CIFS_SES_FLAG_SCALE_CHANNELS;\n-\tspin_unlock(&ses->ses_lock);\n-\n \tif (smb2_command != SMB2_INTERNAL_CMD)\n \t\tcifs_queue_server_reconn(server);\n \n@@ -609,7 +601,7 @@ static int smb2_ioctl_req_init(u32 opcode, struct cifs_tcon *tcon,\n \t */\n \tif (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO ||\n \t    (opcode == FSCTL_QUERY_NETWORK_INTERFACE_INFO &&\n-\t     (tcon->ses->flags & CIFS_SES_FLAGS_PENDING_QUERY_INTERFACES)))\n+\t     test_bit(CIFS_SES_FLAGS_PENDING_QUERY_INTERFACES, &tcon->ses->flags)))\n \t\treturn __smb2_plain_req_init(SMB2_IOCTL, tcon, server,\n \t\t\t\t\t     request_buf, total_len);\n \n","prefixes":["1/2"]}