From patchwork Wed Sep 18 05:15:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1986657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=ObQp3rrg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2836-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7n1X0JkXz1y1g for ; Wed, 18 Sep 2024 15:16:15 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6BE5D286026 for ; Wed, 18 Sep 2024 05:16:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC114137764; Wed, 18 Sep 2024 05:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="ObQp3rrg" X-Original-To: linux-cifs@vger.kernel.org Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B68B9132464 for ; Wed, 18 Sep 2024 05:16:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636571; cv=pass; b=bOVJ3/VLKrsuKwowBoXi8qyaVeecD8ZkDP1aGX6oQiO4MjgW8m7+dzLoRyKHrlKbrN0RYPcPWnMyqnjAP4jNkJ5P9BiqPGqqfoOtK60nLrW6gFKyAfl688M8dGeUcwjEXb3PHO9+Vq6vMR82VS9nJGxNhHDIUI1hE3ECabivEdQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636571; c=relaxed/simple; bh=cOeY6x7J7dJJaNT12nfmfhVGI5V78VQLAf046Bf9o6o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CS97WYa2JpSwIax/ke/ei/fuarPE3oaUgJyqWYMNNhkMxoqYX45s48oU/DvhHD3LXTtYN05Hf+ZU43/DdPlFohvVv0Gw/WNou12oSDANIUbCUzdGHIhpbpyuUxQ9HLLJYAziOHYsppzkEqSN3eJI7N5zgMbgAIrhSPkZHRVZgts= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=ObQp3rrg; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=IBUyE1jiCDLMMLV+y0cUTmRChmJY1isG8qoIPxrO2+Y=; b=ObQp3rrgkcwSBlKQVUAdUWis/jQwpVXW5vTIeNdLG/0LWLHEMIbvwxY8H0RCso54Qao/rQ cSuOizqHvQti9r//PeSnP9hV8mvbxrELD2vLyH7xwd+RQ3t/KnEYpMh8OcvPjou/XGQx9w VIbg85lbYMIa+rlcVT7MMhO0ZaGYesSq2gPePrdJtM2ZaMSH49z6K5ayBKlMGAFxxL8OVZ CK9xtcRR2GEBvd/V1MNu9hgtmRTR27cjMk0Tnk4uLB7UyuJNXyfIVjKHsPHQn+WqZB27st PoRZo7ero7ORIv8DLqMwnrHU/8hETY41jHZYaiQRZ5CaEmHCsWhfVPpzywT7Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636567; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=IBUyE1jiCDLMMLV+y0cUTmRChmJY1isG8qoIPxrO2+Y=; b=EyzHZZHToK7igWS684bAkLO2+nqp50iV1ACSfhcTMcY/NCdGQKawfwOw4njxtrKnAMwWAf afdZ7ZGcFCQ3elmUS+4xhltAb0NyrTMrM0WfxO7gVfvlrhMWKIhBz4ujiDzu42jK7LkDz0 7v8tQQ1ZuR8ami3+HptC1oRW0DVtOLGb4p4kvR0L8lZQ+LSkMrlTLO0uQ0uT5ew78FzBnw rqAFoQeXDzZl+qoqM3lwhESS1tAa5PU0AssAtW+np5eiE+8aKDTgQO8Md3dgH5SgvEGoVu NjMn0c8v4q7EDuAL9XhLgRIx0peDPYz0cYUicWYWDLFYS1CKmrgHRA5YQvmKUA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1726636567; a=rsa-sha256; cv=none; b=O5FuCRYrntD/Jnd5sDQMqPpwVgEhDb6wwAISoOIqNEOXogRFjmo6+wI/MgQpG3KD8zy9Gu VBq2zEe1Ao6QJooOk2w+biZL9G2G12mC3klZztsVArq7F1nHqFfuPleQ6MMYapPi087uX/ 09Ge7OUa/3kD7rjb8+qM5gdS4bGm6Wsow+VAthsXPkm4DMebOfCaPkBI0k/mSf6ItA2hpo UY9g/5mrDxVMorlZ6pPi68mqk+aZF5zqbnkjkXrIU3emGaAsJemlcaP8Y6WNQjrjyb3ZqP 3kiWBlvBD4aq9kh1ZxxafNhn1NNqsTB+lGKbNU07FdbRqrOz37epAb3sYEvtpA== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 1/9] smb: client: avoid unnecessary reconnects when refreshing referrals Date: Wed, 18 Sep 2024 02:15:34 -0300 Message-ID: <20240918051542.64349-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Do not mark tcons for reconnect when current connection matches any of the targets returned by new referral even when there is no cached entry. Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/dfs_cache.c | 191 ++++++++++++++++++++++++-------------- 1 file changed, 119 insertions(+), 72 deletions(-) diff --git a/fs/smb/client/dfs_cache.c b/fs/smb/client/dfs_cache.c index 11c8efecf7aa..3cf7c88489be 100644 --- a/fs/smb/client/dfs_cache.c +++ b/fs/smb/client/dfs_cache.c @@ -1095,16 +1095,18 @@ int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it, return 0; } -static bool target_share_equal(struct TCP_Server_Info *server, const char *s1, const char *s2) +static bool target_share_equal(struct cifs_tcon *tcon, const char *s1) { - char unc[sizeof("\\\\") + SERVER_NAME_LENGTH] = {0}; + struct TCP_Server_Info *server = tcon->ses->server; + struct sockaddr_storage ss; const char *host; + const char *s2 = &tcon->tree_name[1]; size_t hostlen; - struct sockaddr_storage ss; + char unc[sizeof("\\\\") + SERVER_NAME_LENGTH] = {0}; bool match; int rc; - if (strcasecmp(s1, s2)) + if (strcasecmp(s2, s1)) return false; /* @@ -1128,34 +1130,6 @@ static bool target_share_equal(struct TCP_Server_Info *server, const char *s1, c return match; } -/* - * Mark dfs tcon for reconnecting when the currently connected tcon does not match any of the new - * target shares in @refs. - */ -static void mark_for_reconnect_if_needed(struct TCP_Server_Info *server, - const char *path, - struct dfs_cache_tgt_list *old_tl, - struct dfs_cache_tgt_list *new_tl) -{ - struct dfs_cache_tgt_iterator *oit, *nit; - - for (oit = dfs_cache_get_tgt_iterator(old_tl); oit; - oit = dfs_cache_get_next_tgt(old_tl, oit)) { - for (nit = dfs_cache_get_tgt_iterator(new_tl); nit; - nit = dfs_cache_get_next_tgt(new_tl, nit)) { - if (target_share_equal(server, - dfs_cache_get_tgt_name(oit), - dfs_cache_get_tgt_name(nit))) { - dfs_cache_noreq_update_tgthint(path, nit); - return; - } - } - } - - cifs_dbg(FYI, "%s: no cached or matched targets. mark dfs share for reconnect.\n", __func__); - cifs_signal_cifsd_for_reconnect(server, true); -} - static bool is_ses_good(struct cifs_ses *ses) { struct TCP_Server_Info *server = ses->server; @@ -1172,43 +1146,127 @@ static bool is_ses_good(struct cifs_ses *ses) return ret; } -/* Refresh dfs referral of @ses and mark it for reconnect if needed */ -static void __refresh_ses_referral(struct cifs_ses *ses, bool force_refresh) +static char *get_ses_refpath(struct cifs_ses *ses) { struct TCP_Server_Info *server = ses->server; - DFS_CACHE_TGT_LIST(old_tl); - DFS_CACHE_TGT_LIST(new_tl); - bool needs_refresh = false; - struct cache_entry *ce; - unsigned int xid; - char *path = NULL; - int rc = 0; - - xid = get_xid(); + char *path = ERR_PTR(-ENOENT); mutex_lock(&server->refpath_lock); if (server->leaf_fullpath) { path = kstrdup(server->leaf_fullpath + 1, GFP_ATOMIC); if (!path) - rc = -ENOMEM; + path = ERR_PTR(-ENOMEM); } mutex_unlock(&server->refpath_lock); - if (!path) + return path; +} + +/* Refresh dfs referral of @ses */ +static void refresh_ses_referral(struct cifs_ses *ses) +{ + struct cache_entry *ce; + unsigned int xid; + char *path; + int rc = 0; + + xid = get_xid(); + + path = get_ses_refpath(ses); + if (IS_ERR(path)) { + rc = PTR_ERR(path); + path = NULL; goto out; + } + + ses = CIFS_DFS_ROOT_SES(ses); + if (!is_ses_good(ses)) { + cifs_dbg(FYI, "%s: skip cache refresh due to disconnected ipc\n", + __func__); + goto out; + } + + ce = cache_refresh_path(xid, ses, path, false); + if (!IS_ERR(ce)) + up_read(&htable_rw_lock); + else + rc = PTR_ERR(ce); + +out: + free_xid(xid); + kfree(path); +} + +static int __refresh_tcon_referral(struct cifs_tcon *tcon, + const char *path, + struct dfs_info3_param *refs, + int numrefs, bool force_refresh) +{ + struct cache_entry *ce; + bool reconnect = force_refresh; + int rc = 0; + int i; + + if (unlikely(!numrefs)) + return 0; + + if (force_refresh) { + for (i = 0; i < numrefs; i++) { + /* TODO: include prefix paths in the matching */ + if (target_share_equal(tcon, refs[i].node_name)) { + reconnect = false; + break; + } + } + } + + down_write(&htable_rw_lock); + ce = lookup_cache_entry(path); + if (!IS_ERR(ce)) { + if (force_refresh || cache_entry_expired(ce)) + rc = update_cache_entry_locked(ce, refs, numrefs); + } else if (PTR_ERR(ce) == -ENOENT) { + ce = add_cache_entry_locked(refs, numrefs); + } + up_write(&htable_rw_lock); + + if (IS_ERR(ce)) + rc = PTR_ERR(ce); + if (reconnect) { + cifs_tcon_dbg(FYI, "%s: mark for reconnect\n", __func__); + cifs_signal_cifsd_for_reconnect(tcon->ses->server, true); + } + return rc; +} + +static void refresh_tcon_referral(struct cifs_tcon *tcon, bool force_refresh) +{ + struct dfs_info3_param *refs = NULL; + struct cache_entry *ce; + struct cifs_ses *ses; + unsigned int xid; + bool needs_refresh; + char *path; + int numrefs = 0; + int rc = 0; + + xid = get_xid(); + ses = tcon->ses; + + path = get_ses_refpath(ses); + if (IS_ERR(path)) { + rc = PTR_ERR(path); + path = NULL; + goto out; + } down_read(&htable_rw_lock); ce = lookup_cache_entry(path); needs_refresh = force_refresh || IS_ERR(ce) || cache_entry_expired(ce); - if (!IS_ERR(ce)) { - rc = get_targets(ce, &old_tl); - cifs_dbg(FYI, "%s: get_targets: %d\n", __func__, rc); - } - up_read(&htable_rw_lock); - if (!needs_refresh) { - rc = 0; + up_read(&htable_rw_lock); goto out; } + up_read(&htable_rw_lock); ses = CIFS_DFS_ROOT_SES(ses); if (!is_ses_good(ses)) { @@ -1217,29 +1275,16 @@ static void __refresh_ses_referral(struct cifs_ses *ses, bool force_refresh) goto out; } - ce = cache_refresh_path(xid, ses, path, true); - if (!IS_ERR(ce)) { - rc = get_targets(ce, &new_tl); - up_read(&htable_rw_lock); - cifs_dbg(FYI, "%s: get_targets: %d\n", __func__, rc); - mark_for_reconnect_if_needed(server, path, &old_tl, &new_tl); + rc = get_dfs_referral(xid, ses, path, &refs, &numrefs); + if (!rc) { + rc = __refresh_tcon_referral(tcon, path, refs, + numrefs, force_refresh); } out: free_xid(xid); - dfs_cache_free_tgts(&old_tl); - dfs_cache_free_tgts(&new_tl); kfree(path); -} - -static inline void refresh_ses_referral(struct cifs_ses *ses) -{ - __refresh_ses_referral(ses, false); -} - -static inline void force_refresh_ses_referral(struct cifs_ses *ses) -{ - __refresh_ses_referral(ses, true); + free_dfs_info_array(refs, numrefs); } /** @@ -1280,7 +1325,7 @@ int dfs_cache_remount_fs(struct cifs_sb_info *cifs_sb) */ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; - force_refresh_ses_referral(tcon->ses); + refresh_tcon_referral(tcon, true); return 0; } @@ -1291,9 +1336,11 @@ void dfs_cache_refresh(struct work_struct *work) struct cifs_ses *ses; tcon = container_of(work, struct cifs_tcon, dfs_cache_work.work); + ses = tcon->ses->dfs_root_ses; - for (ses = tcon->ses; ses; ses = ses->dfs_root_ses) + for (; ses; ses = ses->dfs_root_ses) refresh_ses_referral(ses); + refresh_tcon_referral(tcon, false); queue_delayed_work(dfscache_wq, &tcon->dfs_cache_work, atomic_read(&dfs_cache_ttl) * HZ); From patchwork Wed Sep 18 05:15:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1986658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=TQM1YlOy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2837-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7n1Z4PT4z1y1g for ; Wed, 18 Sep 2024 15:16:18 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D3E13B26EE1 for ; Wed, 18 Sep 2024 05:16:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1253F139D1B; Wed, 18 Sep 2024 05:16:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="TQM1YlOy" X-Original-To: linux-cifs@vger.kernel.org Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7288913792B for ; Wed, 18 Sep 2024 05:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636572; cv=pass; b=Wp3B4w3/F4xzDZO1Ugu6ocM8KmwuoB11MGXo3Bxy22vPerBQbahfqXC7fKchGqjAjKRcSZbv4+xxARZt/1kNLovtJdnKXk3K/Z4GEPv/atZ96+CH/+6/qN2k/l/WQFxtINuIRGIj8GIe6km1gXf25cpdJ72QvUTnbu28K+ew4II= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636572; c=relaxed/simple; bh=M8yXWvKkAZrRCEo1J0g7+JdKRbniTURXUM5S+BHDCtE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=apRuvbzePB5h1Un60Nkvt6O+C2ov5nyuMtNSfwszTDbyT6REzmkjE58Du6dU9InvUrxNxm4HGoq0Q1i+HHrWEwhkRBsKMgLc5dBhFurFpJtrJIsVlsToyhB+2fAVeybQ4bYKgV9buKu33K8FnxyOJLJZcBdMTbXlARwtVKMfp9o= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=TQM1YlOy; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pLYjtw+j9tWHFsr8fJTdUEj5OnHSbDmq606lLM6/UFc=; b=TQM1YlOymwTjf7DDR/UV5AKsi59081FPYdTiThQfeWrlNJs6iwFjiMfmWQ/ihDI5x+D2g9 latTvsPDku5aGb/A1WVcAu56ZSHViP90rSRCi8ZrdgD0V77w05KLE25XRWdgG+1OFF0s4i m+ilFfDCh6BK91WpdsNifH60kIKw0AuzvUxdREvMZDF9hThMKuO94h3ApWN80l8Eu4lYdX +t+yhAVuiXNgjurdFj1m0jMFOCESzWOJMAx2Bg8Tp2iyfwRb3b4Bv4AcGPuQ7nAuUvwQZ/ GCikKw3El1IGGKqu8xbRmH6PR4Q7vfUq4WZwnvCE3sWOUnbCG5Aoi0vwfn3PVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636569; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pLYjtw+j9tWHFsr8fJTdUEj5OnHSbDmq606lLM6/UFc=; b=pghyYKQ0kEB7H767Hz0Dg16hn9n065MFlYEoiUbakdTd0XKBEz6rJYpOELLCHI7FLK3hlO S8+MPD8ZebMMHKKDw+HkDXMcHZvDD7m4cLsj4paIs9Z+nf/i1kQP7rvmBQ5kRml18mTz2R WZgVoH3S6tT/1JO6PISxQkC+bHXWknRNyxXdB6o455FYvDXTTMGhktWytEsoni/WOhNTZb SYqd57kM4kcdahPfZVU6FIj6BSbh2O0P6kZWp4IfKz0a1q37Gg8tWm2y3ttgCXsMDcWrp4 ZPXULoZknNS0Cnt+Md39XOp4rFiIftRLyBTXYPQiT7lSOiewFFtDPdtjBS301w== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1726636569; a=rsa-sha256; cv=none; b=IHxcYl6LSdVgvu0SOte8YFzY7i1ilgRu1O3e/wzeHHUiEd9KEP1sOYzjBPRP9is98r/Zhv Xy+W0zP7FtQPQ0bqR0puQe52HtODeh6AxjgXiDUnxUJYwXFHg70usy7dCrKf1Pi9Mxy2Og HsqDiF8PUiSwxSQeu137fwv9oEcfZ0Tt/VEHZZsr11kPD40ZXbP4KFOFqJvYTQ0fkRsvVC 8cv/HqUswO46buv1fsX4XpVgv8DrfWm5y1BvVMDyOSntHArr6idK8+qgvBaKbcN80fqF9m MJx0lZocF6np9BSZMKxReIlEhihKIauBcA1UHMyAqTrRy3pOOV0FH8xsUZya/Q== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 2/9] smb: client: improve purging of cached referrals Date: Wed, 18 Sep 2024 02:15:35 -0300 Message-ID: <20240918051542.64349-2-pc@manguebit.com> In-Reply-To: <20240918051542.64349-1-pc@manguebit.com> References: <20240918051542.64349-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Purge cached referrals that have a single target when reaching maximum of cache size as the client won't need them to failover. Otherwise remove oldest cache entry. Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/dfs_cache.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/fs/smb/client/dfs_cache.c b/fs/smb/client/dfs_cache.c index 3cf7c88489be..e496dbf8c622 100644 --- a/fs/smb/client/dfs_cache.c +++ b/fs/smb/client/dfs_cache.c @@ -126,6 +126,7 @@ static inline void free_tgts(struct cache_entry *ce) static inline void flush_cache_ent(struct cache_entry *ce) { + cifs_dbg(FYI, "%s: %s\n", __func__, ce->path); hlist_del_init(&ce->hlist); kfree(ce->path); free_tgts(ce); @@ -441,34 +442,31 @@ static struct cache_entry *alloc_cache_entry(struct dfs_info3_param *refs, int n return ce; } -static void remove_oldest_entry_locked(void) +/* Remove all referrals that have a single target or oldest entry */ +static void purge_cache(void) { int i; struct cache_entry *ce; - struct cache_entry *to_del = NULL; - - WARN_ON(!rwsem_is_locked(&htable_rw_lock)); + struct cache_entry *oldest = NULL; for (i = 0; i < CACHE_HTABLE_SIZE; i++) { struct hlist_head *l = &cache_htable[i]; + struct hlist_node *n; - hlist_for_each_entry(ce, l, hlist) { + hlist_for_each_entry_safe(ce, n, l, hlist) { if (hlist_unhashed(&ce->hlist)) continue; - if (!to_del || timespec64_compare(&ce->etime, - &to_del->etime) < 0) - to_del = ce; + if (ce->numtgts == 1) + flush_cache_ent(ce); + else if (!oldest || + timespec64_compare(&ce->etime, + &oldest->etime) < 0) + oldest = ce; } } - if (!to_del) { - cifs_dbg(FYI, "%s: no entry to remove\n", __func__); - return; - } - - cifs_dbg(FYI, "%s: removing entry\n", __func__); - dump_ce(to_del); - flush_cache_ent(to_del); + if (atomic_read(&cache_count) >= CACHE_MAX_ENTRIES && oldest) + flush_cache_ent(oldest); } /* Add a new DFS cache entry */ @@ -484,7 +482,7 @@ static struct cache_entry *add_cache_entry_locked(struct dfs_info3_param *refs, if (atomic_read(&cache_count) >= CACHE_MAX_ENTRIES) { cifs_dbg(FYI, "%s: reached max cache size (%d)\n", __func__, CACHE_MAX_ENTRIES); - remove_oldest_entry_locked(); + purge_cache(); } rc = cache_entry_hash(refs[0].path_name, strlen(refs[0].path_name), &hash); From patchwork Wed Sep 18 05:15:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1986659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=jnIfRU/p; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2838-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7n1b31gWz1y1g for ; Wed, 18 Sep 2024 15:16:19 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 35B13286599 for ; Wed, 18 Sep 2024 05:16:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACC1713A879; Wed, 18 Sep 2024 05:16:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="jnIfRU/p" X-Original-To: linux-cifs@vger.kernel.org Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 715B2132464 for ; Wed, 18 Sep 2024 05:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636574; cv=pass; b=QnG8m71rBaLRJiHRcv00Kqn2669iJKArv5+ecFgFghrKoJUX88fhNyQi/iAkjGOKhOmk/oSoErbm6vxvVC4aYhV1gglJTMcSXpCnM8YpvUmrYWcJbGL8Zw7rIgCYkQVnYGTELw9RBuLE7kcswo8eWiQ2dHP62QjXW41ho+mhbgk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636574; c=relaxed/simple; bh=9O6T3rhV9pxjKZeBuyYL3USTRTnvgwILhKAxWQwqblI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UCJmhoB3Xc19cznkL0BHU654+1mZBfnBW0rEct9S7lLzcHo31ff+xcV21Rw130CGuKgQHofeTLaTTGrk6APqtnQbb04+6PSrTYHYs7HpYw3gaHLzMV1zxbP5PfPe56wmEUyEB0MwD6FumlsbWGbYbFjj6f6pw8k3d4H0q0bcBGc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=jnIfRU/p; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HEyQ1h7FWrN0OwUUEj15caJg5Atz9E35yD/EM7YPLDE=; b=jnIfRU/pw64R1SWKnDbj6agQOCsYaJ6TLECo6aYSVadDz4Hs1K/L5HYM6deT7Sr2ufTLrc dHfpKsuxMHLOEb/b11VB6HmB2DPPGMh+Q37UJft1zlXleOTlB06BrgZjzBfuh1muodHKZO 5MPjpB70l4r8qjKm/dwFMqXfApwqRAlblR59rGNVvE2N9Z/UeOvePftQNvabbU8V7J8zft 78UbG5heA2uiWNn1JCgFJK2MDjSDe8Blc4B99qJfGWPW8Yba/giHkCO1ZE2r64mXEHY/yQ Tjyf/lyQzhPkY+YpIbR0+ZwituWNAR9Zau7VqYfGIUSiVW3DbW38SXUmMOgEhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636570; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HEyQ1h7FWrN0OwUUEj15caJg5Atz9E35yD/EM7YPLDE=; b=NIFk9GolumSgX4mx+yC/M0fN0oB8AUJOXQx4+8O/zCIduh5SI7mxoCg2XVEbhl0rEV+qSD JDkmOWKVTno2kd6xJMGZYcVQn7nccmo7mSTHQPloqMBVJu5OCNG4ATInLH3vOMt+R18idx qx6uFXRw1ZdYAO24DI1yLgAR5FKAfacZmls2fzt/qr1TCMNAeBT+8mrYp404seaBG5nQCh aXGGNaRTeBBVYJWzWFsiFveKHwJx9+LAww1zTJGv6GOlG0CNuCEG18WXU6QxQRqoXgMrDC ow4/wuDV3+nW/eF+H5tEoMyzVPWLV2FFahp1Hr1VGtj6MhHiGvlK+GZUGZtziw== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1726636570; a=rsa-sha256; cv=none; b=RFBkPtP6j4EIIekYEXxxss5SPtmSfF3S16TPF8MluwDLpZF6foP0dVltQKbD0X21avCJ6f hiuQuoZtHN0yhAIsA0LiJRusGALzmKJ9B91lKT4nJxwliEFH72XbXGSckNHMVS+cv2sLfd umqhfZT3Za9wWwnyK5g8DBJtmNwQCV02ySmcHwlgGG/MCNqXMLUPdoDIVyqeo5gQJyI04W n5/pX5xl2pehDvSCtIBMaKkJLIt+LLdqnLvzDDOylpJe5Wcdd93dTs/XfeOtUcVc1y+9jA NCPFGBczBozFVJ28kngiHemQRvQPwuFd2lK6/8jbxbv4xfpN5ouH2r3P+xip9A== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 3/9] smb: client: fix DFS interlink failover Date: Wed, 18 Sep 2024 02:15:36 -0300 Message-ID: <20240918051542.64349-3-pc@manguebit.com> In-Reply-To: <20240918051542.64349-1-pc@manguebit.com> References: <20240918051542.64349-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The DFS interlinks point to different DFS namespaces so make sure to use the correct DFS root server to chase any DFS links under it by storing the SMB session in dfs_ref_walk structure and then using it on every referral walk. Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/cifsglob.h | 3 ++ fs/smb/client/cifsproto.h | 12 ++----- fs/smb/client/connect.c | 41 +++++++++++---------- fs/smb/client/dfs.c | 73 ++++++++++++++++++-------------------- fs/smb/client/dfs.h | 42 ++++++++++++++-------- fs/smb/client/dfs_cache.c | 3 +- fs/smb/client/fs_context.h | 1 + fs/smb/client/misc.c | 3 ++ fs/smb/client/namespace.c | 2 +- 9 files changed, 94 insertions(+), 86 deletions(-) diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 939ef5844571..e969d1ae2498 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -821,6 +821,7 @@ struct TCP_Server_Info { * format: \\HOST\SHARE[\OPTIONAL PATH] */ char *leaf_fullpath; + bool dfs_conn:1; }; static inline bool is_smb1(struct TCP_Server_Info *server) @@ -1059,6 +1060,7 @@ struct cifs_ses { struct list_head smb_ses_list; struct list_head rlist; /* reconnect list */ struct list_head tcon_list; + struct list_head dlist; /* dfs list */ struct cifs_tcon *tcon_ipc; spinlock_t ses_lock; /* protect anything here that is not protected */ struct mutex session_mutex; @@ -1287,6 +1289,7 @@ struct cifs_tcon { /* BB add field for back pointer to sb struct(s)? */ #ifdef CONFIG_CIFS_DFS_UPCALL struct delayed_work dfs_cache_work; + struct list_head dfs_ses_list; #endif struct delayed_work query_interfaces; /* query interfaces workqueue job */ char *origin_fullpath; /* canonical copy of smb3_fs_context::source */ diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index c69e3f48a60c..68c716e6261b 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -724,15 +724,9 @@ static inline int cifs_create_options(struct cifs_sb_info *cifs_sb, int options) int cifs_wait_for_server_reconnect(struct TCP_Server_Info *server, bool retry); -/* Put references of @ses and its children */ static inline void cifs_put_smb_ses(struct cifs_ses *ses) { - struct cifs_ses *next; - - do { - next = ses->dfs_root_ses; - __cifs_put_smb_ses(ses); - } while ((ses = next)); + __cifs_put_smb_ses(ses); } /* Get an active reference of @ses and its children. @@ -746,9 +740,7 @@ static inline void cifs_put_smb_ses(struct cifs_ses *ses) static inline void cifs_smb_ses_inc_refcount(struct cifs_ses *ses) { lockdep_assert_held(&cifs_tcp_ses_lock); - - for (; ses; ses = ses->dfs_root_ses) - ses->ses_count++; + ses->ses_count++; } static inline bool dfs_src_pathname_equal(const char *s1, const char *s2) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 08a41c7aaf72..76f02739dda5 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -1530,6 +1530,9 @@ static int match_server(struct TCP_Server_Info *server, if (server->nosharesock) return 0; + if (!match_super && (ctx->dfs_conn || server->dfs_conn)) + return 0; + /* If multidialect negotiation see if existing sessions match one */ if (strcmp(ctx->vals->version_string, SMB3ANY_VERSION_STRING) == 0) { if (server->vals->protocol_id < SMB30_PROT_ID) @@ -1723,6 +1726,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx, if (ctx->nosharesock) tcp_ses->nosharesock = true; + tcp_ses->dfs_conn = ctx->dfs_conn; tcp_ses->ops = ctx->ops; tcp_ses->vals = ctx->vals; @@ -1873,13 +1877,15 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx, } /* this function must be called with ses_lock and chan_lock held */ -static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx) +static int match_session(struct cifs_ses *ses, + struct smb3_fs_context *ctx, + bool match_super) { if (ctx->sectype != Unspecified && ctx->sectype != ses->sectype) return 0; - if (ctx->dfs_root_ses != ses->dfs_root_ses) + if (!match_super && ctx->dfs_root_ses != ses->dfs_root_ses) return 0; /* @@ -1998,7 +2004,7 @@ cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) continue; } spin_lock(&ses->chan_lock); - if (match_session(ses, ctx)) { + if (match_session(ses, ctx, false)) { spin_unlock(&ses->chan_lock); spin_unlock(&ses->ses_lock); ret = ses; @@ -2382,8 +2388,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) * need to lock before changing something in the session. */ spin_lock(&cifs_tcp_ses_lock); - if (ctx->dfs_root_ses) - cifs_smb_ses_inc_refcount(ctx->dfs_root_ses); ses->dfs_root_ses = ctx->dfs_root_ses; list_add(&ses->smb_ses_list, &server->smb_ses_list); spin_unlock(&cifs_tcp_ses_lock); @@ -2458,6 +2462,7 @@ cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace) { unsigned int xid; struct cifs_ses *ses; + LIST_HEAD(ses_list); /* * IPC tcon share the lifetime of their session and are @@ -2482,6 +2487,9 @@ cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace) list_del_init(&tcon->tcon_list); tcon->status = TID_EXITING; +#ifdef CONFIG_CIFS_DFS_UPCALL + list_replace_init(&tcon->dfs_ses_list, &ses_list); +#endif spin_unlock(&tcon->tc_lock); spin_unlock(&cifs_tcp_ses_lock); @@ -2509,6 +2517,9 @@ cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace) cifs_fscache_release_super_cookie(tcon); tconInfoFree(tcon, netfs_trace_tcon_ref_free); cifs_put_smb_ses(ses); +#ifdef CONFIG_CIFS_DFS_UPCALL + dfs_put_root_smb_sessions(&ses_list); +#endif } /** @@ -2892,7 +2903,7 @@ cifs_match_super(struct super_block *sb, void *data) spin_lock(&ses->chan_lock); spin_lock(&tcon->tc_lock); if (!match_server(tcp_srv, ctx, true) || - !match_session(ses, ctx) || + !match_session(ses, ctx, true) || !match_tcon(tcon, ctx) || !match_prepath(sb, tcon, mnt_data)) { rc = 0; @@ -3623,13 +3634,12 @@ int cifs_is_path_remote(struct cifs_mount_ctx *mnt_ctx) int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx) { struct cifs_mount_ctx mnt_ctx = { .cifs_sb = cifs_sb, .fs_ctx = ctx, }; - bool isdfs; int rc; - rc = dfs_mount_share(&mnt_ctx, &isdfs); + rc = dfs_mount_share(&mnt_ctx); if (rc) goto error; - if (!isdfs) + if (!ctx->dfs_conn) goto out; /* @@ -4034,7 +4044,7 @@ cifs_set_vol_auth(struct smb3_fs_context *ctx, struct cifs_ses *ses) } static struct cifs_tcon * -__cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid) +cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid) { int rc; struct cifs_tcon *master_tcon = cifs_sb_master_tcon(cifs_sb); @@ -4132,17 +4142,6 @@ __cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid) return tcon; } -static struct cifs_tcon * -cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid) -{ - struct cifs_tcon *ret; - - cifs_mount_lock(); - ret = __cifs_construct_tcon(cifs_sb, fsuid); - cifs_mount_unlock(); - return ret; -} - struct cifs_tcon * cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb) { diff --git a/fs/smb/client/dfs.c b/fs/smb/client/dfs.c index 3ec965547e3d..3f6077c68d68 100644 --- a/fs/smb/client/dfs.c +++ b/fs/smb/client/dfs.c @@ -69,7 +69,7 @@ static int get_session(struct cifs_mount_ctx *mnt_ctx, const char *full_path) * Get an active reference of @ses so that next call to cifs_put_tcon() won't * release it as any new DFS referrals must go through its IPC tcon. */ -static void add_root_smb_session(struct cifs_mount_ctx *mnt_ctx) +static void set_root_smb_session(struct cifs_mount_ctx *mnt_ctx) { struct smb3_fs_context *ctx = mnt_ctx->fs_ctx; struct cifs_ses *ses = mnt_ctx->ses; @@ -95,7 +95,7 @@ static inline int parse_dfs_target(struct smb3_fs_context *ctx, return rc; } -static int set_ref_paths(struct cifs_mount_ctx *mnt_ctx, +static int setup_dfs_ref(struct cifs_mount_ctx *mnt_ctx, struct dfs_info3_param *tgt, struct dfs_ref_walk *rw) { @@ -120,6 +120,7 @@ static int set_ref_paths(struct cifs_mount_ctx *mnt_ctx, } ref_walk_path(rw) = ref_path; ref_walk_fpath(rw) = full_path; + ref_walk_ses(rw) = ctx->dfs_root_ses; return 0; } @@ -128,11 +129,11 @@ static int __dfs_referral_walk(struct cifs_mount_ctx *mnt_ctx, { struct smb3_fs_context *ctx = mnt_ctx->fs_ctx; struct dfs_info3_param tgt = {}; - bool is_refsrv; int rc = -ENOENT; again: do { + ctx->dfs_root_ses = ref_walk_ses(rw); if (ref_walk_empty(rw)) { rc = dfs_get_referral(mnt_ctx, ref_walk_path(rw) + 1, NULL, ref_walk_tl(rw)); @@ -158,10 +159,7 @@ static int __dfs_referral_walk(struct cifs_mount_ctx *mnt_ctx, if (rc) continue; - is_refsrv = tgt.server_type == DFS_TYPE_ROOT || - DFS_INTERLINK(tgt.flags); ref_walk_set_tgt_hint(rw); - if (tgt.flags & DFSREF_STORAGE_SERVER) { rc = cifs_mount_get_tcon(mnt_ctx); if (!rc) @@ -172,12 +170,10 @@ static int __dfs_referral_walk(struct cifs_mount_ctx *mnt_ctx, continue; } - if (is_refsrv) - add_root_smb_session(mnt_ctx); - + set_root_smb_session(mnt_ctx); rc = ref_walk_advance(rw); if (!rc) { - rc = set_ref_paths(mnt_ctx, &tgt, rw); + rc = setup_dfs_ref(mnt_ctx, &tgt, rw); if (!rc) { rc = -EREMOTE; goto again; @@ -193,20 +189,22 @@ static int __dfs_referral_walk(struct cifs_mount_ctx *mnt_ctx, return rc; } -static int dfs_referral_walk(struct cifs_mount_ctx *mnt_ctx) +static int dfs_referral_walk(struct cifs_mount_ctx *mnt_ctx, + struct dfs_ref_walk **rw) { - struct dfs_ref_walk *rw; int rc; - rw = ref_walk_alloc(); - if (IS_ERR(rw)) - return PTR_ERR(rw); + *rw = ref_walk_alloc(); + if (IS_ERR(*rw)) { + rc = PTR_ERR(*rw); + *rw = NULL; + return rc; + } - ref_walk_init(rw); - rc = set_ref_paths(mnt_ctx, NULL, rw); + ref_walk_init(*rw); + rc = setup_dfs_ref(mnt_ctx, NULL, *rw); if (!rc) - rc = __dfs_referral_walk(mnt_ctx, rw); - ref_walk_free(rw); + rc = __dfs_referral_walk(mnt_ctx, *rw); return rc; } @@ -214,16 +212,16 @@ static int __dfs_mount_share(struct cifs_mount_ctx *mnt_ctx) { struct cifs_sb_info *cifs_sb = mnt_ctx->cifs_sb; struct smb3_fs_context *ctx = mnt_ctx->fs_ctx; + struct dfs_ref_walk *rw = NULL; struct cifs_tcon *tcon; char *origin_fullpath; - bool new_tcon = true; int rc; origin_fullpath = dfs_get_path(cifs_sb, ctx->source); if (IS_ERR(origin_fullpath)) return PTR_ERR(origin_fullpath); - rc = dfs_referral_walk(mnt_ctx); + rc = dfs_referral_walk(mnt_ctx, &rw); if (!rc) { /* * Prevent superblock from being created with any missing @@ -241,21 +239,16 @@ static int __dfs_mount_share(struct cifs_mount_ctx *mnt_ctx) tcon = mnt_ctx->tcon; spin_lock(&tcon->tc_lock); - if (!tcon->origin_fullpath) { - tcon->origin_fullpath = origin_fullpath; - origin_fullpath = NULL; - } else { - new_tcon = false; - } + tcon->origin_fullpath = origin_fullpath; + origin_fullpath = NULL; + ref_walk_set_tcon(rw, tcon); spin_unlock(&tcon->tc_lock); - - if (new_tcon) { - queue_delayed_work(dfscache_wq, &tcon->dfs_cache_work, - dfs_cache_get_ttl() * HZ); - } + queue_delayed_work(dfscache_wq, &tcon->dfs_cache_work, + dfs_cache_get_ttl() * HZ); out: kfree(origin_fullpath); + ref_walk_free(rw); return rc; } @@ -279,7 +272,7 @@ static int update_fs_context_dstaddr(struct smb3_fs_context *ctx) return rc; } -int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx, bool *isdfs) +int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx) { struct smb3_fs_context *ctx = mnt_ctx->fs_ctx; bool nodfs = ctx->nodfs; @@ -289,7 +282,6 @@ int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx, bool *isdfs) if (rc) return rc; - *isdfs = false; rc = get_session(mnt_ctx, NULL); if (rc) return rc; @@ -317,10 +309,15 @@ int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx, bool *isdfs) return rc; } - *isdfs = true; - add_root_smb_session(mnt_ctx); - rc = __dfs_mount_share(mnt_ctx); - dfs_put_root_smb_sessions(mnt_ctx); + if (!ctx->dfs_conn) { + ctx->dfs_conn = true; + cifs_mount_put_conns(mnt_ctx); + rc = get_session(mnt_ctx, NULL); + } + if (!rc) { + set_root_smb_session(mnt_ctx); + rc = __dfs_mount_share(mnt_ctx); + } return rc; } diff --git a/fs/smb/client/dfs.h b/fs/smb/client/dfs.h index e5c4dcf83750..a23150676d9e 100644 --- a/fs/smb/client/dfs.h +++ b/fs/smb/client/dfs.h @@ -19,6 +19,7 @@ struct dfs_ref { char *path; char *full_path; + struct cifs_ses *ses; struct dfs_cache_tgt_list tl; struct dfs_cache_tgt_iterator *tit; }; @@ -38,6 +39,7 @@ struct dfs_ref_walk { #define ref_walk_path(w) (ref_walk_cur(w)->path) #define ref_walk_fpath(w) (ref_walk_cur(w)->full_path) #define ref_walk_tl(w) (&ref_walk_cur(w)->tl) +#define ref_walk_ses(w) (ref_walk_cur(w)->ses) static inline struct dfs_ref_walk *ref_walk_alloc(void) { @@ -60,14 +62,19 @@ static inline void __ref_walk_free(struct dfs_ref *ref) kfree(ref->path); kfree(ref->full_path); dfs_cache_free_tgts(&ref->tl); + if (ref->ses) + cifs_put_smb_ses(ref->ses); memset(ref, 0, sizeof(*ref)); } static inline void ref_walk_free(struct dfs_ref_walk *rw) { - struct dfs_ref *ref = ref_walk_start(rw); + struct dfs_ref *ref; - for (; ref <= ref_walk_end(rw); ref++) + if (!rw) + return; + + for (ref = ref_walk_start(rw); ref <= ref_walk_end(rw); ref++) __ref_walk_free(ref); kfree(rw); } @@ -116,9 +123,22 @@ static inline void ref_walk_set_tgt_hint(struct dfs_ref_walk *rw) ref_walk_tit(rw)); } +static inline void ref_walk_set_tcon(struct dfs_ref_walk *rw, + struct cifs_tcon *tcon) +{ + struct dfs_ref *ref = ref_walk_start(rw); + + for (; ref <= ref_walk_cur(rw); ref++) { + if (WARN_ON_ONCE(!ref->ses)) + continue; + list_add_tail(&ref->ses->dlist, &tcon->dfs_ses_list); + ref->ses = NULL; + } +} + int dfs_parse_target_referral(const char *full_path, const struct dfs_info3_param *ref, struct smb3_fs_context *ctx); -int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx, bool *isdfs); +int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx); static inline char *dfs_get_path(struct cifs_sb_info *cifs_sb, const char *path) { @@ -142,20 +162,14 @@ static inline int dfs_get_referral(struct cifs_mount_ctx *mnt_ctx, const char *p * references of all DFS root sessions that were used across the mount process * in dfs_mount_share(). */ -static inline void dfs_put_root_smb_sessions(struct cifs_mount_ctx *mnt_ctx) +static inline void dfs_put_root_smb_sessions(struct list_head *head) { - const struct smb3_fs_context *ctx = mnt_ctx->fs_ctx; - struct cifs_ses *ses = ctx->dfs_root_ses; - struct cifs_ses *cur; + struct cifs_ses *ses, *n; - if (!ses) - return; - - for (cur = ses; cur; cur = cur->dfs_root_ses) { - if (cur->dfs_root_ses) - cifs_put_smb_ses(cur->dfs_root_ses); + list_for_each_entry_safe(ses, n, head, dlist) { + list_del_init(&ses->dlist); + cifs_put_smb_ses(ses); } - cifs_put_smb_ses(ses); } #endif /* _CIFS_DFS_H */ diff --git a/fs/smb/client/dfs_cache.c b/fs/smb/client/dfs_cache.c index e496dbf8c622..110f03df012a 100644 --- a/fs/smb/client/dfs_cache.c +++ b/fs/smb/client/dfs_cache.c @@ -1334,9 +1334,8 @@ void dfs_cache_refresh(struct work_struct *work) struct cifs_ses *ses; tcon = container_of(work, struct cifs_tcon, dfs_cache_work.work); - ses = tcon->ses->dfs_root_ses; - for (; ses; ses = ses->dfs_root_ses) + list_for_each_entry(ses, &tcon->dfs_ses_list, dlist) refresh_ses_referral(ses); refresh_tcon_referral(tcon, false); diff --git a/fs/smb/client/fs_context.h b/fs/smb/client/fs_context.h index cf577ec0dd0a..69f9d938b336 100644 --- a/fs/smb/client/fs_context.h +++ b/fs/smb/client/fs_context.h @@ -284,6 +284,7 @@ struct smb3_fs_context { struct cifs_ses *dfs_root_ses; bool dfs_automount:1; /* set for dfs automount only */ enum cifs_reparse_type reparse_type; + bool dfs_conn:1; /* set for dfs mounts */ }; extern const struct fs_parameter_spec smb3_fs_parameters[]; diff --git a/fs/smb/client/misc.c b/fs/smb/client/misc.c index dab526191b07..47b861517bed 100644 --- a/fs/smb/client/misc.c +++ b/fs/smb/client/misc.c @@ -145,6 +145,9 @@ tcon_info_alloc(bool dir_leases_enabled, enum smb3_tcon_ref_trace trace) mutex_init(&ret_buf->fscache_lock); #endif trace_smb3_tcon_ref(ret_buf->debug_id, ret_buf->tc_count, trace); +#ifdef CONFIG_CIFS_DFS_UPCALL + INIT_LIST_HEAD(&ret_buf->dfs_ses_list); +#endif return ret_buf; } diff --git a/fs/smb/client/namespace.c b/fs/smb/client/namespace.c index 4a517b280f2b..0f788031b740 100644 --- a/fs/smb/client/namespace.c +++ b/fs/smb/client/namespace.c @@ -240,7 +240,7 @@ static struct vfsmount *cifs_do_automount(struct path *path) ctx->source = NULL; goto out; } - ctx->dfs_automount = is_dfs_mount(mntpt); + ctx->dfs_automount = ctx->dfs_conn = is_dfs_mount(mntpt); cifs_dbg(FYI, "%s: ctx: source=%s UNC=%s prepath=%s dfs_automount=%d\n", __func__, ctx->source, ctx->UNC, ctx->prepath, ctx->dfs_automount); From patchwork Wed Sep 18 05:15:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1986660 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=DqqoE1Y/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2839-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7n1b3jltz1y2j for ; Wed, 18 Sep 2024 15:16:19 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EC686286668 for ; Wed, 18 Sep 2024 05:16:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7598C13B787; Wed, 18 Sep 2024 05:16:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="DqqoE1Y/" X-Original-To: linux-cifs@vger.kernel.org Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2A8E13792B for ; Wed, 18 Sep 2024 05:16:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636575; cv=pass; b=VWV+/xGWD5DDEEiLQJ8/iIqtvb8OkiTdt4kfKntrScBB3wkP5ZRepcQ0sWUi0oCcrHbRsTFTvqY0PnVYgXvtBxTUKuv9hg2qmCgTy1pS3i0XhOdYfT7d0PyLN0oB4Wt5J3CY8eBMweRfpDtEqEAj/QJT6BP8gHsh7RBRPDnjii0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636575; c=relaxed/simple; bh=EIpCt1Pif6m1MkOu0Pqy1nWpYGf6z8o/aN+CGRROdeg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JApjrXIZFfqFbt7Yc3Cjo0fcxVuiN/Ch/EI+WNfq8iiz1MrUCDibT2oOOWNjMJ7Dxh43SAzyUMeK6PQsmLx/vvGZOLJVsalvVRYcxGjOE58nv0lAQIY+ETsZ4v5VoRln3puWwA5TkYuW0NfMPBo5x2vD2oTV6J7qv2mEt/1xvkM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=DqqoE1Y/; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X61xWO3F0fJnJ3tQgzZri7RuhJxa3stG+DtYLiZtyb0=; b=DqqoE1Y/3rz+f3e3sKb0gCrrPoj19p1ZIZlJP4Wnf6MY7G/0TpjvfXbNG5/JY/TU53Wae1 ipcLwk1bcrYPOxb+STN7Wz5UPhUbV8RYyHFs/JL/U38iyAoPHx8l35F95g25eMEnIwdoc2 7C4pO+ssWRGaEW735GDId6LciiIuLfjcx9mT/SScaFXy02uKrGC5lKb+PoqW/ARmLWG1du CcBW5ygDv/Na/y2UUBGn4B6Vg4i5kotwmzxQpxt3E0mKTlCrtXj8z77Vy+2G5vd7EG9qJ9 G/UJ+iZDS00oqcs/HoDLVfk1xp9+VCg4Ddp6vDV60u/UqoE4wY0nNhxkhX3Jfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636572; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X61xWO3F0fJnJ3tQgzZri7RuhJxa3stG+DtYLiZtyb0=; b=AbodPH1Hzz7fbqDV/+U4wT6D0H1FtY5jFM/AECoFv+Z3fCzzBvM19bqjLJ+08mVC1D2AYl gvOhhWSv0OV/8Or8WYDFa0sHZFEXvq/T1mK1xES2mrNA3GjNvoYMCDcG9WQOCD6ZpI4tMG rTpoq3bhmOmWvepP6jAD7AISLKNe2jTKn+auRiO9jzHALmLgGMFbWBoE6PP8k1DHcomBoz tUYoDa5V4BmGQ5qflkk8a08BcvtYYFnzJYKcPbyYkcj7pK02HjiJ3ujOOY9k6wTVDdWMVY Xp2NntRTFOprtaYUQ2oEEtJsF3jKTGR3xyAoqXJ7N/vizl9nT8F3UpXE/O1S2Q== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1726636572; a=rsa-sha256; cv=none; b=kiJH/isp89yKZIoOVsye2MNXVcyhw6awQSXG/KV7drQG23vzy0q18cbNS9dl2l9YuTSHKW oX8h7LYLt0hvy8+czFb1cKe+UMJcLbMw1FRl58fWYgQpC17o47M6CuUfyH+Owqf5JZlHrg jb0KhXrgPtjv9wjqONpEqm6W8GAXSZUBgJeLn5GI77L5g1IjvfDbUo8NaKSewVNXVgggOm s7VQsrTixqKfswUFdVt+4tUj5dBVQ/bO9KNMv01vl4EBXzTUOT02Q12DL/8WT0uFI4EKPA c874Bs2sX+0s1funcBfHAaCDYp8XBufs9goBIipXLDwXf8liE6M8jnIlYOn9sA== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 4/9] smb: client: stop flooding dmesg in smb2_calc_signature() Date: Wed, 18 Sep 2024 02:15:37 -0300 Message-ID: <20240918051542.64349-4-pc@manguebit.com> In-Reply-To: <20240918051542.64349-1-pc@manguebit.com> References: <20240918051542.64349-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When having several mounts that share same credential and the client couldn't re-establish an SMB session due to an expired kerberos ticket or rotated password, smb2_calc_signature() will end up flooding dmesg when not finding SMB sessions to calculate signatures. Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/smb2transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/smb/client/smb2transport.c b/fs/smb/client/smb2transport.c index e4636fca821d..c8bf0000f73b 100644 --- a/fs/smb/client/smb2transport.c +++ b/fs/smb/client/smb2transport.c @@ -242,7 +242,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server, ses = smb2_find_smb_ses(server, le64_to_cpu(shdr->SessionId)); if (unlikely(!ses)) { - cifs_server_dbg(VFS, "%s: Could not find session\n", __func__); + cifs_server_dbg(FYI, "%s: Could not find session\n", __func__); return -ENOENT; } From patchwork Wed Sep 18 05:15:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1986661 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=jqtXewC2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2840-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7n1c2NBTz1y2l for ; Wed, 18 Sep 2024 15:16:20 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E23981C2298F for ; Wed, 18 Sep 2024 05:16:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A3E14137764; Wed, 18 Sep 2024 05:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="jqtXewC2" X-Original-To: linux-cifs@vger.kernel.org Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C427132464 for ; Wed, 18 Sep 2024 05:16:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636576; cv=pass; b=gLN8P0FGyIZOTE8z9G6gOpMUFxxMGkcPNfR5Fen3BQ9ht07v31fmm2hXmjZRvDgV7n9fNeUgTDh4WCBr6d+QV0gKX1LVrJDhJBp+sh3LP7baddiGFMQyt8ZHp+x+gLBKgKAnG/AneIFnVLYARF+qU7FUn6piJM7Jd6/R7TqF/KE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636576; c=relaxed/simple; bh=Xel/Am3ycYmMf6qo9lo2zzjp2O13yv9Cj6ztaQWK3uo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i78DR+V5t+dnJ/vxgFYmgQTrI99M8LaLlOpSkDd18JMF3mJa9vEFTJ6y51SW7V0Uro6+paU3N9oZLnu+3CKhmukcgRZ/bTWbhRTAsfSstKId77JHtY7Kamnys63dLhuSdXy+nd5skvS4BbCM+XNaqhAbjko8cfAWmDUB+oLhTzM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=jqtXewC2; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nQMyVYG0NCUiUwE0eVuz27cx/Q34Ji3m9025KeLs0tQ=; b=jqtXewC2rGg89G2wNt0tUgBPOR8G8Y0+wn/RrDNF8FmndTmnQwE6XwUjc8picMf4QqWRq0 NgoUpHXfiaL+X6bDPcWaXDQzwsaLpatX208I/m3ri5rKXbv4RqStqEi5TojymsV+q6tmoj BlL0aX1ugBPuM9IT7PLhdVqWL/LWJBVfT6UX9qHRpqgY+Sx8mqVBrzWw0Ud45Q8EiHq8ZD 1hX/GpW2NhSj6w/fgprOmg4B2rpwUgqO/Kdapl6TVWDszXSraP12ai8Q716Kwi3UQerERS ZVYydWPdSteRdq2g+wjgaBRND1LEf3rYZ5Ui9ko7jaAUf7kY5s5/Kj3jVmt1qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636573; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nQMyVYG0NCUiUwE0eVuz27cx/Q34Ji3m9025KeLs0tQ=; b=AbZAjzr/hJsZwDLWA0n9rlyb12bWf84t7s59PLuswui3M5hW+NCD6hLDRP1R6XFKcGREdv YkROkOKSjUdYdpF96OlUrMUQopBQNWBEqTPD+D0/4TPoKBJZnl7VAu65F5+iuG4YEKUGJh 103c6Onb4x0cNJ7ZsLRuQgcCho/OrIfwkazE8EAvRxZ3iImy6MOklmR3bMNXu7JwGaFjcZ GovmlAOgCey2nEGM3j9NhmUz+G5WvKceQLWJciDqXJu8hnuph8so1ygVrzKRoG/ssrwBXa 1ZvSepYHFbDytOuw+LOTAc5n6LU2XLS+70N0BxKFHATctliL1DFsZQveOsGd+w== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1726636573; a=rsa-sha256; cv=none; b=r4cu7yyQcmU8AXQ3QXQJ8hBnZGQkaoZnuNl4tnUMyjyBWC7xVMIi9zzIycuby8Pq5I1W20 3OCJRvpDc7QGInYZvJl2tkIzLRZwA/d79tZkJD+7NRq/ZM9jnd7/Y0gmhBJjcWCpFlr13Y 1iI0y7FjKf2m3JOjp23jly7uvnYKfHvPiRc0hD8ZKwwfuiuffScj5zbVwBmzCVa5CvN220 bxWztddVUxoWa0w1i2LaynFw7h3Hr+QPX4w7I06CRQ+7NhfdorZw5GnJWdhJy41dnXvR3y 9g+V3JxVYhKcT3se6nHu2rWsiVAOBeW3G/9WU4QI6BtG0h9Tk3C33kHJlWhFxQ== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 5/9] smb: client: print failed session logoffs with FYI Date: Wed, 18 Sep 2024 02:15:38 -0300 Message-ID: <20240918051542.64349-5-pc@manguebit.com> In-Reply-To: <20240918051542.64349-1-pc@manguebit.com> References: <20240918051542.64349-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Do not flood dmesg with failed session logoffs as kerberos tickets getting expired or passwords being rotated is a very common scenario. Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/connect.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 76f02739dda5..e1df9f093339 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -2064,8 +2064,7 @@ void __cifs_put_smb_ses(struct cifs_ses *ses) if (do_logoff) { xid = get_xid(); rc = server->ops->logoff(xid, ses); - if (rc) - cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n", + cifs_server_dbg(FYI, "%s: Session Logoff: rc=%d\n", __func__, rc); _free_xid(xid); } From patchwork Wed Sep 18 05:15:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1986662 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=Qym1NZFy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2841-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7n1d11B4z1y1g for ; Wed, 18 Sep 2024 15:16:21 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 318121C22711 for ; Wed, 18 Sep 2024 05:16:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A12913A3EC; Wed, 18 Sep 2024 05:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="Qym1NZFy" X-Original-To: linux-cifs@vger.kernel.org Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A8A5132464 for ; Wed, 18 Sep 2024 05:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636578; cv=pass; b=oprZhJU73bWplz1C7A1XfLGQkHWNFPAEYXB3Bov3CeV/mppKUx3/Y4zjxT8StA5G9+3BcEWrGgBDOaQpu7X6+HF0Zi0RoxM/oEFxD/5D9YH+01SgCJXE97KJSUwP0xfwpp1galNdg3OiVeulwKDpy7Mu0ugOS8EGn7+ByVeQ2q8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636578; c=relaxed/simple; bh=7BDrw2Wsgu9hbilz+d46QQdb+93h8AMbjWmzlruoob8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZUfuPiblX10G76Ga8DforOIEn6p/wsVNEota/oprAN09XT0ifFIunAUtzjkhcVohtHcXZLvfYr616KSGM0U+QIvVEfqg27FFWeKpWfzCXT+yp+haACI6MgKoHH8ijy3A5pCE8bkiA/sR/X1SGflriDq+UK6xaWywY7JSzcs5xk8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=Qym1NZFy; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tI8M5neBcwcVw4Zjc9idtrkzUNfYBZs0C9OxoF3vZSY=; b=Qym1NZFymmYd5sBb9aFXuE0hzsHIY2GlUwQ+UBbvm7FIygAc2ysq5dp/qlqaYZTt2i5YmE GxUx2W4LBpnVHORFEXkm66AAydhCbGLGD4M/zBr9tcRE0MeMkrm/qWTfSfnC6oD76zZtN2 QuwQryLY6DP7mJjeXWKs6ZF8/t6QFP8ptqUyB92H3fRgrejH12Go+C2tttlEo7514Ty/RW 9zSJhLU9NSkt880OK8KovQYtpkyqHkL7KYqQdx82l0cCC1vP2axP+2kiN/v25km7mCO4Mp csE34+cigwQ9YN6kgCQFDY92nsDGFeKLLwjy8+NkTUWI0djO/wzuXx+jVy0kHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636575; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tI8M5neBcwcVw4Zjc9idtrkzUNfYBZs0C9OxoF3vZSY=; b=lgJ8wEuq/dj2AdgYojot3/QoIXAopELP6B3Sxm6hJRF/lnn0dE84D0eztwsK48nLqnuLtp 09Dy4tS6YenFw29Ix3Ewd/lS0nA/AIY05qBZWbyd62YBvdoQ0+XWRF3wk1/8ybrDFi78N+ Om/XuzjCLJDhwK7K35UewumNgLTbIR92CgKt6F/vErkDkdwL//Y3e7XH5FUe/LtEADnp7y y/z64J6sJTZnxhxwHSH9dV7YVxPpAVxWJ6za3JWel3yAF/kXhc2ZbpXaOr+6yqlYIgdyrr hqdC5fw/fiVLUaLIizvswZe3uWmFyQCjfpcVhrTbd426i29+GZ/RMfxHhOoRsA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1726636575; a=rsa-sha256; cv=none; b=eBjjEdlYCB5GmMWGnKRVZb109tfHisSreqVvr+ZIXIukxo+n81oulSrt94eKCw3H4p2KiA ciYqzp55rbcLSOA/7go/eTg/UmNH0Yo4aT8gfVxbohredrADpp2dvogzNjcHfmPb4hS6Vg m31za+tlZgP+WB6qwAzK4mqKw32PdWd/YOWl6nGK2olWLIaay7MkLoPnosEFeDsLYThIzB ccpAxwV0hz+CavFPOp3kAJr+766VsYfHnF3q1YnFPhwyPPh7QMjhIuLYtkfRpsh8TfjgpD T6hjnnfO/IENEzwtjwC4GWwVVvWYrDE/ItBfeJ8s1v5/I7msZyzJW4v1SLsMhg== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 6/9] smb: client: stop flooding dmesg on failed session setups Date: Wed, 18 Sep 2024 02:15:39 -0300 Message-ID: <20240918051542.64349-6-pc@manguebit.com> In-Reply-To: <20240918051542.64349-1-pc@manguebit.com> References: <20240918051542.64349-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Stop flooding dmesg over failed session setups as kerberos tickets getting expired or passwords being rotated is a very common scenario. Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/connect.c | 4 +++- fs/smb/client/smb2pdu.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index e1df9f093339..a382f532974a 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -3390,6 +3390,8 @@ int cifs_mount_get_session(struct cifs_mount_ctx *mnt_ctx) ses = cifs_get_smb_ses(server, ctx); if (IS_ERR(ses)) { rc = PTR_ERR(ses); + if (rc == -ENOKEY && ctx->sectype == Kerberos) + cifs_dbg(VFS, "Verify user has a krb5 ticket and keyutils is installed\n"); ses = NULL; goto out; } @@ -4008,7 +4010,7 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, rc = server->ops->sess_setup(xid, ses, server, nls_info); if (rc) { - cifs_server_dbg(VFS, "Send error in SessSetup = %d\n", rc); + cifs_server_dbg(FYI, "Send error in SessSetup = %d\n", rc); spin_lock(&ses->ses_lock); if (ses->ses_status == SES_IN_SETUP) ses->ses_status = SES_NEED_RECON; diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index f68746becd64..1f78b7368b00 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -1626,8 +1626,8 @@ SMB2_auth_kerberos(struct SMB2_sess_data *sess_data) spnego_key = cifs_get_spnego_key(ses, server); if (IS_ERR(spnego_key)) { rc = PTR_ERR(spnego_key); - if (rc == -ENOKEY) - cifs_dbg(VFS, "Verify user has a krb5 ticket and keyutils is installed\n"); + cifs_dbg(FYI, "%s: couldn't auth with kerberos: %d\n", + __func__, rc); spnego_key = NULL; goto out; } From patchwork Wed Sep 18 05:15:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1986663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=dih68IZi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2842-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7n1f0DhQz1y2j for ; Wed, 18 Sep 2024 15:16:21 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0DE761C2284F for ; Wed, 18 Sep 2024 05:16:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79124137764; Wed, 18 Sep 2024 05:16:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="dih68IZi" X-Original-To: linux-cifs@vger.kernel.org Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA6B0139D1B for ; Wed, 18 Sep 2024 05:16:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636579; cv=pass; b=cV6senzFsOvhxBAcyDKQtBfsW4RhFnOQ0uKHGvN0Td5HtaWWMhAGzbXIEK0hSQ4MyzbbxvEOGg/Va4WfOGwpjkxXdiZeRDt+rfupytPK64Sjm7MpJ1TyuzXQAX58ZXtKAopVAQAGYDVZucAFiqS5llInCcv+zGsfZBbEBtQvTLA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636579; c=relaxed/simple; bh=fK2tZsUjCHUzE726FLveHLSKV3QsberRB7D8sJ/+xn8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j3VndqfnGyHxtWuJcH+0n9WeY0Jbtyu3ILtHge4DBA3AnEJ5oYQktJphkyhEN/5Z8pCuuOhYSkKOTPWQmMWz6xqAgJVScSyp2QkSZZ+fef267j0Z3VeG6Abe0CqK3c00zH9gDFHo7hDj6rl7Ui0tezfehF/4tbB8A71o5KbFK4g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=dih68IZi; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X8GAwxoM2jkzIiF+K8JYIaYW/UaUBpJmIHmBZuPGWFs=; b=dih68IZiuNXmn7OhdnGv3N15aq3yXaYW95WU32HnzlQ8IWEI/IzTRrrZk2nwWdhCtG4AAR t86eFhqLsITY0O0ZY2syJjI8K7T4V5jRyaTgNQkbn/g2pEL+ka1zREFNQN5fvWgThW4Ofe qrkIgOe0pLQNBHTQyfo+UPlmcCF4txA49r5wXnYlaT44TL3MSEbAhqq8w5v0I5mezfK302 4p5kdgvrYguSEiEp/DbfIGcgr/tVwfkjoNz38XDFaAjFY50zy031RbimKOzYXCJF6kV2dW lFlJPxxs2bdbwR3zAX3DfLNkJuNK1I52S+uMYWM+WPLTpUbdKLow/o4m18mmcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636576; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X8GAwxoM2jkzIiF+K8JYIaYW/UaUBpJmIHmBZuPGWFs=; b=KjeiWxPIkn1b8NgaQ9w0hc5VLV9Fx7LVk8/X3NTqZRkhaLwsemM1IFD2+0yArU28OConGk 3wKx03jxyuLcleE67RXRXOkm5dYvyLy4HDMXbLwsksH0Sh7FssiSGwLe7xJCFju984KSVw wUH9/n1XRju9nKUODFXDO3XOhUnaTV2sXx0arettsGiB+BAcZp1vPds6Kdc86566iaH8wg wQQxNjBq98bWkPTSBypppHziWhrXMrR45bX5wEo14SrxumyPhoTa/FKoQ81S3a4ygzo562 NhcQxT95WGS3DjCyj4XSMw2e4UZL4cGK7KDLMZo5CtcEo1jVvbrt3jHiiOzo7g== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1726636576; a=rsa-sha256; cv=none; b=UlGKi0K9H8IrYT3EgASJ6mTsrfUH8FGXOdY/zhFiSHSZkyjF5pvYoxsgcAxTO6cdiAFcMu Uqi0jsc2CExgmgor3wb/paoXQ4X5pBLzgpcF2M9TP4UEMreVG6tA2FKKXwpxixFr6P1WOw IYbFfHAzJfZoNEecZXpMCVMLq/ZbmMpK5rPEW9BE9yU+1ZJ5OacEPPHBzfgLzj5fIUrrpd X7amzDKCiS3NjcHZaXTsrWJ1gABY9wRne8e6FwW9FHXkE8jzvZLZ+NYZteEztv/7K9/3Yy In9yQPQjVWzm+MQhEQtL4csPSLT/B1Du/WvgrzbPk8pTfBLXzUBngiTrPZW6jg== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 7/9] smb: client: stop flooding dmesg with automounts Date: Wed, 18 Sep 2024 02:15:40 -0300 Message-ID: <20240918051542.64349-7-pc@manguebit.com> In-Reply-To: <20240918051542.64349-1-pc@manguebit.com> References: <20240918051542.64349-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Avoid logging info and expected errors when automounting DFS links and reparse mount points as a share might contain hundreds of them and the client would end up flooding dmesg. Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/cifsfs.c | 4 ++-- fs/smb/client/connect.c | 3 ++- fs/smb/client/dfs.c | 3 +-- fs/smb/client/fs_context.h | 2 +- fs/smb/client/namespace.c | 5 +++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index 2a2523c93944..c91cf57f337c 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -910,7 +910,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type, if (cifsFYI) { cifs_dbg(FYI, "%s: devname=%s flags=0x%x\n", __func__, old_ctx->source, flags); - } else { + } else if (!old_ctx->automount) { cifs_info("Attempting to mount %s\n", old_ctx->source); } @@ -937,7 +937,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type, rc = cifs_mount(cifs_sb, cifs_sb->ctx); if (rc) { - if (!(flags & SB_SILENT)) + if (!(flags & SB_SILENT) && !old_ctx->automount) cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n", rc); root = ERR_PTR(rc); diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index a382f532974a..e71b6933464a 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -3390,7 +3390,8 @@ int cifs_mount_get_session(struct cifs_mount_ctx *mnt_ctx) ses = cifs_get_smb_ses(server, ctx); if (IS_ERR(ses)) { rc = PTR_ERR(ses); - if (rc == -ENOKEY && ctx->sectype == Kerberos) + if (rc == -ENOKEY && ctx->sectype == Kerberos && + !ctx->automount) cifs_dbg(VFS, "Verify user has a krb5 ticket and keyutils is installed\n"); ses = NULL; goto out; diff --git a/fs/smb/client/dfs.c b/fs/smb/client/dfs.c index 3f6077c68d68..96db96062a8a 100644 --- a/fs/smb/client/dfs.c +++ b/fs/smb/client/dfs.c @@ -263,11 +263,10 @@ static int update_fs_context_dstaddr(struct smb3_fs_context *ctx) struct sockaddr *addr = (struct sockaddr *)&ctx->dstaddr; int rc = 0; - if (!ctx->nodfs && ctx->dfs_automount) { + if (!ctx->nodfs && ctx->automount && ctx->dfs_conn) { rc = dns_resolve_server_name_to_ip(ctx->source, addr, NULL); if (!rc) cifs_set_port(addr, ctx->port); - ctx->dfs_automount = false; } return rc; } diff --git a/fs/smb/client/fs_context.h b/fs/smb/client/fs_context.h index 69f9d938b336..5135f7b2e8d3 100644 --- a/fs/smb/client/fs_context.h +++ b/fs/smb/client/fs_context.h @@ -282,7 +282,7 @@ struct smb3_fs_context { bool witness:1; /* use witness protocol */ char *leaf_fullpath; struct cifs_ses *dfs_root_ses; - bool dfs_automount:1; /* set for dfs automount only */ + bool automount:1; /* set for automounts */ enum cifs_reparse_type reparse_type; bool dfs_conn:1; /* set for dfs mounts */ }; diff --git a/fs/smb/client/namespace.c b/fs/smb/client/namespace.c index 0f788031b740..9bfc0a592d27 100644 --- a/fs/smb/client/namespace.c +++ b/fs/smb/client/namespace.c @@ -220,6 +220,7 @@ static struct vfsmount *cifs_do_automount(struct path *path) tmp.leaf_fullpath = NULL; tmp.UNC = tmp.prepath = NULL; tmp.dfs_root_ses = NULL; + tmp.automount = true; fs_context_set_ids(&tmp); rc = smb3_fs_context_dup(ctx, &tmp); @@ -240,9 +241,9 @@ static struct vfsmount *cifs_do_automount(struct path *path) ctx->source = NULL; goto out; } - ctx->dfs_automount = ctx->dfs_conn = is_dfs_mount(mntpt); + ctx->dfs_conn = is_dfs_mount(mntpt); cifs_dbg(FYI, "%s: ctx: source=%s UNC=%s prepath=%s dfs_automount=%d\n", - __func__, ctx->source, ctx->UNC, ctx->prepath, ctx->dfs_automount); + __func__, ctx->source, ctx->UNC, ctx->prepath, ctx->dfs_conn); mnt = fc_mount(fc); out: From patchwork Wed Sep 18 05:15:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1986664 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=YP/5sozE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2843-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7n1g3Jxhz1y1g for ; Wed, 18 Sep 2024 15:16:23 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 610F01C227FF for ; Wed, 18 Sep 2024 05:16:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C888813B58B; Wed, 18 Sep 2024 05:16:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="YP/5sozE" X-Original-To: linux-cifs@vger.kernel.org Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53485132464 for ; Wed, 18 Sep 2024 05:16:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636580; cv=pass; b=DdUtN1N6LGmrIK0sDDQMsxjKjfFFbzmqvy4OS391L/M7byUyFT1pidwxMXioR07np00clcn/1sy7nX5RGFqeM59/9RCcWZXO9+r0JVzDUKtKeHBqAu7prNOt3KGfRiVN331j9LlTRTat3+hn/zQ0zurjQHATzwkxoSM/6f/vtbY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636580; c=relaxed/simple; bh=9+FxDeUZkQnFlvbnQFCMQtJasPfYNhF7CVCe9NbS/+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c0MHr83/kK6IMud3NDj95o9VeAT1QBNxOm5UNqe5Tx0H1CRPHk3wQDjkO8jdfPn6AHkn08QQLl/PCfNo0T11WLm4Atpnhdf/2SdUhDYr6p9zU7IlpkafA6vaLFcEI3PVbqclrkBGdn07pJVbmM2Wm0soKjfvV6DziI/T5SeGd/E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=YP/5sozE; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=35pYiSAOtdfHfdek4lP+dEnnScBBYjWTWYlQ53AlhNw=; b=YP/5sozEyN00pTWYKzDd/WW9JjCcAjrrmMNBW5co5DvZty+dACmhk6k76NNT+1c6w2ysk2 NFNJShUsiMt634hYjUopgnRAhczs1vqCF/BlDKcvLTP6mOd99StSSXkxliyi7/zJSCpPJr w4pSC96ndUlEBiS6g4dSJOC7RTyry/wgPC6pt1572ajLrp+8ZhVwDX0nTEFklYBbf3hCnJ gHf9izEbCsp3af0XFyYPT2+9CYBP0aKclxZ0/YPSssW40HPXVeqIbkWb0c/C3rYm5XNFBo 2ysZdvg1qLrXzyiOozrrfCZ1TrDUj4fUYLY5lNCoEkgpOGJSzl80YYVB89pqFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636577; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=35pYiSAOtdfHfdek4lP+dEnnScBBYjWTWYlQ53AlhNw=; b=oJtLbu/ihUjd2O2V477VbstHxjct5Zlsdx4KfM7vlChFfjPG0tmVRyPsPtdhQymnXXmbod yZyrNuErtPS1HmFcYoG/UxWFJJWT0qf1BTkrffwDRn4ZHRogdUY0giEdAM+UFe1brt2/Xu EHlqCQGcxWxSDc3DYeEI8NI0FLpVL7OFhV8DoEm0QE62FFFwi6jnhLrmuiJM8mWajcFEPJ knqN6qoJNAOoyj54NZOKf71JC26OGU6P4drViu4QAPihgA1qdvX6Bov1/2ZjKtMVtfhZWk JYeilTpdHoTETdeZQIMwOj5W+bvMefumTs+P8Kxu/GWqL37pCouXQgnJ2pZAyQ== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1726636577; a=rsa-sha256; cv=none; b=Kg3847J0KemPcNAEGdPNhQgMz6qfdnwDCoc4sNmCqmlnfQzVgPkM+1v5gr5fPd10CHvQsc BBNByiDanhPbJ33XjPzXfbrsY+bdPp4dClOG+LetrfMZWjmqcSu2AjJN1Tkmx55RX3rU8X L0v+bW87hGoXQneJkpzq3SfKJrK/joS2j3aul4rL0nIhKr7AOD5pdVw6UyTkIvdx6gtsHX 04AcSeHLIEJa38pk/3eV633dbSmdBh+i/LXACacfI6LpygpeT2wtJfEACVvmTjpNKaLCoD LMamH+wAHrf/5jV2jfc1NReR2/4P8vj7p0Z85B5fzJ0wfOY3kvrZw8rP+GxK3Q== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 8/9] smb: client: fix DFS failover in multiuser mounts Date: Wed, 18 Sep 2024 02:15:41 -0300 Message-ID: <20240918051542.64349-8-pc@manguebit.com> In-Reply-To: <20240918051542.64349-1-pc@manguebit.com> References: <20240918051542.64349-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For sessions and tcons created on behalf of new users accessing a multiuser mount, matching their sessions in tcon_super_cb() with master tcon will always lead to false as every new user will have its own session and tcon. All multiuser sessions, however, will inherit ->dfs_root_ses from master tcon, so match it instead. Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/misc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/misc.c b/fs/smb/client/misc.c index 47b861517bed..054f10ebf65a 100644 --- a/fs/smb/client/misc.c +++ b/fs/smb/client/misc.c @@ -1111,7 +1111,8 @@ static void tcon_super_cb(struct super_block *sb, void *arg) t2 = cifs_sb_master_tcon(cifs_sb); spin_lock(&t2->tc_lock); - if (t1->ses == t2->ses && + if ((t1->ses == t2->ses || + t1->ses->dfs_root_ses == t2->ses->dfs_root_ses) && t1->ses->server == t2->ses->server && t2->origin_fullpath && dfs_src_pathname_equal(t2->origin_fullpath, t1->origin_fullpath)) From patchwork Wed Sep 18 05:15:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1986665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=ROxDSAQC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2844-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7n1k1wBYz1y1g for ; Wed, 18 Sep 2024 15:16:26 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7F8011F22219 for ; Wed, 18 Sep 2024 05:16:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 292CA132464; Wed, 18 Sep 2024 05:16:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="ROxDSAQC" X-Original-To: linux-cifs@vger.kernel.org Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F92F13A3EC for ; Wed, 18 Sep 2024 05:16:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636582; cv=pass; b=WJ8jFp/l4YxlqomrVUmDu4/z6HhJA2pxqLLcIuV0REusd9KnZVcJdgfiI1scj7sMGv5IXp8k/TpTkKhsxkrzDJniDSqkr1EigwUzZiqTyjDBTCtABXdjtM2CT5GdSGtSl6btlU+zpOMToH00FjuB8R/qsACmqDia9JXLwnfFrKU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726636582; c=relaxed/simple; bh=d3NEc/JbGFf3TRhq6vEL16X1LsGHTTdlSLhfjVHdl20=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qbemTax+lKYvQOeIhsVjqAAcN1MUAIMROW9ZyDMyXJs+qKJBu1MYLrPexHhXoy/L3MHyhYrGSwGFiUWM/Ym8H3pU5DhYLftn2lM3KG/rV2M9M7UagPLuZubJvxFs+lwoiax2wM5msmck6dpeRnsTFEP8C2PBvs1sSqPscgkb8oc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=ROxDSAQC; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oc+2fbCEJbzJbzJOeWAYxCHBz1uZPJ6lPSWdyAyQFk4=; b=ROxDSAQCxL3MRkPNDW//R96BZ7t+J3s/FuyjEfrc576qhMPgGl7KuyEDtm5Ej+32u9I7Cm g72wSV0kNRgPjUCOnlY2AKuSN5nd3Glot5JxToeZzDNxNo4Fbto295s+FXzLTBzJWsy2Cz xt2faq/pHCaUX63I6vrQPzsWRpo7SiJcwfz0hft2IqkFZ5vDN2fbgoY0imDyIne6DsHDM4 6wKyu0YTjPqKulYZVSIdViKHsoeCG3lqqqwHRC2aINaKU4+MClTDdbaKxVb6MGVmOibwLR PkT+t0tS+3jCR1s8IVm26q/51HZzgflywwbXL6pjtiPt0qz4d7a+tfKwodTEoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1726636579; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oc+2fbCEJbzJbzJOeWAYxCHBz1uZPJ6lPSWdyAyQFk4=; b=hEgp7sjkvjQnNHx4hPUtsFMG6tDDkcELYLedpVYZ3kDJ7HVsdqseK9fIAEIRH5A79qcYxQ gcc/TUue5wB3tFcDbNtnhWpTsx3HnyzUuA2lqrrhkXYLgcWhe+hk+oQ+pyjH/1KEjp8g4F vSErZx+CY0jM5xgWNJKbB4gWVb5K7HTAVPOQ/zmh3cxzLdSU6iDj1/3uhoanvv4VPHyClO L+sP0eQauJhDdaXOgLIyYf3LKWPk7mdoV9UkeA7INSKyOoowku696MvN180DejPDX5Sa/R pxYXn6uvZ2dzuetYFnPigD9LCAw6W8MtNII7yv/xeTFKcCMWtpF+izhCDwZEwA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1726636579; a=rsa-sha256; cv=none; b=L3896pH5hdEnECFeV+IV4qAcV07qIey80AD1lvoRRZOQd0E6TfBXe7BKCmzU+1fXmAQv2n hyv/Ry8rPKrbbR0ycEG4HJGIUgKmFofrL+JWxaX3KPNC5dkiO6RSenHAJiqJVa+d3mHChE xX2xDhIbo9mHd5mNaY44ZKOfYpBetagBjsdBtKPjCQviVnx+WuFDQ2qRMBP32oZUJQdvRi ThvMjFtwLLtb2lGzp5Ht4WZDsPWCIgaDqRrXlmNJaePnJ2DrqMmimI5mzL1COEMsj0VRL2 QPZFf8BfCMx1fM/g3oRzkVimHZkQO71SQbswaThkBGY0KwSqzdTsYDPQgHW3BQ== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 9/9] smb: client: propagate error from cifs_construct_tcon() Date: Wed, 18 Sep 2024 02:15:42 -0300 Message-ID: <20240918051542.64349-9-pc@manguebit.com> In-Reply-To: <20240918051542.64349-1-pc@manguebit.com> References: <20240918051542.64349-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Propagate error from cifs_construct_tcon() in cifs_sb_tlink() instead of always returning -EACCES. Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/connect.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index e71b6933464a..5dda17ed9c77 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -4213,9 +4213,9 @@ tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink) struct tcon_link * cifs_sb_tlink(struct cifs_sb_info *cifs_sb) { - int ret; - kuid_t fsuid = current_fsuid(); struct tcon_link *tlink, *newtlink; + kuid_t fsuid = current_fsuid(); + int err; if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) return cifs_get_tlink(cifs_sb_master_tlink(cifs_sb)); @@ -4250,9 +4250,9 @@ cifs_sb_tlink(struct cifs_sb_info *cifs_sb) spin_unlock(&cifs_sb->tlink_tree_lock); } else { wait_for_construction: - ret = wait_on_bit(&tlink->tl_flags, TCON_LINK_PENDING, + err = wait_on_bit(&tlink->tl_flags, TCON_LINK_PENDING, TASK_INTERRUPTIBLE); - if (ret) { + if (err) { cifs_put_tlink(tlink); return ERR_PTR(-ERESTARTSYS); } @@ -4263,8 +4263,9 @@ cifs_sb_tlink(struct cifs_sb_info *cifs_sb) /* return error if we tried this already recently */ if (time_before(jiffies, tlink->tl_time + TLINK_ERROR_EXPIRE)) { + err = PTR_ERR(tlink->tl_tcon); cifs_put_tlink(tlink); - return ERR_PTR(-EACCES); + return ERR_PTR(err); } if (test_and_set_bit(TCON_LINK_PENDING, &tlink->tl_flags)) @@ -4276,8 +4277,9 @@ cifs_sb_tlink(struct cifs_sb_info *cifs_sb) wake_up_bit(&tlink->tl_flags, TCON_LINK_PENDING); if (IS_ERR(tlink->tl_tcon)) { + err = PTR_ERR(tlink->tl_tcon); cifs_put_tlink(tlink); - return ERR_PTR(-EACCES); + return ERR_PTR(err); } return tlink;