Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfs: Remove some extraneous directory invalidations

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>

authored by

David Howells and committed by
Christian Brauner
30f878fa 07a10767

+9 -13
+9 -13
fs/afs/dir_edit.c
··· 247 247 */ 248 248 index = b / AFS_DIR_BLOCKS_PER_PAGE; 249 249 if (nr_blocks >= AFS_DIR_MAX_BLOCKS) 250 - goto error; 250 + goto error_too_many_blocks; 251 251 if (index >= folio_nr_pages(folio0)) { 252 252 folio = afs_dir_get_folio(vnode, index); 253 253 if (!folio) ··· 260 260 261 261 /* Abandon the edit if we got a callback break. */ 262 262 if (!test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) 263 - goto invalidated; 263 + goto already_invalidated; 264 264 265 265 _debug("block %u: %2u %3u %u", 266 266 b, ··· 348 348 _leave(""); 349 349 return; 350 350 351 - invalidated: 351 + already_invalidated: 352 352 trace_afs_edit_dir(vnode, why, afs_edit_dir_create_inval, 0, 0, 0, 0, name->name); 353 - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); 354 353 kunmap_local(block); 355 354 if (folio != folio0) { 356 355 folio_unlock(folio); ··· 357 358 } 358 359 goto out_unmap; 359 360 361 + error_too_many_blocks: 362 + clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); 360 363 error: 361 364 trace_afs_edit_dir(vnode, why, afs_edit_dir_create_error, 0, 0, 0, 0, name->name); 362 - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); 363 365 goto out_unmap; 364 366 } 365 367 ··· 421 421 422 422 /* Abandon the edit if we got a callback break. */ 423 423 if (!test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) 424 - goto invalidated; 424 + goto already_invalidated; 425 425 426 426 if (b > AFS_DIR_BLOCKS_WITH_CTR || 427 427 meta->meta.alloc_ctrs[b] <= AFS_DIR_SLOTS_PER_BLOCK - 1 - need_slots) { ··· 475 475 _leave(""); 476 476 return; 477 477 478 - invalidated: 478 + already_invalidated: 479 479 trace_afs_edit_dir(vnode, why, afs_edit_dir_delete_inval, 480 480 0, 0, 0, 0, name->name); 481 - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); 482 481 kunmap_local(block); 483 482 if (folio != folio0) { 484 483 folio_unlock(folio); ··· 488 489 error: 489 490 trace_afs_edit_dir(vnode, why, afs_edit_dir_delete_error, 490 491 0, 0, 0, 0, name->name); 491 - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); 492 492 goto out_unmap; 493 493 } 494 494 ··· 528 530 529 531 /* Abandon the edit if we got a callback break. */ 530 532 if (!test_bit(AFS_VNODE_DIR_VALID, &vnode->flags)) 531 - goto invalidated; 533 + goto already_invalidated; 532 534 533 535 slot = afs_dir_scan_block(block, &dotdot_name, b); 534 536 if (slot >= 0) ··· 562 564 _leave(""); 563 565 return; 564 566 565 - invalidated: 567 + already_invalidated: 566 568 kunmap_local(block); 567 569 folio_unlock(folio); 568 570 folio_put(folio); 569 571 trace_afs_edit_dir(vnode, why, afs_edit_dir_update_inval, 570 572 0, 0, 0, 0, ".."); 571 - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); 572 573 goto out; 573 574 574 575 error: 575 576 trace_afs_edit_dir(vnode, why, afs_edit_dir_update_error, 576 577 0, 0, 0, 0, ".."); 577 - clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); 578 578 goto out; 579 579 }