From patchwork Mon Oct 30 11:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22C71C4332F for ; Mon, 30 Oct 2023 11:00:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232294AbjJ3LAb (ORCPT ); Mon, 30 Oct 2023 07:00:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231741AbjJ3LAb (ORCPT ); Mon, 30 Oct 2023 07:00:31 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31FEAB3 for ; Mon, 30 Oct 2023 04:00:29 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1cc2f17ab26so12394695ad.0 for ; Mon, 30 Oct 2023 04:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663628; x=1699268428; 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=JfBQ0kZpS0waR4OSRDMf+jgERxVRLh5PmV9Xsh8YXgc=; b=WCXrSsi+JTzwDGFir365W/QzP1Ai7dmplKDWmvj6akG3Y40Bq2cW0x4eeF/hbCPwfy 2ub/K9yHXZ2bzle9rqP/qW1oxZiqDArcgijKREwGuPzQpYKieP4/Py9TwzUawqi11TFf Wb7hxmYDAQMwrxCBQnuXMpGvsv+mhJ3vNsaVp1vSsOBdl0MzabsSdOm45kxxV8/ukaMy /KspZ94dahT6JXBisYKs4cL28drMqBXL9W8xmcmlLJB42gWjRBj1j/ibrbfZ5JOtnaAD nqKx2djmaWpYKv7HLHvyAVxca6Vh2RrSjBvhwouEsxVR/H+xdno1Otp1+z2L8CVLbI4x zzZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663628; x=1699268428; 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=JfBQ0kZpS0waR4OSRDMf+jgERxVRLh5PmV9Xsh8YXgc=; b=wYazZMCdcz09K04okNCJV8sth0HJ9qmGhi7Zm+qcE0t5BKM/++wZFAO0c8reIcLhog 3Fya97oo+ofzIn2lqZqlzXGDdymOAtId77OhlJid3Zmb39xXKKRpHahLOrE7HQIuQk0Z nBar4IhEEx6CjC6Lk/pjYml3i9TH4tavM7gQeuBUcZeQR0ubAac1o95SQ82xi+PKrMUo 8LaAeh78hHwbr7st/EhhA4B3/CKLNsj/vllYn+y/8DNQIryc0fh/caK/PguAUSy0axC4 lfI9ThYj3jZM4wLyV13HmSnZEwWJZrQiiQ9pAXlAe8Ud68X0JvfKyjH8k1S3d11KHzyG +KIg== X-Gm-Message-State: AOJu0YynexVlAfqpAzCuBiEhUaMeIzD9oOlbgNfELCZ6+98qs1n5yqcF 67ncln0onkheCF7h6Vvyl+d7BJ2hNgFZyw== X-Google-Smtp-Source: AGHT+IF0r676uf78wOZb+NWgXSHxo7pypZBClLRCfFOQD9AYylWPgl9XlBF3tYzlVygYBcO6tcom/Q== X-Received: by 2002:a17:903:190:b0:1cc:50ad:4e with SMTP id z16-20020a170903019000b001cc50ad004emr1524300plg.47.1698663628484; Mon, 30 Oct 2023 04:00:28 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:28 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 01/14] cifs: print server capabilities in DebugData Date: Mon, 30 Oct 2023 11:00:07 +0000 Message-Id: <20231030110020.45627-1-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N In the output of /proc/fs/cifs/DebugData, we do not print the server->capabilities field today. With this change, we will do that. Signed-off-by: Shyam Prasad N --- fs/smb/client/cifs_debug.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c index 76922fcc4bc6..a9dfecc397a8 100644 --- a/fs/smb/client/cifs_debug.c +++ b/fs/smb/client/cifs_debug.c @@ -427,6 +427,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) if (server->nosharesock) seq_printf(m, " nosharesock"); + seq_printf(m, "\nServer capability: 0x%x", server->capabilities); + if (server->rdma) seq_printf(m, "\nRDMA "); seq_printf(m, "\nTCP status: %d Instance: %d" From patchwork Mon Oct 30 11:00:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440490 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF24DC4332F for ; Mon, 30 Oct 2023 11:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231741AbjJ3LAf (ORCPT ); Mon, 30 Oct 2023 07:00:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbjJ3LAe (ORCPT ); Mon, 30 Oct 2023 07:00:34 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13F5E8E for ; Mon, 30 Oct 2023 04:00:32 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5a1d89ff4b9so2250427a12.0 for ; Mon, 30 Oct 2023 04:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663631; x=1699268431; 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=+9XWfUK1gR7L2c5oJtv73DgD0wDa60KgbGGhbOtXmB8=; b=c6hYP+iQxyE+FDHVHeef7k/Ld/8AgqrMmIoSCP52FBwGXSNfUJYv+y/7ovrFPHmzKN ZGPG6/ZVr2khKns71AD2xv/PMHr+xrrWBvfYeE9cibiNuU/OsvxIGHU/eKSEaXrdQ7SG S99WpE4Kgh8BHf/fITzYxoYdhZIo0LMsSsgvoU7Gfcu2I0XFECPKzYOsjm5LNK6xJETY TiCg1LcVDOaPN1C6EoQ6cFRYwWbsY4ow8g2tBrEe7kIOSisE1y1TUWhP7LPgc4CZeZoG lt8DHhWcuCMC914zG2pFKM6/H4NSgl56E5OLhuYI3+M4bsyFHg0Dy58ckn+uWyophCUi hWQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663631; x=1699268431; 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=+9XWfUK1gR7L2c5oJtv73DgD0wDa60KgbGGhbOtXmB8=; b=XcCfs7ucR4Zpuy5mB767MpTQvLupoOEBlpsAQl5Z/eBpBMRAoxqabvLO/+rWyIimQW fT8/zuu2K2Ju0CtSy6N7eRKtodPAY6chDoSa3IDk68BBXdN7C8Qwktq24aqxbBCQ6fDO qqbz1VKVgHWdTGsZp2PorIQi0KiFMJU8NyW1tW3DdjB5J232VLpwZ/C3ziktMO8Bk/wn UJviksz7sPcvkogid0TmiKhv9KwDUYgB7VshD7UCpYmN0cmMXNRPMDjN83RKjRJQcGx4 bcrGf4yWXnsY/1cLFvjReuQujVx2PbpXPiYbMcaWQxa1MUyqLRbPXtG17UWvLUGwUlnH bAsQ== X-Gm-Message-State: AOJu0YwJ36tKooa/tX5SGlC3BLU+481YuciXv5NYMaQqO9YPEuA7kYMm uP5S2E2Hd+dzzXGATTTUI2I= X-Google-Smtp-Source: AGHT+IE8Q1W1QsdH3AnX9GJ/AmE62fuEgrZ24AWwizPGZHAp/DF/6/ORrQHx6yQ22opMzZHKls3cPg== X-Received: by 2002:a05:6a21:780a:b0:17b:4c98:840d with SMTP id be10-20020a056a21780a00b0017b4c98840dmr6805811pzc.51.1698663631222; Mon, 30 Oct 2023 04:00:31 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:30 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 02/14] cifs: add xid to query server interface call Date: Mon, 30 Oct 2023 11:00:08 +0000 Message-Id: <20231030110020.45627-2-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N We were passing 0 as the xid for the call to query server interfaces. This is not great for debugging. This change adds a real xid. Signed-off-by: Shyam Prasad N --- fs/smb/client/connect.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 7b923e36501b..15a1c86482ed 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -119,6 +119,7 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server) static void smb2_query_server_interfaces(struct work_struct *work) { int rc; + int xid; struct cifs_tcon *tcon = container_of(work, struct cifs_tcon, query_interfaces.work); @@ -126,7 +127,10 @@ static void smb2_query_server_interfaces(struct work_struct *work) /* * query server network interfaces, in case they change */ - rc = SMB3_request_interfaces(0, tcon, false); + xid = get_xid(); + rc = SMB3_request_interfaces(xid, tcon, false); + free_xid(xid); + if (rc) { cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n", __func__, rc); From patchwork Mon Oct 30 11:00:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65225C4332F for ; Mon, 30 Oct 2023 11:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232462AbjJ3LAi (ORCPT ); Mon, 30 Oct 2023 07:00:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbjJ3LAg (ORCPT ); Mon, 30 Oct 2023 07:00:36 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0228A2 for ; Mon, 30 Oct 2023 04:00:34 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1cc3c51f830so6434185ad.1 for ; Mon, 30 Oct 2023 04:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663634; x=1699268434; 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=ICzSLXeoD0ITnkAtcKn86VcbHdl72JGenBPNIvo1dvo=; b=m6IanPKRN4m2emMDJX8oODecfM9nLkB3xb2lhjhT31S6mHh7gH+RdTyd32ItGHR1bE x0glxhP6erxP1KPlwk4Y5M+D51pOtNGy2R9VfNGNLBVdxPW43VPxg8sw1RJfhVYToAxs XPxkoN+rKtqrbhITjFgFArPI5HI9Su23PJIQAuuP0Q7IbvfXy0KE/1scc5irMWa/1/lV mHDoCwS+nVtptvup8wSZSBuuFASBz3L50D2TvEWA+xQOeCw7Qxi+/RjDIa/qaQ1VX7LM OKK1AwJTbKlpwOrQaFzJrD4ve84WnhLOgtRRva7pv6YXmqI+adgbTOz2SxWKGD79odnd bgng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663634; x=1699268434; 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=ICzSLXeoD0ITnkAtcKn86VcbHdl72JGenBPNIvo1dvo=; b=SXx8oRarSsBvDKfqyHXUBMswdaE/fQ6aA/nB0IRY+o4zAl6+7lTW0b4zuGA8Krf7os VPAi1xUJLEvWo4UV2nlDEK9Zu6ixtm3NayuH2iZPJ5RuLWyO0npGRS2Qcc9uZmQcEJXN 4LBZ1pnPNBVzRguyd8Pd6CsNIqXdaWiWPreqaAH7ricR6EkoNYr68rW432OtsnMUaJFy OvldBSwFkbIF1qrWk8lIMFCA/4FRSyCxtUWBSAqI1x7H8JJJlilB4BMy5XxeMnqOWNHr saTwde0KwiW7FxNGLnr8X7WS/WLMaCjyFEDuvbXOAR0qZkn+py+3pLivWm117eoe+2en 1r8Q== X-Gm-Message-State: AOJu0YxhVfytcFtF5+epYJS3CM51xQkZed/LiW7fpBmwtg4DOOrVIXDK AXiLf3JrL7ecYgkGtJwRHNNizXw0PuMWBA== X-Google-Smtp-Source: AGHT+IF9CWeKcH6VfQK1PeONsH0DBSMb6lITp0zU6X0W7S0DhQ+jKu1cRGv4C9+7jhdqWGcKyPG5Zg== X-Received: by 2002:a17:902:c94d:b0:1cc:4e78:d10f with SMTP id i13-20020a170902c94d00b001cc4e78d10fmr1709194pla.8.1698663633954; Mon, 30 Oct 2023 04:00:33 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:33 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 03/14] cifs: reconnect helper should set reconnect for the right channel Date: Mon, 30 Oct 2023 11:00:09 +0000 Message-Id: <20231030110020.45627-3-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N We introduced a helper function to be used by non-cifsd threads to mark the connection for reconnect. For multichannel, when only a particular channel needs to be reconnected, this had a bug. This change fixes that by marking that particular channel for reconnect. Fixes: dca65818c80c ("cifs: use a different reconnect helper for non-cifsd threads") Signed-off-by: Shyam Prasad N Reviewed-by: Paulo Alcantara (SUSE) --- fs/smb/client/connect.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 15a1c86482ed..c993c7a3415a 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -160,13 +160,14 @@ cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server, /* If server is a channel, select the primary channel */ pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; - spin_lock(&pserver->srv_lock); + /* if we need to signal just this channel */ if (!all_channels) { - pserver->tcpStatus = CifsNeedReconnect; - spin_unlock(&pserver->srv_lock); + spin_lock(&server->srv_lock); + if (server->tcpStatus != CifsExiting) + server->tcpStatus = CifsNeedReconnect; + spin_unlock(&server->srv_lock); return; } - spin_unlock(&pserver->srv_lock); spin_lock(&cifs_tcp_ses_lock); list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) { From patchwork Mon Oct 30 11:00:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440492 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E71ABC4332F for ; Mon, 30 Oct 2023 11:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232617AbjJ3LAl (ORCPT ); Mon, 30 Oct 2023 07:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbjJ3LAj (ORCPT ); Mon, 30 Oct 2023 07:00:39 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 253DA8E for ; Mon, 30 Oct 2023 04:00:37 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1cc58219376so2982365ad.1 for ; Mon, 30 Oct 2023 04:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663636; x=1699268436; 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=TSCBoTpZQNnQSt2SvBhlDPv2smh1rFdBZGtA8T/SKTk=; b=GfOtue1nHbXMfjUtLq4oTR0CU8LqPQw7ON6BCdSlhQHlROty/c94Hg12fpai7riFXp gO2xJHXnAhUct0tnD8GV5A0A2uaihY9SRmmQ4SngmxtzIk5DaajGr+PxI/P9WBY8zSRT jkJJGAwBCKB7JNn3+8RUMOwxtO7gwLQWCHO10NV7dHsC/KCPhOcwtccCNPvLsLQJEOEC Ue12+746hsR+Wdw+rbjpdMcZKOVqFQiiCUvCe0m/khsDG8xTVQK3zfYMeBfWD1wZ1Q85 0Wzym96tSqgw5x+Vx0m4sn25ADXLnZjmBo1YYcYKIJpjflTFHnxBt6EHakJeXiR+IaxV sXAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663636; x=1699268436; 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=TSCBoTpZQNnQSt2SvBhlDPv2smh1rFdBZGtA8T/SKTk=; b=Vjeuf9zIyp8x+gJgOIAzdrpxT7CLQXT4ovzYgGibFoqN1bXMOeY0yGHUEu4IQLtJyI ELnXFSfojaNajc8TglK8It/0NTBqTMTnPSMmumnCPyFl00dj0dQdn1vIPmcBca270kw4 +ozTS6FsTOmT7j8APqSb7X+6up29Ak0AoZfjt3XRqm4fxLs6zhhZfQ5UIhFBnQz54csu ISKq2ZZBUDC5RyKp820HFxIe1XgltCpiFODCctzy7Edr92fWYiHe9sehhczhqFDGjnPP p9ciqooh7KsnAAi00EdQGJG2qqGfwok7GXND3KFvDzkJcHLPboPPXG/dqwcEozFUDKv6 7bVg== X-Gm-Message-State: AOJu0Yzow1qnP/zHsMaLmz+m2Zim6CTAmq1QEW89UzGARGbw/sGxnvR1 xtuJf9I6RqnLSkgQEbtuD80= X-Google-Smtp-Source: AGHT+IGXR4BtS6R+ESnLf/pIU1OZuXwKIghFE/tnM5aKJsiHsK9UDSRbAZddtzDdgu5pdUkVyZmlXg== X-Received: by 2002:a17:902:f301:b0:1cc:31a8:d733 with SMTP id c1-20020a170902f30100b001cc31a8d733mr4895644ple.44.1698663636571; Mon, 30 Oct 2023 04:00:36 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:36 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 04/14] cifs: do not reset chan_max if multichannel is not supported at mount Date: Mon, 30 Oct 2023 11:00:10 +0000 Message-Id: <20231030110020.45627-4-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N If the mount command has specified multichannel as a mount option, but multichannel is found to be unsupported by the server at the time of mount, we set chan_max to 1. Which means that the user needs to remount the share if the server starts supporting multichannel. This change removes this reset. What it means is that if the user specified multichannel or max_channels during mount, and at this time, multichannel is not supported, but the server starts supporting it at a later point, the client will be capable of scaling out the number of channels. Signed-off-by: Shyam Prasad N --- fs/smb/client/sess.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c index 79f26c560edf..c899b05c92f7 100644 --- a/fs/smb/client/sess.c +++ b/fs/smb/client/sess.c @@ -186,7 +186,6 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) } if (!(server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) { - ses->chan_max = 1; spin_unlock(&ses->chan_lock); cifs_server_dbg(VFS, "no multichannel support\n"); return 0; From patchwork Mon Oct 30 11:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ACA5C4167D for ; Mon, 30 Oct 2023 11:00:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232531AbjJ3LAm (ORCPT ); Mon, 30 Oct 2023 07:00:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232477AbjJ3LAl (ORCPT ); Mon, 30 Oct 2023 07:00:41 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD4EAB3 for ; Mon, 30 Oct 2023 04:00:39 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6b3c2607d9bso3661466b3a.1 for ; Mon, 30 Oct 2023 04:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663639; x=1699268439; 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=N4I3xxzZQ/86tSmbPo/sbLx+lHeB8MIVUaivcbdB4X4=; b=BpX2YiHveN0dJnbo2nmp3e4jQ22Dz0uDCr7ZYAXFDkSNf9ofZPGbn+g0mmCCqEy13q wRqyJdRNG+ZcvMi/jAbXLZTOMJehbHsf1qy2oasaBlZXIo2cy9C6em1i7VMMmHOiiomZ lxWEjVl1EfLjFEIyPt6okVCX91a+NGiCjbRPNDCPpJ/96FrIk166hc/avNRHZgmMVtIf lWeD8mnpigd/Vur8MNnrddi+IYnjH04X7prnAnWSYd+jF9cCKyKgPS7HmHX2+rlaAnPO 17eFs41jfSbBWiOr+ECf1jjc3s+eFo1cLBUDXD7FGFMA739xiF0MbqCErD3o/w3dOAKk cg8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663639; x=1699268439; 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=N4I3xxzZQ/86tSmbPo/sbLx+lHeB8MIVUaivcbdB4X4=; b=QcQ+YdcFIyre0lGcwKQRSjGFOoyf+DDhIZNeGRAeIPAZwxOT6yWSTuAyYASFJNF84L qe6zShfIOU8Up152GBgycdO3mq8nGfjLlmZpLbs892pM4oAHF7W2XXm/Apqy9yae7yYn VC+Iz6idTMgMeCi4xOngFYPu7dmTWuBwfceApjOD3GsngkN6ZUGtWrCfvfpiXGNlisbd p3XeM7a2DC4U9jEZsCMpwUfN1zhHY7h33ymG6DUsennUwZUumJOdLdjrPBJscoke/Tcm AmYUH/7ZVQio2jSnttyhe1MFyl387mmMe6ildZAKmGXQ1XPDzpPUcWHB8bUkTzK/LSBW SNhw== X-Gm-Message-State: AOJu0YwLiLm6p787SotAZVNdzzlU2m3ahYHh3eK+zjtICMTI8T47FVbD 5DY0+U2HsqsvhhOnkj4Je+k= X-Google-Smtp-Source: AGHT+IHtEct68+3DqrXwE1m0OWNEl4jXUfXhab//GkY5AIyZ5ojK0yh/Rprmx02R/U/snKxH8uQW0Q== X-Received: by 2002:a05:6a20:8f03:b0:13d:5b8e:db83 with SMTP id b3-20020a056a208f0300b0013d5b8edb83mr9506948pzk.9.1698663639193; Mon, 30 Oct 2023 04:00:39 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:38 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 05/14] cifs: force interface update before a fresh session setup Date: Mon, 30 Oct 2023 11:00:11 +0000 Message-Id: <20231030110020.45627-5-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N During a session reconnect, it is possible that the server moved to another physical server (happens in case of Azure files). So at this time, force a query of server interfaces again (in case of multichannel session), such that the secondary channels connect to the right IP addresses (possibly updated now). Signed-off-by: Shyam Prasad N --- fs/smb/client/connect.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index c993c7a3415a..97c9a32cff36 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -3854,8 +3854,12 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT(ses); spin_unlock(&ses->chan_lock); - if (!is_binding) + if (!is_binding) { ses->ses_status = SES_IN_SETUP; + + /* force iface_list refresh */ + ses->iface_last_update = 0; + } spin_unlock(&ses->ses_lock); /* update ses ip_addr only for primary chan */ From patchwork Mon Oct 30 11:00:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440494 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C248FC4332F for ; Mon, 30 Oct 2023 11:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232821AbjJ3LAr (ORCPT ); Mon, 30 Oct 2023 07:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232477AbjJ3LAp (ORCPT ); Mon, 30 Oct 2023 07:00:45 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6857CB3 for ; Mon, 30 Oct 2023 04:00:42 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c9b7c234a7so38052545ad.3 for ; Mon, 30 Oct 2023 04:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663642; x=1699268442; 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=juopXulIPRUS5UvLW/eHiGvTVVvlKCYB2NS5V7NQG3A=; b=cL7936BXBjAXpcpMQJMXzIK/vGtq/Uod8vLKVUDgfQRzIniyfqbNc9XoHMImyIyb35 gzn4J0owcXLfWaOiGsV2rJbsc9a8ydIbPHHu8VU3cZTYj5ATesfoxTWRpSmT3YOa8ti7 M03sIoon0mo89mVwf8LjQH7oSxfAkNjc1AEeKsc84Id3CZB1J5N/ik1PZAn3DX7KhEoz wvwhoTIGMpP6io3BeMrFG2VxxLmyV/sYgFnHHL6oVHr7n310bSAmCt3fPYK2aVv4FhDE pNsElQxI/o3TFgVsaVd8Nuie+3+GL9WMEEQVmRU4rHMaTDnnWmW594l94PIfXIv/dm90 QIYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663642; x=1699268442; 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=juopXulIPRUS5UvLW/eHiGvTVVvlKCYB2NS5V7NQG3A=; b=rGPgpHZZUByRpJXCjOHL8dK0cZ0NfGCcCSaOZv7icxzvDnNotfsp4zprKjl1EBnorR fOvAXSqNgVAOyDIiXv/UV74zIj+feDhgPWzp9f7Oeo0mkZzO+Jjsd2aLcGgtBtNXpSlG JN6QJNo6IZ9tj0Kdzmczk2jhE3wQYot2mzXY/xAom2GiaUoofK0dfbyP4GzSKjaTt4iK wwMquC7rFkEDJxYsrLFgh+FzBgm0LLOK+TfoRFhYQnGp/vKzLZEw9zSodwpm5X5Y2ZwX jK/JswW4xFJP8sK2tQoVTVWhEX4Fwnt3II+/xeFVQccl4h9LrkagINBNZ/7OvFr70X5k Ll2g== X-Gm-Message-State: AOJu0YyBeYjXxla9Q0uRCgemAY9vdIS7+lkNY4cVc/INPd4AAQIPoy4d AybgDhF1Pw1MwWZwpSorfG0= X-Google-Smtp-Source: AGHT+IEE3e/BD5Wzi/VcE8wg5uSoN16kO/2+cGTsD1JLxEfCW1FUqwb9DoHEYYxDfHNcbYkealG42g== X-Received: by 2002:a17:902:d2d2:b0:1cc:558a:6b02 with SMTP id n18-20020a170902d2d200b001cc558a6b02mr1037443plc.64.1698663641821; Mon, 30 Oct 2023 04:00:41 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:41 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 06/14] cifs: handle cases where a channel is closed Date: Mon, 30 Oct 2023 11:00:12 +0000 Message-Id: <20231030110020.45627-6-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N So far, SMB multichannel could only scale up, but not scale down the number of channels. In this series of patch, we now allow the client to deal with the case of multichannel disabled on the server when the share is mounted. With that change, we now need the ability to scale down the channels. This change allows the client to deal with cases of missing channels more gracefully. Signed-off-by: Shyam Prasad N --- fs/smb/client/cifs_debug.c | 5 +++++ fs/smb/client/cifsglob.h | 1 + fs/smb/client/cifsproto.h | 2 +- fs/smb/client/connect.c | 10 ++++++++-- fs/smb/client/sess.c | 25 +++++++++++++++++++++---- fs/smb/client/smb2transport.c | 8 +++++++- 6 files changed, 43 insertions(+), 8 deletions(-) diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c index a9dfecc397a8..9fca09539728 100644 --- a/fs/smb/client/cifs_debug.c +++ b/fs/smb/client/cifs_debug.c @@ -136,6 +136,11 @@ cifs_dump_channel(struct seq_file *m, int i, struct cifs_chan *chan) { struct TCP_Server_Info *server = chan->server; + if (!server) { + seq_printf(m, "\n\n\t\tChannel: %d DISABLED", i+1); + return; + } + seq_printf(m, "\n\n\t\tChannel: %d ConnectionId: 0x%llx" "\n\t\tNumber of credits: %d,%d,%d Dialect 0x%x" "\n\t\tTCP status: %d Instance: %d" diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 02082621d8e0..552ed441281a 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -1050,6 +1050,7 @@ struct cifs_ses { spinlock_t chan_lock; /* ========= begin: protected by chan_lock ======== */ #define CIFS_MAX_CHANNELS 16 +#define CIFS_INVAL_CHAN_INDEX (-1) #define CIFS_ALL_CHANNELS_SET(ses) \ ((1UL << (ses)->chan_count) - 1) #define CIFS_ALL_CHANS_GOOD(ses) \ diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index 0c37eefa18a5..65c84b3d1a65 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -616,7 +616,7 @@ bool is_server_using_iface(struct TCP_Server_Info *server, bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface); void cifs_ses_mark_for_reconnect(struct cifs_ses *ses); -unsigned int +int cifs_ses_get_chan_index(struct cifs_ses *ses, struct TCP_Server_Info *server); void diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 97c9a32cff36..8393977e21ee 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -173,8 +173,12 @@ cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server, list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) { spin_lock(&ses->chan_lock); for (i = 0; i < ses->chan_count; i++) { + if (!ses->chans[i].server) + continue; + spin_lock(&ses->chans[i].server->srv_lock); - ses->chans[i].server->tcpStatus = CifsNeedReconnect; + if (ses->chans[i].server->tcpStatus != CifsExiting) + ses->chans[i].server->tcpStatus = CifsNeedReconnect; spin_unlock(&ses->chans[i].server->srv_lock); } spin_unlock(&ses->chan_lock); @@ -2033,7 +2037,9 @@ void __cifs_put_smb_ses(struct cifs_ses *ses) kref_put(&ses->chans[i].iface->refcount, release_iface); ses->chans[i].iface = NULL; } - cifs_put_tcp_session(ses->chans[i].server, 0); + + if (ses->chans[i].server) + cifs_put_tcp_session(ses->chans[i].server, 0); ses->chans[i].server = NULL; } } diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c index c899b05c92f7..9d2228c2d7e5 100644 --- a/fs/smb/client/sess.c +++ b/fs/smb/client/sess.c @@ -69,7 +69,7 @@ bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface) /* channel helper functions. assumed that chan_lock is held by caller. */ -unsigned int +int cifs_ses_get_chan_index(struct cifs_ses *ses, struct TCP_Server_Info *server) { @@ -85,14 +85,16 @@ cifs_ses_get_chan_index(struct cifs_ses *ses, cifs_dbg(VFS, "unable to get chan index for server: 0x%llx", server->conn_id); WARN_ON(1); - return 0; + return CIFS_INVAL_CHAN_INDEX; } void cifs_chan_set_in_reconnect(struct cifs_ses *ses, struct TCP_Server_Info *server) { - unsigned int chan_index = cifs_ses_get_chan_index(ses, server); + int chan_index = cifs_ses_get_chan_index(ses, server); + if (chan_index == CIFS_INVAL_CHAN_INDEX) + return; ses->chans[chan_index].in_reconnect = true; } @@ -102,6 +104,8 @@ cifs_chan_clear_in_reconnect(struct cifs_ses *ses, struct TCP_Server_Info *server) { unsigned int chan_index = cifs_ses_get_chan_index(ses, server); + if (chan_index == CIFS_INVAL_CHAN_INDEX) + return; ses->chans[chan_index].in_reconnect = false; } @@ -111,6 +115,8 @@ cifs_chan_in_reconnect(struct cifs_ses *ses, struct TCP_Server_Info *server) { unsigned int chan_index = cifs_ses_get_chan_index(ses, server); + if (chan_index == CIFS_INVAL_CHAN_INDEX) + return true; /* err on the safer side */ return CIFS_CHAN_IN_RECONNECT(ses, chan_index); } @@ -120,6 +126,8 @@ cifs_chan_set_need_reconnect(struct cifs_ses *ses, struct TCP_Server_Info *server) { unsigned int chan_index = cifs_ses_get_chan_index(ses, server); + if (chan_index == CIFS_INVAL_CHAN_INDEX) + return; set_bit(chan_index, &ses->chans_need_reconnect); cifs_dbg(FYI, "Set reconnect bitmask for chan %u; now 0x%lx\n", @@ -131,6 +139,8 @@ cifs_chan_clear_need_reconnect(struct cifs_ses *ses, struct TCP_Server_Info *server) { unsigned int chan_index = cifs_ses_get_chan_index(ses, server); + if (chan_index == CIFS_INVAL_CHAN_INDEX) + return; clear_bit(chan_index, &ses->chans_need_reconnect); cifs_dbg(FYI, "Cleared reconnect bitmask for chan %u; now 0x%lx\n", @@ -142,6 +152,8 @@ cifs_chan_needs_reconnect(struct cifs_ses *ses, struct TCP_Server_Info *server) { unsigned int chan_index = cifs_ses_get_chan_index(ses, server); + if (chan_index == CIFS_INVAL_CHAN_INDEX) + return true; /* err on the safer side */ return CIFS_CHAN_NEEDS_RECONNECT(ses, chan_index); } @@ -151,6 +163,8 @@ cifs_chan_is_iface_active(struct cifs_ses *ses, struct TCP_Server_Info *server) { unsigned int chan_index = cifs_ses_get_chan_index(ses, server); + if (chan_index == CIFS_INVAL_CHAN_INDEX) + return true; /* err on the safer side */ return ses->chans[chan_index].iface && ses->chans[chan_index].iface->is_active; @@ -269,7 +283,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) spin_lock(&ses->chan_lock); chan_index = cifs_ses_get_chan_index(ses, server); - if (!chan_index) { + if (chan_index == CIFS_INVAL_CHAN_INDEX) { spin_unlock(&ses->chan_lock); return 0; } @@ -319,6 +333,9 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) spin_lock(&ses->chan_lock); chan_index = cifs_ses_get_chan_index(ses, server); + if (chan_index == CIFS_INVAL_CHAN_INDEX) + return 0; + ses->chans[chan_index].iface = iface; /* No iface is found. if secondary chan, drop connection */ diff --git a/fs/smb/client/smb2transport.c b/fs/smb/client/smb2transport.c index 23c50ed7d4b5..84ea67301303 100644 --- a/fs/smb/client/smb2transport.c +++ b/fs/smb/client/smb2transport.c @@ -413,7 +413,13 @@ generate_smb3signingkey(struct cifs_ses *ses, ses->ses_status == SES_GOOD); chan_index = cifs_ses_get_chan_index(ses, server); - /* TODO: introduce ref counting for channels when the can be freed */ + if (chan_index == CIFS_INVAL_CHAN_INDEX) { + spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); + + return -EINVAL; + } + spin_unlock(&ses->chan_lock); spin_unlock(&ses->ses_lock); From patchwork Mon Oct 30 11:00:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96C66C4332F for ; Mon, 30 Oct 2023 11:00:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232845AbjJ3LAu (ORCPT ); Mon, 30 Oct 2023 07:00:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232834AbjJ3LAs (ORCPT ); Mon, 30 Oct 2023 07:00:48 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A980A2 for ; Mon, 30 Oct 2023 04:00:45 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1cc5b705769so1669295ad.0 for ; Mon, 30 Oct 2023 04:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663644; x=1699268444; 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=VbxzwsYML2TG9HjAaC8hFOUftGKDbbj8oRkfNsQrJGA=; b=YpN5s6DJgceXik7lBazXetZrphV3vAtQuDDMxr3Zgg3AFdCfF2OBhwPMDgTJEyEd1w dW0LxJQtJS2iozgeiow6U5uu/+t1yUI1fwf8fmRLJkc4w/2dXHSnrSH8EREj0FJjjtmn sC8gA26PdgFJ0UbTcVtSVky7/ijid08Iq3NwuTxdjVBHzQpUDB3ij7BoNKB8Nzx9kPn5 jHiVPYUsY4TZng7lEyBcTn6tsz+82HTPGpToeeFeutC1sZeut9iFPk5HO0YhvM1Jdnh4 KD8/JWdkAD5xzIM8rP49TwOq2i32qzdsFqhiDS8JzzjwKiEBl8BiM9abwqZbshm1iHNw NeeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663644; x=1699268444; 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=VbxzwsYML2TG9HjAaC8hFOUftGKDbbj8oRkfNsQrJGA=; b=a0lVHb2vuu5jR9QYIDhKgbOKaaaFbervEjqI90cz8XwoXFL/I3yq5WHeDUjm5fYDgl nm8bOtWwdjIEq0j6+n6qT0kQQx3BP41r8PrkPC4GrUu8aZU4SQG4Z6zzG0BLVFXR3xKg PQTjo7a8Kfyc9uPrftF6XpqWkmAPPCpKu69PTYyt1lKEjP8UFKujX6RcmMyE5l4chIQG D0CLPF4VaZ0m4FTRxNwJ9LXdz39n2Eo/ZIdHwnB6noFo/d3xYq/L++RjpSuNa7VAN3HD M+qcj//0ATvF03Xf9kOxS1rfilbaePkqZMZllHUeOf1Gee+DTu5JkC3iBtidNLCsLVSb vf1w== X-Gm-Message-State: AOJu0YzvdZnNuncuFjncfkiY4eMXHv/2um6VK959N8E1j8ZLW6wZ3j7V 2iXpmDWdu+E+af0VaKA9QGrq1mTPmlyRZw== X-Google-Smtp-Source: AGHT+IFb7mvdmTS/GRL/xLdFpjH5ZZfqX7Tgi6Pn3Rh//f9BI2TraqH9+8jtpHM2tovHy/jYcj/jvA== X-Received: by 2002:a17:902:c1cb:b0:1cc:29ed:96ae with SMTP id c11-20020a170902c1cb00b001cc29ed96aemr7824865plc.41.1698663644447; Mon, 30 Oct 2023 04:00:44 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:44 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 07/14] cifs: distribute channels across interfaces based on speed Date: Mon, 30 Oct 2023 11:00:13 +0000 Message-Id: <20231030110020.45627-7-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N Today, if the server interfaces RSS capable, we simply choose the fastest interface to setup a channel. This is not a scalable approach, and does not make a lot of attempt to distribute the connections. This change does a weighted distribution of channels across all the available server interfaces, where the weight is a function of the advertised interface speed. Also make sure that we don't mix rdma and non-rdma for channels. Signed-off-by: Shyam Prasad N --- fs/smb/client/cifs_debug.c | 16 ++++++++ fs/smb/client/cifsglob.h | 2 + fs/smb/client/sess.c | 83 +++++++++++++++++++++++++++++++------- 3 files changed, 87 insertions(+), 14 deletions(-) diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c index 9fca09539728..e23fcabb78d6 100644 --- a/fs/smb/client/cifs_debug.c +++ b/fs/smb/client/cifs_debug.c @@ -284,6 +284,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) struct cifs_ses *ses; struct cifs_tcon *tcon; struct cifs_server_iface *iface; + size_t iface_weight = 0, iface_min_speed = 0; + struct cifs_server_iface *last_iface = NULL; int c, i, j; seq_puts(m, @@ -543,11 +545,25 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) "\tLast updated: %lu seconds ago", ses->iface_count, (jiffies - ses->iface_last_update) / HZ); + + last_iface = list_last_entry(&ses->iface_list, + struct cifs_server_iface, + iface_head); + iface_min_speed = last_iface->speed; + j = 0; list_for_each_entry(iface, &ses->iface_list, iface_head) { seq_printf(m, "\n\t%d)", ++j); cifs_dump_iface(m, iface); + + iface_weight = iface->speed / iface_min_speed; + seq_printf(m, "\t\tWeight (cur,total): (%zu,%zu)" + "\n\t\tAllocated channels: %u\n", + iface->weight_fulfilled, + iface_weight, + iface->num_channels); + if (is_ses_using_iface(ses, iface)) seq_puts(m, "\t\t[CONNECTED]\n"); } diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 552ed441281a..81e7a45f413d 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -969,6 +969,8 @@ struct cifs_server_iface { struct list_head iface_head; struct kref refcount; size_t speed; + size_t weight_fulfilled; + unsigned int num_channels; unsigned int rdma_capable : 1; unsigned int rss_capable : 1; unsigned int is_active : 1; /* unset if non existent */ diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c index 9d2228c2d7e5..d009994f82cf 100644 --- a/fs/smb/client/sess.c +++ b/fs/smb/client/sess.c @@ -178,7 +178,9 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) int left; int rc = 0; int tries = 0; + size_t iface_weight = 0, iface_min_speed = 0; struct cifs_server_iface *iface = NULL, *niface = NULL; + struct cifs_server_iface *last_iface = NULL; spin_lock(&ses->chan_lock); @@ -206,21 +208,11 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) } spin_unlock(&ses->chan_lock); - /* - * Keep connecting to same, fastest, iface for all channels as - * long as its RSS. Try next fastest one if not RSS or channel - * creation fails. - */ - spin_lock(&ses->iface_lock); - iface = list_first_entry(&ses->iface_list, struct cifs_server_iface, - iface_head); - spin_unlock(&ses->iface_lock); - while (left > 0) { tries++; if (tries > 3*ses->chan_max) { - cifs_dbg(FYI, "too many channel open attempts (%d channels left to open)\n", + cifs_dbg(VFS, "too many channel open attempts (%d channels left to open)\n", left); break; } @@ -228,17 +220,34 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) spin_lock(&ses->iface_lock); if (!ses->iface_count) { spin_unlock(&ses->iface_lock); + cifs_dbg(VFS, "server %s does not advertise interfaces\n", ses->server->hostname); break; } + if (!iface) + iface = list_first_entry(&ses->iface_list, struct cifs_server_iface, + iface_head); + last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface, + iface_head); + iface_min_speed = last_iface->speed; + list_for_each_entry_safe_from(iface, niface, &ses->iface_list, iface_head) { + /* do not mix rdma and non-rdma interfaces */ + if (iface->rdma_capable != ses->server->rdma) + continue; + /* skip ifaces that are unusable */ if (!iface->is_active || (is_ses_using_iface(ses, iface) && - !iface->rss_capable)) { + !iface->rss_capable)) + continue; + + /* check if we already allocated enough channels */ + iface_weight = iface->speed / iface_min_speed; + + if (iface->weight_fulfilled >= iface_weight) continue; - } /* take ref before unlock */ kref_get(&iface->refcount); @@ -255,10 +264,21 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) continue; } - cifs_dbg(FYI, "successfully opened new channel on iface:%pIS\n", + iface->num_channels++; + iface->weight_fulfilled++; + cifs_dbg(VFS, "successfully opened new channel on iface:%pIS\n", &iface->sockaddr); break; } + + /* reached end of list. reset weight_fulfilled and start over */ + if (list_entry_is_head(iface, &ses->iface_list, iface_head)) { + list_for_each_entry(iface, &ses->iface_list, iface_head) + iface->weight_fulfilled = 0; + spin_unlock(&ses->iface_lock); + iface = NULL; + continue; + } spin_unlock(&ses->iface_lock); left--; @@ -277,8 +297,10 @@ int cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) { unsigned int chan_index; + size_t iface_weight = 0, iface_min_speed = 0; struct cifs_server_iface *iface = NULL; struct cifs_server_iface *old_iface = NULL; + struct cifs_server_iface *last_iface = NULL; int rc = 0; spin_lock(&ses->chan_lock); @@ -298,13 +320,34 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) spin_unlock(&ses->chan_lock); spin_lock(&ses->iface_lock); + if (!ses->iface_count) { + spin_unlock(&ses->iface_lock); + cifs_dbg(VFS, "server %s does not advertise interfaces\n", ses->server->hostname); + return 0; + } + + last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface, + iface_head); + iface_min_speed = last_iface->speed; + /* then look for a new one */ list_for_each_entry(iface, &ses->iface_list, iface_head) { + /* do not mix rdma and non-rdma interfaces */ + if (iface->rdma_capable != server->rdma) + continue; + if (!iface->is_active || (is_ses_using_iface(ses, iface) && !iface->rss_capable)) { continue; } + + /* check if we already allocated enough channels */ + iface_weight = iface->speed / iface_min_speed; + + if (iface->weight_fulfilled >= iface_weight) + continue; + kref_get(&iface->refcount); break; } @@ -320,10 +363,22 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) cifs_dbg(FYI, "replacing iface: %pIS with %pIS\n", &old_iface->sockaddr, &iface->sockaddr); + + old_iface->num_channels--; + if (old_iface->weight_fulfilled) + old_iface->weight_fulfilled--; + iface->num_channels++; + iface->weight_fulfilled++; + kref_put(&old_iface->refcount, release_iface); } else if (old_iface) { cifs_dbg(FYI, "releasing ref to iface: %pIS\n", &old_iface->sockaddr); + + old_iface->num_channels--; + if (old_iface->weight_fulfilled) + old_iface->weight_fulfilled--; + kref_put(&old_iface->refcount, release_iface); } else { WARN_ON(!iface); From patchwork Mon Oct 30 11:00:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440496 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD231C4167B for ; Mon, 30 Oct 2023 11:00:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232477AbjJ3LAw (ORCPT ); Mon, 30 Oct 2023 07:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232902AbjJ3LAu (ORCPT ); Mon, 30 Oct 2023 07:00:50 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA83DA2 for ; Mon, 30 Oct 2023 04:00:47 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1cc394f4cdfso6749755ad.0 for ; Mon, 30 Oct 2023 04:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663647; x=1699268447; 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=qyP4YNE6Ns7yBrAVyG5IyRivauhL8xPwm1O+XM8Vg3I=; b=j0ZrNlKRYZBz7P3OR3RsyUOZx15g6gyCihQ/vMCY1iiSipSRzDPUhzTnnZlvApo6pW Vp2CC33u/xap8Aell9boGILZCv4P4GHj1gfLanwDylLUrbuABL/F31wJQTdqqt20aKWE V7mJ6jl4q4xMywMlnoJa3JjEyM3OV2UeCEz1mBkMhHvmSSd0dOzqllbtGTI0Lwx2IInk U5vB5P9wrt10qKR1QYU2HZyC5g25aAGg6FmmXGNaLGwgAobWWCAYSxcfc5DpDa7o4YaS HmVABaPAa46SnHpx1K8e4c+7qPPfmgP0WWiDiu6WNkkCcqN7ksIwic+pC8nTxp1N/PNT tTfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663647; x=1699268447; 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=qyP4YNE6Ns7yBrAVyG5IyRivauhL8xPwm1O+XM8Vg3I=; b=Fu3nre6HW5YgGkOrOtqWaXjqZ9sBqTVuQ7PnXNeMmVSeMT+8HpbRTPlPiRAXO6AUY4 xhq6uZImAr0MOsuZkEoSeJlh1UtwtSW5j+WH1yM1ts2NXBlKxDF6YuW8cIcn2PuYZtgp 4EdPpQolLW4Ja7kGeq0oZKaXmTLtzvnRVtqEAkvOQ1ONDXjDYnAm9+S/reENs+OeyRE1 dhBSwldGS2nouAeO4cogt8Ha7dorW6koM7WGJYDljJxDA1M8spLwrs0lDnt5n/QeegvQ 4O3VnEuXAiZO6BU+ZJ+UjOCFKmTb4KmTWhTkNBTVHv/U3KXyVTqaxUdTbZjNw+ZEeDtn eRdw== X-Gm-Message-State: AOJu0YyerfdQVYhCpNU9JkIdFpH5jFco7ceJ5U/++GwbprvZogsKnFvC nyI3f2L5ovDIYYjH/IRGh1U= X-Google-Smtp-Source: AGHT+IEybekkA1aC6fawp0wfMdfQL2ho3g0NSMKBtnx7YivgK5T/bbDCDDA6205JMs1Z30PN7iMdvQ== X-Received: by 2002:a17:903:2387:b0:1cc:54fa:f15a with SMTP id v7-20020a170903238700b001cc54faf15amr935226plh.13.1698663647082; Mon, 30 Oct 2023 04:00:47 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:46 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 08/14] cifs: account for primary channel in the interface list Date: Mon, 30 Oct 2023 11:00:14 +0000 Message-Id: <20231030110020.45627-8-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N The refcounting of server interfaces should account for the primary channel too. Although this is not strictly necessary, doing so will account for the primary channel in DebugData. Signed-off-by: Shyam Prasad N --- fs/smb/client/sess.c | 23 +++++++++++++++++++++++ fs/smb/client/smb2ops.c | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c index d009994f82cf..6843deed6119 100644 --- a/fs/smb/client/sess.c +++ b/fs/smb/client/sess.c @@ -332,6 +332,16 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) /* then look for a new one */ list_for_each_entry(iface, &ses->iface_list, iface_head) { + if (!chan_index) { + /* if we're trying to get the updated iface for primary channel */ + if (!cifs_match_ipaddr((struct sockaddr *) &server->dstaddr, + (struct sockaddr *) &iface->sockaddr)) + continue; + + kref_get(&iface->refcount); + break; + } + /* do not mix rdma and non-rdma interfaces */ if (iface->rdma_capable != server->rdma) continue; @@ -358,6 +368,13 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) cifs_dbg(FYI, "unable to find a suitable iface\n"); } + if (!chan_index && !iface) { + cifs_dbg(VFS, "unable to get the interface matching: %pIS\n", + &server->dstaddr); + spin_unlock(&ses->iface_lock); + return 0; + } + /* now drop the ref to the current iface */ if (old_iface && iface) { cifs_dbg(FYI, "replacing iface: %pIS with %pIS\n", @@ -380,6 +397,12 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) old_iface->weight_fulfilled--; kref_put(&old_iface->refcount, release_iface); + } else if (!chan_index) { + /* special case: update interface for primary channel */ + cifs_dbg(FYI, "referencing primary channel iface: %pIS\n", + &iface->sockaddr); + iface->num_channels++; + iface->weight_fulfilled++; } else { WARN_ON(!iface); cifs_dbg(FYI, "adding new iface: %pIS\n", &iface->sockaddr); diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 9aeecee6b91b..e7e1e0e5bdfe 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -756,6 +756,7 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_ unsigned int ret_data_len = 0; struct network_interface_info_ioctl_rsp *out_buf = NULL; struct cifs_ses *ses = tcon->ses; + struct TCP_Server_Info *pserver; /* do not query too frequently */ if (ses->iface_last_update && @@ -780,6 +781,11 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_ if (rc) goto out; + /* check if iface is still active */ + pserver = ses->chans[0].server; + if (pserver && !cifs_chan_is_iface_active(ses, pserver)) + cifs_chan_update_iface(ses, pserver); + out: kfree(out_buf); return rc; From patchwork Mon Oct 30 11:00:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BBA1C4332F for ; Mon, 30 Oct 2023 11:00:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232849AbjJ3LAy (ORCPT ); Mon, 30 Oct 2023 07:00:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232834AbjJ3LAw (ORCPT ); Mon, 30 Oct 2023 07:00:52 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CD5BB7 for ; Mon, 30 Oct 2023 04:00:50 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1cc3bb32b5dso12223135ad.3 for ; Mon, 30 Oct 2023 04:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663650; x=1699268450; 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=ZpeBlQtoIatyPHt0zNGHUw+uJ9g65B52GwNHUGgaCn4=; b=aD8zXWXmINnOFsrb/067ViZhWdvoHYtTPeQS2fJe+vk7D0VzQbBMwsjtSfw9hQrLwM J38RYNNRBCc6+yXmOo6TcbWxorpxcguvVknsWt1ysOud9AOGCt6WA599Z3tvGw6U0aoK 2wdDWTgH4LizFz/WaF+vOGOD0LwlfxIKoxIDYiBoc4pWdQ/LhOdbywQmmKCum2yUrCAc YiMe6QxRzNfK5rcu9tYIIKc7fttgb6al8j+2m4eYqmFZBppXAbvai2umNqlWGTiztXMM LVtecAyTtdS1ldoLnBdXbwVaeX9FryznNuGkH3tKHbuDjPhNM0X+5ctTPUYs34kq+hE3 waZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663650; x=1699268450; 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=ZpeBlQtoIatyPHt0zNGHUw+uJ9g65B52GwNHUGgaCn4=; b=PrigahUIN/H/+VY0eHAYjrsJDMXt4r+WE9hbW40fK+3cqlB0q6wtb522ikiVP7Iht/ qcv0FDGhFRfjqIqZdjxHYUeGSyHHc6eOcO/a6Xv6Pfes1DrvkM3i8d78JLzXz1LiXCnR o86vSVCwmP7ZZNF4LWy8p9YwwhYaXiY8L/0wT06yc8xsrdLxKtevh1mDjAY4m0akkgrp FV/TMRaeFH2tbHZ2twuy/3voaKhNymc/g0NH91O2P99cb3QU13QCuujrnAsQaJ9Ruttr V4GAoPYQ6ITczh3LT+6ZqzsIMhY4+AX6tVdu9qCxdb1Vp3loENXvdGPLMjzw6aXLP8Pw pHdQ== X-Gm-Message-State: AOJu0YyTLD9F64n66G1Q5X53vM+o03fWrXUp5hkOKP1ST5iXCsouStml Sdt0eb9WV+zLMhcyayDYg7FxHN2Y3IHCaA== X-Google-Smtp-Source: AGHT+IHz3/KyXzZxAoadvuozSq+FqzYKJeyd8FdzwWKpBgyRLrhNvaGSR8n8IlsKP9pxy0PuZy1ypQ== X-Received: by 2002:a17:903:191:b0:1c6:d88:dc07 with SMTP id z17-20020a170903019100b001c60d88dc07mr11237097plg.48.1698663649709; Mon, 30 Oct 2023 04:00:49 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:49 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 09/14] cifs: add a back pointer to cifs_sb from tcon Date: Mon, 30 Oct 2023 11:00:15 +0000 Message-Id: <20231030110020.45627-9-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N Today, we have no way to access the cifs_sb when we just have pointers to struct tcon. This is very limiting as many functions deal with cifs_sb, and these calls do not directly originate from VFS. This change introduces a new cifs_sb field in cifs_tcon that points to the cifs_sb for the tcon. The assumption here is that a tcon will always map to this cifs_sb and will never change. Also, refcounting should not be necessary, since cifs_sb will never be freed before tcon. Signed-off-by: Shyam Prasad N Reviewed-by: Paulo Alcantara (SUSE) --- fs/smb/client/cifsglob.h | 1 + fs/smb/client/connect.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 81e7a45f413d..cdbc2cd207dc 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -1134,6 +1134,7 @@ struct cifs_tcon { int tc_count; struct list_head rlist; /* reconnect list */ spinlock_t tc_lock; /* protect anything here that is not protected */ + struct cifs_sb_info *cifs_sb; /* back pointer to cifs super block */ atomic_t num_local_opens; /* num of all opens including disconnected */ atomic_t num_remote_opens; /* num of all network opens on server */ struct list_head openFileList; diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 8393977e21ee..184075da5c6e 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -3355,6 +3355,7 @@ int cifs_mount_get_tcon(struct cifs_mount_ctx *mnt_ctx) tcon = NULL; goto out; } + tcon->cifs_sb = cifs_sb; /* if new SMB3.11 POSIX extensions are supported do not remap / and \ */ if (tcon->posix_extensions) @@ -3986,6 +3987,7 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid) cifs_put_smb_ses(ses); goto out; } + tcon->cifs_sb = cifs_sb; #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY if (cap_unix(ses)) From patchwork Mon Oct 30 11:00:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440498 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5F46C4167D for ; Mon, 30 Oct 2023 11:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232834AbjJ3LA4 (ORCPT ); Mon, 30 Oct 2023 07:00:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232839AbjJ3LAz (ORCPT ); Mon, 30 Oct 2023 07:00:55 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1211C0 for ; Mon, 30 Oct 2023 04:00:52 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c8a1541232so38205065ad.0 for ; Mon, 30 Oct 2023 04:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663652; x=1699268452; 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=g2rHcIvsbGvPqhqUsa3jjoReaW4WV1bGbaJkMyFwPlQ=; b=icJphQnDErani1wQ/1G+/UAKR5uXxG3zCgn6sVUjXdooLq4Lanol74y1rsz8nQuonp WqQlTANH1p6Ci2/Pj4uSb0MsTTu1ceqKxg5agwG0bkX+/Q/kWx+bTYHylNOqXhNlYUR/ n+983mPhFGr4xPuEH5n+8KMcIOoDOB60ecaH8qq326fDefZiDrTWqTQwvkq+XW15w9RD 4DaCkdcHCqPCAoSFmLXCR2zIx0udEJfhehMsQ3Ci93wQVr0XQFneeU+nrJKpB255UWEH 2V/lPgqeBdJsxc0AqMw7yUP63BMZ9Xf4IJ7kSZuuAw+fnsA5MWcLP4WLRhX8YfGf7Rbf JXjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663652; x=1699268452; 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=g2rHcIvsbGvPqhqUsa3jjoReaW4WV1bGbaJkMyFwPlQ=; b=NvBAPc2Fom6+XAS5HODQylPRYOGGIwHwHMr0LBDP+b4nsN8308qrvt3QV/gjA7Ba+G GyipgaugLT1ygTI4B7rsxPjfREx3FhhOurVH1n2BEnT5QAypIGoZx4vto0J9YA99Q6TC MfExKPbzqXtjhBdPzh99UtZNBbC0+ifeinERVPv7UPi8KGojN7/UfpZ4EnWuTn0ArOFf pS/65SV033bLoCezAUwXB2PYrQ7m5N3xo57kRvMonQhbU7EpqJuOwzQZq5w4UwNUONOH ltQo3ql/i8Py/fi0UmmNTU1vkkZUWq/f3zupesLZqpsR/YLbADFZr/d7CrQTwqKSqFX6 EeXg== X-Gm-Message-State: AOJu0YzI9vOAZ+hJg5717zH+HRAsET5qaGWkaaQlc3+h2HFhXvrZC3mu I18DbqUjXn6TMy3MldXAWf1kKq8/NjEaRg== X-Google-Smtp-Source: AGHT+IF4BAh+X7Yt7GNoJGm6Tc4Xcv1ztPi+0caPGJZ2W5OTgJFZlbV38qk5vqG8WbuBk3CKE3YBEw== X-Received: by 2002:a17:902:ecce:b0:1cc:59a1:79c6 with SMTP id a14-20020a170902ecce00b001cc59a179c6mr672446plh.18.1698663652338; Mon, 30 Oct 2023 04:00:52 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:51 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 10/14] cifs: reconnect work should have reference on server struct Date: Mon, 30 Oct 2023 11:00:16 +0000 Message-Id: <20231030110020.45627-10-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N The delayed work for reconnect takes server struct as a parameter. But it does so without holding a ref to it. Normally, this may not show a problem as the reconnect work is only cancelled on umount. However, since we now plan to support scaling down of channels, and the scale down can happen from reconnect work itself, we need to fix it. This change takes a reference on the server struct before it is passed to the delayed work. And drops the reference in the delayed work itself. Or if the delayed work is successfully cancelled, by the process that cancels it. Signed-off-by: Shyam Prasad N --- fs/smb/client/connect.c | 27 +++++++++++++++++++++------ fs/smb/client/smb2pdu.c | 23 +++++++++++++---------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 184075da5c6e..e71aa33bf026 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -389,7 +389,13 @@ static int __cifs_reconnect(struct TCP_Server_Info *server, spin_unlock(&server->srv_lock); cifs_swn_reset_server_dstaddr(server); cifs_server_unlock(server); - mod_delayed_work(cifsiod_wq, &server->reconnect, 0); + + /* increase ref count which reconnect work will drop */ + spin_lock(&cifs_tcp_ses_lock); + server->srv_count++; + spin_unlock(&cifs_tcp_ses_lock); + if (mod_delayed_work(cifsiod_wq, &server->reconnect, 0)) + cifs_put_tcp_session(server, false); } } while (server->tcpStatus == CifsNeedReconnect); @@ -519,7 +525,13 @@ static int reconnect_dfs_server(struct TCP_Server_Info *server) spin_unlock(&server->srv_lock); cifs_swn_reset_server_dstaddr(server); cifs_server_unlock(server); - mod_delayed_work(cifsiod_wq, &server->reconnect, 0); + + /* increase ref count which reconnect work will drop */ + spin_lock(&cifs_tcp_ses_lock); + server->srv_count++; + spin_unlock(&cifs_tcp_ses_lock); + if (mod_delayed_work(cifsiod_wq, &server->reconnect, 0)) + cifs_put_tcp_session(server, false); } while (server->tcpStatus == CifsNeedReconnect); mutex_lock(&server->refpath_lock); @@ -1601,16 +1613,19 @@ cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect) cancel_delayed_work_sync(&server->echo); - if (from_reconnect) + if (from_reconnect) { /* * Avoid deadlock here: reconnect work calls * cifs_put_tcp_session() at its end. Need to be sure * that reconnect work does nothing with server pointer after * that step. */ - cancel_delayed_work(&server->reconnect); - else - cancel_delayed_work_sync(&server->reconnect); + if (cancel_delayed_work(&server->reconnect)) + cifs_put_tcp_session(server, from_reconnect); + } else { + if (cancel_delayed_work_sync(&server->reconnect)) + cifs_put_tcp_session(server, from_reconnect); + } spin_lock(&server->srv_lock); server->tcpStatus = CifsExiting; diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index c75a80bb6d9e..b7665155f4e2 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -3852,12 +3852,6 @@ void smb2_reconnect_server(struct work_struct *work) } spin_unlock(&ses->chan_lock); } - /* - * Get the reference to server struct to be sure that the last call of - * cifs_put_tcon() in the loop below won't release the server pointer. - */ - if (tcon_exist || ses_exist) - server->srv_count++; spin_unlock(&cifs_tcp_ses_lock); @@ -3905,13 +3899,17 @@ void smb2_reconnect_server(struct work_struct *work) done: cifs_dbg(FYI, "Reconnecting tcons and channels finished\n"); - if (resched) + if (resched) { queue_delayed_work(cifsiod_wq, &server->reconnect, 2 * HZ); + mutex_unlock(&pserver->reconnect_mutex); + + /* no need to put tcp session as we're retrying */ + return; + } mutex_unlock(&pserver->reconnect_mutex); /* now we can safely release srv struct */ - if (tcon_exist || ses_exist) - cifs_put_tcp_session(server, 1); + cifs_put_tcp_session(server, true); } int @@ -3931,7 +3929,12 @@ SMB2_echo(struct TCP_Server_Info *server) server->ops->need_neg(server)) { spin_unlock(&server->srv_lock); /* No need to send echo on newly established connections */ - mod_delayed_work(cifsiod_wq, &server->reconnect, 0); + spin_lock(&cifs_tcp_ses_lock); + server->srv_count++; + spin_unlock(&cifs_tcp_ses_lock); + if (mod_delayed_work(cifsiod_wq, &server->reconnect, 0)) + cifs_put_tcp_session(server, false); + return rc; } spin_unlock(&server->srv_lock); From patchwork Mon Oct 30 11:00:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3425C4332F for ; Mon, 30 Oct 2023 11:00:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232839AbjJ3LA7 (ORCPT ); Mon, 30 Oct 2023 07:00:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232860AbjJ3LA6 (ORCPT ); Mon, 30 Oct 2023 07:00:58 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2A9F8E for ; Mon, 30 Oct 2023 04:00:55 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-5aa481d53e5so2527880a12.1 for ; Mon, 30 Oct 2023 04:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663655; x=1699268455; 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=ANtRK5CIMrRcnxqCNV/cGBCNsANqWR7d1jq+KVeQWF8=; b=dogt0l9dQnwrWb6HmW7g3Axhek19+v4yNEicQ93T91JfDEZcHUm17epWyCqzvxTPCt aHYvBciPgd+FoD1ZbxjsKs7LZe/grQtGZRU+11aZLJbvmjyyR8IR6fL+yArPlbc5Olbs XWsuCYwUkicjMluw4JuQCNUEzdIijn7VAay14haXrMXKfwUslGDOHH0QsJ/f7QXg+MCu J3sXJTPPKbRlBWf6vZIZXFI4EoY/KTLiFG8yU8TQaD/0fLBWXh1mgv2sc7BuLXB5bVbZ +7sbJOmCZShJFX/7lymguZOxG6u9fS5ypETwxmJC+lLt1/ycQ8PLQMgA6Tejuh74EN9n sUiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663655; x=1699268455; 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=ANtRK5CIMrRcnxqCNV/cGBCNsANqWR7d1jq+KVeQWF8=; b=DgKmgsiWGXlbvIvkGDQFzGHuWxiA340AVO1Cmg33FXwNvZ/3fjabYEKejS8MwP5NWQ Id+CONmkQEaeyLisY2UtmnKLudSay4EA6p6EFxz50RuhS9Gkx4khgxRg3ihpeFOj5IpF KBeCYx1CV4yKMAUk2qZAvxvsj1zJzejPaAdsoS+KRbsa3VqSKtFTb1kTQU8XRQklqcws j0TA6Yb8H67GUVSjlzXbknv0ge18sA6KzFMN2soeIaP1/oVImGjDC7fnpPweB8Nnl/Db gQKvhAPYY66Tq82x7ltBAt5gbiT6QOp12DaOLyXFntyqOnJEqW7seVD5AuNfRC+SFw6r TOBw== X-Gm-Message-State: AOJu0Yy1jGO35yd2P70GSiGMewiaHYBDFEwbevudP8u78RLiMD9HWIva QqydTx0Eq2nNJwcIvEDZZm0= X-Google-Smtp-Source: AGHT+IGA1vo0Cff6eRm5JxcBxa66prGWn8wrTxcHsele2EsQTd5E4SGAjM3KBjfxqjRyV6jKrdNpow== X-Received: by 2002:a05:6a21:6da1:b0:175:7085:ba18 with SMTP id wl33-20020a056a216da100b001757085ba18mr8223932pzb.58.1698663655099; Mon, 30 Oct 2023 04:00:55 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:54 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 11/14] cifs: handle when server starts supporting multichannel Date: Mon, 30 Oct 2023 11:00:17 +0000 Message-Id: <20231030110020.45627-11-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N When the user mounts with multichannel option, but the server does not support it, there can be a time in future where it can be supported. With this change, such a case is handled. Signed-off-by: Shyam Prasad N --- fs/smb/client/cifsproto.h | 4 ++++ fs/smb/client/connect.c | 6 +++++- fs/smb/client/smb2pdu.c | 31 ++++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index 65c84b3d1a65..5a4c1f1e0d91 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -132,6 +132,10 @@ extern int SendReceiveBlockingLock(const unsigned int xid, struct smb_hdr *in_buf, struct smb_hdr *out_buf, int *bytes_returned); + +void +smb2_query_server_interfaces(struct work_struct *work); + void cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server, bool all_channels); diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index e71aa33bf026..149cde77500e 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -116,7 +116,8 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server) return rc; } -static void smb2_query_server_interfaces(struct work_struct *work) +void +smb2_query_server_interfaces(struct work_struct *work) { int rc; int xid; @@ -134,6 +135,9 @@ static void smb2_query_server_interfaces(struct work_struct *work) if (rc) { cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n", __func__, rc); + + if (rc == -EOPNOTSUPP) + return; } queue_delayed_work(cifsiod_wq, &tcon->query_interfaces, diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index b7665155f4e2..2617437a4627 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -163,6 +163,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, int rc = 0; struct nls_table *nls_codepage = NULL; struct cifs_ses *ses; + int xid; /* * SMB2s NegProt, SessSetup, Logoff do not have tcon yet so @@ -307,17 +308,41 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, tcon->need_reopen_files = true; rc = cifs_tree_connect(0, tcon, nls_codepage); - mutex_unlock(&ses->session_mutex); cifs_dbg(FYI, "reconnect tcon rc = %d\n", rc); if (rc) { /* If sess reconnected but tcon didn't, something strange ... */ + mutex_unlock(&ses->session_mutex); cifs_dbg(VFS, "reconnect tcon failed rc = %d\n", rc); goto out; } - if (smb2_command != SMB2_INTERNAL_CMD) - mod_delayed_work(cifsiod_wq, &server->reconnect, 0); + if (!rc && + (server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) { + mutex_unlock(&ses->session_mutex); + + /* + * query server network interfaces, in case they change + */ + xid = get_xid(); + rc = SMB3_request_interfaces(xid, tcon, false); + free_xid(xid); + + if (rc) + cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n", + __func__, rc); + + if (ses->chan_max > ses->chan_count && + !SERVER_IS_CHAN(server)) { + if (ses->chan_count == 1) + cifs_dbg(VFS, "server %s supports multichannel now\n", + ses->server->hostname); + + cifs_try_adding_channels(tcon->cifs_sb, ses); + } + } else { + mutex_unlock(&ses->session_mutex); + } atomic_inc(&tconInfoReconnectCount); out: From patchwork Mon Oct 30 11:00:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24FBBC4332F for ; Mon, 30 Oct 2023 11:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232847AbjJ3LBD (ORCPT ); Mon, 30 Oct 2023 07:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232858AbjJ3LBC (ORCPT ); Mon, 30 Oct 2023 07:01:02 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 717A9B3 for ; Mon, 30 Oct 2023 04:00:58 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6b89ab5ddb7so4336876b3a.0 for ; Mon, 30 Oct 2023 04:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663658; x=1699268458; 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=zq0easth6d3aqIW4iTipq/gwSsWnm9owuLJTgsRttFo=; b=G25W4hNDmN4t5Q/GprlNgdj24BkJ+fU1NZr5kCTQf3cjNAPGf6VQiN6BXJr9KtA74x YY1DbMzY0+5KzvcxafGe7XHom3O/Ti3R+EI/kgZOxVAbXWYpjCRD2RTRk9m9iXGHrHPQ Fi7xx6lTlBRlyzrna2meGY/2HBkzxH2sznq9hFz+hAZgTtQ11dY6RydNFnwKBpCio6vk Ppse2bhFX63sKczPg4GGJ6CG3IGcbSTYjb+GaBBZXI7t9JrBZN/dF+5vbHcnz+FuyXQ6 xf8sKmwXrorjtma1O0p/QPMhQ84qA/1abzAaTEUCnU9D9lwwIWaCIIqAwdYVF4o6zfAs KrLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663658; x=1699268458; 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=zq0easth6d3aqIW4iTipq/gwSsWnm9owuLJTgsRttFo=; b=HRgs8cIKAOG5tNVbWR0QBWxI+XCc5VJ1xc63ZS1bfVgZy54BUV8VkzCM/HMruaUA/u k8IvxVE3GqYbw+qorBLDV0HgOYAy0XP2w71YY3iLJFRcunEj+BrJyTnzD9utfjgfp5tj x/Q2BlIWa0JMGR3yj75/ysGPJdepglxwVGNLUptN0S+aZaexv4VsRus2PilBpiw4lWjK VjPTwfjez3d4ZJYeWOm42YhJoY1wyhwj4yoP5dWmAHZkrXPH6YXRumPvSr+1miJszFlo fEwMrKuFqmR7JOImpOX7bb05Y6qPC9iEEM2LkDX1D0yu6kXDCZbeYJPJWDkWNiO4rlLj s2+w== X-Gm-Message-State: AOJu0Ywp/cmj8mefErdcTC1SL7AuvuXLI42gLWGOP8VHnMIKZJ/2CZcA HF3Y9iFu89YKvGWbgHLQjr4= X-Google-Smtp-Source: AGHT+IEzHaheRjDSK4lU9H8srFUxWqKjt5wtmL/Kn2wuvU1ouEIfvSzKP3vgMTe1vf0YYhNhRNY0ig== X-Received: by 2002:a05:6a20:7f93:b0:161:2cf2:75ec with SMTP id d19-20020a056a207f9300b001612cf275ecmr14205307pzj.49.1698663657755; Mon, 30 Oct 2023 04:00:57 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:00:57 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 12/14] cifs: handle when server stops supporting multichannel Date: Mon, 30 Oct 2023 11:00:18 +0000 Message-Id: <20231030110020.45627-12-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N When a server stops supporting multichannel, we will keep attempting reconnects to the secondary channels today. Avoid this by freeing extra channels when negotiate returns no multichannel support. Signed-off-by: Shyam Prasad N --- fs/smb/client/cifsglob.h | 1 + fs/smb/client/cifsproto.h | 2 ++ fs/smb/client/connect.c | 10 ++++++ fs/smb/client/sess.c | 64 ++++++++++++++++++++++++++++++----- fs/smb/client/smb2pdu.c | 70 ++++++++++++++++++++++++++++++++++++++- fs/smb/client/transport.c | 2 +- 6 files changed, 139 insertions(+), 10 deletions(-) diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index cdbc2cd207dc..1e1a5f3ab600 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -650,6 +650,7 @@ struct TCP_Server_Info { bool noautotune; /* do not autotune send buf sizes */ bool nosharesock; bool tcp_nodelay; + bool terminate; unsigned int credits; /* send no more requests at once */ unsigned int max_credits; /* can override large 32000 default at mnt */ unsigned int in_flight; /* number of requests on the wire to server */ diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index 5a4c1f1e0d91..828c3916cb88 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -644,6 +644,8 @@ cifs_chan_needs_reconnect(struct cifs_ses *ses, bool cifs_chan_is_iface_active(struct cifs_ses *ses, struct TCP_Server_Info *server); +void +cifs_disable_secondary_channels(struct cifs_ses *ses); int cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server); int diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 149cde77500e..6fe80d5d7c23 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -220,6 +220,14 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, spin_lock(&cifs_tcp_ses_lock); list_for_each_entry_safe(ses, nses, &pserver->smb_ses_list, smb_ses_list) { + /* + * if channel has been marked for termination, nothing to do + * for the channel. in fact, we cannot find the channel for the + * server. So safe to exit here + */ + if (server->terminate) + break; + /* check if iface is still active */ if (!cifs_chan_is_iface_active(ses, server)) cifs_chan_update_iface(ses, server); @@ -254,6 +262,8 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, spin_lock(&tcon->tc_lock); tcon->status = TID_NEED_RECON; spin_unlock(&tcon->tc_lock); + + cancel_delayed_work_sync(&tcon->query_interfaces); } if (ses->tcon_ipc) { ses->tcon_ipc->need_reconnect = true; diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c index 6843deed6119..51bcd78fc5bf 100644 --- a/fs/smb/client/sess.c +++ b/fs/smb/client/sess.c @@ -288,6 +288,60 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) return new_chan_count - old_chan_count; } +/* + * called when multichannel is disabled by the server. + * this always gets called from smb2_reconnect + * and cannot get called in parallel threads. + */ +void +cifs_disable_secondary_channels(struct cifs_ses *ses) +{ + int i, chan_count; + struct TCP_Server_Info *server; + struct cifs_server_iface *iface; + + spin_lock(&ses->chan_lock); + chan_count = ses->chan_count; + if (chan_count == 1) + goto done; + + ses->chan_count = 1; + + /* for all secondary channels reset the need reconnect bit */ + ses->chans_need_reconnect &= 1; + + for (i = 1; i < chan_count; i++) { + iface = ses->chans[i].iface; + server = ses->chans[i].server; + + if (iface) { + spin_lock(&ses->iface_lock); + kref_put(&iface->refcount, release_iface); + ses->chans[i].iface = NULL; + iface->num_channels--; + if (iface->weight_fulfilled) + iface->weight_fulfilled--; + spin_unlock(&ses->iface_lock); + } + + spin_unlock(&ses->chan_lock); + if (server && !server->terminate) { + server->terminate = true; + cifs_signal_cifsd_for_reconnect(server, false); + } + spin_lock(&ses->chan_lock); + + if (server) { + ses->chans[i].server = NULL; + cifs_put_tcp_session(server, false); + } + + } + +done: + spin_unlock(&ses->chan_lock); +} + /* * update the iface for the channel if necessary. * will return 0 when iface is updated, 1 if removed, 2 otherwise @@ -580,14 +634,10 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses, out: if (rc && chan->server) { - /* - * we should avoid race with these delayed works before we - * remove this channel - */ - cancel_delayed_work_sync(&chan->server->echo); - cancel_delayed_work_sync(&chan->server->reconnect); + cifs_put_tcp_session(chan->server, 0); spin_lock(&ses->chan_lock); + /* we rely on all bits beyond chan_count to be clear */ cifs_chan_clear_need_reconnect(ses, chan->server); ses->chan_count--; @@ -597,8 +647,6 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses, */ WARN_ON(ses->chan_count < 1); spin_unlock(&ses->chan_lock); - - cifs_put_tcp_session(chan->server, 0); } kfree(ctx->UNC); diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 2617437a4627..d1d4d9100870 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -164,6 +164,8 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, struct nls_table *nls_codepage = NULL; struct cifs_ses *ses; int xid; + struct TCP_Server_Info *pserver; + unsigned int chan_index; /* * SMB2s NegProt, SessSetup, Logoff do not have tcon yet so @@ -224,6 +226,12 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, return -EAGAIN; } } + + /* if server is marked for termination, cifsd will cleanup */ + if (server->terminate) { + spin_unlock(&server->srv_lock); + return -EHOSTDOWN; + } spin_unlock(&server->srv_lock); again: @@ -242,12 +250,24 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, tcon->need_reconnect); mutex_lock(&ses->session_mutex); + /* + * if this is called by delayed work, and the channel has been disabled + * in parallel, the delayed work can continue to execute in parallel + * there's a chance that this channel may not exist anymore + */ + spin_lock(&server->srv_lock); + if (server->tcpStatus == CifsExiting) { + spin_unlock(&server->srv_lock); + mutex_unlock(&ses->session_mutex); + rc = -EHOSTDOWN; + goto out; + } + /* * Recheck after acquire mutex. If another thread is negotiating * and the server never sends an answer the socket will be closed * and tcpStatus set to reconnect. */ - spin_lock(&server->srv_lock); if (server->tcpStatus == CifsNeedReconnect) { spin_unlock(&server->srv_lock); mutex_unlock(&ses->session_mutex); @@ -284,6 +304,47 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, rc = cifs_negotiate_protocol(0, ses, server); if (!rc) { + /* + * if server stopped supporting multichannel + * and the first channel reconnected, disable all the others. + */ + if (ses->chan_count > 1 && + !(server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) { + if (SERVER_IS_CHAN(server)) { + cifs_dbg(VFS, "server %s does not support " \ + "multichannel anymore. skipping secondary channel\n", + ses->server->hostname); + + spin_lock(&ses->chan_lock); + chan_index = cifs_ses_get_chan_index(ses, server); + if (chan_index == CIFS_INVAL_CHAN_INDEX) { + spin_unlock(&ses->chan_lock); + goto skip_terminate; + } + + ses->chans[chan_index].server = NULL; + cifs_put_tcp_session(server, 1); + spin_unlock(&ses->chan_lock); + + server->terminate = true; + cifs_signal_cifsd_for_reconnect(server, false); + + /* mark primary server as needing reconnect */ + pserver = server->primary_server; + cifs_signal_cifsd_for_reconnect(pserver, false); + +skip_terminate: + mutex_unlock(&ses->session_mutex); + rc = -EHOSTDOWN; + goto out; + } else { + cifs_dbg(VFS, "server %s does not support " \ + "multichannel anymore. disabling all other channels\n", + ses->server->hostname); + cifs_disable_secondary_channels(ses); + } + } + rc = cifs_setup_session(0, ses, server, nls_codepage); if ((rc == -EACCES) && !tcon->retry) { mutex_unlock(&ses->session_mutex); @@ -3833,6 +3894,13 @@ void smb2_reconnect_server(struct work_struct *work) /* Prevent simultaneous reconnects that can corrupt tcon->rlist list */ mutex_lock(&pserver->reconnect_mutex); + /* if the server is marked for termination, drop the ref count here */ + if (server->terminate) { + cifs_put_tcp_session(server, true); + mutex_unlock(&pserver->reconnect_mutex); + return; + } + INIT_LIST_HEAD(&tmp_list); INIT_LIST_HEAD(&tmp_ses_list); cifs_dbg(FYI, "Reconnecting tcons and channels\n"); diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c index 14710afdc2a3..c60c65926933 100644 --- a/fs/smb/client/transport.c +++ b/fs/smb/client/transport.c @@ -1032,7 +1032,7 @@ struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses) spin_lock(&ses->chan_lock); for (i = 0; i < ses->chan_count; i++) { server = ses->chans[i].server; - if (!server) + if (!server || server->terminate) continue; /* From patchwork Mon Oct 30 11:00:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13440501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BB37C4167D for ; Mon, 30 Oct 2023 11:01:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232860AbjJ3LBE (ORCPT ); Mon, 30 Oct 2023 07:01:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232555AbjJ3LBD (ORCPT ); Mon, 30 Oct 2023 07:01:03 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1355FB7 for ; Mon, 30 Oct 2023 04:01:01 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1cc5b705769so1671425ad.0 for ; Mon, 30 Oct 2023 04:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698663660; x=1699268460; 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=Pp38NWtNMiYYx3sxCJ1Uwk6p3j55j/QF+jF5tL5bvhI=; b=IKqMPnsreB5GyA5HF1w0+koVDZzZNFpF/2EqpI4Bn4VSd7xH81LjaHDGi+Ydga80iA G+EfMm3ZRG09yGC8LnVWfJNut6EYWOBHuw3H9fD0FSvQxkdjGnLrsiJg5Qzx06rgBfaJ HGyZyLCK8iFL+EEBdEQ0jYSTMNFpTvqwOkR4oK4w5zTDieH+AwujF8ReRKzvP9g0kXBy n/yLM1Quo/rakcdahEPSojf+xTVzkusa1KKaG4/7UXzh87W5qH3PJ0r4aarStVzDN9mH m+LN7+J+L2+9CmMfjE0DR1qDKy1Lig++3ie+Ia3R2KefKtCCdHz8yeWrrFuLPJEYIcNY 1Fdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698663660; x=1699268460; 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=Pp38NWtNMiYYx3sxCJ1Uwk6p3j55j/QF+jF5tL5bvhI=; b=X0TwmupBBCn/+HIzPYdvfJnglix5pB25y+e9TpM4qXQKUurNKaBxOlpDbCLXdfymQ+ OPinaWciJOkmggpcEVFXGo4SeB3sGYP4Wp3iU3/a21wz3hVQBWVoZ0LE7kEiMaO+1KYV 0MM14ubFaocc/r3MlCIGhi5+mBtKZxFlhcy5SO584JSMERB8loFkQ44mFIPsd/JkCrTE Z5XfdxWLTRHr0HYjvS7PI9jH+ge1lNsNRYOFhn2b5YEiN+AyNDE+W4XQjf+4xq+MsDv8 R5Tk3eycpe1y2RvtWt9OezpqFuG8+2JUIhrQpKp3DIUWFVfW32kH8K4jtNhzPmwSIt03 LEFg== X-Gm-Message-State: AOJu0YxoKuwhLCr+lkbSnO1WB7Xph2iL3SXcXxr7K6X4UBHiRoUahWQX G91GU1PFRLnoWXNnW9XI87RX36JYLIdSpw== X-Google-Smtp-Source: AGHT+IFXkZK5qeRkAzaFzlwR266eHSnGBNgK8TYV2454qixzEyn/ONfts3GfxV/7ygjuDd8+7TFT9A== X-Received: by 2002:a17:903:2292:b0:1cc:474a:ddeb with SMTP id b18-20020a170903229200b001cc474addebmr3715898plh.47.1698663660413; Mon, 30 Oct 2023 04:01:00 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001c9cc44eb60sm6006034plf.201.2023.10.30.04.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:01:00 -0700 (PDT) From: nspmangalore@gmail.com X-Google-Original-From: sprasad@microsoft.com To: smfrench@gmail.com, pc@manguebit.com, bharathsm.hsk@gmail.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 13/14] cifs: display the endpoint IP details in DebugData Date: Mon, 30 Oct 2023 11:00:19 +0000 Message-Id: <20231030110020.45627-13-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030110020.45627-1-sprasad@microsoft.com> References: <20231030110020.45627-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shyam Prasad N With multichannel, it is useful to know the src port details for each channel. This change will print the ip addr and port details for both the socket dest and src endpoints. Signed-off-by: Shyam Prasad N --- fs/smb/client/cifs_debug.c | 73 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c index e23fcabb78d6..d8362e098310 100644 --- a/fs/smb/client/cifs_debug.c +++ b/fs/smb/client/cifs_debug.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "cifspdu.h" #include "cifsglob.h" #include "cifsproto.h" @@ -158,11 +159,37 @@ cifs_dump_channel(struct seq_file *m, int i, struct cifs_chan *chan) in_flight(server), atomic_read(&server->in_send), atomic_read(&server->num_waiters)); + #ifdef CONFIG_NET_NS if (server->net) seq_printf(m, " Net namespace: %u ", server->net->ns.inum); #endif /* NET_NS */ +#ifdef CONFIG_CIFS_SMB_DIRECT + if (!server->rdma) + goto skip_rdma; + + if (server->smbd_conn && server->smbd_conn->id) { + struct rdma_addr *addr = + &server->smbd_conn->id->route.addr; + seq_printf(m, "\n\t\tIP addr: dst: %pISpc, src: %pISpc", + &addr->dst_addr, &addr->src_addr); + } + +skip_rdma: +#endif + if (server->ssocket) { + struct sockaddr src; + int addrlen; + + addrlen = kernel_getsockname(server->ssocket, &src); + if (addrlen != sizeof(struct sockaddr_in) && + addrlen != sizeof(struct sockaddr_in6)) + return; + + seq_printf(m, "\n\t\tIP addr: dst: %pISpc, src: %pISpc", + &server->dstaddr, &src); + } } static inline const char *smb_speed_to_str(size_t bps) @@ -279,7 +306,7 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v) static int cifs_debug_data_proc_show(struct seq_file *m, void *v) { struct mid_q_entry *mid_entry; - struct TCP_Server_Info *server; + struct TCP_Server_Info *server, *nserver; struct TCP_Server_Info *chan_server; struct cifs_ses *ses; struct cifs_tcon *tcon; @@ -336,7 +363,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) c = 0; spin_lock(&cifs_tcp_ses_lock); - list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { + list_for_each_entry_safe(server, nserver, &cifs_tcp_ses_list, tcp_ses_list) { /* channel info will be printed as a part of sessions below */ if (SERVER_IS_CHAN(server)) continue; @@ -414,8 +441,39 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) seq_printf(m, "\nMR mr_ready_count: %x mr_used_count: %x", atomic_read(&server->smbd_conn->mr_ready_count), atomic_read(&server->smbd_conn->mr_used_count)); + if (server->smbd_conn->id) { + struct rdma_addr *addr = + &server->smbd_conn->id->route.addr; + seq_printf(m, "\nIP addr: dst: %pISpc, src: %pISpc", + &addr->dst_addr, &addr->src_addr); + } skip_rdma: #endif + if (server->ssocket) { + struct sockaddr src; + int addrlen; + + /* kernel_getsockname can block. so drop the lock first */ + server->srv_count++; + spin_unlock(&cifs_tcp_ses_lock); + + addrlen = kernel_getsockname(server->ssocket, &src); + if (addrlen != sizeof(struct sockaddr_in) && + addrlen != sizeof(struct sockaddr_in6)) { + cifs_put_tcp_session(server, 0); + spin_lock(&cifs_tcp_ses_lock); + + goto skip_addr_details; + } + + seq_printf(m, "\nIP addr: dst: %pISpc, src: %pISpc", + &server->dstaddr, &src); + + cifs_put_tcp_session(server, 0); + spin_lock(&cifs_tcp_ses_lock); + } + +skip_addr_details: seq_printf(m, "\nNumber of credits: %d,%d,%d Dialect 0x%x", server->credits, server->echo_credits, @@ -515,7 +573,18 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) seq_printf(m, "\n\n\tExtra Channels: %zu ", ses->chan_count-1); for (j = 1; j < ses->chan_count; j++) { + /* + * kernel_getsockname can block inside + * cifs_dump_channel. so drop the lock first + */ + server->srv_count++; + spin_unlock(&cifs_tcp_ses_lock); + cifs_dump_channel(m, j, &ses->chans[j]); + + cifs_put_tcp_session(server, 0); + spin_lock(&cifs_tcp_ses_lock); + if (CIFS_CHAN_NEEDS_RECONNECT(ses, j)) seq_puts(m, "\tDISCONNECTED "); if (CIFS_CHAN_IN_RECONNECT(ses, j))