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

Configure Feed

Select the types of activity you want to include in your feed.

xfs: refactor xfsaild_push loop into helper

Factor the loop body of xfsaild_push() into a separate
xfsaild_process_logitem() helper to improve readability.

This is a pure code movement with no functional change.

Signed-off-by: Yuto Ohnuki <ytohnuki@amazon.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>

authored by

Yuto Ohnuki and committed by
Carlos Maiolino
7cac6094 394d70b8

+69 -58
+69 -58
fs/xfs/xfs_trans_ail.c
··· 464 464 return target_lsn; 465 465 } 466 466 467 + static void 468 + xfsaild_process_logitem( 469 + struct xfs_ail *ailp, 470 + struct xfs_log_item *lip, 471 + int *stuck, 472 + int *flushing) 473 + { 474 + struct xfs_mount *mp = ailp->ail_log->l_mp; 475 + uint type = lip->li_type; 476 + unsigned long flags = lip->li_flags; 477 + xfs_lsn_t item_lsn = lip->li_lsn; 478 + int lock_result; 479 + 480 + /* 481 + * Note that iop_push may unlock and reacquire the AIL lock. We 482 + * rely on the AIL cursor implementation to be able to deal with 483 + * the dropped lock. 484 + * 485 + * The log item may have been freed by the push, so it must not 486 + * be accessed or dereferenced below this line. 487 + */ 488 + lock_result = xfsaild_push_item(ailp, lip); 489 + switch (lock_result) { 490 + case XFS_ITEM_SUCCESS: 491 + XFS_STATS_INC(mp, xs_push_ail_success); 492 + trace_xfs_ail_push(ailp, type, flags, item_lsn); 493 + 494 + ailp->ail_last_pushed_lsn = item_lsn; 495 + break; 496 + 497 + case XFS_ITEM_FLUSHING: 498 + /* 499 + * The item or its backing buffer is already being 500 + * flushed. The typical reason for that is that an 501 + * inode buffer is locked because we already pushed the 502 + * updates to it as part of inode clustering. 503 + * 504 + * We do not want to stop flushing just because lots 505 + * of items are already being flushed, but we need to 506 + * re-try the flushing relatively soon if most of the 507 + * AIL is being flushed. 508 + */ 509 + XFS_STATS_INC(mp, xs_push_ail_flushing); 510 + trace_xfs_ail_flushing(ailp, type, flags, item_lsn); 511 + 512 + (*flushing)++; 513 + ailp->ail_last_pushed_lsn = item_lsn; 514 + break; 515 + 516 + case XFS_ITEM_PINNED: 517 + XFS_STATS_INC(mp, xs_push_ail_pinned); 518 + trace_xfs_ail_pinned(ailp, type, flags, item_lsn); 519 + 520 + (*stuck)++; 521 + ailp->ail_log_flush++; 522 + break; 523 + case XFS_ITEM_LOCKED: 524 + XFS_STATS_INC(mp, xs_push_ail_locked); 525 + trace_xfs_ail_locked(ailp, type, flags, item_lsn); 526 + 527 + (*stuck)++; 528 + break; 529 + default: 530 + ASSERT(0); 531 + break; 532 + } 533 + } 534 + 467 535 static long 468 536 xfsaild_push( 469 537 struct xfs_ail *ailp) ··· 579 511 580 512 lsn = lip->li_lsn; 581 513 while ((XFS_LSN_CMP(lip->li_lsn, ailp->ail_target) <= 0)) { 582 - int lock_result; 583 - uint type = lip->li_type; 584 - unsigned long flags = lip->li_flags; 585 - xfs_lsn_t item_lsn = lip->li_lsn; 586 514 587 515 if (test_bit(XFS_LI_FLUSHING, &lip->li_flags)) 588 516 goto next_item; 589 517 590 - /* 591 - * Note that iop_push may unlock and reacquire the AIL lock. We 592 - * rely on the AIL cursor implementation to be able to deal with 593 - * the dropped lock. 594 - * 595 - * The log item may have been freed by the push, so it must not 596 - * be accessed or dereferenced below this line. 597 - */ 598 - lock_result = xfsaild_push_item(ailp, lip); 599 - switch (lock_result) { 600 - case XFS_ITEM_SUCCESS: 601 - XFS_STATS_INC(mp, xs_push_ail_success); 602 - trace_xfs_ail_push(ailp, type, flags, item_lsn); 603 - 604 - ailp->ail_last_pushed_lsn = item_lsn; 605 - break; 606 - 607 - case XFS_ITEM_FLUSHING: 608 - /* 609 - * The item or its backing buffer is already being 610 - * flushed. The typical reason for that is that an 611 - * inode buffer is locked because we already pushed the 612 - * updates to it as part of inode clustering. 613 - * 614 - * We do not want to stop flushing just because lots 615 - * of items are already being flushed, but we need to 616 - * re-try the flushing relatively soon if most of the 617 - * AIL is being flushed. 618 - */ 619 - XFS_STATS_INC(mp, xs_push_ail_flushing); 620 - trace_xfs_ail_flushing(ailp, type, flags, item_lsn); 621 - 622 - flushing++; 623 - ailp->ail_last_pushed_lsn = item_lsn; 624 - break; 625 - 626 - case XFS_ITEM_PINNED: 627 - XFS_STATS_INC(mp, xs_push_ail_pinned); 628 - trace_xfs_ail_pinned(ailp, type, flags, item_lsn); 629 - 630 - stuck++; 631 - ailp->ail_log_flush++; 632 - break; 633 - case XFS_ITEM_LOCKED: 634 - XFS_STATS_INC(mp, xs_push_ail_locked); 635 - trace_xfs_ail_locked(ailp, type, flags, item_lsn); 636 - 637 - stuck++; 638 - break; 639 - default: 640 - ASSERT(0); 641 - break; 642 - } 643 - 518 + xfsaild_process_logitem(ailp, lip, &stuck, &flushing); 644 519 count++; 645 520 646 521 /*