From patchwork Fri Nov 8 17:32:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13868574 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DB49D64074 for ; Fri, 8 Nov 2024 17:34:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADF596B00B8; Fri, 8 Nov 2024 12:34:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A8E836B00BA; Fri, 8 Nov 2024 12:34:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E1CF6B00BB; Fri, 8 Nov 2024 12:34:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6EE776B00B8 for ; Fri, 8 Nov 2024 12:34:48 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2F9B3140EEF for ; Fri, 8 Nov 2024 17:34:48 +0000 (UTC) X-FDA: 82763625966.03.4282695 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 424CE20021 for ; Fri, 8 Nov 2024 17:34:08 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ROsu8jLL; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731087098; 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:dkim-signature; bh=PpSYjRYWbFXxWDdh6eO8irNXCJzGx0/SlE83d2O2JK0=; b=FZg5AGedh7GdmQmDEG9KJwQQwkmkrLQkU2QCT65u7UAYlF01BUitA/a6vjS7HaNVCIDG7F xJQWpsrZVbYU5aezG87DgMALsI/ledWPelWsY9x14O8nz54BCigiy9naDZpYa13aTzeWTR 69zyIKthSN0gzKn42TP6B4aAEf6M65M= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ROsu8jLL; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087098; a=rsa-sha256; cv=none; b=3HOR9rDGkqun4ZDujCBqWUR5rtHmUxhgtQ5TFz25qZAxtlgycYm7VEw2uzbF17mSVdTqRu GfqjKL4akOqy4fh3Y4C3IDa7UI0B7Pev8g3rd8asBcrA/qwtPiGi0+V6C59yLDkH6cIEP7 KHlaQ78TTaR2Zy1TgD7Ap+Qmn5Cxmlk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731087285; 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=PpSYjRYWbFXxWDdh6eO8irNXCJzGx0/SlE83d2O2JK0=; b=ROsu8jLLE0BWP8APM1FgqSlFAvsK0DyGxGMquqvtK1/XWGBgpnIn9KDH8Olc4QF3FG2803 OwSyfWwMYtWU/b4EqRBNXQ9ROva5uxSjsktKUa8KGtnGgkRFiWOmZKamMmeDmprwnSbLEA MF6vJYD5u97SrzgPRhlbUEnpyGSCkhQ= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-vLwEkQlAMwO8A82QkSZrig-1; Fri, 08 Nov 2024 12:34:44 -0500 X-MC-Unique: vLwEkQlAMwO8A82QkSZrig-1 X-Mimecast-MFC-AGG-ID: vLwEkQlAMwO8A82QkSZrig Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7319E19560B5; Fri, 8 Nov 2024 17:34:41 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.231]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 037561953883; Fri, 8 Nov 2024 17:34:35 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 16/33] netfs: Remove some extraneous directory invalidations Date: Fri, 8 Nov 2024 17:32:17 +0000 Message-ID: <20241108173236.1382366-17-dhowells@redhat.com> In-Reply-To: <20241108173236.1382366-1-dhowells@redhat.com> References: <20241108173236.1382366-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 424CE20021 X-Stat-Signature: ocrg7zofsq6hbafru8yy11y9tug1m67g X-Rspam-User: X-HE-Tag: 1731087248-312117 X-HE-Meta: U2FsdGVkX19I7P34knaoIIvdZVlWmD02CmEjW0R/mP6wnOXXlVvln17XJfVEB97Ynn8OZ9NpCQlAT7suFjh2q6tmFyIGP3PmtDMqS2xK/ZVGny5Xagctsh7uV2NHqvVz6uNFcmbIEytm6UrCQv1XpNnH2sMWh1IYBiy6GRi5hHxGF8VJt9zSVs8Iid/Zekiybja69ze33jlfoQbHUScNNBF+duqAWKsBgT3/4Ink5e7cjdDX3GOFxbrEhMqmrV7BnnSWLMx232p46tf4bM2GEvNlOrsxlx/dPX3vlpYekVz7aJbun4H2JgJzs2/TconDEW4wNE4InJGh+C9bVvihSJyo2D01kiUwAQzgJSjwEyxvqgMNMnVFg2GeqprrdvHB4ui61+fXaYnv59D30KC8G3jOrqsZ4C+URKec/5iapjgjHVGzihopz7mG04rPRyOysTMTSYaR8ngCPik7HEdlcAcMK3P1P0Tsi5KfIXkxFnkcp1mtcchrxFYVElVX62+zsGPpp5cgIGTnPxXYv/RN6f62ERNGP6NDi5q3/usEUxjiPzl2Y8nIvTOqFf+tbAyu33j4JA+3kmD/wmqsQBn3sHFOOc1gSx2CzpdqU5sBYK3ZCwbIkgOMkTqHnBrUhGMsKTmnt6Pn4fKlUFvKmMPMFqqKz9pxcIxSkHz/yndoW2+L3+mkAA64DL2lueEitWGNiRWgnYNCL+sA2rkBFbwkP1PH/CuoGDFD6LbkuBiKSeV5zPwc3cHEaQomAJb0I2MwphUn4ZOdyXYQ8p+94w9BC01gIMpOn2fUcSWgfS0in4dUtPiXSaMF4v+hhNKEShd+tzAAATC3NQnc0IZcGz4NtKCBHXzDIkJOcUcQEHncBaNkwjH6n1j8ceTzWSoBJnnuyqaPDfH7ESm+PhJ8ouuGsgv0xjOy54ovuyxXMfBYbFWxXuoYpKtcqEO7hnWl4u3i7vyrEgCVbp2dL3GuuWO nJj0+2tr mK+AniPndrljKT6kAywiCrcUdnToQr/aamwfNEVtMBIS4ZAtN/8FmIav4Vjyqg+4du8un9BicMNzZ5NSWEGeXIgJnAt2QiEc1HezTVFBk/EtFgpQZya5iBCOD2aGMEy+nlI+NEDEsLa0eLtSwLwlJUEP4Ra3sax600ojLAF3CxuA6yg8FJn6Msdw2efxqlIi3cHvmtSHMx2KuKUydgHyA7y9kCFDR46ikE3isp3+cXagP1Ihs2AmC4yWkC6njuasMxmcv+bVLaQi8bZzfGXa+kzZmxUHDyTqEDSTf2P8i7atH247DezcKOzi1HxZV6Z2LtwbHYUVArDkZG6Pjckbtiv+pDEIen6+Mvq870rlchy83TlMYVJzDr+3AsZkxTMlY+fsK0WUP3kV3xz3K6i25O8h8l6oqQv4x3VGY0P8nnHcmrB8IQD7NzG8jM6Pkj31yJvW4aHshh1dKfHRyM1zEmIvUAfFS1/pHAle6ghJ7V4QrQ2acZHPriG6wdWaGx3lB0nJ0TGUrHIchGcQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In the directory editing code, we shouldn't re-invalidate the directory if it is already invalidated. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/dir_edit.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/fs/afs/dir_edit.c b/fs/afs/dir_edit.c index fe223fb78111..13fb236a3f50 100644 --- a/fs/afs/dir_edit.c +++ b/fs/afs/dir_edit.c @@ -247,7 +247,7 @@ void afs_edit_dir_add(struct afs_vnode *vnode, */ index = b / AFS_DIR_BLOCKS_PER_PAGE; if (nr_blocks >= AFS_DIR_MAX_BLOCKS) - goto error; + goto error_too_many_blocks; if (index >= folio_nr_pages(folio0)) { folio = afs_dir_get_folio(vnode, index); if (!folio) @@ -260,7 +260,7 @@ void afs_edit_dir_add(struct afs_vnode *vnode, /* Abandon the edit if we got a callback break. */ if (!test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) - goto invalidated; + goto already_invalidated; _debug("block %u: %2u %3u %u", b, @@ -348,9 +348,8 @@ void afs_edit_dir_add(struct afs_vnode *vnode, _leave(""); return; -invalidated: +already_invalidated: trace_afs_edit_dir(vnode, why, afs_edit_dir_create_inval, 0, 0, 0, 0, name->name); - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); kunmap_local(block); if (folio != folio0) { folio_unlock(folio); @@ -358,9 +357,10 @@ void afs_edit_dir_add(struct afs_vnode *vnode, } goto out_unmap; +error_too_many_blocks: + clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); error: trace_afs_edit_dir(vnode, why, afs_edit_dir_create_error, 0, 0, 0, 0, name->name); - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); goto out_unmap; } @@ -421,7 +421,7 @@ void afs_edit_dir_remove(struct afs_vnode *vnode, /* Abandon the edit if we got a callback break. */ if (!test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) - goto invalidated; + goto already_invalidated; if (b > AFS_DIR_BLOCKS_WITH_CTR || meta->meta.alloc_ctrs[b] <= AFS_DIR_SLOTS_PER_BLOCK - 1 - need_slots) { @@ -475,10 +475,9 @@ void afs_edit_dir_remove(struct afs_vnode *vnode, _leave(""); return; -invalidated: +already_invalidated: trace_afs_edit_dir(vnode, why, afs_edit_dir_delete_inval, 0, 0, 0, 0, name->name); - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); kunmap_local(block); if (folio != folio0) { folio_unlock(folio); @@ -489,7 +488,6 @@ void afs_edit_dir_remove(struct afs_vnode *vnode, error: trace_afs_edit_dir(vnode, why, afs_edit_dir_delete_error, 0, 0, 0, 0, name->name); - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); goto out_unmap; } @@ -530,7 +528,7 @@ void afs_edit_dir_update_dotdot(struct afs_vnode *vnode, struct afs_vnode *new_d /* Abandon the edit if we got a callback break. */ if (!test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) - goto invalidated; + goto already_invalidated; slot = afs_dir_scan_block(block, &dotdot_name, b); if (slot >= 0) @@ -564,18 +562,16 @@ void afs_edit_dir_update_dotdot(struct afs_vnode *vnode, struct afs_vnode *new_d _leave(""); return; -invalidated: +already_invalidated: kunmap_local(block); folio_unlock(folio); folio_put(folio); trace_afs_edit_dir(vnode, why, afs_edit_dir_update_inval, 0, 0, 0, 0, ".."); - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); goto out; error: trace_afs_edit_dir(vnode, why, afs_edit_dir_update_error, 0, 0, 0, 0, ".."); - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); goto out; }