From patchwork Fri Jun 9 17:46:54 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: 13274258 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 7FEE6C7EE2E for ; Fri, 9 Jun 2023 17:47:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229493AbjFIRrj (ORCPT ); Fri, 9 Jun 2023 13:47:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjFIRrj (ORCPT ); Fri, 9 Jun 2023 13:47:39 -0400 Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 873B3DD for ; Fri, 9 Jun 2023 10:47:38 -0700 (PDT) Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-55af55a0fdaso1363326eaf.2 for ; Fri, 09 Jun 2023 10:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686332857; x=1688924857; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZFu/lUEM6FUe1loWdD2nYcG4AZ+lX44UcYWbi69QQe4=; b=TFsQAqU1UQUsTAQ0XF1gI8k9Sk5X4UVkwQUOAlJYaZ4pc5wLY/lx7xrFtPNRHnoEBj pKHFhgyyBHKQH+ifGh5Pb/UQ1lDLmNVrZZupGkskLpmSPZLGnGnZ5q1129OIUz/aysiZ Ye/6ToE8L8Gax9UA3A02kGz/U/ugeupmno9Jdxh7mGnBeVHYkwWPfiIqyRBwFTuPk+KO RQVF16NwGxR9ZB9hO+z+pEOUb1jh1QhHEPIXPYAnvNBtYFQ17RDIwFzgCpKgQVQFUG6Z STbv0t6e3DuxBRsQMw+8pEfEYSPZAlFLN6HY32xdQGFgpKcm08zDVj/OcGjF8cpYbzGt QxxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686332857; x=1688924857; 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=ZFu/lUEM6FUe1loWdD2nYcG4AZ+lX44UcYWbi69QQe4=; b=Xb1brbx1O4SZaky1wrzt1J0sIqzLIn7aWLQf8Wjj8sw2kdbtkzvFGpw3slVZqIXRaj 4gF3GVAz9crM+N+zM5p9ZmOg3ufozMRnaZKiruly3svfMaHICkrFsyrkMrARNv14S5b3 mwveejlBPp1WnNPOd1/SSvX1xXlfolJrxIi3oitCE5MrR2kGenwPQBaoCST4cAgIxb+1 7z9mZy7b9eqA46CdrOs0zeP30QmiTXNG97JnSjyxTGOTedhuF75EivDdg7+/ARHOU5NX 5xNfr8OaEDEkQzWDtTRB17mGz7/TRlCGNq1fcP5cLfeh0yBkh3yKZ1xiqcd0jp3dzaut GSzA== X-Gm-Message-State: AC+VfDw5qCly2KpdH/x+JNpeEEy/OAW4AdWLGATjc7D6xBw+Iiwe8hV+ OWjlcjDVAj3/pCvO1rn6VGi9ZeG6/5soDExO X-Google-Smtp-Source: ACHHUZ42nmjGi0RbSzeZ4xxwlpOMLQ4lkGNAFkqd5/P+IT3DC4NFoD2C4DUV0tYIbvpZiWUNBLbxlw== X-Received: by 2002:a05:6808:2129:b0:398:5a28:d80f with SMTP id r41-20020a056808212900b003985a28d80fmr2570678oiw.4.1686332857156; Fri, 09 Jun 2023 10:47:37 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id m4-20020a17090a71c400b0025671de4606sm5003064pjs.4.2023.06.09.10.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:47:36 -0700 (PDT) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@cjr.nz, bharathsm.hsk@gmail.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 1/6] cifs: fix status checks in cifs_tree_connect Date: Fri, 9 Jun 2023 17:46:54 +0000 Message-Id: <20230609174659.60327-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 The ordering of status checks at the beginning of cifs_tree_connect is wrong. As a result, a tcon which is good may stay marked as needing reconnect infinitely. Fixes: 2f0e4f034220 ("cifs: check only tcon status on tcon related functions") Signed-off-by: Shyam Prasad N --- fs/smb/client/connect.c | 9 +++++---- fs/smb/client/dfs.c | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 8e9a672320ab..1250d156619b 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -4086,16 +4086,17 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru /* only send once per connect */ spin_lock(&tcon->tc_lock); + if (tcon->status == TID_GOOD) { + spin_unlock(&tcon->tc_lock); + return 0; + } + if (tcon->status != TID_NEW && tcon->status != TID_NEED_TCON) { spin_unlock(&tcon->tc_lock); return -EHOSTDOWN; } - if (tcon->status == TID_GOOD) { - spin_unlock(&tcon->tc_lock); - return 0; - } tcon->status = TID_IN_TCON; spin_unlock(&tcon->tc_lock); diff --git a/fs/smb/client/dfs.c b/fs/smb/client/dfs.c index 2f93bf8c3325..2390b2fedd6a 100644 --- a/fs/smb/client/dfs.c +++ b/fs/smb/client/dfs.c @@ -575,16 +575,17 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru /* only send once per connect */ spin_lock(&tcon->tc_lock); + if (tcon->status == TID_GOOD) { + spin_unlock(&tcon->tc_lock); + return 0; + } + if (tcon->status != TID_NEW && tcon->status != TID_NEED_TCON) { spin_unlock(&tcon->tc_lock); return -EHOSTDOWN; } - if (tcon->status == TID_GOOD) { - spin_unlock(&tcon->tc_lock); - return 0; - } tcon->status = TID_IN_TCON; spin_unlock(&tcon->tc_lock); From patchwork Fri Jun 9 17:46:55 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: 13274259 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 9D0AFC7EE2E for ; Fri, 9 Jun 2023 17:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229662AbjFIRrt (ORCPT ); Fri, 9 Jun 2023 13:47:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjFIRrt (ORCPT ); Fri, 9 Jun 2023 13:47:49 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E032E4E for ; Fri, 9 Jun 2023 10:47:48 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-38ede2e0e69so826324b6e.2 for ; Fri, 09 Jun 2023 10:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686332866; x=1688924866; 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=4W9hKuQo1vg7Chz4fdL0TbJ2gmtpajiRwOA8OZd9rzo=; b=BA3ItHcw0hotJ10eDnw4Pqwzr8JblgryNCfW9CJ6I9axxhb2z37XgKlRBQbZywhdL4 KGNdfbvocwOEN+230u0hgBStIROYIV9k0+WOtqaCyQie7SJXmOcJj/Ru9kpIVpP1gipb 262J4TDsmZLnVQAioyQjw4lMAyOm9XWZGU0IbZrpkP39XXK4LjMZ5jG0hHl7V5qt/1bO 0it+IenT5scI79z47xtlezEd/+pc5HXrmyRNUYBxyHihq/mz+4DPKE0nYQIyLCXld3S2 hAeZzt2fFu8eX1iLxKnNqDIH0X4F+9fOzLqhuFXpcw3vP0PF8EwwiVB28P7jWUZoiYbv PSmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686332866; x=1688924866; 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=4W9hKuQo1vg7Chz4fdL0TbJ2gmtpajiRwOA8OZd9rzo=; b=ENRLsQZj/h/t25t2SncC7qqLhquVEK29/qOZYlq7TswULMzpQZmY6xIzJNzQPwzUXe T+yqHhahXBsKC4N3A1/EExC5u4kZKscrYAwwQDFUOqDi46QmTnTOgHwhxpp8GC9S9pha t6nWNUxzW8ufppLtY5DUfAj0EpiGV1bq5OzHLcnfypXhXMG5rITpxFT5eOvnTIK5V8CI hpTQ3TnadYoKsLGshmx2LN87iQZgEtFRmh5OurbEsh17pgJhUOZbVPGjENYGnWqikel2 Kf8TRKuzgsmlv6Hl+f0cErT3O5UHe7W3itzfDqJUBcWCGLynWaLctvxYF883D0XJYdMJ 58Ig== X-Gm-Message-State: AC+VfDz1TQr4DIJX+F2VdxLr+bzY0Uf6ZMwh7gos2g4CgqbT3WkDlBGN Hxi3f7wqgsYcbbGqbp70wNy+vtAXt8o0frHN X-Google-Smtp-Source: ACHHUZ7b57tnjLp2zaKm7YNoqC/+UVLXLjT6xveTPegML5aYkZPAkR1y90yld95svgJMRtIzFn8RoQ== X-Received: by 2002:a05:6808:f15:b0:397:f94e:4321 with SMTP id m21-20020a0568080f1500b00397f94e4321mr2448144oiw.23.1686332865782; Fri, 09 Jun 2023 10:47:45 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id m4-20020a17090a71c400b0025671de4606sm5003064pjs.4.2023.06.09.10.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:47:45 -0700 (PDT) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@cjr.nz, bharathsm.hsk@gmail.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 2/6] cifs: print all credit counters in DebugData Date: Fri, 9 Jun 2023 17:46:55 +0000 Message-Id: <20230609174659.60327-2-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609174659.60327-1-sprasad@microsoft.com> References: <20230609174659.60327-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Output of /proc/fs/cifs/DebugData shows only the per-connection counter for the number of credits of regular type. i.e. the credits reserved for echo and oplocks are not displayed. There have been situations recently where having this info would have been useful. This change prints the credit counters of all three types: regular, echo, oplocks. Signed-off-by: Shyam Prasad N --- fs/smb/client/cifs_debug.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c index 5034b862cec2..17c884724590 100644 --- a/fs/smb/client/cifs_debug.c +++ b/fs/smb/client/cifs_debug.c @@ -130,12 +130,14 @@ cifs_dump_channel(struct seq_file *m, int i, struct cifs_chan *chan) struct TCP_Server_Info *server = chan->server; seq_printf(m, "\n\n\t\tChannel: %d ConnectionId: 0x%llx" - "\n\t\tNumber of credits: %d Dialect 0x%x" + "\n\t\tNumber of credits: %d,%d,%d Dialect 0x%x" "\n\t\tTCP status: %d Instance: %d" "\n\t\tLocal Users To Server: %d SecMode: 0x%x Req On Wire: %d" "\n\t\tIn Send: %d In MaxReq Wait: %d", i+1, server->conn_id, server->credits, + server->echo_credits, + server->oplock_credits, server->dialect, server->tcpStatus, server->reconnect_instance, @@ -350,8 +352,11 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) atomic_read(&server->smbd_conn->mr_used_count)); skip_rdma: #endif - seq_printf(m, "\nNumber of credits: %d Dialect 0x%x", - server->credits, server->dialect); + seq_printf(m, "\nNumber of credits: %d,%d,%d Dialect 0x%x", + server->credits, + server->echo_credits, + server->oplock_credits, + server->dialect); if (server->compress_algorithm == SMB3_COMPRESS_LZNT1) seq_printf(m, " COMPRESS_LZNT1"); else if (server->compress_algorithm == SMB3_COMPRESS_LZ77) From patchwork Fri Jun 9 17:46:56 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: 13274260 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 E8F0FC7EE29 for ; Fri, 9 Jun 2023 17:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229622AbjFIRrv (ORCPT ); Fri, 9 Jun 2023 13:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjFIRru (ORCPT ); Fri, 9 Jun 2023 13:47:50 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6EEFDD for ; Fri, 9 Jun 2023 10:47:49 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-53f7bef98b7so954390a12.3 for ; Fri, 09 Jun 2023 10:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686332869; x=1688924869; 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=WXHL4rbnBke9oDpZAUPXu1H2QGHdN6ca0eZSQ1UNlhM=; b=BNCWjbnjosBRHeABzR/60W0+z15Mh3jazrz+3Use840BEqaxXeAHd0SQTRejwK0vh+ 2ioeCI/BBpB7iCBB9fG2GbwpQdK9FsA0JWy90iJiwo9aZXKmr22TNlxB0TzH5LisxAfB 2oP4UQYiXgMfKObQbepwdU1vRscZakaUlYjl5v+FVT0dJzNvVe1awDbazAWsRPUKf4TT rIMJrsm4LTPcf5tOaVsO47oW0UDQKzVwbUbpHN41UY4Cg9Y1wa0DrIfxKdKtWltel0Pw wN/O3Evq6+68iyAOhJNLCxecRFhZHBYkFG3/rnVLaSN9/zcr+g10o6QMKqd8Hs3wToNX Sr9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686332869; x=1688924869; 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=WXHL4rbnBke9oDpZAUPXu1H2QGHdN6ca0eZSQ1UNlhM=; b=duo2FAAq4TNTSFJsaWjT8Uf8EMjJJuaI8RUVOQxioU/evKGtMo6IC67km3/zA/J8oZ Uf/FxlyakEvTkZ17Da9Mw0fodBoJop/dpLzks6WscLAWZ2wO/3Jg4TypeR/VhUiBjFMk ZttvMdA9u2sLJ0+MkaSHjNHv02HgTCydSxOX/E7iApBp93YF9CKkid77OWFxS13H+W9w WGcgl2I73Y8gSp0jgFlYUYdr3d2xMxMrJkaWfjjO+IzTDTToUmbdq7QilKfZb3TFN/hI ChjkhOevnFRS5wTaWlR+Z7uRYyOUKawFFCxE3DZQMH4YmcA0Cl77ltpHR9z+MddSU2dh +VFQ== X-Gm-Message-State: AC+VfDxDkl09AiD3lPj/Y/EqPS3JP5OEremfY79XxiLI8YbT/KKkJRhv DALOX0mPuAo338eB/V1C9NqsOEsLIVtRvyRE X-Google-Smtp-Source: ACHHUZ6gT0tba9d1vsl6H7oUXkhgS3LntiO6u23McMA6RWUFpcqfZwCW+qgl6PEDn9X0xs1hMqVltQ== X-Received: by 2002:a17:90a:1d1:b0:253:34da:487 with SMTP id 17-20020a17090a01d100b0025334da0487mr1664763pjd.35.1686332868568; Fri, 09 Jun 2023 10:47:48 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id m4-20020a17090a71c400b0025671de4606sm5003064pjs.4.2023.06.09.10.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:47:48 -0700 (PDT) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@cjr.nz, bharathsm.hsk@gmail.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 3/6] cifs: add a warning when the in-flight count goes negative Date: Fri, 9 Jun 2023 17:46:56 +0000 Message-Id: <20230609174659.60327-3-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609174659.60327-1-sprasad@microsoft.com> References: <20230609174659.60327-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org We've seen the in-flight count go into negative with some internal stress testing in Microsoft. Adding a WARN when this happens, in hope of understanding why this happens when it happens. Signed-off-by: Shyam Prasad N --- fs/smb/client/smb2ops.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 6e3be58cfe49..43162915e03c 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -91,6 +91,7 @@ smb2_add_credits(struct TCP_Server_Info *server, server->conn_id, server->hostname, *val, add, server->in_flight); } + WARN_ON(server->in_flight == 0); server->in_flight--; if (server->in_flight == 0 && ((optype & CIFS_OP_MASK) != CIFS_NEG_OP) && From patchwork Fri Jun 9 17:46:57 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: 13274261 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 3DA6CC7EE29 for ; Fri, 9 Jun 2023 17:47:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjFIRry (ORCPT ); Fri, 9 Jun 2023 13:47:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjFIRrx (ORCPT ); Fri, 9 Jun 2023 13:47:53 -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 53D482737 for ; Fri, 9 Jun 2023 10:47:52 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-64d57cd373fso1499164b3a.1 for ; Fri, 09 Jun 2023 10:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686332871; x=1688924871; 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=wce3RZSFBAGDGOQ6rHhvRpjxgdV9x2dVLItk6MZgLMI=; b=N8wupbYCnkdd5IFxJav6Enidp8x/BvK4iCl5szNfxNaZCp4ZHwsfRiYXY1jKTc3UvP pD/ubYBtt/aDwO5XP9Xz7vbq4erz3W0nc5L+izZAGJERWzYP7O51TR7KQKcT1UnOFpzI FKOWGXrDRSwJoNulMW7mv8n484taoBQCiYWYrbzGcB4hsilkAHbWquIjnA9/2CYm42sB HhG74jG2vo6dDI4aUXMPIix4GEZTLKSpPQjDgQMqJMvsPOctm0etZy9xPNI+HToU2Ith fLE2D/a+zRN9FAewPuS05lO8b/EQzsGda1OJ4hxHOg7iKOhWj3es2PL0TQ0jZNpxjXqy Rkpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686332871; x=1688924871; 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=wce3RZSFBAGDGOQ6rHhvRpjxgdV9x2dVLItk6MZgLMI=; b=EgX37W3eE8VDIJWOztoT0yok63kUu3bFeRh7zQ/fnfRLgjc+78aoqPoDEjQXHRNkUq kOqMW/REU/9iADCjd9wf+j2qW5rcn10Lkarpou6IeJRUP7Ni5S0SX5NgHoul4kjSOz0i KJw9CCgmwsNT7jTpSHXZdYVAVYt6vvS0y2uHnRppOqYLQOIp57PoL9H12T7s8LitEZ4Q KvjvJcGJE4JZLN2iB3HMJUqz5hMVSg8V/B+W2BAYYqgH0avAYONRtO6vFwPPguw7hkj4 U4kAR98Cp8sL7AvV2Xyjgk/scYdFWBl19BFSACeUlYSf0ATLMPY/BKvJpG7x1i8yQ8qQ 7P7g== X-Gm-Message-State: AC+VfDzrUOYIsAmXFUUbC3JiFjFZRc4sfXJCXUtZK1SFBz6rGG4CIomD RfkEPw7WxxGD/1lzkMstmHi+luNRZv/82GaQ X-Google-Smtp-Source: ACHHUZ48/OShmaIDkkSQ955eP9S11HqN5HOxUcQcEFuj3uwkSUNuH8BTYubUpa2jBC/uk8Z1P4Idng== X-Received: by 2002:a17:903:2444:b0:1ac:a88a:70b6 with SMTP id l4-20020a170903244400b001aca88a70b6mr6917244pls.31.1686332871304; Fri, 09 Jun 2023 10:47:51 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id m4-20020a17090a71c400b0025671de4606sm5003064pjs.4.2023.06.09.10.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:47:50 -0700 (PDT) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@cjr.nz, bharathsm.hsk@gmail.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 4/6] cifs: display the endpoint IP details in DebugData Date: Fri, 9 Jun 2023 17:46:57 +0000 Message-Id: <20230609174659.60327-4-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609174659.60327-1-sprasad@microsoft.com> References: <20230609174659.60327-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 Reviewed-by: Enzo Matsumiya --- fs/smb/client/cifs_debug.c | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c index 17c884724590..d5fd3681f56e 100644 --- a/fs/smb/client/cifs_debug.c +++ b/fs/smb/client/cifs_debug.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "cifspdu.h" #include "cifsglob.h" #include "cifsproto.h" @@ -146,6 +147,30 @@ 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)); + +#ifndef CONFIG_CIFS_SMB_DIRECT + if (server->ssocket) { + if (server->dstaddr.ss_family == AF_INET6) { + struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)&server->dstaddr; + struct sock *sk = server->ssocket->sk; + struct inet_sock *inet = inet_sk(server->ssocket->sk); + seq_printf(m, "\n\t\tIPv6 Dest: [%pI6]:%d Src: [%pI6]:%d", + &ipv6->sin6_addr, + ntohs(ipv6->sin6_port), + &sk->sk_v6_rcv_saddr.s6_addr32, + ntohs(inet->inet_sport)); + } else { + struct sockaddr_in *ipv4 = (struct sockaddr_in *)&server->dstaddr; + struct inet_sock *inet = inet_sk(server->ssocket->sk); + seq_printf(m, "\n\t\tIPv4 Dest: %pI4:%d Src: %pI4:%d", + &ipv4->sin_addr, + ntohs(ipv4->sin_port), + &inet->inet_saddr, + ntohs(inet->inet_sport)); + } + } +#endif + } static void @@ -351,6 +376,27 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) atomic_read(&server->smbd_conn->mr_ready_count), atomic_read(&server->smbd_conn->mr_used_count)); skip_rdma: +#else + if (server->ssocket) { + if (server->dstaddr.ss_family == AF_INET6) { + struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)&server->dstaddr; + struct sock *sk = server->ssocket->sk; + struct inet_sock *inet = inet_sk(server->ssocket->sk); + seq_printf(m, "\nIPv6 Dest: [%pI6]:%d Src: [%pI6]:%d", + &ipv6->sin6_addr, + ntohs(ipv6->sin6_port), + &sk->sk_v6_rcv_saddr.s6_addr32, + ntohs(inet->inet_sport)); + } else { + struct sockaddr_in *ipv4 = (struct sockaddr_in *)&server->dstaddr; + struct inet_sock *inet = inet_sk(server->ssocket->sk); + seq_printf(m, "\nIPv4 Dest: %pI4:%d Src: %pI4:%d", + &ipv4->sin_addr, + ntohs(ipv4->sin_port), + &inet->inet_saddr, + ntohs(inet->inet_sport)); + } + } #endif seq_printf(m, "\nNumber of credits: %d,%d,%d Dialect 0x%x", server->credits, From patchwork Fri Jun 9 17:46:58 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: 13274262 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 E3B28C7EE37 for ; Fri, 9 Jun 2023 17:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230384AbjFIRr5 (ORCPT ); Fri, 9 Jun 2023 13:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjFIRr4 (ORCPT ); Fri, 9 Jun 2023 13:47:56 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 299AD2D44 for ; Fri, 9 Jun 2023 10:47:55 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2566e60cc5aso895567a91.3 for ; Fri, 09 Jun 2023 10:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686332874; x=1688924874; 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=sQV9Mb9/pjPesEsESX+LtfOPLaBFiXKP4bha95yYAvk=; b=JnTSU+hzLOxaX/1Vu7x5bYR8/sGgCKI0LpsEWMScDQYE1xg5wN2RS/lnvF5bJJy0MN xm0gM2kq8KN4Kg0+sfbHKUQ2wcF9YoUVNFn4SUamJIkd4FnoRTNus+3FJQTrx7KlWwzc C69vx1WEF2VIgAy/16u63rI87d4vNzLCubHF0GbmhT+xU1khmn2z9fQ3Iq9RDKNodqar fpwVD+KGTWpqA56/LGCRqtKs4UF6pUc7RHVPve5O3yUE8nmTX5jdeTWswKsqkOo6tq6n 65SBPR1N4/Cm/nIWJg0K2/FKqm3tkJV+BtxqUkPP6A81wDQk8VX4gdqT7Xwc8zHEEqEv XcyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686332874; x=1688924874; 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=sQV9Mb9/pjPesEsESX+LtfOPLaBFiXKP4bha95yYAvk=; b=c4J5k0/hbSzdIbUJVHQhWECrcXClFvOuyJ6ZWNL2azEjHi6FhW7uVxRsuw9UuctlSZ tmjukG7fYu9k0bldjSLLllC1WwsX0k6Io66riySDs/PvagNfp2WRDNJ7BPWdvBAxs7rx ReVQqTt3INgOln06Sv26OLC1KUxUs2hB0EaIW10RHiZHvlnFFuxmCJsJ+2gPt/H4/kVn jOGQv1yJZcVB4CpI4lXa2VIcnfKArFqeYvhsX6aBZfYt/SvfJ9dGeB/q4kNg6N3ntcrb msoQlfUWK68ci8AddEWE5SNcvZlU8Ppw0urWFZxZRpvtLSToZfq+bZOwVz/ssWAnyL4Y u1hQ== X-Gm-Message-State: AC+VfDwkjuxYlgULdXm1v90BnCBmGQxQ2SNY0dXpslBU2ysuKraTzOy2 UqRUXt2efYiNHaDhQTmXitgy008/avdjsDWZ X-Google-Smtp-Source: ACHHUZ7o7phj5t8XMNDlhFL+9CjU6ejfqLaXrYVu6Fopfw1a4DTfYcZWb8yu54UY33LZdmN10Xl6HA== X-Received: by 2002:a17:90a:6f46:b0:255:c061:9e5b with SMTP id d64-20020a17090a6f4600b00255c0619e5bmr2035740pjk.37.1686332874144; Fri, 09 Jun 2023 10:47:54 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id m4-20020a17090a71c400b0025671de4606sm5003064pjs.4.2023.06.09.10.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:47:53 -0700 (PDT) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@cjr.nz, bharathsm.hsk@gmail.com, tom@talpey.com Cc: Shyam Prasad N Subject: [PATCH 5/6] cifs: fix max_credits implementation Date: Fri, 9 Jun 2023 17:46:58 +0000 Message-Id: <20230609174659.60327-5-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609174659.60327-1-sprasad@microsoft.com> References: <20230609174659.60327-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org The current implementation of max_credits on the client does not work because the CreditRequest logic for several commands does not take max_credits into account. Still, we can end up asking the server for more credits, depending on the number of credits in flight. For this, we need to limit the credits while parsing the responses too. Signed-off-by: Shyam Prasad N --- fs/smb/client/smb2ops.c | 2 ++ fs/smb/client/smb2pdu.c | 32 ++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 43162915e03c..18faf267c54d 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -34,6 +34,8 @@ static int change_conf(struct TCP_Server_Info *server) { server->credits += server->echo_credits + server->oplock_credits; + if (server->credits > server->max_credits) + server->credits = server->max_credits; server->oplock_credits = server->echo_credits = 0; switch (server->credits) { case 0: diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 7063b395d22f..17fe212ab895 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -1305,7 +1305,12 @@ SMB2_sess_alloc_buffer(struct SMB2_sess_data *sess_data) } /* enough to enable echos and oplocks and one max size write */ - req->hdr.CreditRequest = cpu_to_le16(130); + if (server->credits >= server->max_credits) + req->hdr.CreditRequest = cpu_to_le16(0); + else + req->hdr.CreditRequest = cpu_to_le16( + min_t(int, server->max_credits - + server->credits, 130)); /* only one of SMB2 signing flags may be set in SMB2 request */ if (server->sign) @@ -1899,7 +1904,12 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, rqst.rq_nvec = 2; /* Need 64 for max size write so ask for more in case not there yet */ - req->hdr.CreditRequest = cpu_to_le16(64); + if (server->credits >= server->max_credits) + req->hdr.CreditRequest = cpu_to_le16(0); + else + req->hdr.CreditRequest = cpu_to_le16( + min_t(int, server->max_credits - + server->credits, 64)); rc = cifs_send_recv(xid, ses, server, &rqst, &resp_buftype, flags, &rsp_iov); @@ -4227,6 +4237,7 @@ smb2_async_readv(struct cifs_readdata *rdata) struct TCP_Server_Info *server; struct cifs_tcon *tcon = tlink_tcon(rdata->cfile->tlink); unsigned int total_len; + int credit_request; cifs_dbg(FYI, "%s: offset=%llu bytes=%u\n", __func__, rdata->offset, rdata->bytes); @@ -4258,7 +4269,13 @@ smb2_async_readv(struct cifs_readdata *rdata) if (rdata->credits.value > 0) { shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(rdata->bytes, SMB2_MAX_BUFFER_SIZE)); - shdr->CreditRequest = cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 8); + credit_request = le16_to_cpu(shdr->CreditCharge) + 8; + if (server->credits >= server->max_credits) + shdr->CreditRequest = cpu_to_le16(0); + else + shdr->CreditRequest = cpu_to_le16( + min_t(int, server->max_credits - + server->credits, credit_request)); rc = adjust_credits(server, &rdata->credits, rdata->bytes); if (rc) @@ -4468,6 +4485,7 @@ smb2_async_writev(struct cifs_writedata *wdata, unsigned int total_len; struct cifs_io_parms _io_parms; struct cifs_io_parms *io_parms = NULL; + int credit_request; if (!wdata->server) server = wdata->server = cifs_pick_channel(tcon->ses); @@ -4572,7 +4590,13 @@ smb2_async_writev(struct cifs_writedata *wdata, if (wdata->credits.value > 0) { shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(wdata->bytes, SMB2_MAX_BUFFER_SIZE)); - shdr->CreditRequest = cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 8); + credit_request = le16_to_cpu(shdr->CreditCharge) + 8; + if (server->credits >= server->max_credits) + shdr->CreditRequest = cpu_to_le16(0); + else + shdr->CreditRequest = cpu_to_le16( + min_t(int, server->max_credits - + server->credits, credit_request)); rc = adjust_credits(server, &wdata->credits, io_parms->length); if (rc) From patchwork Fri Jun 9 17:46:59 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: 13274263 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 A7AC5C7EE29 for ; Fri, 9 Jun 2023 17:48:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbjFIRsA (ORCPT ); Fri, 9 Jun 2023 13:48:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjFIRr7 (ORCPT ); Fri, 9 Jun 2023 13:47:59 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D757E47 for ; Fri, 9 Jun 2023 10:47:58 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2563ca70f64so788998a91.0 for ; Fri, 09 Jun 2023 10:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686332877; x=1688924877; 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=N6/h0b9a5wSYNN4GJoMo2o4EWk5PesQOmKscL5La0xw=; b=f1FL/IRVr/VPLOAFTdCYP6e9xmwaXGAUtQLEW4Moeafk+gIBqk8aQzC5t6bNuMULhC lWwuNWfwiQN7jybMGVZdzJZqH+GZJRJm99DbK8G+4YkrSBdp3E+mBmRgxVK7jilAX4rM R8ek9XopiCtSWpBGNLrj5dySPE02+DOiu5VQAMrjN1LU8M+iQXwUawghQ0IPEeUQimYM ZPAoco/DI6cSZfffX3MyLEsUoy5VZZ/dzZX6mzKOp8bfyZjkwaCphFCScZO6KAQNFLcx E+0lASnL0GibuIVmIAi6z+0Df4fdv469D1Xi/Kikgq6+XqMD8D2aE6UqwsS7bhK/WNIU atvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686332877; x=1688924877; 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=N6/h0b9a5wSYNN4GJoMo2o4EWk5PesQOmKscL5La0xw=; b=DT1ola3Sa4CXhtzyPHz65OfSSwN5mYV9yqssgpJeP1by45Et2ea4cjmTcQzuiM5zY9 Q7QDfeVTOpCEMBJYf5vDO7wMfOOSbHbQhvnAfortepUb6hxn9SsIL4oT+3Z75U4tgjuM BaMDllqNwqFikF3HE+X26S05B2IRZH7Xg48ChSExj+/hT8GYEjUDS8rr74/BmhsFBxDC SK8C6BldSuFCobg9ru/UJise9+bQJVqTjg84tqdO+5a8F+SVkBtiJNNTWoKDJVOhAndp 4Jsvrrkujei8ezPnSbGdoWaLEqfueingUnqakJLtgPJ9jAK4okromyWOTfhXcWPO/igU vl5Q== X-Gm-Message-State: AC+VfDw/UOasfjFbAE9NXVxLqAig5DpjPVyeomKHSbnQyAs0spN3z6yq cmc9gLBwMp6iySvGVGRKBSaN36U+eVAB2EFl X-Google-Smtp-Source: ACHHUZ7INrmJcdyS7fD1UN9zXCcvvTwxJO1ieUTbOct1xJMpAqwTvfO9Sqj/ikTVKuiOoojwdjnaXQ== X-Received: by 2002:a17:90a:199:b0:252:94b5:36f1 with SMTP id 25-20020a17090a019900b0025294b536f1mr1453283pjc.27.1686332877361; Fri, 09 Jun 2023 10:47:57 -0700 (PDT) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:1:7e0e:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id m4-20020a17090a71c400b0025671de4606sm5003064pjs.4.2023.06.09.10.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:47:57 -0700 (PDT) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: linux-cifs@vger.kernel.org, smfrench@gmail.com, pc@cjr.nz, bharathsm.hsk@gmail.com, tom@talpey.com Cc: Shyam Prasad N , kernel test robot , Dan Carpenter Subject: [PATCH 6/6] cifs: fix sockaddr comparison in iface_cmp Date: Fri, 9 Jun 2023 17:46:59 +0000 Message-Id: <20230609174659.60327-6-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609174659.60327-1-sprasad@microsoft.com> References: <20230609174659.60327-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org iface_cmp used to simply do a memcmp of the two provided struct sockaddrs. The comparison needs to do more based on the address family. Similar logic was already present in cifs_match_ipaddr. Doing something similar now. Signed-off-by: Shyam Prasad N Reported-by: kernel test robot Reported-by: Dan Carpenter --- fs/smb/client/cifsglob.h | 37 ----------------------------- fs/smb/client/cifsproto.h | 1 + fs/smb/client/connect.c | 50 +++++++++++++++++++++++++++++++++++++++ fs/smb/client/smb2ops.c | 37 +++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 37 deletions(-) diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 0d84bb1a8cd9..b212a4e16b39 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -970,43 +970,6 @@ release_iface(struct kref *ref) kfree(iface); } -/* - * compare two interfaces a and b - * return 0 if everything matches. - * return 1 if a has higher link speed, or rdma capable, or rss capable - * return -1 otherwise. - */ -static inline int -iface_cmp(struct cifs_server_iface *a, struct cifs_server_iface *b) -{ - int cmp_ret = 0; - - WARN_ON(!a || !b); - if (a->speed == b->speed) { - if (a->rdma_capable == b->rdma_capable) { - if (a->rss_capable == b->rss_capable) { - cmp_ret = memcmp(&a->sockaddr, &b->sockaddr, - sizeof(a->sockaddr)); - if (!cmp_ret) - return 0; - else if (cmp_ret > 0) - return 1; - else - return -1; - } else if (a->rss_capable > b->rss_capable) - return 1; - else - return -1; - } else if (a->rdma_capable > b->rdma_capable) - return 1; - else - return -1; - } else if (a->speed > b->speed) - return 1; - else - return -1; -} - struct cifs_chan { unsigned int in_reconnect : 1; /* if session setup in progress for this channel */ struct TCP_Server_Info *server; diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index c1c704990b98..d127aded2f28 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -87,6 +87,7 @@ extern int cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid); extern int smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx); extern int smb3_parse_opt(const char *options, const char *key, char **val); +extern int cifs_ipaddr_cmp(struct sockaddr *srcaddr, struct sockaddr *rhs); extern bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs); extern int cifs_discard_remaining_data(struct TCP_Server_Info *server); extern int cifs_call_async(struct TCP_Server_Info *server, diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 1250d156619b..9d16626e7a66 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -1288,6 +1288,56 @@ cifs_demultiplex_thread(void *p) module_put_and_kthread_exit(0); } +int +cifs_ipaddr_cmp(struct sockaddr *srcaddr, struct sockaddr *rhs) +{ + struct sockaddr_in *saddr4 = (struct sockaddr_in *)srcaddr; + struct sockaddr_in *vaddr4 = (struct sockaddr_in *)rhs; + struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *)srcaddr; + struct sockaddr_in6 *vaddr6 = (struct sockaddr_in6 *)rhs; + + switch (srcaddr->sa_family) { + case AF_UNSPEC: + switch (rhs->sa_family) { + case AF_UNSPEC: + return 0; + case AF_INET: + case AF_INET6: + return 1; + default: + return -1; + } + case AF_INET: { + switch (rhs->sa_family) { + case AF_UNSPEC: + return -1; + case AF_INET: + return memcmp(saddr4, vaddr4, + sizeof(struct sockaddr_in)); + case AF_INET6: + return 1; + default: + return -1; + } + } + case AF_INET6: { + switch (rhs->sa_family) { + case AF_UNSPEC: + case AF_INET: + return -1; + case AF_INET6: + return memcmp(saddr6, + vaddr6, + sizeof(struct sockaddr_in6)); + default: + return -1; + } + } + default: + return -1; /* don't expect to be here */ + } +} + /* * Returns true if srcaddr isn't specified and rhs isn't specified, or * if srcaddr is specified and matches the IP address of the rhs argument diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 18faf267c54d..046341115add 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -513,6 +513,43 @@ smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx) return rsize; } +/* + * compare two interfaces a and b + * return 0 if everything matches. + * return 1 if a is rdma capable, or rss capable, or has higher link speed + * return -1 otherwise. + */ +static int +iface_cmp(struct cifs_server_iface *a, struct cifs_server_iface *b) +{ + int cmp_ret = 0; + + WARN_ON(!a || !b); + if (a->rdma_capable == b->rdma_capable) { + if (a->rss_capable == b->rss_capable) { + if (a->speed == b->speed) { + cmp_ret = cifs_ipaddr_cmp((struct sockaddr *) &a->sockaddr, + (struct sockaddr *) &b->sockaddr); + if (!cmp_ret) + return 0; + else if (cmp_ret > 0) + return 1; + else + return -1; + } else if (a->speed > b->speed) + return 1; + else + return -1; + } else if (a->rss_capable > b->rss_capable) + return 1; + else + return -1; + } else if (a->rdma_capable > b->rdma_capable) + return 1; + else + return -1; +} + static int parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf, size_t buf_len, struct cifs_ses *ses, bool in_mount)