From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 5ED813F58E1 for ; Wed, 22 Jul 2026 16:52:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784739124; cv=none; b=WILlSdEnx1lQxsPU/3LA800XVkVDf0jJPp2Oo1C7/5JiXYfhgNvBUcqzY9/C01+5AeDIQ2T3u41ohC8R8+cbXC8ZTJTDtyCpvTypLA8EuopJzdaNgKdaWFOU64/M4HTBi2VblaZiivK5c1smLwvSEGcg/1TAhml0fxjal2TWX+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784739124; c=relaxed/simple; bh=3OBjDCrXbkshDPWrBFZvUPmCd/A4iyF0hKSuVFjDq2o=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=RQcKiWTC9vXVQfQ8evR4mCISOsBYoMrnBcnPdjN76s86mZlDBfarjdd1caPgVeRzA1cQiD6jFnqbMFEp1TVIRVfIO7OV7oEjiadQHiDwa4ROkAkzgjivBbKnI5zvWb+8HZe6/4JYhJfovVlIxUSinxDrgbDVO3DBzG/eKQKJ08g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=T4Oy45FR; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="T4Oy45FR" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-49548aebcd8so38639355e9.3 for ; Wed, 22 Jul 2026 09:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1784739118; x=1785343918; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=3OBjDCrXbkshDPWrBFZvUPmCd/A4iyF0hKSuVFjDq2o=; b=T4Oy45FRsQool3gTagcgDvStP4ABcXfRiueFgBhv1c2Ir4svF5BVLc6NGb61PpwHcO NC0i+SkTJIOfFxOgYcEWowhe9QccTxtoSqZ1oroyvQXKCg3RJV3Rm7dP2HzWfRoDlX88 Gnpe8RBIKMc930f9I7eSKUueyhZYPyENgBCx8oeoibtkd+bYzrJmmRViayZYESVqFSNR 525SWoxqIKMJzUuuqxBlF/nOC+pFTgdqjpqEpioCjtlyN4gqqGZ9ZBAs3B+A06sJlGb3 p4Tk0Q4y2k5WkEH6sgPM3okmRjZJ+CJIw9cGoM+lc+hoXUPSvtJ5LpbuJwqbdqYNL/V1 P0jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784739118; x=1785343918; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3OBjDCrXbkshDPWrBFZvUPmCd/A4iyF0hKSuVFjDq2o=; b=IUcihsceyMEqfWq2se/KqWTKsMmEOB+3KXOsfD4PwrJNrRqQhW73NeG4NNk8UXU8E/ M6cbqxsSsxXDzSr6z0C3SyJXEcCHOraHb5KKCeIjpxvoKbvWJI8EvQuwR/mk4SUlqEOs lcjOo9pL2U/jGHgUlwhytNqlmP1IgrjXg/4JNhOiYy+teH8LPAXd3ZCYc0oXkKmRbo1X 5DEekX9mydXDNb1Rx2xrbyrJrESLrqmiF9EqSdwLSnBU8S6Zq1Sv0z4rE+DGwAswFLvE UGlshJOwN4jEKvk0KJSfzNXcYWrZAWAFJ6nK9krFME3GJDwgioAoAS8OP+chc4hpPg9O JEbg== X-Forwarded-Encrypted: i=1; AHgh+Rp09aID9ZepIR6234vT1yMOzLo/QhaZly+A71+WjCAUFs0//OJgBd2C4F50QY+XUft1rQtzO8+B9epbnpo=@vger.kernel.org X-Gm-Message-State: AOJu0YxZzF73brb2Eynb+UEb5mX8EwN9N8c2C4rSNV42pCMuOaquDUhW 6/5DsJrW4AWoQNM5SozGZem65rpunpsim8ra8Uv4uCKQPrhket8mImOCuzXZF80I1Fk= X-Gm-Gg: AR+sD11UeVSGGqWqnpVZBX4ptMUewXW6rWI10a1j6XmZ57+cU/2qoVUAfavgc8WhNj+ 6ZxqnyVvdR4uFdD9SF0yxm8aDYUmNDeZJcjYLWktdm7KE/93YGoBtNrfnsdaXy9v0jQTq4sc3Dn 9X9a3vMxCjnuCuzYWz45+qiFY8k4L4+PwLyXB/D2JNhyWpPRbVEgF73VfxHt3yDeiB1+4B2KE4Y YS4hUSiiIv/D92Bm93RKIZSPBNZMBAnZkJayQTPGrzso3szbp6rYrXEQhL6Mz7Pjk0Qd9BvcXZ9 kfsmLKkRLE/QNd5ARcxFyqIQTnh1cCp1XSXuezcvvvLYSMq/ZXjr9GFTCzyWrTiIFvKY99J/OxD 2e1614TVvk9rieUtjda7jyyhOsTi4IVE7QV7guVuFXxI4QFmNID0bmKrd8PVNC7sUndQRaMxXkQ tHtgigTNjhFA== X-Received: by 2002:a05:600c:a0a:b0:493:ee2b:c876 with SMTP id 5b1f17b1804b1-4954a41302fmr281006525e9.35.1784739117891; Wed, 22 Jul 2026 09:51:57 -0700 (PDT) Received: from localhost ([2804:1b2:1845:e230:d77c:4dd5:9d52:7b96]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5c2c6486f59sm3647313e0c.11.2026.07.22.09.51.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2026 09:51:57 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 22 Jul 2026 13:51:52 -0300 Message-Id: Cc: "Paulo Alcantara" , "Ronnie Sahlberg" , "Shyam Prasad N" , "Tom Talpey" , "Bharath SM" , "Henrique Carvalho" , , , Subject: Re: [RFC] smb: client: define async channel update serialization From: "Henrique Carvalho" To: "Pengpeng Hou" , "Steve French" X-Mailer: aerc 0.21.0 References: <20260722041043.90682-1-pengpeng@iscas.ac.cn> In-Reply-To: <20260722041043.90682-1-pengpeng@iscas.ac.cn> On Wed Jul 22, 2026 at 1:10 AM -03, Pengpeng Hou wrote: > Commit 556bb341f9f2 ("smb: client: introduce multichannel async work > during mount") moved multichannel setup out of the mount path and into > independent work items. Mounts can share an existing session, so more tha= n > one worker can update the same channel array concurrently. > > cifs_try_adding_channels() snapshots chan_count and the number of missing > channels under chan_lock, but drops that lock while each channel is opene= d. > Two workers can therefore act on the same initial count. More importantly= , > cifs_ses_add_channel() publishes a new slot before taking session_mutex, = and > its failure path later decrements the current chan_count. If another work= er > has appended a slot in between, that rollback can remove the wrong tail. > At the array limit, a stale worker can also index chans[chan_count] after > another worker has filled the last slot. > > I considered making the mount worker use > CIFS_SES_FLAG_SCALE_CHANNELS, but that flag is not a blocking lock. A wor= ker > that fails to acquire it has no retry or completion to wait on. I have a patch that uses the delaying idea, please see: https://lore.kernel= .org/linux-cifs/20260429205236.456099-2-henrique.carvalho@suse.com/ It should be rebased and tweaked, though, I have been delaying this for a while now. Do you have any opinion? > In addition, > smb2_reconnect() currently clears the flag on a shared exit path even whe= n it > only observed another updater owning it, Actually this looks like a bug to me, no? Why is smb2_reconnect() clearing a flag it did not acquire? > and an early channel-disable path > runs before the existing flag acquisition. > > Extending session_mutex around slot publication and rollback would serial= ize > concurrent additions, but it does not by itself serialize the reconfigure > decrease path. Conversely, a new mutex around all of > smb3_update_ses_channels() needs an explicit lock order because reconnect= can > call channel removal while already holding session_mutex, whereas channel > addition later acquires session_mutex for session setup. > > Would you prefer this to be fixed by coalescing mount requests onto one > per-session work item, or by introducing a dedicated channel-update > serialization primitive with an agreed lock order? Once that lifetime and > locking contract is clear, I can prepare a narrow patch and keep the capa= city > check at the actual chans[] append as a final invariant. I like the idea to put everything in the same worker so instead of having a mchan_mount work have just an mchan_work and reschedule it from mount / remount / reconnect. I have started this but abandoned because I couldn't find a good enough reason to change things. It just seemed I was moving the complexity elsewhere without any real benefit. --=20 Henrique