From patchwork Sat Dec 17 16:08:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 13075867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA145C4332F for ; Sat, 17 Dec 2022 16:09:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbiLQQJO (ORCPT ); Sat, 17 Dec 2022 11:09:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbiLQQJN (ORCPT ); Sat, 17 Dec 2022 11:09:13 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29F1DDE88 for ; Sat, 17 Dec 2022 08:09:11 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id 1so7873108lfz.4 for ; Sat, 17 Dec 2022 08:09:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=r8F8nuW7iMAdPwEf2w/j1li0d06ObK2muadeH3tSnys=; b=L/Omo6PjALko/7OfPUxLvtt9d98IVpcSpc/TMxqQPlkhR8hAa6ZWuu9V6nj3jDGyLG UktgrHJF28WuIPJe6lIZGmAuVXjRnsvtgUT5SWyuZOsxwKHSkGalxADZ8AscMdnUzB2y jCsL1qA4Np9Pk3My365EL/NWrlJrJ2I0NhOOfOEG8zPdRiLopf4clKDbl8qVWlll4Pk+ aCWIFhibwkX5X80PI6gY3IjYs0l1uUam3rSDtiMDVi2QuWPXSYnp/orfrDxmh1fhB5Sg lPeeb6Hg7z7O+vNB84zU+IujrDlnli2zLIkIzkbRyx33nvp024FUUUwHSlYcQ9QX3lb3 li6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=r8F8nuW7iMAdPwEf2w/j1li0d06ObK2muadeH3tSnys=; b=nn6sr5pRgdv7tHAycUMCSfEx8AvlhFts8xnLyP6p9tyQE7hJjBja56Al5V0tWBcuHw WZrBMzM7H0OFmlfEye/fcE/1q6aAFsXQrhe5k02K1Q36yx3e4TVXC58xB+Kx+Tsr2iXY Txi/gkHja3rl4SEIkE6lrIwIiFF4jSypNBkjsTe4b6FEGsJ7dSAZFNa0VIL7ivK0tsYi g7FYaIFfxcn5Ir0iEzSobAAU9l8qFmEF3M2HgfdQvIUWqF7ZiXMAGvr6DZ+eTfVFig+p 7bKiYiRl0GpyJ1li6YXttKoeG9IoZjwSirrvyS0lbWed2BwCk7KTSV43WuQRqLyFw1o6 AhtA== X-Gm-Message-State: ANoB5pmsLTFRte+BT02JlAKU2bx+NHOp6XSuJbJOzGF3rYwg08f8Yzjt By+N7Lc0WLD4ALatVfEi7ZpGKAGDLyIsp1MAlFRp+fu4 X-Google-Smtp-Source: AA0mqf7+KNo7O5RBgfZ8NfEo0UQEW0k1loqpiToD8qOzgWXZXBEa5tLBmm1//gqZs1P7bMVgVo3sQV//2DYtbR3f+l4= X-Received: by 2002:a19:5219:0:b0:4b5:9125:1432 with SMTP id m25-20020a195219000000b004b591251432mr4047970lfb.204.1671293348931; Sat, 17 Dec 2022 08:09:08 -0800 (PST) MIME-Version: 1.0 From: Steve French Date: Sat, 17 Dec 2022 10:08:57 -0600 Message-ID: Subject: [PATCH][SMB3 client] DFS/reconnect fixes part 3 of 4 To: CIFS Cc: Paulo Alcantara Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org More from Paulo's recent DFS/reconnect patch series (resending to list since they seem to have bounced when sent earlier) From 0ce17b4bdb508d223cc07db324ae33113edaf938 Mon Sep 17 00:00:00 2001 From: Paulo Alcantara Date: Tue, 13 Dec 2022 00:29:22 -0300 Subject: [PATCH 07/14] cifs: don't refresh cached referrals from unactive mounts There is no point refreshing cached referrals from unactive mounts as they will no longer be used and new mounts will either create or refresh them anyway. Signed-off-by: Paulo Alcantara (SUSE) Signed-off-by: Steve French --- fs/cifs/dfs_cache.c | 73 +-------------------------------------------- 1 file changed, 1 insertion(+), 72 deletions(-) diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c index bf5e674f43b8..bef672534397 100644 --- a/fs/cifs/dfs_cache.c +++ b/fs/cifs/dfs_cache.c @@ -1549,74 +1549,6 @@ static void refresh_mounts(struct cifs_ses **sessions) } } -static void refresh_cache(struct cifs_ses **sessions) -{ - int i; - struct cifs_ses *ses; - unsigned int xid; - char *ref_paths[CACHE_MAX_ENTRIES]; - int count = 0; - struct cache_entry *ce; - - /* - * Refresh all cached entries. Get all new referrals outside critical section to avoid - * starvation while performing SMB2 IOCTL on broken or slow connections. - - * The cache entries may cover more paths than the active mounts - * (e.g. domain-based DFS referrals or multi tier DFS setups). - */ - down_read(&htable_rw_lock); - for (i = 0; i < CACHE_HTABLE_SIZE; i++) { - struct hlist_head *l = &cache_htable[i]; - - hlist_for_each_entry(ce, l, hlist) { - if (count == ARRAY_SIZE(ref_paths)) - goto out_unlock; - if (hlist_unhashed(&ce->hlist) || !cache_entry_expired(ce) || - IS_ERR(find_ipc_from_server_path(sessions, ce->path))) - continue; - ref_paths[count++] = kstrdup(ce->path, GFP_ATOMIC); - } - } - -out_unlock: - up_read(&htable_rw_lock); - - for (i = 0; i < count; i++) { - char *path = ref_paths[i]; - struct dfs_info3_param *refs = NULL; - int numrefs = 0; - int rc = 0; - - if (!path) - continue; - - ses = find_ipc_from_server_path(sessions, path); - if (IS_ERR(ses)) - goto next_referral; - - xid = get_xid(); - rc = get_dfs_referral(xid, ses, path, &refs, &numrefs); - free_xid(xid); - - if (!rc) { - down_write(&htable_rw_lock); - ce = lookup_cache_entry(path); - /* - * We need to re-check it because other tasks might have it deleted or - * updated. - */ - if (!IS_ERR(ce) && cache_entry_expired(ce)) - update_cache_entry_locked(ce, refs, numrefs); - up_write(&htable_rw_lock); - } - -next_referral: - kfree(path); - free_dfs_info_array(refs, numrefs); - } -} - /* * Worker that will refresh DFS cache and active mounts based on lowest TTL value from a DFS * referral. @@ -1654,11 +1586,8 @@ static void refresh_cache_worker(struct work_struct *work) i += count; } - if (sessions[0]) { - /* Refresh all active mounts and cached entries */ + if (sessions[0]) refresh_mounts(sessions); - refresh_cache(sessions); - } list_for_each_entry_safe(mg, tmp_mg, &mglist, refresh_list) { list_del_init(&mg->refresh_list); -- 2.34.1