@@ -444,6 +444,42 @@ xfs_buf_item_pin(
444
444
atomic_inc (& bip -> bli_buf -> b_pin_count );
445
445
}
446
446
447
+ /*
448
+ * For a stale BLI, process all the necessary completions that must be
449
+ * performed when the final BLI reference goes away. The buffer will be
450
+ * referenced and locked here - we return to the caller with the buffer still
451
+ * referenced and locked for them to finalise processing of the buffer.
452
+ */
453
+ static void
454
+ xfs_buf_item_finish_stale (
455
+ struct xfs_buf_log_item * bip )
456
+ {
457
+ struct xfs_buf * bp = bip -> bli_buf ;
458
+ struct xfs_log_item * lip = & bip -> bli_item ;
459
+
460
+ ASSERT (bip -> bli_flags & XFS_BLI_STALE );
461
+ ASSERT (xfs_buf_islocked (bp ));
462
+ ASSERT (bp -> b_flags & XBF_STALE );
463
+ ASSERT (bip -> __bli_format .blf_flags & XFS_BLF_CANCEL );
464
+ ASSERT (list_empty (& lip -> li_trans ));
465
+ ASSERT (!bp -> b_transp );
466
+
467
+ if (bip -> bli_flags & XFS_BLI_STALE_INODE ) {
468
+ xfs_buf_item_done (bp );
469
+ xfs_buf_inode_iodone (bp );
470
+ ASSERT (list_empty (& bp -> b_li_list ));
471
+ return ;
472
+ }
473
+
474
+ /*
475
+ * We may or may not be on the AIL here, xfs_trans_ail_delete() will do
476
+ * the right thing regardless of the situation in which we are called.
477
+ */
478
+ xfs_trans_ail_delete (lip , SHUTDOWN_LOG_IO_ERROR );
479
+ xfs_buf_item_relse (bip );
480
+ ASSERT (bp -> b_log_item == NULL );
481
+ }
482
+
447
483
/*
448
484
* This is called to unpin the buffer associated with the buf log item which was
449
485
* previously pinned with a call to xfs_buf_item_pin(). We enter this function
@@ -493,13 +529,6 @@ xfs_buf_item_unpin(
493
529
}
494
530
495
531
if (stale ) {
496
- ASSERT (bip -> bli_flags & XFS_BLI_STALE );
497
- ASSERT (xfs_buf_islocked (bp ));
498
- ASSERT (bp -> b_flags & XBF_STALE );
499
- ASSERT (bip -> __bli_format .blf_flags & XFS_BLF_CANCEL );
500
- ASSERT (list_empty (& lip -> li_trans ));
501
- ASSERT (!bp -> b_transp );
502
-
503
532
trace_xfs_buf_item_unpin_stale (bip );
504
533
505
534
/*
@@ -510,22 +539,7 @@ xfs_buf_item_unpin(
510
539
* processing is complete.
511
540
*/
512
541
xfs_buf_rele (bp );
513
-
514
- /*
515
- * If we get called here because of an IO error, we may or may
516
- * not have the item on the AIL. xfs_trans_ail_delete() will
517
- * take care of that situation. xfs_trans_ail_delete() drops
518
- * the AIL lock.
519
- */
520
- if (bip -> bli_flags & XFS_BLI_STALE_INODE ) {
521
- xfs_buf_item_done (bp );
522
- xfs_buf_inode_iodone (bp );
523
- ASSERT (list_empty (& bp -> b_li_list ));
524
- } else {
525
- xfs_trans_ail_delete (lip , SHUTDOWN_LOG_IO_ERROR );
526
- xfs_buf_item_relse (bip );
527
- ASSERT (bp -> b_log_item == NULL );
528
- }
542
+ xfs_buf_item_finish_stale (bip );
529
543
xfs_buf_relse (bp );
530
544
return ;
531
545
}
0 commit comments