xfs: factor common AIL item deletion code
authorDave Chinner <dchinner@redhat.com>
Wed, 25 Mar 2020 03:10:29 +0000 (20:10 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Fri, 27 Mar 2020 15:32:55 +0000 (08:32 -0700)
Factor the common AIL deletion code that does all the wakeups into a
helper so we only have one copy of this somewhat tricky code to
interface with all the wakeups necessary when the LSN of the log
tail changes.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_inode_item.c
fs/xfs/xfs_trans_ail.c
fs/xfs/xfs_trans_priv.h

index 4a3d13d4a022889cbb50819c2e7d4b08ee315064..bd8c368098707edb606ebce7f9664638c363e431 100644 (file)
@@ -742,17 +742,7 @@ xfs_iflush_done(
                                xfs_clear_li_failed(blip);
                        }
                }
-
-               if (mlip_changed) {
-                       if (!XFS_FORCED_SHUTDOWN(ailp->ail_mount))
-                               xlog_assign_tail_lsn_locked(ailp->ail_mount);
-                       if (list_empty(&ailp->ail_head))
-                               wake_up_all(&ailp->ail_empty);
-               }
-               spin_unlock(&ailp->ail_lock);
-
-               if (mlip_changed)
-                       xfs_log_space_wake(ailp->ail_mount);
+               xfs_ail_update_finish(ailp, mlip_changed);
        }
 
        /*
index 2ef0dfbfb303d3103ac61569a3ad16d0d5fe83ef..26d2e7928121cde5090d7035393bb745c4054981 100644 (file)
@@ -681,6 +681,27 @@ xfs_ail_push_all_sync(
        finish_wait(&ailp->ail_empty, &wait);
 }
 
+void
+xfs_ail_update_finish(
+       struct xfs_ail          *ailp,
+       bool                    do_tail_update) __releases(ailp->ail_lock)
+{
+       struct xfs_mount        *mp = ailp->ail_mount;
+
+       if (!do_tail_update) {
+               spin_unlock(&ailp->ail_lock);
+               return;
+       }
+
+       if (!XFS_FORCED_SHUTDOWN(mp))
+               xlog_assign_tail_lsn_locked(mp);
+
+       if (list_empty(&ailp->ail_head))
+               wake_up_all(&ailp->ail_empty);
+       spin_unlock(&ailp->ail_lock);
+       xfs_log_space_wake(mp);
+}
+
 /*
  * xfs_trans_ail_update - bulk AIL insertion operation.
  *
@@ -740,15 +761,7 @@ xfs_trans_ail_update_bulk(
        if (!list_empty(&tmp))
                xfs_ail_splice(ailp, cur, &tmp, lsn);
 
-       if (mlip_changed) {
-               if (!XFS_FORCED_SHUTDOWN(ailp->ail_mount))
-                       xlog_assign_tail_lsn_locked(ailp->ail_mount);
-               spin_unlock(&ailp->ail_lock);
-
-               xfs_log_space_wake(ailp->ail_mount);
-       } else {
-               spin_unlock(&ailp->ail_lock);
-       }
+       xfs_ail_update_finish(ailp, mlip_changed);
 }
 
 bool
@@ -792,10 +805,10 @@ void
 xfs_trans_ail_delete(
        struct xfs_ail          *ailp,
        struct xfs_log_item     *lip,
-       int                     shutdown_type) __releases(ailp->ail_lock)
+       int                     shutdown_type)
 {
        struct xfs_mount        *mp = ailp->ail_mount;
-       bool                    mlip_changed;
+       bool                    need_update;
 
        if (!test_bit(XFS_LI_IN_AIL, &lip->li_flags)) {
                spin_unlock(&ailp->ail_lock);
@@ -808,17 +821,8 @@ xfs_trans_ail_delete(
                return;
        }
 
-       mlip_changed = xfs_ail_delete_one(ailp, lip);
-       if (mlip_changed) {
-               if (!XFS_FORCED_SHUTDOWN(mp))
-                       xlog_assign_tail_lsn_locked(mp);
-               if (list_empty(&ailp->ail_head))
-                       wake_up_all(&ailp->ail_empty);
-       }
-
-       spin_unlock(&ailp->ail_lock);
-       if (mlip_changed)
-               xfs_log_space_wake(ailp->ail_mount);
+       need_update = xfs_ail_delete_one(ailp, lip);
+       xfs_ail_update_finish(ailp, need_update);
 }
 
 int
index 2e073c1c4614f2a79cc9452854da1cead65fb06c..64ffa746730e4f74a9611563f9b512a897527e07 100644 (file)
@@ -92,8 +92,10 @@ xfs_trans_ail_update(
 }
 
 bool xfs_ail_delete_one(struct xfs_ail *ailp, struct xfs_log_item *lip);
+void xfs_ail_update_finish(struct xfs_ail *ailp, bool do_tail_update)
+                       __releases(ailp->ail_lock);
 void xfs_trans_ail_delete(struct xfs_ail *ailp, struct xfs_log_item *lip,
-               int shutdown_type) __releases(ailp->ail_lock);
+               int shutdown_type);
 
 static inline void
 xfs_trans_ail_remove(