From patchwork Thu May 27 14:21:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1484656 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 4FrVPy0rX9z9sTD; Fri, 28 May 2021 00:22:13 +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 1lmGtj-0003th-0e; Thu, 27 May 2021 14:22:07 +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 1lmGti-0003tJ-1h for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:22:06 +0000 Received: from mail-pj1-f72.google.com ([209.85.216.72]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lmGth-00028S-PA for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:22:05 +0000 Received: by mail-pj1-f72.google.com with SMTP id a11-20020a17090a70cbb029015d3e996884so2686354pjm.4 for ; Thu, 27 May 2021 07:22:05 -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=vOrnr2gXWixDQhJLNxDAxbBegeYlY4lAIzvNY2xCtZY=; b=p8zRcQNGAotWEJYTfZdbmLoq1K/33h/g/DO+0QYHagmwGCVtqoN7hz9+pJAlSlD9eH ohIc6Lm67S0kSfnsIWwHqIKQv7I1ELbyKS4NL49zPIeUJhwetjnMrvx66RwgBni/GpBD Zyo3KQxxv7UX+05wwfzcu2Z/1OPkbCwj75syVIeHwtPnQjtcPcN1e8UGlEfIHae2YHpm uklfx7CJuyZSC5zJHsqPKrdMaeSYNx/k03DlrTVZQEdLmxAaGJg5oL7NJ0nUSEQ2aINY U9r7Xc+xD6f+qW6eimZPKDQkbVbi6xc+TOWwNJI2lmJKNloQx6AVk44oi+4fOGJTzg4H PV2g== X-Gm-Message-State: AOAM532qGUHZnNtKWxwU2kYcS7fLZJkDt+rgi+DFsDY/Nb6Cav8vp/P1 CvQSDhlEzGFE0jBld/sJ6d0NJyhEjkHRF2sqPMD6HZ71k8pHPGQYo+gqUhPxgq248+npd+NRZeC 6OaKfyUecohDgW6HMYTRgdrpPRUumK4qH3iLGg83rcQ== X-Received: by 2002:a05:6a00:22c1:b029:2dc:edbe:5e9 with SMTP id f1-20020a056a0022c1b02902dcedbe05e9mr3985774pfj.51.1622125324161; Thu, 27 May 2021 07:22:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJBD1xk0UT+kiRGe1EHsEQyeWmqQrY5tqweoQiYs58SpbVQunI7Ul8S8fdy9hjYME+gsT/bA== X-Received: by 2002:a05:6a00:22c1:b029:2dc:edbe:5e9 with SMTP id f1-20020a056a0022c1b02902dcedbe05e9mr3985758pfj.51.1622125323956; Thu, 27 May 2021 07:22:03 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id t12sm2171695pjw.57.2021.05.27.07.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 07:22:03 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/3] cifs: rename reconn_inval_dfs_target() Date: Thu, 27 May 2021 08:21:56 -0600 Message-Id: <20210527142158.16171-2-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: Paulo Alcantara BugLink: https://bugs.launchpad.net/bugs/1929831 This function has nothing to do with *invalidation* but setting up the next target server from a cached referral. Rename it to reconn_set_next_dfs_target(). While at it, get rid of some meaningless checks. Signed-off-by: Paulo Alcantara (SUSE) Reviewed-by: Aurelien Aptel Signed-off-by: Steve French (backported from commit 7d397a034d5c45528c7bdf7fc3752c4793029cce) [rtg minor context adjustmnent] Signed-off-by: Tim Gardner --- fs/cifs/connect.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index ab9eeb5ff8e57..1746aadf85ef4 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -435,15 +435,14 @@ static inline void put_tcp_super(struct super_block *sb) cifs_sb_deactive(sb); } -static void reconn_inval_dfs_target(struct TCP_Server_Info *server, - struct cifs_sb_info *cifs_sb, - struct dfs_cache_tgt_list *tgt_list, - struct dfs_cache_tgt_iterator **tgt_it) +static void reconn_set_next_dfs_target(struct TCP_Server_Info *server, + struct cifs_sb_info *cifs_sb, + struct dfs_cache_tgt_list *tgt_list, + struct dfs_cache_tgt_iterator **tgt_it) { const char *name; - if (!cifs_sb || !cifs_sb->origin_fullpath || !tgt_list || - !server->nr_targets) + if (!cifs_sb || !cifs_sb->origin_fullpath) return; if (!*tgt_it) { @@ -620,7 +619,7 @@ cifs_reconnect(struct TCP_Server_Info *server) * feature is disabled, then we will retry last server we * connected to before. */ - reconn_inval_dfs_target(server, cifs_sb, &tgt_list, &tgt_it); + reconn_set_next_dfs_target(server, cifs_sb, &tgt_list, &tgt_it); #endif rc = reconn_set_ipaddr(server); if (rc) { 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); From patchwork Thu May 27 14:21:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1484658 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 4FrVQ24dN9z9sRN; Fri, 28 May 2021 00:22:18 +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 1lmGtq-0003xg-Nr; Thu, 27 May 2021 14:22:14 +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 1lmGtk-0003u4-9J for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:22:08 +0000 Received: from mail-pj1-f71.google.com ([209.85.216.71]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lmGtk-00029p-0j for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:22:08 +0000 Received: by mail-pj1-f71.google.com with SMTP id mw15-20020a17090b4d0fb0290157199aadbaso2683845pjb.7 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=uSvM/2MgPrTiX7qH33GpIFImhzJlTvdBXIVSUECQIO4=; b=Z68XbWTm/Y79ZDdooq9gd1jFabMzczN8Nded3rXyK6XwGnMvvDK3mL32J/aUojlYqX 73zUAsw5dPdbekRSKbZLVxObZcfUzlIbnB42z5mlxtPTugKl0Raf0n1d2b3jE5iwSEBa rjzFuHuiySWeafhJrwnGEsbs4H8jxHfIUmdhtt1/B59jFqm/aqR+iKd6aee+naHPoBLD CM7GRIpwUwmxGSCS8k0KkwZ8qftq+zsHAy3FrQogObhbtGHBabullU9WrUFrWxe/kW6D n3IZayQl2pVTD4fxBZYiLr4mlcTgE/itSR4C5dtu0Ps6iePKa5VEauq/QazRI8Zm3Vbi drlA== X-Gm-Message-State: AOAM532GnP+7m72JqY5pe41l/22cCBYKYl+FdUGCL5vJ6h2Gpb1WRTNE ecvC64jldiaszgdEyayt1gFSSu4AkUizKFx8pk1xNKrJtzeF26dy1SjdKM2OLJGEpYo3KXFFEiK b5eoKsMyLVx2l/ltzjPxYA8EF7g2HrH3quimdAK5AiQ== X-Received: by 2002:a62:1d52:0:b029:2dd:ee:1439 with SMTP id d79-20020a621d520000b02902dd00ee1439mr3888898pfd.57.1622125326340; Thu, 27 May 2021 07:22:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVhjcN80V7WJ706GkdMbXPfFMN+BQc8IJ7dBAk75Ff61m8QZI/ooUGLxOrn38VTiX+2Bi4TA== X-Received: by 2002:a62:1d52:0:b029:2dd:ee:1439 with SMTP id d79-20020a621d520000b02902dd00ee1439mr3888885pfd.57.1622125326091; Thu, 27 May 2021 07:22:06 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id t12sm2171695pjw.57.2021.05.27.07.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 07:22:05 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/3] cifs: On cifs_reconnect, resolve the hostname again. Date: Thu, 27 May 2021 08:21:58 -0600 Message-Id: <20210527142158.16171-4-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: Shyam Prasad N BugLink: https://bugs.launchpad.net/bugs/1929831 On cifs_reconnect, make sure that DNS resolution happens again. It could be the cause of connection to go dead in the first place. This also contains the fix for a build issue identified by Intel bot. Reported-by: kernel test robot Signed-off-by: Shyam Prasad N Reviewed-by: Paulo Alcantara (SUSE) Reviewed-by: Pavel Shilovsky CC: # 5.11+ Signed-off-by: Steve French (backported from commit 4e456b30f78c429b183db420e23b26cde7e03a78) [rtg - context adjustment] Signed-off-by: Tim Gardner --- fs/cifs/Kconfig | 3 +-- fs/cifs/Makefile | 5 +++-- fs/cifs/connect.c | 27 ++++++++++++++++++++------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/fs/cifs/Kconfig b/fs/cifs/Kconfig index 22cf04fb32d35..16e2d2ef96bb0 100644 --- a/fs/cifs/Kconfig +++ b/fs/cifs/Kconfig @@ -18,6 +18,7 @@ config CIFS select CRYPTO_AES select CRYPTO_LIB_DES select KEYS + select DNS_RESOLVER help This is the client VFS module for the SMB3 family of NAS protocols, (including support for the most recent, most secure dialect SMB3.1.1) @@ -112,7 +113,6 @@ config CIFS_WEAK_PW_HASH config CIFS_UPCALL bool "Kerberos/SPNEGO advanced session setup" depends on CIFS - select DNS_RESOLVER help Enables an upcall mechanism for CIFS which accesses userspace helper utilities to provide SPNEGO packaged (RFC 4178) Kerberos tickets @@ -179,7 +179,6 @@ config CIFS_DEBUG_DUMP_KEYS config CIFS_DFS_UPCALL bool "DFS feature support" depends on CIFS - select DNS_RESOLVER help Distributed File System (DFS) support is used to access shares transparently in an enterprise name space, even if the share diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile index 51bae9340842f..523fc419af8ad 100644 --- a/fs/cifs/Makefile +++ b/fs/cifs/Makefile @@ -10,13 +10,14 @@ cifs-y := trace.o cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o \ cifs_unicode.o nterr.o cifsencrypt.o \ readdir.o ioctl.o sess.o export.o smb1ops.o winucase.o \ smb2ops.o smb2maperror.o smb2transport.o \ - smb2misc.o smb2pdu.o smb2inode.o smb2file.o cifsacl.o + smb2misc.o smb2pdu.o smb2inode.o smb2file.o cifsacl.o \ + dns_resolve.o cifs-$(CONFIG_CIFS_XATTR) += xattr.o cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o -cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o dfs_cache.o +cifs-$(CONFIG_CIFS_DFS_UPCALL) += cifs_dfs_ref.o dfs_cache.o cifs-$(CONFIG_CIFS_FSCACHE) += fscache.o cache.o diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index e096751a73873..e2fb0e087a9ee 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -343,7 +343,6 @@ 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_from_hostname(struct TCP_Server_Info *server) { int rc; @@ -615,12 +614,26 @@ cifs_reconnect(struct TCP_Server_Info *server) mutex_lock(&server->srv_mutex); #ifdef CONFIG_CIFS_DFS_UPCALL - /* - * Set up next DFS target server (if any) for reconnect. If DFS - * feature is disabled, then we will retry last server we - * connected to before. - */ - reconn_set_next_dfs_target(server, cifs_sb, &tgt_list, &tgt_it); + if (cifs_sb && cifs_sb->origin_fullpath) + /* + * Set up next DFS target server (if any) for reconnect. If DFS + * feature is disabled, then we will retry last server we + * connected to before. + */ + reconn_set_next_dfs_target(server, cifs_sb, &tgt_list, &tgt_it); + else { +#endif + /* + * Resolve the hostname again to make sure that IP address is up-to-date. + */ + rc = reconn_set_ipaddr_from_hostname(server); + if (rc) { + cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n", + __func__, rc); + } + +#ifdef CONFIG_CIFS_DFS_UPCALL + } #endif if (cifs_rdma_enabled(server))