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

xfs: add helper to conditionally remove items from the AIL

Several areas of code duplicate a pattern where we take the AIL lock,
check whether an item is in the AIL and remove it if so. Create a new
helper for this pattern and use it where appropriate.

Signed-off-by: Brian Foster <bfoster@redhat.com>

authored by

Brian Foster and committed by
Dave Chinner
146e54b7 f307080a

+21 -33
+1 -5
fs/xfs/xfs_buf_item.c
··· 647 647 xfs_buf_item_relse(bp); 648 648 else if (aborted) { 649 649 ASSERT(XFS_FORCED_SHUTDOWN(lip->li_mountp)); 650 - if (lip->li_flags & XFS_LI_IN_AIL) { 651 - spin_lock(&lip->li_ailp->xa_lock); 652 - xfs_trans_ail_delete(lip->li_ailp, lip, 653 - SHUTDOWN_LOG_IO_ERROR); 654 - } 650 + xfs_trans_ail_remove(lip, SHUTDOWN_LOG_IO_ERROR); 655 651 xfs_buf_item_relse(bp); 656 652 } 657 653 }
+2 -6
fs/xfs/xfs_dquot.c
··· 954 954 struct xfs_log_item *lip = &dqp->q_logitem.qli_item; 955 955 dqp->dq_flags &= ~XFS_DQ_DIRTY; 956 956 957 - spin_lock(&mp->m_ail->xa_lock); 958 - if (lip->li_flags & XFS_LI_IN_AIL) 959 - xfs_trans_ail_delete(mp->m_ail, lip, 960 - SHUTDOWN_CORRUPT_INCORE); 961 - else 962 - spin_unlock(&mp->m_ail->xa_lock); 957 + xfs_trans_ail_remove(lip, SHUTDOWN_CORRUPT_INCORE); 958 + 963 959 error = -EIO; 964 960 goto out_unlock; 965 961 }
+1 -13
fs/xfs/xfs_extfree_item.c
··· 286 286 xfs_efi_release( 287 287 struct xfs_efi_log_item *efip) 288 288 { 289 - struct xfs_ail *ailp = efip->efi_item.li_ailp; 290 - 291 289 if (atomic_dec_and_test(&efip->efi_refcount)) { 292 - spin_lock(&ailp->xa_lock); 293 - /* 294 - * We don't know whether the EFI made it to the AIL. Remove it 295 - * if so. Note that xfs_trans_ail_delete() drops the AIL lock. 296 - */ 297 - if (efip->efi_item.li_flags & XFS_LI_IN_AIL) 298 - xfs_trans_ail_delete(ailp, &efip->efi_item, 299 - SHUTDOWN_LOG_IO_ERROR); 300 - else 301 - spin_unlock(&ailp->xa_lock); 302 - 290 + xfs_trans_ail_remove(&efip->efi_item, SHUTDOWN_LOG_IO_ERROR); 303 291 xfs_efi_item_free(efip); 304 292 } 305 293 }
+2 -9
fs/xfs/xfs_inode_item.c
··· 703 703 xfs_inode_log_item_t *iip = ip->i_itemp; 704 704 705 705 if (iip) { 706 - struct xfs_ail *ailp = iip->ili_item.li_ailp; 707 706 if (iip->ili_item.li_flags & XFS_LI_IN_AIL) { 708 - spin_lock(&ailp->xa_lock); 709 - if (iip->ili_item.li_flags & XFS_LI_IN_AIL) { 710 - /* xfs_trans_ail_delete() drops the AIL lock. */ 711 - xfs_trans_ail_delete(ailp, &iip->ili_item, 712 - stale ? 713 - SHUTDOWN_LOG_IO_ERROR : 707 + xfs_trans_ail_remove(&iip->ili_item, 708 + stale ? SHUTDOWN_LOG_IO_ERROR : 714 709 SHUTDOWN_CORRUPT_INCORE); 715 - } else 716 - spin_unlock(&ailp->xa_lock); 717 710 } 718 711 iip->ili_logged = 0; 719 712 /*
+15
fs/xfs/xfs_trans_priv.h
··· 119 119 xfs_trans_ail_delete_bulk(ailp, &lip, 1, shutdown_type); 120 120 } 121 121 122 + static inline void 123 + xfs_trans_ail_remove( 124 + struct xfs_log_item *lip, 125 + int shutdown_type) 126 + { 127 + struct xfs_ail *ailp = lip->li_ailp; 128 + 129 + spin_lock(&ailp->xa_lock); 130 + /* xfs_trans_ail_delete() drops the AIL lock */ 131 + if (lip->li_flags & XFS_LI_IN_AIL) 132 + xfs_trans_ail_delete(ailp, lip, shutdown_type); 133 + else 134 + spin_unlock(&ailp->xa_lock); 135 + } 136 + 122 137 void xfs_ail_push(struct xfs_ail *, xfs_lsn_t); 123 138 void xfs_ail_push_all(struct xfs_ail *); 124 139 void xfs_ail_push_all_sync(struct xfs_ail *);