From patchwork Thu May 27 14:21:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1484657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FrVPy2Mk9z9sWc; Fri, 28 May 2021 00:22:14 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lmGtn-0003vQ-75; Thu, 27 May 2021 14:22:11 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lmGtj-0003tv-Hx for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:22:07 +0000 Received: from mail-pf1-f200.google.com ([209.85.210.200]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lmGtj-00029R-A2 for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:22:07 +0000 Received: by mail-pf1-f200.google.com with SMTP id o11-20020a62f90b0000b02902db3045f898so513926pfh.23 for ; Thu, 27 May 2021 07:22:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5Pme5tf1/zTbEJiFKXrFBqpgYSIetKwi/6QIeERlAXQ=; b=czdF0LOd1hEzTU3cahUp9T4UwozmMNGy+/FzQKKi9NJ1UGWjtpXQHvQQzQzNT0k8VI owuXjTB4EfAugXDiAG0oPBD0q2IUiWYcrFMyAM8jbPT4qF4ufvux1Uq+CL1lM6fDbrEj 08nx1nzUChr0Uqnw6EZconACl7to24Fr31ApdBJalPFjjJL9r9b5rqYcy84d85Gh3WIG /VnBdoN1kAGoHDWcA1TYzvPP1CLrdtnc7iL/Y5IUFYVa2XDjbm25+n4rcRNE6YoQf0RK ws+fYkYUV68czRzgUzguWelrFX4sm0mEjBWzP/g7PVSwGrK18ft8q7cx9+k/we2Vfmau ea5w== X-Gm-Message-State: AOAM530qcMdXG4hzrX5iChrvxY2UryJH69N7/kOqQE5GEgBRn9DIs5V3 ccrb8w6WmVmX13EWMPkNxA63r8k6qKlRJqvo5ync2VQ/aCijrii9OCrZ5QgwSyoy3qKaqghNCb1 usfXvxetMkVNaqandMmiMYSFFQ9EgXfIoSntpt68ruw== X-Received: by 2002:a17:902:e2d3:b029:f9:d714:8220 with SMTP id l19-20020a170902e2d3b02900f9d7148220mr3472225plc.65.1622125325446; Thu, 27 May 2021 07:22:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzX96Wv7BykA7dA5DkSbeQ0Zi+Pqoh4IXJ6NRZLIWWLEb6hyr3i1vsvmA/qO7gjitqnxeafZA== X-Received: by 2002:a17:902:e2d3:b029:f9:d714:8220 with SMTP id l19-20020a170902e2d3b02900f9d7148220mr3472213plc.65.1622125325164; Thu, 27 May 2021 07:22:05 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id t12sm2171695pjw.57.2021.05.27.07.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 07:22:04 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/3] cifs: Simplify reconnect code when dfs upcall is enabled Date: Thu, 27 May 2021 08:21:57 -0600 Message-Id: <20210527142158.16171-3-tim.gardner@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210527142158.16171-1-tim.gardner@canonical.com> References: <20210527142158.16171-1-tim.gardner@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Samuel Cabrero BugLink: https://bugs.launchpad.net/bugs/1929831 Some witness notifications, like client move, tell the client to reconnect to a specific IP address. In this situation the DFS failover code path has to be skipped so clean up as much as possible the cifs_reconnect() code. Signed-off-by: Samuel Cabrero Reviewed-by: Aurelien Aptel Signed-off-by: Steve French (backported from commit 7d6535b720421d58886d5590ffc3617d359aa871) [rtg - minor context adjustment] Signed-off-by: Tim Gardner --- fs/cifs/connect.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 1746aadf85ef4..e096751a73873 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -344,7 +344,7 @@ static char *extract_hostname(const char *unc); * This should be called with server->srv_mutex held. */ #ifdef CONFIG_CIFS_DFS_UPCALL -static int reconn_set_ipaddr(struct TCP_Server_Info *server) +static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server) { int rc; int len; @@ -379,12 +379,6 @@ static int reconn_set_ipaddr(struct TCP_Server_Info *server) return !rc ? -1 : 0; } -#else -static inline int reconn_set_ipaddr(struct TCP_Server_Info *server) -{ - return 0; -} -#endif #ifdef CONFIG_CIFS_DFS_UPCALL struct super_cb_data { @@ -441,6 +435,7 @@ static void reconn_set_next_dfs_target(struct TCP_Server_Info *server, struct dfs_cache_tgt_iterator **tgt_it) { const char *name; + int rc; if (!cifs_sb || !cifs_sb->origin_fullpath) return; @@ -465,6 +460,12 @@ static void reconn_set_next_dfs_target(struct TCP_Server_Info *server, "%s: failed to extract hostname from target: %ld\n", __func__, PTR_ERR(server->hostname)); } + + rc = reconn_set_ipaddr_from_hostname(server); + if (rc) { + cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n", + __func__, rc); + } } static inline int reconn_setup_dfs_targets(struct cifs_sb_info *cifs_sb, @@ -621,11 +622,6 @@ cifs_reconnect(struct TCP_Server_Info *server) */ reconn_set_next_dfs_target(server, cifs_sb, &tgt_list, &tgt_it); #endif - rc = reconn_set_ipaddr(server); - if (rc) { - cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n", - __func__, rc); - } if (cifs_rdma_enabled(server)) rc = smbd_reconnect(server);