]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netfs: Remove some extraneous directory invalidations
authorDavid Howells <dhowells@redhat.com>
Mon, 16 Dec 2024 20:41:04 +0000 (20:41 +0000)
committerChristian Brauner <brauner@kernel.org>
Fri, 20 Dec 2024 21:34:05 +0000 (22:34 +0100)
In the directory editing code, we shouldn't re-invalidate the directory
if it is already invalidated.

Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20241216204124.3752367-15-dhowells@redhat.com
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/afs/dir_edit.c

index fe223fb781111a4ee5fab5c95c5d0ffc61600123..13fb236a3f50c336c26b3a81ad2001d59f22fb72 100644 (file)
@@ -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 @@ out_unmap:
        _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 @@ invalidated:
        }
        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 @@ out_unmap:
        _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 @@ invalidated:
 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 @@ out:
        _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;
 }