From patchwork Mon Dec 16 20:41:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13910339 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 D9CE3E77180 for ; Mon, 16 Dec 2024 20:43:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67D226B00D2; Mon, 16 Dec 2024 15:43:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 62E2C6B00D4; Mon, 16 Dec 2024 15:43:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CDD86B00D5; Mon, 16 Dec 2024 15:43:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 30AFD6B00D2 for ; Mon, 16 Dec 2024 15:43:31 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DF919140F6D for ; Mon, 16 Dec 2024 20:43:30 +0000 (UTC) X-FDA: 82901995680.20.BC4EFD5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 35FC5180006 for ; Mon, 16 Dec 2024 20:43:25 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UhdvZgRw; spf=pass (imf24.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=1734381786; 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=tLItBIVTYpygJAbME/io7WA8/WpUTuOMn+nidtELVr0K0dKTBcJ1E3wB7zAfssTHuNsrvs zeWstDStm2Y60wtX7b36i0uXSTSgjQsvdfwVj8Apmzi3/MTKj3nR+5dRUXtEFEGJqBcVjJ ZUwvvaQQ9wHDEJbdKM7975QqrbAm+zo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UhdvZgRw; spf=pass (imf24.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=1734381786; a=rsa-sha256; cv=none; b=6V1+RNWxnxGNb1YyjUgulW5hCFYDlK7+NWlGWnO68Dood6t08Py3tCg3UG8Efw7dhadgRS SA9u+Jkq7RwMe/cwksEEp422relHuM70Pq0ud/JhwMSZZ6Y4HeVxDJPda/aWJaMolU/3Yu sbAxusgH/jG9161ELj1wUxkJqBpiFys= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734381808; 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=UhdvZgRwjzwahjeSl4XzGnJne45lv6Ova+KgSLgtGaOTLE5qH1RpuiRh+yU6qEh9A/ABpv 7z4xvfTlERIEOGAECE+d7gMQNGBvMVTx68+GiGMuTaqK7H8+TTsRgLKfrcDACeOTNXVYNp QKaC2Wh1cAWVtn6/uxLKHEO2LcbcOR0= Received: from mx-prod-mc-02.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-690-Be-sEHZqNiu-Vx9yVyfHTw-1; Mon, 16 Dec 2024 15:43:23 -0500 X-MC-Unique: Be-sEHZqNiu-Vx9yVyfHTw-1 X-Mimecast-MFC-AGG-ID: Be-sEHZqNiu-Vx9yVyfHTw 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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0125C1956056; Mon, 16 Dec 2024 20:43:20 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.48]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 395421955F41; Mon, 16 Dec 2024 20:43:14 +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 v5 14/32] netfs: Remove some extraneous directory invalidations Date: Mon, 16 Dec 2024 20:41:04 +0000 Message-ID: <20241216204124.3752367-15-dhowells@redhat.com> In-Reply-To: <20241216204124.3752367-1-dhowells@redhat.com> References: <20241216204124.3752367-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspamd-Queue-Id: 35FC5180006 X-Rspamd-Server: rspam12 X-Stat-Signature: im6aqzrmb9cfpfzer8ywux4xecpioi8o X-Rspam-User: X-HE-Tag: 1734381805-737398 X-HE-Meta: U2FsdGVkX1/QAqsio+C2a5L5Qx7D/wBkeB2Snrjm9TlCUZfpGyXpQPvy8YkjunayOgtHKdayjk7e2WEqbIH3s2qkOFyBxmWeVLX7RIH4c1+bNJBTFLFMrxABrko4LIb4PSymlCDqStH2lGG6JMfndKpGrOwXmWZtj+Mghy3opYUYXhm0Ttzf5uLBgN7XKVWcaa6Nmh297j9y2sj8l3CTdkm1PtNKbnCDPE6/3Jtcio/nEP8L9nAjXAGDCqjCPRpkMvax0a6UsabvVKbbQwHWMxUS7ss33Ov5kSi+ovOkpnLr9pNnGsx/+ctO0F72nTQfVSd0fR4uL+i0Jn9H8mBJIjyoEjFSzfDOcjgQtdFrYLXcOk4xmKIWMnWeni9Ywo5t/78WZVeTo3eyJNyrihKmXjURYbJEEJpXe65bN0XypXYyv14WbgPYsXydOTQsqHm0dnrGuYhiyPVfGjB7DZBTMj3XqD+jasgqEnq325hmVxtbkec8YcVrqEk8eXj3ERL687LhRN78UoyxEBPYcmNp+vWUcOnqjz5A9KG448GRXQFmEGfDdhJnjVnBmZXduSL+P2iASHCAfIsO5XEsAMb52iFHfD5LjYyuW8JAYncCKPOmTEQLBFxqF1NTMp7/Koz/8BOF/JjmCEDmIi/jknG8aq7uYXluKXn6g4ZJUWnstKmIULTyRGHsSIvBG29G8eZCkD9+iDv/MiD5hXmnsivzOAXP8eFqAMtbMp9zZw1YVW3NmHsS2JWBZ4pMJrJNpGjfKWPGTm4ikwcbVc43ktt9/fkXq28vFGlVMiuyH39OuFGsoMrapBEW6bPcgGyXF+BCC9m6A0vfRgutsmCMR580MYwe0jzANH+zny6mwI/jvp+jfbJZ7SuQSH2xSP+bfj9morFnwdjTA/KfpeusApyaVVCfMsWhDC9Qm2HpRyZfU4VAcdnHuVjbAa5rT73r4USB/qe1zzq3ig244h1Tuq3 IjhMolxq HQxTflMd8cfXi4b+5ONQl5nQmop5G5C+gCflBELiTvuZrn0X0mY9sTY1g/ftTRvJXHosuWSYSXdjGQMgsrh3vO2CKEqElD+P+CMyxa/HpYvQmXRYTUi4gMK+qfkMlnoY1G8FinEnsqnKGohP2mMJES2pDu0zoUkpl3ZkLSEhzRpQnuhBOxwWoTZcC8lXJ6h509yNqrlofFopTCkdwyqlWxNX2NDEMS5vg7oxjAxM/h8WYzn8Jn1MHjhbjAwEWksjEzxqRxBnmkP87bl6ohaEn2GUobC/9nh5RlMt4MTGsweNS0QbSbJMejCAh9VTh3KADxAk+EVItoxQhqYmgHcFg67qUhH9P/AMQ7qHz8Qmc0vq63r6DkP0eXl4x8ixEEiiC5mh8zG0zdbt4Mn0dE6LD50pz0md5WOs4JQ/7HPY7AkPMjg/PZbK8p+6T/z8d/QZjDPpr 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; }