]> git.karo-electronics.de Git - linux-beck.git/commitdiff
xfs: add helper to conditionally remove items from the AIL
authorBrian Foster <bfoster@redhat.com>
Wed, 19 Aug 2015 00:01:08 +0000 (10:01 +1000)
committerDave Chinner <david@fromorbit.com>
Wed, 19 Aug 2015 00:01:08 +0000 (10:01 +1000)
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>
fs/xfs/xfs_buf_item.c
fs/xfs/xfs_dquot.c
fs/xfs/xfs_extfree_item.c
fs/xfs/xfs_inode_item.c
fs/xfs/xfs_trans_priv.h

index 092d652bc03df3153b6bcf427ed972ffe480fd86..919057e0a45bcc0aa3b7cdbbf80f5577fd901a6b 100644 (file)
@@ -647,11 +647,7 @@ xfs_buf_item_unlock(
                        xfs_buf_item_relse(bp);
                else if (aborted) {
                        ASSERT(XFS_FORCED_SHUTDOWN(lip->li_mountp));
-                       if (lip->li_flags & XFS_LI_IN_AIL) {
-                               spin_lock(&lip->li_ailp->xa_lock);
-                               xfs_trans_ail_delete(lip->li_ailp, lip,
-                                                    SHUTDOWN_LOG_IO_ERROR);
-                       }
+                       xfs_trans_ail_remove(lip, SHUTDOWN_LOG_IO_ERROR);
                        xfs_buf_item_relse(bp);
                }
        }
index 4143dc75dca4b22b15003ebd1bce5b3561a5deb8..6964d7ceba969516d321413cc357b57caa201543 100644 (file)
@@ -954,12 +954,8 @@ xfs_qm_dqflush(
                struct xfs_log_item     *lip = &dqp->q_logitem.qli_item;
                dqp->dq_flags &= ~XFS_DQ_DIRTY;
 
-               spin_lock(&mp->m_ail->xa_lock);
-               if (lip->li_flags & XFS_LI_IN_AIL)
-                       xfs_trans_ail_delete(mp->m_ail, lip,
-                                            SHUTDOWN_CORRUPT_INCORE);
-               else
-                       spin_unlock(&mp->m_ail->xa_lock);
+               xfs_trans_ail_remove(lip, SHUTDOWN_CORRUPT_INCORE);
+
                error = -EIO;
                goto out_unlock;
        }
index ce1d4fb39c4d1e7881fe3fbf3f5eba593e8d2905..4aa0153214f91fb9ec03621c0b006317ca3d0e09 100644 (file)
@@ -286,20 +286,8 @@ void
 xfs_efi_release(
        struct xfs_efi_log_item *efip)
 {
-       struct xfs_ail          *ailp = efip->efi_item.li_ailp;
-
        if (atomic_dec_and_test(&efip->efi_refcount)) {
-               spin_lock(&ailp->xa_lock);
-               /*
-                * We don't know whether the EFI made it to the AIL. Remove it
-                * if so. Note that xfs_trans_ail_delete() drops the AIL lock.
-                */
-               if (efip->efi_item.li_flags & XFS_LI_IN_AIL)
-                       xfs_trans_ail_delete(ailp, &efip->efi_item,
-                                            SHUTDOWN_LOG_IO_ERROR);
-               else
-                       spin_unlock(&ailp->xa_lock);
-
+               xfs_trans_ail_remove(&efip->efi_item, SHUTDOWN_LOG_IO_ERROR);
                xfs_efi_item_free(efip);
        }
 }
index bf13a5a7e2f4ffd90d1ae65402a240ac81e80349..62bd80f4edd9aacb74c254c70b3e9de8618ef988 100644 (file)
@@ -703,17 +703,10 @@ xfs_iflush_abort(
        xfs_inode_log_item_t    *iip = ip->i_itemp;
 
        if (iip) {
-               struct xfs_ail  *ailp = iip->ili_item.li_ailp;
                if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
-                       spin_lock(&ailp->xa_lock);
-                       if (iip->ili_item.li_flags & XFS_LI_IN_AIL) {
-                               /* xfs_trans_ail_delete() drops the AIL lock. */
-                               xfs_trans_ail_delete(ailp, &iip->ili_item,
-                                               stale ?
-                                                    SHUTDOWN_LOG_IO_ERROR :
+                       xfs_trans_ail_remove(&iip->ili_item,
+                                            stale ? SHUTDOWN_LOG_IO_ERROR :
                                                     SHUTDOWN_CORRUPT_INCORE);
-                       } else
-                               spin_unlock(&ailp->xa_lock);
                }
                iip->ili_logged = 0;
                /*
index 1b736294558a76f0498f7e034885ddc5ce9c1497..49931b72da8a8400f767a1cb7d368b31ce62c04b 100644 (file)
@@ -119,6 +119,21 @@ xfs_trans_ail_delete(
        xfs_trans_ail_delete_bulk(ailp, &lip, 1, shutdown_type);
 }
 
+static inline void
+xfs_trans_ail_remove(
+       struct xfs_log_item     *lip,
+       int                     shutdown_type)
+{
+       struct xfs_ail          *ailp = lip->li_ailp;
+
+       spin_lock(&ailp->xa_lock);
+       /* xfs_trans_ail_delete() drops the AIL lock */
+       if (lip->li_flags & XFS_LI_IN_AIL)
+               xfs_trans_ail_delete(ailp, lip, shutdown_type);
+       else
+               spin_unlock(&ailp->xa_lock);
+}
+
 void                   xfs_ail_push(struct xfs_ail *, xfs_lsn_t);
 void                   xfs_ail_push_all(struct xfs_ail *);
 void                   xfs_ail_push_all_sync(struct xfs_ail *);