From patchwork Tue Feb 6 15:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13547426 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 2A4AC132C04 for ; Tue, 6 Feb 2024 15:00:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707231658; cv=none; b=WkSODRDmfLOkUB9s/UD/wznYUz57C8JS1KIuQOz9EArRmas1flVUSPSf8l5ISozUR1jtqdaU2rQuPVgY58VIPVtcH72/k1mvbo+bzpSVeRcKRF9Z1jd7TxFYHCzpSr+g3MvewZd0VLDuKn+hhPrclUt60TjsM9hsQMkchla0vbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707231658; c=relaxed/simple; bh=VOjw6zdt6ysdHKlrSLJ9ybf1leA1AU4wrH8jwM5LvO8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=C82i2jrQO4Vr6tNzBzjE8+BOmL4UJZtpWi02ch92COoGaZiRo73g+kxMZ6nM/Xb5GKOmkobrt124W3HcA3zvj1VsReCRT8cIpykD3kNJGL4qvuXiGLine9dxRaJZ6a/XkypoP89oE1h7JVLYhFf8QS25/X/OVAqDZCH8Stf4fVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bJRCBhVZ; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bJRCBhVZ" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5d3912c9a83so4351217a12.3 for ; Tue, 06 Feb 2024 07:00:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707231656; x=1707836456; 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; bh=4qak/bMFK3ZZUXX1iYJGjyJFzWMe99xsH3fWn58J3h0=; b=bJRCBhVZfIS4Cu8+X0gbhEOCkKESXHyvHGvIC9Eb2u4kKqmR9BpdFHzrm/1c0bo1NM +syK8gGpt1HU9/eilJSqylVKQXUIeXGwRA0JOvZEFMPzgdwOFoqnT/f1N1XNs9U/srJZ psdZvQyBMWAx2JE02EZ/5Kp897XpImnNi0ohA4kSRBEe/ChzczYhn4NTgWPEQqPG6BGi tyi4MBiE/bbMjyljc5AWIuzWoiQTO/xFg5LHVKMKA6XPI26X1VMm1RDn4xFfnEF26nzx rEwDkvByq31xSothB3aQ60ZuplkVOZy0xwd8oKcXEZhFQxwMkjhHZbOm0C7c9WlYQw69 vPmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707231656; x=1707836456; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4qak/bMFK3ZZUXX1iYJGjyJFzWMe99xsH3fWn58J3h0=; b=oy3pSP9BvFysEQuMF2C5CuuEY8kq2lfmqfFFu5eXfufq74qN18Kqyd3Mnsg+G16i+q ADVuZVVG4MuNmlTtz0N52aFh6/r0kuSzok6CEwX1b1oLr/rDa1QwwUX7C5lqj4YEITAG S9Y7sz9btrDocPN3Bvg/4KdnMkTPTEO2KYKhKAg7f2P8v2akdX/2HMRNmDpj2s8NH8jQ YWQSFicg0xNcumt6H7egIr5a2Sh8Cz3ki9kkquGpROcBIFyG7yPYmubmidP1roq/eynh j1cPid9LIFq6HUYk+R6GQNffOZQ+Gam8ht9TvJEp3T+S8xICFcdqvVvosEKLOtMjtWhQ VGVA== X-Gm-Message-State: AOJu0YwEgKDs9aiOkclQPK9mg2koe/RgN8KOmF16TyaAXLc5eLgVHR7j JlQaCQtzkMljKPaoc0qHX0MrgH7XQ+jUIA0SuunrLk7oucD9fTlXJDVq1bTh X-Google-Smtp-Source: AGHT+IEMk6L7RSFPmYV6vRvoJN9WHEo9jHdyStsg1H1cP9zS2JhoIBWYiISpRtPkxyU4qTnSvxk3bQ== X-Received: by 2002:a17:902:e548:b0:1d8:fafa:f923 with SMTP id n8-20020a170902e54800b001d8fafaf923mr2430617plf.10.1707231655587; Tue, 06 Feb 2024 07:00:55 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV7y6BmilRdA5kFta4ACDq4B5TAbbuaof6Y608Qo29exPLagEB6fpCpDtehGj8v6dnRKtuOuvoQi3iXwO5G9I8SSMt00YnGi0ZAcVzH9DZ/4eQJalW4DM9VjYLvj2nUGZXj75nNQhzxwRYuPXxlgWUBJJIpbxwgpntaqf9DLw== Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id mp7-20020a170902fd0700b001d8f81ecebesm1963075plb.192.2024.02.06.07.00.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 07:00:55 -0800 (PST) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@manguebit.com, bharathsm@microsoft.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 1/2] cifs: change tcon status when need_reconnect is set on it Date: Tue, 6 Feb 2024 15:00:46 +0000 Message-Id: <20240206150047.29046-1-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shyam Prasad N When a tcon is marked for need_reconnect, the intention is to have it reconnected. This change adjusts tcon->status in cifs_tree_connect when need_reconnect is set. Also, this change has a minor correction in resetting need_reconnect on success. It makes sure that it is done with tc_lock held. Signed-off-by: Shyam Prasad N --- fs/smb/client/connect.c | 5 +++++ fs/smb/client/dfs.c | 7 ++++++- fs/smb/client/file.c | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index c5cf88de32b7..28cacdd90bbf 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -4230,6 +4230,11 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru /* only send once per connect */ spin_lock(&tcon->tc_lock); + + /* if tcon is marked for needing reconnect, update state */ + if (tcon->need_reconnect) + tcon->status = TID_NEED_TCON; + if (tcon->status == TID_GOOD) { spin_unlock(&tcon->tc_lock); return 0; diff --git a/fs/smb/client/dfs.c b/fs/smb/client/dfs.c index a8a1d386da65..449c59830039 100644 --- a/fs/smb/client/dfs.c +++ b/fs/smb/client/dfs.c @@ -565,6 +565,11 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru /* only send once per connect */ spin_lock(&tcon->tc_lock); + + /* if tcon is marked for needing reconnect, update state */ + if (tcon->need_reconnect) + tcon->status = TID_NEED_TCON; + if (tcon->status == TID_GOOD) { spin_unlock(&tcon->tc_lock); return 0; @@ -625,8 +630,8 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru spin_lock(&tcon->tc_lock); if (tcon->status == TID_IN_TCON) tcon->status = TID_GOOD; - spin_unlock(&tcon->tc_lock); tcon->need_reconnect = false; + spin_unlock(&tcon->tc_lock); } return rc; diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 6e53657154d6..d068e2a962de 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -175,6 +175,9 @@ cifs_mark_open_files_invalid(struct cifs_tcon *tcon) /* only send once per connect */ spin_lock(&tcon->tc_lock); + if (tcon->need_reconnect) + tcon->status = TID_NEED_RECON; + if (tcon->status != TID_NEED_RECON) { spin_unlock(&tcon->tc_lock); return; From patchwork Tue Feb 6 15:00:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13547427 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 B7F9913248D for ; Tue, 6 Feb 2024 15:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707231662; cv=none; b=e1MJ0HiEXrTFyzM8BCRYv45XzbawssUfBlh1u0WACTX+AzBN5VzFPN0tBZEpN/MRtmS6a7DAYnkewT9Jp4zZOpW/P4g7dMfB8kl2bHxYVU5OnFPzSlKAvFzkRS1pp54rRueR+TDMUqCLbWI3bE7Uo0r3mv4HQsTu7SYX0+nBfcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707231662; c=relaxed/simple; bh=nXYhExoNdAA56mNtCf1unIHCwtDCOVvXfIfY4OA9mw4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CNjutQHiaqRo8TLEHWHLRFD0rti3HdBmA98q6TcBRIoE9/Ye46V82NPhmL46nRGq1vNFg7Y/iWhyHlPhuZgobsFzzaf1TaS7Kk8zD74xCfN8mwoW4iJ2xtphDPrLKiMX6rUTya307+dM+5XAR2zb8i5Ub0IezSYvZazaQgGgfes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LrFRJ1yu; arc=none smtp.client-ip=209.85.215.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LrFRJ1yu" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-5d8b276979aso832445a12.2 for ; Tue, 06 Feb 2024 07:01:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707231659; x=1707836459; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aoxc2C9ooRZCcJ35WSoZUMfVMEHXfSDdllFFAd+NNIw=; b=LrFRJ1yutqFrI1Z450E6rDuWyC7D41Lkb+ll3bCnx8WCeSjS7JOL93p0HPjvwwtuT+ 4nOXzOeI9qX1ABujnwyZ8FWPCzy59HDL/Ubb82F1nFh7CkhZkDHqUUHT5bEND78YEk6E gc/LFmlARwOqbEcLSo7C4bH65JgYyGR34TQaQ8Zbg6LUxRyhfcqrU1E7jERPD9qEaOfo NkXX6W4iSv+UJ+Z45wfGrySQa4vHsZ1VwNF+s1SfU4x85jPh8ymJrecWFgoVpaW9iMad C1mqIpxbi+Ha7CDj07meb+TlaAIc/zgMOjszCIfMKfysVUuu9ZTKzgc4iPnZTpZwMlZz zFKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707231659; x=1707836459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aoxc2C9ooRZCcJ35WSoZUMfVMEHXfSDdllFFAd+NNIw=; b=ZsNMEOK/3BTTT0ZjSYWJro78hrHxEw91qEopVMcyrInwIKb9TSPA4p4dzmEvJyObwP fvdRbHkd+ypn0Ec+pUzNBQCexy2sNXSGbMNfEEImAOT3ck+iFA1bqJB882j+8kBk/Di/ BuU8CzlKTorzxXH/uzzv9jOByd8JiLmCU+c94HkSxcyja5mFeXrSQ0qYtEY0cvZlBC66 SOAyoBE2cuSX6TjPxW0W/ArmgTuBySV431E+bCabEo+ScvTuDCvBWKy1P0gXm1If384e h6k95ghvt6zgb36qUErBrpdIabiwCxMulPz0XpJTswxI0kNAjIbErbqqXieUFxzvjOjh iWrA== X-Gm-Message-State: AOJu0Yx2iA+zwUQHKAh3Jmm9u/yKoeZgr2VXr1NIXRWNLiCJvzOU+sZj /5YtUJ1r2I0vQqDUeqlYRmM8Z8gUkjpCsr7bTMbYjSOU9aurb+0aFXSJel2u X-Google-Smtp-Source: AGHT+IECZ7iXjdwQ0cpGTQKe8BjSpg1c1l4AvjUaVOIE4oqxybQMM+QP54IiCRWLOClng+y+kXp0SQ== X-Received: by 2002:a17:90a:7506:b0:296:696:1271 with SMTP id q6-20020a17090a750600b0029606961271mr2866497pjk.43.1707231658717; Tue, 06 Feb 2024 07:00:58 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWIa9Jm3+nOGrQ9UAvVMTT1/nZnIe9PWDwqKB9z3jMVBxstsswTuDUQxmwaJ+Lnc6aQvf92f7RecyAUxW/X1m8oC3dldL6B7rBw4oTlRXhNWwZeHFZdXKvPp9bD2mh2d4gsDfe8kRXGDEzFiWEL/ORVHROz0PDoShJYNWgKIg== Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id mp7-20020a170902fd0700b001d8f81ecebesm1963075plb.192.2024.02.06.07.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 07:00:58 -0800 (PST) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@manguebit.com, bharathsm@microsoft.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 2/2] cifs: handle cases where multiple sessions share connection Date: Tue, 6 Feb 2024 15:00:47 +0000 Message-Id: <20240206150047.29046-2-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206150047.29046-1-sprasad@microsoft.com> References: <20240206150047.29046-1-sprasad@microsoft.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Shyam Prasad N Based on our implementation of multichannel, it is entirely possible that a server struct may not be found in any channel of an SMB session. In such cases, we should be prepared to move on and search for the server struct in the next session. Signed-off-by: Shyam Prasad N --- fs/smb/client/connect.c | 6 ++++++ fs/smb/client/sess.c | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 28cacdd90bbf..c984d802d2f7 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -233,6 +233,12 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, list_for_each_entry_safe(ses, nses, &pserver->smb_ses_list, smb_ses_list) { /* check if iface is still active */ spin_lock(&ses->chan_lock); + if (cifs_ses_get_chan_index(ses, server) == + CIFS_INVAL_CHAN_INDEX) { + spin_unlock(&ses->chan_lock); + continue; + } + if (!cifs_chan_is_iface_active(ses, server)) { spin_unlock(&ses->chan_lock); cifs_chan_update_iface(ses, server); diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c index 476d54fceb50..8f37373fd333 100644 --- a/fs/smb/client/sess.c +++ b/fs/smb/client/sess.c @@ -88,7 +88,6 @@ cifs_ses_get_chan_index(struct cifs_ses *ses, if (server) cifs_dbg(VFS, "unable to get chan index for server: 0x%llx", server->conn_id); - WARN_ON(1); return CIFS_INVAL_CHAN_INDEX; }