XFS: AIL cleanup and bug fixes
cover XFS: AIL cleanup and bug fixes
Clean up the AIL interfaces and the way it is referenced by external code by making the struct xfs_ail the primary method of accessing the AIL.
The main bug fix in this patch series is the second patch - it fixes the restart bug in traversals of the AIL. The method used is to track the next item in the list in a stack based cursor so we don't need to trust the current log item after we've dropped the AIL lock.
Because this changes the interface to the traversal code, it makes sense to clean up the entire AIL subsystem interface while I am there. The overall goal here is to make the struct xfs_ail the sole structure used to access the AIL - for inserts, deletes, traversals, locking, etc so that we don't need to reference the xfs_mount just to get to the AIL.
This also enables us to move the struct xfs_ail definition out of xfs_mount.h and reduce the visible scope of it to just the files that need to access members of the structure.
Version 2:
o cleanup based on review comments
PATCH 1/8 XFS: Allocate the struct xfs_ail
Rather than embedding the struct xfs_ail in the struct xfs_mount, allocate it during AIL initialisation. Add a back pointer to the struct xfs_ail so that we can pass around the xfs_ail and still be able to access the xfs_mount if need be. This is th first step involved in isolating the AIL implementation from the surrounding filesystem code.
--- fs/xfs/linux-2.6/xfs_super.c | 28 +++++++------- fs/xfs/xfs_mount.h | 10 +---- fs/xfs/xfs_trans_ail.c | 87 +++++++++++++++++++++++------------------ fs/xfs/xfs_trans_priv.h | 17 ++++++-- 4 files changed, 77 insertions(+), 65 deletions(-)
fs/xfs/linux-2.6/xfs_super.c +14 -14
@@ -814,18 +814,18 @@ xfs_setup_devices(*/ void xfsaild_wakeup ( -xfs_mount_t *mp, +struct xfs_ail *ailp,xfs_lsn_t threshold_lsn) { - mp->m_ail.xa_target = threshold_lsn; -wake_up_process (mp->m_ail.xa_task); + ailp->xa_target = threshold_lsn; +wake_up_process (ailp->xa_task); }int xfsaild (void *data) { -xfs_mount_t *mp = (xfs_mount_t *)data; +struct xfs_ail *ailp = data;xfs_lsn_t last_pushed_lsn =0 ;long tout =0 ;
@@ -837,11 +837,11 @@ xfsaild(/* swsusp */ try_to_freeze (); -ASSERT (mp->m_log); -if (XFS_FORCED_SHUTDOWN (mp)) +ASSERT (ailp->xa_mount->m_log); +if (XFS_FORCED_SHUTDOWN (ailp->xa_mount))continue ; - tout =xfsaild_push (mp, &last_pushed_lsn); + tout =xfsaild_push (ailp, &last_pushed_lsn); }return 0 ;
@@ -849,20 +849,20 @@ xfsaild(int xfsaild_start ( -xfs_mount_t *mp) +struct xfs_ail *ailp) { - mp->m_ail.xa_target =0 ; - mp->m_ail.xa_task =kthread_run (xfsaild, mp,"xfsaild" ); -if (IS_ERR (mp->m_ail.xa_task)) -return -PTR_ERR (mp->m_ail.xa_task); + ailp->xa_target =0 ; + ailp->xa_task =kthread_run (xfsaild, ailp,"xfsaild" ); +if (IS_ERR (ailp->xa_task)) +return -PTR_ERR (ailp->xa_task);return 0 ; }void xfsaild_stop ( -xfs_mount_t *mp) +struct xfs_ail *ailp) { -kthread_stop (mp->m_ail.xa_task); +kthread_stop (ailp->xa_task); }
fs/xfs/xfs_mount.h +2 -8
@@ -63,6 +63,7 @@ struct xfs_extdelta;struct xfs_swapext ;struct xfs_mru_cache ;struct xfs_nameops ; +struct xfs_ail ;/* * Prototypes and functions for the Data Migration subsystem.
@@ -224,18 +225,11 @@ extern void xfs_icsb_sync_counters_locked(struct xfs_mount *, int);#define xfs_icsb_sync_counters_locked (mp, flags) do { } while (0)#endif -typedef struct xfs_ail { -struct list_head xa_ail; -uint xa_gen; -struct task_struct *xa_task; -xfs_lsn_t xa_target; -}xfs_ail_t ; - typedef struct xfs_mount { struct super_block *m_super; xfs_tid_t m_tid; /* next unused tid for fs */ spinlock_t m_ail_lock; /* fs AIL mutex */ - xfs_ail_t m_ail; /* fs active log item list */ + struct xfs_ail *m_ail; /* fs active log item list */ xfs_sb_t m_sb; /* copy of fs superblock */ spinlock_t m_sb_lock; /* sb counter lock */ struct xfs_buf *m_sb_bp; /* buffer for superblock */
fs/xfs/xfs_trans_ail.c +49 -38
222 lines not on this page · raw message
fs/xfs/xfs_trans_priv.h +12 -5
@@ -56,13 +56,20 @@ struct xfs_log_item *xfs_trans_first_ail(struct xfs_mount *, int *);struct xfs_log_item *xfs_trans_next_ail (struct xfs_mount *,struct xfs_log_item *,int *,int *); -/* * AIL push thread support */ -long xfsaild_push (struct xfs_mount *,xfs_lsn_t *); -void xfsaild_wakeup (struct xfs_mount *,xfs_lsn_t ); -int xfsaild_start (struct xfs_mount *); -void xfsaild_stop (struct xfs_mount *); +struct xfs_ail { +struct xfs_mount *xa_mount; +struct list_head xa_ail; +uint xa_gen; +struct task_struct *xa_task; +xfs_lsn_t xa_target; +}; + +long xfsaild_push (struct xfs_ail *,xfs_lsn_t *); +void xfsaild_wakeup (struct xfs_ail *,xfs_lsn_t ); +int xfsaild_start (struct xfs_ail *); +void xfsaild_stop (struct xfs_ail *);#endif /* __XFS_TRANS_PRIV_H__ */
Signature · 1 line
1.5.6.5
PATCH 2/8 XFS: Use a cursor for AIL traversal.
In reply to Dave ChinnerTo replace the current generation number ensuring sanity of the AIL traversal, replace it with an external cursor that is linked to the AIL.
Basically, we store the next item in the cursor whenever we want to drop the AIL lock to do something to the current item. When we regain the lock. the current item may already be free, so we can't reference it, but the next item in the traversal is already held in the cursor.
When we move or delete an object, we search all the active cursors and if there is an item match we clear the cursor(s) that point to the object. This forces the traversal to restart transparently.
We don't invalidate the cursor on insert because the cursor still points to a valid item. If the intem is inserted between the current item and the cursor it does not matter; the traversal is considered to be past the insertion point so it will be picked up in the next traversal.
Hence traversal restarts pretty much disappear altogether with this method of traversal, which should substantially reduce the overhead of pushing on a busy AIL.
Version 2
o add restart logic
o comment cursor interface
o minor cleanups
--- fs/xfs/xfs_log.c | 4 +- fs/xfs/xfs_log_recover.c | 61 +++++--------- fs/xfs/xfs_trans_ail.c | 207 +++++++++++++++++++++++++++++++++------------- fs/xfs/xfs_trans_priv.h | 55 ++++++++++--- 4 files changed, 218 insertions(+), 109 deletions(-)
fs/xfs/xfs_log.c +2 -2
@@ -900,7 +900,7 @@ xfs_log_move_tail(xfs_mount_t *mp,int xfs_log_need_covered (xfs_mount_t *mp) { -int needed =0 , gen; +int needed =0 ;xlog_t *log = mp->m_log;if (!xfs_fs_writable (mp))
@@ -909,7 +909,7 @@ xfs_log_need_covered(xfs_mount_t *mp)spin_lock (&log->l_icloglock);if (((log->l_covered_state ==XLOG_STATE_COVER_NEED ) || (log->l_covered_state ==XLOG_STATE_COVER_NEED2 )) - && !xfs_trans_first_ail (mp, &gen) + && !xfs_trans_first_ail (mp,NULL ) &&xlog_iclogs_empty (log)) {if (log->l_covered_state ==XLOG_STATE_COVER_NEED ) log->l_covered_state =XLOG_STATE_COVER_DONE ;
fs/xfs/xfs_log_recover.c +21 -40
127 lines not on this page · raw message
fs/xfs/xfs_trans_ail.c +151 -56
327 lines not on this page · raw message
fs/xfs/xfs_trans_priv.h +44 -11
72 lines not on this page · raw message
Signature · 1 line
1.5.6.5
PATCH 3/8 XFS: move the AIl traversal over to a consistent interface
In reply to Dave ChinnerWith the new cursor interface, it makes sense to make all the traversing code use the cursor interface and make the old one go away. This means more of the AIL interfacing is done by passing struct xfs_ail pointers around the place instead of struct xfs_mount pointers.
We can replace the use of xfs_trans_first_ail() in xfs_log_need_covered() as it is only checking if the AIL is empty. We can do that with a call to xfs_trans_ail_tail() instead, where a zero LSN returned indicates and empty AIL...
--- fs/xfs/xfs_log.c | 4 +- fs/xfs/xfs_log_recover.c | 15 +++--- fs/xfs/xfs_trans.h | 1 - fs/xfs/xfs_trans_ail.c | 117 ++++++++++++++++----------------------------- fs/xfs/xfs_trans_priv.h | 13 +++-- 5 files changed, 58 insertions(+), 92 deletions(-)
fs/xfs/xfs_log.c +2 -2
@@ -909,7 +909,7 @@ xfs_log_need_covered(xfs_mount_t *mp)spin_lock (&log->l_icloglock);if (((log->l_covered_state ==XLOG_STATE_COVER_NEED ) || (log->l_covered_state ==XLOG_STATE_COVER_NEED2 )) - && !xfs_trans_first_ail (mp,NULL ) + && !xfs_trans_ail_tail (mp->m_ail) &&xlog_iclogs_empty (log)) {if (log->l_covered_state ==XLOG_STATE_COVER_NEED ) log->l_covered_state =XLOG_STATE_COVER_DONE ;
@@ -946,7 +946,7 @@ xlog_assign_tail_lsn(xfs_mount_t *mp)xfs_lsn_t tail_lsn;xlog_t *log = mp->m_log; - tail_lsn =xfs_trans_tail_ail (mp); + tail_lsn =xfs_trans_ail_tail (mp->m_ail);spin_lock (&log->l_grant_lock);if (tail_lsn !=0 ) { log->l_tail_lsn = tail_lsn;
fs/xfs/xfs_log_recover.c +7 -8
@@ -2728,8 +2728,7 @@ xlog_recover_do_efd_trans(*/ mp = log->l_mp;spin_lock (&mp->m_ail_lock); -xfs_trans_ail_cursor_init (mp->m_ail, &cur); - lip =xfs_trans_first_ail (mp, &cur); + lip =xfs_trans_ail_cursor_first (mp->m_ail, &cur,0 );while (lip !=NULL ) {if (lip->li_type ==XFS_LI_EFI ) { efip = (xfs_efi_log_item_t *)lip;
@@ -2744,7 +2743,7 @@ xlog_recover_do_efd_trans(break ; } } - lip =xfs_trans_next_ail (mp, &cur); + lip =xfs_trans_ail_cursor_next (mp->m_ail, &cur); }xfs_trans_ail_cursor_done (mp->m_ail, &cur);spin_unlock (&mp->m_ail_lock);
@@ -3061,8 +3060,7 @@ xlog_recover_process_efis( mp = log->l_mp;spin_lock (&mp->m_ail_lock); -xfs_trans_ail_cursor_init (mp->m_ail, &cur); - lip =xfs_trans_first_ail (mp, &cur); + lip =xfs_trans_ail_cursor_first (mp->m_ail, &cur,0 );while (lip !=NULL ) {/* * We're done when we see something other than an EFI.
@@ -3070,7 +3068,8 @@ xlog_recover_process_efis(*/ if (lip->li_type !=XFS_LI_EFI ) {#ifdef DEBUG -for (; lip; lip =xfs_trans_next_ail (mp, &cur)) +for (; lip; + lip =xfs_trans_ail_cursor_next (mp->m_ail, &cur))ASSERT (lip->li_type !=XFS_LI_EFI );#endif break ;
@@ -3081,7 +3080,7 @@ xlog_recover_process_efis(*/ efip = (xfs_efi_log_item_t *)lip;if (efip->efi_flags &XFS_EFI_RECOVERED ) { - lip =xfs_trans_next_ail (mp, &cur); + lip =xfs_trans_ail_cursor_next (mp->m_ail, &cur);continue ; }
@@ -3090,7 +3089,7 @@ xlog_recover_process_efis(spin_lock (&mp->m_ail_lock);if (error) goto out; - lip =xfs_trans_next_ail (mp, &cur); + lip =xfs_trans_ail_cursor_next (mp->m_ail, &cur); } out:xfs_trans_ail_cursor_done (mp->m_ail, &cur);
fs/xfs/xfs_trans.h +0 -1
@@ -971,7 +971,6 @@ void xfs_trans_cancel(xfs_trans_t *, int);int xfs_trans_ail_init (struct xfs_mount *);void xfs_trans_ail_destroy (struct xfs_mount *);void xfs_trans_push_ail (struct xfs_mount *,xfs_lsn_t ); -xfs_lsn_t xfs_trans_tail_ail (struct xfs_mount *);void xfs_trans_unlocked_item (struct xfs_mount *,xfs_log_item_t *); xfs_log_busy_slot_t *xfs_trans_add_busy(xfs_trans_t *tp,
fs/xfs/xfs_trans_ail.c +42 -75
183 lines not on this page · raw message
fs/xfs/xfs_trans_priv.h +7 -6
@@ -90,14 +90,15 @@ void xfs_trans_update_ail(struct xfs_mount *mp, void xfs_trans_delete_ail(struct xfs_mount *mp, struct xfs_log_item *lip) __releases(mp->m_ail_lock); -struct xfs_log_item *xfs_trans_first_ail (struct xfs_mount *mp, -struct xfs_ail_cursor *cur); -struct xfs_log_item *xfs_trans_next_ail (struct xfs_mount *mp, -struct xfs_ail_cursor *cur); -void xfs_trans_ail_cursor_init (struct xfs_ail *ailp, +xfs_lsn_t xfs_trans_ail_tail (struct xfs_ail *ailp); + +struct xfs_log_item *xfs_trans_ail_cursor_first (struct xfs_ail *ailp, +struct xfs_ail_cursor *cur, +xfs_lsn_t lsn); +struct xfs_log_item *xfs_trans_ail_cursor_next (struct xfs_ail *ailp,struct xfs_ail_cursor *cur); -void xfs_trans_ail_cursor_done (struct xfs_ail *ailp, +void xfs_trans_ail_cursor_done (struct xfs_ail *ailp,struct xfs_ail_cursor *cur);long xfsaild_push (struct xfs_ail *,xfs_lsn_t *);
Signature · 1 line
1.5.6.5
PATCH 4/8 XFS: Allow 64 bit machines to avoid the AIL lock during flushes
In reply to Dave ChinnerWhen copying lsn's from the log item to the inode or dquot flush lsn, we currently grab the AIL lock. We do this because the LSN is a 64 bit quantity and it needs to be read atomically. The lock is used to guarantee atomicity for 32 bit platforms.
Make the LSN copying a small function, and make the function used conditional on BITS_PER_LONG so that 64 bit machines don't need to take the AIL lock in these places.
--- fs/xfs/quota/xfs_dquot.c | 6 ++---- fs/xfs/xfs_inode.c | 17 +++++++---------- fs/xfs/xfs_trans_priv.h | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 14 deletions(-)
fs/xfs/quota/xfs_dquot.c +2 -4
@@ -1274,10 +1274,8 @@ xfs_qm_dqflush( dqp->dq_flags &= ~(XFS_DQ_DIRTY ); mp = dqp->q_mount; -/* lsn is 64 bits */ -spin_lock (&mp->m_ail_lock); - dqp->q_logitem.qli_flush_lsn = dqp->q_logitem.qli_item.li_lsn; -spin_unlock (&mp->m_ail_lock); +xfs_trans_ail_copy_lsn (mp->m_ail, &dqp->q_logitem.qli_flush_lsn, + &dqp->q_logitem.qli_item.li_lsn);/* * Attach an iodone routine so that we can remove this dquot from the
fs/xfs/xfs_inode.c +7 -10
@@ -2213,9 +2213,9 @@ xfs_ifree_cluster( iip = (xfs_inode_log_item_t *)lip;ASSERT (iip->ili_logged ==1 ); lip->li_cb = (void (*)(xfs_buf_t *,xfs_log_item_t *)) xfs_istale_done; -spin_lock (&mp->m_ail_lock); - iip->ili_flush_lsn = iip->ili_item.li_lsn; -spin_unlock (&mp->m_ail_lock); +xfs_trans_ail_copy_lsn (mp->m_ail, + &iip->ili_flush_lsn, + &iip->ili_item.li_lsn);xfs_iflags_set (iip->ili_inode,XFS_ISTALE ); pre_flushed++; }
@@ -2236,9 +2236,8 @@ xfs_ifree_cluster( iip->ili_last_fields = iip->ili_format.ilf_fields; iip->ili_format.ilf_fields =0 ; iip->ili_logged =1 ; -spin_lock (&mp->m_ail_lock); - iip->ili_flush_lsn = iip->ili_item.li_lsn; -spin_unlock (&mp->m_ail_lock); +xfs_trans_ail_copy_lsn (mp->m_ail, &iip->ili_flush_lsn, + &iip->ili_item.li_lsn); xfs_buf_attach_iodone(bp, (void(*)(xfs_buf_t*,xfs_log_item_t*))
@@ -3479,10 +3478,8 @@ xfs_iflush_int( iip->ili_format.ilf_fields =0 ; iip->ili_logged =1 ; -ASSERT (sizeof (xfs_lsn_t) ==8 );/* don't lock if it shrinks */ -spin_lock (&mp->m_ail_lock); - iip->ili_flush_lsn = iip->ili_item.li_lsn; -spin_unlock (&mp->m_ail_lock); +xfs_trans_ail_copy_lsn (mp->m_ail, &iip->ili_flush_lsn, + &iip->ili_item.li_lsn);/* * Attach the function xfs_iflush_done to the inode's
fs/xfs/xfs_trans_priv.h +23 -0
@@ -106,4 +106,27 @@ void xfsaild_wakeup(struct xfs_ail *, xfs_lsn_t);int xfsaild_start (struct xfs_ail *);void xfsaild_stop (struct xfs_ail *); +#if BITS_PER_LONG !=64 +static inline void +xfs_trans_ail_copy_lsn ( +struct xfs_ail *ailp, +xfs_lsn_t *dst, +xfs_lsn_t *src) +{ +ASSERT (sizeof (xfs_lsn_t) ==8 );/* don't lock if it shrinks */ +spin_lock (&ailp->xa_mount->m_ail_lock); + *dst = *src; +spin_unlock (&ailp->xa_mount->m_ail_lock); +} +#else +static inline void +xfs_trans_ail_copy_lsn ( +struct xfs_ail *ailp, +xfs_lsn_t *dst, +xfs_lsn_t *src) +{ +ASSERT (sizeof (xfs_lsn_t) ==8 ); + *dst = *src; +} +#endif #endif /* __XFS_TRANS_PRIV_H__ */
Signature · 1 line
1.5.6.5
PATCH 5/8 XFS: Move the AIL lock into the struct xfs_ail
In reply to Dave ChinnerBring the ail lock inside the struct xfs_ail. This means the AIL can be entirely manipulated via the struct xfs_ail rather than needing both the struct xfs_mount and the struct xfs_ail.
--- fs/xfs/quota/xfs_dquot.c | 4 +- fs/xfs/quota/xfs_dquot_item.c | 2 +- fs/xfs/xfs_buf_item.c | 4 +- fs/xfs/xfs_extfree_item.c | 12 ++++---- fs/xfs/xfs_inode.c | 4 +- fs/xfs/xfs_inode_item.c | 8 +++--- fs/xfs/xfs_log.c | 1 - fs/xfs/xfs_log_recover.c | 16 ++++++------ fs/xfs/xfs_mount.h | 1 - fs/xfs/xfs_trans.c | 4 +- fs/xfs/xfs_trans_ail.c | 56 +++++++++++++++++++++------------------- fs/xfs/xfs_trans_priv.h | 5 ++- 12 files changed, 59 insertions(+), 58 deletions(-)
fs/xfs/quota/xfs_dquot.c +2 -2
@@ -1335,7 +1335,7 @@ xfs_qm_dqflush_done(if ((qip->qli_item.li_flags &XFS_LI_IN_AIL ) && qip->qli_item.li_lsn == qip->qli_flush_lsn) { -spin_lock (&dqp->q_mount->m_ail_lock); +spin_lock (&dqp->q_mount->m_ail->xa_lock);/* * xfs_trans_delete_ail() drops the AIL lock. */
@@ -1343,7 +1343,7 @@ xfs_qm_dqflush_done(xfs_trans_delete_ail (dqp->q_mount, (xfs_log_item_t *)qip); else - spin_unlock(&dqp->q_mount->m_ail_lock); + spin_unlock(&dqp->q_mount->m_ail->xa_lock); }/*
fs/xfs/quota/xfs_dquot_item.c +1 -1
@@ -555,7 +555,7 @@ xfs_qm_qoffend_logitem_committed(xfs_qoff_logitem_t *qfs; qfs = qfe->qql_start_lip; -spin_lock (&qfs->qql_item.li_mountp->m_ail_lock); +spin_lock (&qfs->qql_item.li_mountp->m_ail->xa_lock);/* * Delete the qoff-start logitem from the AIL. * xfs_trans_delete_ail() drops the AIL lock.
fs/xfs/xfs_buf_item.c +2 -2
@@ -408,7 +408,7 @@ xfs_buf_item_unpin(XFS_BUF_SET_FSPRIVATE (bp,NULL );XFS_BUF_CLR_IODONE_FUNC (bp); }else { -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);xfs_trans_delete_ail (mp, (xfs_log_item_t *)bip);xfs_buf_item_relse (bp); ASSERT(XFS_BUF_FSPRIVATE(bp, void *) == NULL);
@@ -1138,7 +1138,7 @@ xfs_buf_iodone(* * Either way, AIL is useless if we're forcing a shutdown. */ -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);/* * xfs_trans_delete_ail() drops the AIL lock. */
fs/xfs/xfs_extfree_item.c +6 -6
@@ -111,7 +111,7 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)xfs_mount_t *mp; mp = efip->efi_item.li_mountp; -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);if (efip->efi_flags &XFS_EFI_CANCELED ) {/* * xfs_trans_delete_ail() drops the AIL lock.
@@ -120,7 +120,7 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)xfs_efi_item_free (efip); }else { efip->efi_flags |=XFS_EFI_COMMITTED ; -spin_unlock (&mp->m_ail_lock); +spin_unlock (&mp->m_ail->xa_lock); } }
@@ -138,7 +138,7 @@ xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)xfs_log_item_desc_t *lidp; mp = efip->efi_item.li_mountp; -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);if (efip->efi_flags &XFS_EFI_CANCELED ) {/* * free the xaction descriptor pointing to this item
@@ -153,7 +153,7 @@ xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)xfs_efi_item_free (efip); }else { efip->efi_flags |=XFS_EFI_COMMITTED ; -spin_unlock (&mp->m_ail_lock); +spin_unlock (&mp->m_ail->xa_lock); } }
@@ -352,7 +352,7 @@ xfs_efi_release(xfs_efi_log_item_t *efip,ASSERT (efip->efi_next_extent >0 );ASSERT (efip->efi_flags &XFS_EFI_COMMITTED ); -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);ASSERT (efip->efi_next_extent >= nextents); efip->efi_next_extent -= nextents; extents_left = efip->efi_next_extent;
@@ -363,7 +363,7 @@ xfs_efi_release(xfs_efi_log_item_t *efip,xfs_trans_delete_ail (mp, (xfs_log_item_t *)efip);xfs_efi_item_free (efip); }else { -spin_unlock (&mp->m_ail_lock); +spin_unlock (&mp->m_ail->xa_lock); } }
fs/xfs/xfs_inode.c +2 -2
@@ -2718,11 +2718,11 @@ xfs_idestroy(ASSERT (((lip->li_flags &XFS_LI_IN_AIL ) ==0 ) ||XFS_FORCED_SHUTDOWN (ip->i_mount));if (lip->li_flags &XFS_LI_IN_AIL ) { -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);if (lip->li_flags &XFS_LI_IN_AIL )xfs_trans_delete_ail (mp, lip);else -spin_unlock (&mp->m_ail_lock); +spin_unlock (&mp->m_ail->xa_lock); }xfs_inode_item_destroy (ip); ip->i_itemp =NULL ;
fs/xfs/xfs_inode_item.c +4 -4
@@ -991,7 +991,7 @@ xfs_iflush_done(*/ if (iip->ili_logged && (iip->ili_item.li_lsn == iip->ili_flush_lsn)) { -spin_lock (&ip->i_mount->m_ail_lock); +spin_lock (&ip->i_mount->m_ail->xa_lock);if (iip->ili_item.li_lsn == iip->ili_flush_lsn) {/* * xfs_trans_delete_ail() drops the AIL lock.
@@ -999,7 +999,7 @@ xfs_iflush_done(xfs_trans_delete_ail (ip->i_mount, (xfs_log_item_t *)iip); }else { -spin_unlock (&ip->i_mount->m_ail_lock); +spin_unlock (&ip->i_mount->m_ail->xa_lock); } }
@@ -1038,14 +1038,14 @@ xfs_iflush_abort( mp = ip->i_mount;if (iip) {if (iip->ili_item.li_flags &XFS_LI_IN_AIL ) { -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);if (iip->ili_item.li_flags &XFS_LI_IN_AIL ) {/* * xfs_trans_delete_ail() drops the AIL lock. */ xfs_trans_delete_ail (mp, (xfs_log_item_t *)iip); }else -spin_unlock (&mp->m_ail_lock); +spin_unlock (&mp->m_ail->xa_lock); } iip->ili_logged =0 ;/*
fs/xfs/xfs_log.c +0 -1
@@ -567,7 +567,6 @@ xfs_log_mount(/* * Initialize the AIL now we have a log. */ -spin_lock_init (&mp->m_ail_lock); error =xfs_trans_ail_init (mp);if (error) {cmn_err (CE_WARN ,"XFS: AIL initialisation failed: error %d" , error);
fs/xfs/xfs_log_recover.c +8 -8
@@ -2681,7 +2681,7 @@ xlog_recover_do_efi_trans( efip->efi_next_extent = efi_formatp->efi_nextents; efip->efi_flags |=XFS_EFI_COMMITTED ; -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);/* * xfs_trans_update_ail() drops the AIL lock. */
@@ -2727,7 +2727,7 @@ xlog_recover_do_efd_trans(* in the AIL. */ mp = log->l_mp; -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock); lip =xfs_trans_ail_cursor_first (mp->m_ail, &cur,0 );while (lip !=NULL ) {if (lip->li_type ==XFS_LI_EFI ) {
@@ -2739,14 +2739,14 @@ xlog_recover_do_efd_trans(*/ xfs_trans_delete_ail (mp, lip);xfs_efi_item_free (efip); -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);break ; } } lip =xfs_trans_ail_cursor_next (mp->m_ail, &cur); }xfs_trans_ail_cursor_done (mp->m_ail, &cur); -spin_unlock (&mp->m_ail_lock); +spin_unlock (&mp->m_ail->xa_lock); }/*
@@ -3058,7 +3058,7 @@ xlog_recover_process_efis(struct xfs_ail_cursor cur; mp = log->l_mp; -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock); lip =xfs_trans_ail_cursor_first (mp->m_ail, &cur,0 );while (lip !=NULL ) {
@@ -3084,16 +3084,16 @@ xlog_recover_process_efis(continue ; } -spin_unlock (&mp->m_ail_lock); +spin_unlock (&mp->m_ail->xa_lock); error =xlog_recover_process_efi (mp, efip); -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);if (error) goto out; lip =xfs_trans_ail_cursor_next (mp->m_ail, &cur); } out:xfs_trans_ail_cursor_done (mp->m_ail, &cur); -spin_unlock (&mp->m_ail_lock); +spin_unlock (&mp->m_ail->xa_lock);return error; }
fs/xfs/xfs_mount.h +0 -1
@@ -228,7 +228,6 @@ extern void xfs_icsb_sync_counters_locked(struct xfs_mount *, int); typedef struct xfs_mount { struct super_block *m_super; xfs_tid_t m_tid; /* next unused tid for fs */ - spinlock_t m_ail_lock; /* fs AIL mutex */ struct xfs_ail *m_ail; /* fs active log item list */ xfs_sb_t m_sb; /* copy of fs superblock */ spinlock_t m_sb_lock; /* sb counter lock */
fs/xfs/xfs_trans.c +2 -2
@@ -1425,7 +1425,7 @@ xfs_trans_chunk_committed(* the test below. */ mp = lip->li_mountp; -spin_lock (&mp->m_ail_lock); +spin_lock (&mp->m_ail->xa_lock);if (XFS_LSN_CMP (item_lsn, lip->li_lsn) >0 ) {/* * This will set the item's lsn to item_lsn
@@ -1436,7 +1436,7 @@ xfs_trans_chunk_committed(*/ xfs_trans_update_ail (mp, lip, item_lsn); }else { -spin_unlock (&mp->m_ail_lock); +spin_unlock (&mp->m_ail->xa_lock); }/*
fs/xfs/xfs_trans_ail.c +29 -27
159 lines not on this page · raw message
fs/xfs/xfs_trans_priv.h +3 -2
@@ -79,6 +79,7 @@ struct xfs_ail {struct task_struct *xa_task;xfs_lsn_t xa_target;struct xfs_ail_cursor xa_cursors; +spinlock_t xa_lock; };/*
@@ -114,9 +115,9 @@ xfs_trans_ail_copy_lsn( xfs_lsn_t *src) {ASSERT (sizeof (xfs_lsn_t) ==8 );/* don't lock if it shrinks */ -spin_lock (&ailp->xa_mount->m_ail_lock); +spin_lock (&ailp->xa_lock); *dst = *src; -spin_unlock (&ailp->xa_mount->m_ail_lock); +spin_unlock (&ailp->xa_lock); }#else static inline void
Signature · 1 line
1.5.6.5
PATCH 6/8 XFS: Given the log a pointer to the AIL
In reply to Dave ChinnerWhen we need to go from the log to the AIL, we have to go via the xfs_mount. Add a xfs_ail pointer to the log so we can go directly to the AIL associated with the log.
--- fs/xfs/xfs_log.c | 3 ++- fs/xfs/xfs_log_priv.h | 1 + fs/xfs/xfs_log_recover.c | 42 +++++++++++++++++++++--------------------- 3 files changed, 24 insertions(+), 22 deletions(-)
fs/xfs/xfs_log.c +2 -1
@@ -572,6 +572,7 @@ xfs_log_mount(cmn_err (CE_WARN ,"XFS: AIL initialisation failed: error %d" , error); goto error; } + mp->m_log->l_ailp = mp->m_ail;/* * skip log recovery on a norecovery mount. pretend it all
@@ -908,7 +909,7 @@ xfs_log_need_covered(xfs_mount_t *mp)spin_lock (&log->l_icloglock);if (((log->l_covered_state ==XLOG_STATE_COVER_NEED ) || (log->l_covered_state ==XLOG_STATE_COVER_NEED2 )) - && !xfs_trans_ail_tail (mp->m_ail) + && !xfs_trans_ail_tail (log->l_ailp) &&xlog_iclogs_empty (log)) {if (log->l_covered_state ==XLOG_STATE_COVER_NEED ) log->l_covered_state =XLOG_STATE_COVER_DONE ;
fs/xfs/xfs_log_priv.h +1 -0
@@ -404,6 +404,7 @@ typedef struct xlog_in_core { typedef struct log { /* The following fields don't need locking */ struct xfs_mount *l_mp; /* mount point */ + struct xfs_ail *l_ailp; /* AIL log is working with */ struct xfs_buf *l_xbuf; /* extra buffer for log * wrapping */ struct xfs_buftarg *l_targ; /* buftarg of log */
fs/xfs/xfs_log_recover.c +21 -21
98 lines not on this page · raw message
Signature · 1 line
1.5.6.5
PATCH 7/8 XFS: Add ail pointer into log items
In reply to Dave ChinnerAdd an xfs_ail pointer to log items so that the log items can reference the AIL directly during callbacks without needed a struct xfs_mount.
--- fs/xfs/xfs_buf_item.c | 5 ++++- fs/xfs/xfs_extfree_item.c | 28 ++++++++++++++++++---------- fs/xfs/xfs_inode_item.c | 1 + fs/xfs/xfs_trans.c | 9 ++++++--- fs/xfs/xfs_trans.h | 1 + fs/xfs/xfs_trans_item.c | 10 ++++++++++ 6 files changed, 40 insertions(+), 14 deletions(-)
fs/xfs/xfs_buf_item.c +4 -1
@@ -731,6 +731,7 @@ xfs_buf_item_init( bip->bli_item.li_type =XFS_LI_BUF ; bip->bli_item.li_ops = &xfs_buf_item_ops; bip->bli_item.li_mountp = mp; + bip->bli_item.li_ailp = mp->m_ail; bip->bli_buf = bp;xfs_buf_hold (bp); bip->bli_format.blf_type =XFS_LI_BUF ;
@@ -1123,11 +1124,13 @@ xfs_buf_iodone( xfs_buf_log_item_t *bip) {struct xfs_mount *mp; +struct xfs_ail *ailp;ASSERT (bip->bli_buf == bp);xfs_buf_rele (bp); mp = bip->bli_item.li_mountp; + ailp = bip->bli_item.li_ailp;/* * If we are forcibly shutting down, this may well be
@@ -1138,7 +1141,7 @@ xfs_buf_iodone(* * Either way, AIL is useless if we're forcing a shutdown. */ -spin_lock (&mp->m_ail->xa_lock); +spin_lock (&ailp->xa_lock);/* * xfs_trans_delete_ail() drops the AIL lock. */
fs/xfs/xfs_extfree_item.c +18 -10
@@ -108,10 +108,12 @@ xfs_efi_item_pin(xfs_efi_log_item_t *efip) STATIC voidxfs_efi_item_unpin (xfs_efi_log_item_t *efip,int stale) { -xfs_mount_t *mp; +xfs_mount_t *mp; +struct xfs_ail *ailp; mp = efip->efi_item.li_mountp; -spin_lock (&mp->m_ail->xa_lock); + ailp = efip->efi_item.li_ailp; +spin_lock (&ailp->xa_lock);if (efip->efi_flags &XFS_EFI_CANCELED ) {/* * xfs_trans_delete_ail() drops the AIL lock.
@@ -120,7 +122,7 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)xfs_efi_item_free (efip); }else { efip->efi_flags |=XFS_EFI_COMMITTED ; -spin_unlock (&mp->m_ail->xa_lock); +spin_unlock (&ailp->xa_lock); } }
@@ -134,11 +136,13 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale) STATIC voidxfs_efi_item_unpin_remove (xfs_efi_log_item_t *efip,xfs_trans_t *tp) { -xfs_mount_t *mp; +xfs_mount_t *mp; +struct xfs_ail *ailp;xfs_log_item_desc_t *lidp; mp = efip->efi_item.li_mountp; -spin_lock (&mp->m_ail->xa_lock); + ailp = efip->efi_item.li_ailp; +spin_lock (&ailp->xa_lock);if (efip->efi_flags &XFS_EFI_CANCELED ) {/* * free the xaction descriptor pointing to this item
@@ -153,7 +157,7 @@ xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)xfs_efi_item_free (efip); }else { efip->efi_flags |=XFS_EFI_COMMITTED ; -spin_unlock (&mp->m_ail->xa_lock); +spin_unlock (&ailp->xa_lock); } }
@@ -268,6 +272,7 @@ xfs_efi_init(xfs_mount_t *mp, efip->efi_item.li_type =XFS_LI_EFI ; efip->efi_item.li_ops = &xfs_efi_item_ops; efip->efi_item.li_mountp = mp; + efip->efi_item.li_ailp = mp->m_ail; efip->efi_format.efi_nextents = nextents; efip->efi_format.efi_id = (__psint_t )(void *)efip;
@@ -345,14 +350,16 @@ voidxfs_efi_release (xfs_efi_log_item_t *efip, uint nextents) { -xfs_mount_t *mp; -int extents_left; +xfs_mount_t *mp; +struct xfs_ail *ailp; +int extents_left; mp = efip->efi_item.li_mountp; + ailp = efip->efi_item.li_ailp;ASSERT (efip->efi_next_extent >0 );ASSERT (efip->efi_flags &XFS_EFI_COMMITTED ); -spin_lock (&mp->m_ail->xa_lock); +spin_lock (&ailp->xa_lock);ASSERT (efip->efi_next_extent >= nextents); efip->efi_next_extent -= nextents; extents_left = efip->efi_next_extent;
@@ -363,7 +370,7 @@ xfs_efi_release(xfs_efi_log_item_t *efip,xfs_trans_delete_ail (mp, (xfs_log_item_t *)efip);xfs_efi_item_free (efip); }else { -spin_unlock (&mp->m_ail->xa_lock); +spin_unlock (&ailp->xa_lock); } }
@@ -565,6 +572,7 @@ xfs_efd_init(xfs_mount_t *mp, efdp->efd_item.li_type =XFS_LI_EFD ; efdp->efd_item.li_ops = &xfs_efd_item_ops; efdp->efd_item.li_mountp = mp; + efdp->efd_item.li_ailp = mp->m_ail; efdp->efd_efip = efip; efdp->efd_format.efd_nextents = nextents; efdp->efd_format.efd_efi_id = efip->efi_format.efi_id;
fs/xfs/xfs_inode_item.c +1 -0
@@ -932,6 +932,7 @@ xfs_inode_item_init( iip->ili_item.li_type =XFS_LI_INODE ; iip->ili_item.li_ops = &xfs_inode_item_ops; iip->ili_item.li_mountp = mp; + iip->ili_item.li_ailp = mp->m_ail; iip->ili_inode = ip;/*
fs/xfs/xfs_trans.c +6 -3
@@ -1383,11 +1383,13 @@ xfs_trans_chunk_committed(xfs_log_item_desc_t *lidp;xfs_log_item_t *lip;xfs_lsn_t item_lsn; -struct xfs_mount *mp;int i; lidp = licp->lic_descs;for (i =0 ; i < licp->lic_unused; i++, lidp++) { +struct xfs_mount *mp; +struct xfs_ail *ailp; +if (xfs_lic_isfree (licp, i)) {continue ; }
@@ -1425,7 +1427,8 @@ xfs_trans_chunk_committed(* the test below. */ mp = lip->li_mountp; -spin_lock (&mp->m_ail->xa_lock); + ailp = lip->li_ailp; +spin_lock (&ailp->xa_lock);if (XFS_LSN_CMP (item_lsn, lip->li_lsn) >0 ) {/* * This will set the item's lsn to item_lsn
@@ -1436,7 +1439,7 @@ xfs_trans_chunk_committed(*/ xfs_trans_update_ail (mp, lip, item_lsn); }else { -spin_unlock (&mp->m_ail->xa_lock); +spin_unlock (&ailp->xa_lock); }/*
fs/xfs/xfs_trans.h +1 -0
@@ -768,6 +768,7 @@ typedef struct xfs_log_item {xfs_lsn_t li_lsn;/* last on-disk lsn */ struct xfs_log_item_desc *li_desc;/* ptr to current desc*/ struct xfs_mount *li_mountp;/* ptr to fs mount */ +struct xfs_ail *li_ailp;/* ptr to AIL */ uint li_type;/* item type */ uint li_flags;/* misc flags */ struct xfs_log_item *li_bio_list;/* buffer item list */
fs/xfs/xfs_trans_item.c +10 -0
@@ -22,6 +22,14 @@#include "xfs_inum.h" #include "xfs_trans.h" #include "xfs_trans_priv.h" +/* XXX: from here down needed until struct xfs_trans has it's own ailp */ +#include "xfs_bit.h" +#include "xfs_buf_item.h" +#include "xfs_sb.h" +#include "xfs_ag.h" +#include "xfs_dir2.h" +#include "xfs_dmapi.h" +#include "xfs_mount.h" STATIC int xfs_trans_unlock_chunk(xfs_log_item_chunk_t *,int ,int ,xfs_lsn_t );
@@ -79,6 +87,7 @@ xfs_trans_add_item(xfs_trans_t *tp, xfs_log_item_t *lip) lidp->lid_size =0 ; lip->li_desc = lidp; lip->li_mountp = tp->t_mountp; + lip->li_ailp = tp->t_mountp->m_ail;return lidp; }
@@ -120,6 +129,7 @@ xfs_trans_add_item(xfs_trans_t *tp, xfs_log_item_t *lip) lidp->lid_size =0 ; lip->li_desc = lidp; lip->li_mountp = tp->t_mountp; + lip->li_ailp = tp->t_mountp->m_ail;return lidp; }
Signature · 1 line
1.5.6.5
PATCH 8/8 XFS: Finish removing the mount pointer from the AIL API
In reply to Dave ChinnerChange all the remaining AIL API functions that are passed struct xfs_mount pointers to pass pointers directly to the struct xfs_ail being used. With this conversion, all external access to the AIL is via the struct xfs_ail. Hence the operation and referencing of the AIL is almost entirely independent of the xfs_mount that is using it - it is now much more tightly tied to the log and the items it is tracking in the log than it is tied to the xfs_mount.
--- fs/xfs/quota/xfs_dquot.c | 15 +++++++-------- fs/xfs/quota/xfs_dquot_item.c | 8 +++++--- fs/xfs/xfs_buf_item.c | 24 +++++++++--------------- fs/xfs/xfs_extfree_item.c | 35 ++++++++++------------------------- fs/xfs/xfs_iget.c | 4 +++- fs/xfs/xfs_inode.c | 8 ++++---- fs/xfs/xfs_inode_item.c | 29 ++++++++++++----------------- fs/xfs/xfs_log.c | 2 +- fs/xfs/xfs_log_recover.c | 13 +++++-------- fs/xfs/xfs_trans.c | 6 ++---- fs/xfs/xfs_trans.h | 3 --- fs/xfs/xfs_trans_ail.c | 41 +++++++++++++++++++++-------------------- fs/xfs/xfs_trans_buf.c | 7 +++---- fs/xfs/xfs_trans_priv.h | 15 +++++++++------ 14 files changed, 91 insertions(+), 119 deletions(-)
fs/xfs/quota/xfs_dquot.c +7 -8
@@ -1321,8 +1321,10 @@ xfs_qm_dqflush_done( xfs_dq_logitem_t *qip) {xfs_dquot_t *dqp; +struct xfs_ail *ailp; dqp = qip->qli_dquot; + ailp = qip->qli_item.li_ailp;/* * We only want to pull the item from the AIL if its
@@ -1335,15 +1337,12 @@ xfs_qm_dqflush_done(if ((qip->qli_item.li_flags &XFS_LI_IN_AIL ) && qip->qli_item.li_lsn == qip->qli_flush_lsn) { -spin_lock (&dqp->q_mount->m_ail->xa_lock); -/* -* xfs_trans_delete_ail() drops the AIL lock. -*/ +/* xfs_trans_ail_delete() drops the AIL lock. */ +spin_lock (&ailp->xa_lock);if (qip->qli_item.li_lsn == qip->qli_flush_lsn) -xfs_trans_delete_ail (dqp->q_mount, - (xfs_log_item_t *)qip); +xfs_trans_ail_delete (ailp, (xfs_log_item_t *)qip);else -spin_unlock (&dqp->q_mount->m_ail->xa_lock); +spin_unlock (&ailp->xa_lock); }/*
@@ -1373,7 +1372,7 @@ xfs_dqunlock(mutex_unlock (&(dqp->q_qlock));if (dqp->q_logitem.qli_dquot == dqp) {/* Once was dqp->q_mount, but might just have been cleared */ -xfs_trans_unlocked_item (dqp->q_logitem.qli_item.li_mountp, +xfs_trans_unlocked_item (dqp->q_logitem.qli_item.li_ailp, (xfs_log_item_t *)&(dqp->q_logitem)); } }
fs/xfs/quota/xfs_dquot_item.c +5 -3
@@ -553,14 +553,16 @@ xfs_qm_qoffend_logitem_committed( xfs_lsn_t lsn) {xfs_qoff_logitem_t *qfs; +struct xfs_ail *ailp; qfs = qfe->qql_start_lip; -spin_lock (&qfs->qql_item.li_mountp->m_ail->xa_lock); + ailp = qfs->qql_item.li_ailp; +spin_lock (&ailp->xa_lock);/* * Delete the qoff-start logitem from the AIL. -* xfs_trans_delete_ail() drops the AIL lock. +* xfs_trans_ail_delete() drops the AIL lock. */ -xfs_trans_delete_ail (qfs->qql_item.li_mountp, (xfs_log_item_t *)qfs); +xfs_trans_ail_delete (ailp, (xfs_log_item_t *)qfs);kmem_free (qfs);kmem_free (qfe);return (xfs_lsn_t)-1 ;
fs/xfs/xfs_buf_item.c +9 -15
@@ -375,7 +375,7 @@ xfs_buf_item_unpin( xfs_buf_log_item_t *bip, int stale) { -xfs_mount_t *mp; +struct xfs_ail *ailp;xfs_buf_t *bp;int freed;
@@ -387,7 +387,7 @@ xfs_buf_item_unpin(xfs_buftrace ("XFS_UNPIN" , bp); freed =atomic_dec_and_test (&bip->bli_refcount); - mp = bip->bli_item.li_mountp; + ailp = bip->bli_item.li_ailp;xfs_bunpin (bp);if (freed && stale) {ASSERT (bip->bli_flags &XFS_BLI_STALE );
@@ -399,17 +399,17 @@ xfs_buf_item_unpin(xfs_buftrace ("XFS_UNPIN STALE" , bp);/* * If we get called here because of an IO error, we may -* or may not have the item on the AIL. xfs_trans_delete_ail() +* or may not have the item on the AIL. xfs_trans_ail_delete() * will take care of that situation. -* xfs_trans_delete_ail() drops the AIL lock. +* xfs_trans_ail_delete() drops the AIL lock. */ if (bip->bli_flags &XFS_BLI_STALE_INODE ) {xfs_buf_do_callbacks (bp, (xfs_log_item_t *)bip);XFS_BUF_SET_FSPRIVATE (bp,NULL );XFS_BUF_CLR_IODONE_FUNC (bp); }else { -spin_lock (&mp->m_ail->xa_lock); -xfs_trans_delete_ail (mp, (xfs_log_item_t *)bip); +spin_lock (&ailp->xa_lock); +xfs_trans_ail_delete (ailp, (xfs_log_item_t *)bip);xfs_buf_item_relse (bp); ASSERT(XFS_BUF_FSPRIVATE(bp, void *) == NULL); }
@@ -1123,29 +1123,23 @@ xfs_buf_iodone( xfs_buf_t *bp, xfs_buf_log_item_t *bip) { -struct xfs_mount *mp; -struct xfs_ail *ailp; +struct xfs_ail *ailp = bip->bli_item.li_ailp;ASSERT (bip->bli_buf == bp);xfs_buf_rele (bp); - mp = bip->bli_item.li_mountp; - ailp = bip->bli_item.li_ailp;/* * If we are forcibly shutting down, this may well be * off the AIL already. That's because we simulate the * log-committed callbacks to unpin these buffers. Or we may never * have put this item on AIL because of the transaction was -* aborted forcibly. xfs_trans_delete_ail() takes care of these. +* aborted forcibly. xfs_trans_ail_delete() takes care of these. * * Either way, AIL is useless if we're forcing a shutdown. */ spin_lock (&ailp->xa_lock); -/* -* xfs_trans_delete_ail() drops the AIL lock. -*/ -xfs_trans_delete_ail (mp, (xfs_log_item_t *)bip); +xfs_trans_ail_delete (ailp, (xfs_log_item_t *)bip);xfs_buf_item_free (bip); }
fs/xfs/xfs_extfree_item.c +10 -25
@@ -108,17 +108,12 @@ xfs_efi_item_pin(xfs_efi_log_item_t *efip) STATIC voidxfs_efi_item_unpin (xfs_efi_log_item_t *efip,int stale) { -xfs_mount_t *mp; -struct xfs_ail *ailp; +struct xfs_ail *ailp = efip->efi_item.li_ailp; - mp = efip->efi_item.li_mountp; - ailp = efip->efi_item.li_ailp;spin_lock (&ailp->xa_lock);if (efip->efi_flags &XFS_EFI_CANCELED ) { -/* -* xfs_trans_delete_ail() drops the AIL lock. -*/ -xfs_trans_delete_ail (mp, (xfs_log_item_t *)efip); +/* xfs_trans_ail_delete() drops the AIL lock. */ +xfs_trans_ail_delete (ailp, (xfs_log_item_t *)efip);xfs_efi_item_free (efip); }else { efip->efi_flags |=XFS_EFI_COMMITTED ;
@@ -136,12 +131,9 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale) STATIC voidxfs_efi_item_unpin_remove (xfs_efi_log_item_t *efip,xfs_trans_t *tp) { -xfs_mount_t *mp; -struct xfs_ail *ailp; +struct xfs_ail *ailp = efip->efi_item.li_ailp;xfs_log_item_desc_t *lidp; - mp = efip->efi_item.li_mountp; - ailp = efip->efi_item.li_ailp;spin_lock (&ailp->xa_lock);if (efip->efi_flags &XFS_EFI_CANCELED ) {/*
@@ -149,11 +141,9 @@ xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)*/ lidp =xfs_trans_find_item (tp, (xfs_log_item_t *) efip);xfs_trans_free_item (tp, lidp); -/* -* pull the item off the AIL. -* xfs_trans_delete_ail() drops the AIL lock. -*/ -xfs_trans_delete_ail (mp, (xfs_log_item_t *)efip); + +/* xfs_trans_ail_delete() drops the AIL lock. */ +xfs_trans_ail_delete (ailp, (xfs_log_item_t *)efip);xfs_efi_item_free (efip); }else { efip->efi_flags |=XFS_EFI_COMMITTED ;
@@ -350,12 +340,9 @@ voidxfs_efi_release (xfs_efi_log_item_t *efip, uint nextents) { -xfs_mount_t *mp; -struct xfs_ail *ailp; +struct xfs_ail *ailp = efip->efi_item.li_ailp;int extents_left; - mp = efip->efi_item.li_mountp; - ailp = efip->efi_item.li_ailp;ASSERT (efip->efi_next_extent >0 );ASSERT (efip->efi_flags &XFS_EFI_COMMITTED );
@@ -364,10 +351,8 @@ xfs_efi_release(xfs_efi_log_item_t *efip, efip->efi_next_extent -= nextents; extents_left = efip->efi_next_extent;if (extents_left ==0 ) { -/* -* xfs_trans_delete_ail() drops the AIL lock. -*/ -xfs_trans_delete_ail (mp, (xfs_log_item_t *)efip); +/* xfs_trans_ail_delete() drops the AIL lock. */ +xfs_trans_ail_delete (ailp, (xfs_log_item_t *)efip);xfs_efi_item_free (efip); }else {spin_unlock (&ailp->xa_lock);
fs/xfs/xfs_iget.c +3 -1
@@ -38,6 +38,8 @@#include "xfs_ialloc.h" #include "xfs_quota.h" #include "xfs_utils.h" +#include "xfs_trans_priv.h" +#include "xfs_inode_item.h" /* * Check the validity of the inode we just found it the cache
@@ -616,7 +618,7 @@ xfs_iunlock(* it is in the AIL and anyone is waiting on it. Don't do * this if the caller has asked us not to. */ -xfs_trans_unlocked_item (ip->i_mount, +xfs_trans_unlocked_item (ip->i_itemp->ili_item.li_ailp, (xfs_log_item_t *)(ip->i_itemp)); }xfs_ilock_trace (ip,3 , lock_flags, (inst_t *)__return_address);
fs/xfs/xfs_inode.c +4 -4
@@ -2712,17 +2712,17 @@ xfs_idestroy(* inode still in the AIL. If it is there, we should remove * it to prevent a use-after-free from occurring. */ -xfs_mount_t *mp = ip->i_mount;xfs_log_item_t *lip = &ip->i_itemp->ili_item; +struct xfs_ail *ailp = lip->li_ailp;ASSERT (((lip->li_flags &XFS_LI_IN_AIL ) ==0 ) ||XFS_FORCED_SHUTDOWN (ip->i_mount));if (lip->li_flags &XFS_LI_IN_AIL ) { -spin_lock (&mp->m_ail->xa_lock); +spin_lock (&ailp->xa_lock);if (lip->li_flags &XFS_LI_IN_AIL ) -xfs_trans_delete_ail (mp, lip); +xfs_trans_ail_delete (ailp, lip);else -spin_unlock (&mp->m_ail->xa_lock); +spin_unlock (&ailp->xa_lock); }xfs_inode_item_destroy (ip); ip->i_itemp =NULL ;
fs/xfs/xfs_inode_item.c +12 -17
@@ -977,9 +977,8 @@ xfs_iflush_done( xfs_buf_t *bp, xfs_inode_log_item_t *iip) { -xfs_inode_t *ip; - - ip = iip->ili_inode; +xfs_inode_t *ip = iip->ili_inode; +struct xfs_ail *ailp = iip->ili_item.li_ailp;/* * We only want to pull the item from the AIL if it is
@@ -992,15 +991,12 @@ xfs_iflush_done(*/ if (iip->ili_logged && (iip->ili_item.li_lsn == iip->ili_flush_lsn)) { -spin_lock (&ip->i_mount->m_ail->xa_lock); +spin_lock (&ailp->xa_lock);if (iip->ili_item.li_lsn == iip->ili_flush_lsn) { -/* -* xfs_trans_delete_ail() drops the AIL lock. -*/ -xfs_trans_delete_ail (ip->i_mount, - (xfs_log_item_t *)iip); +/* xfs_trans_ail_delete() drops the AIL lock. */ +xfs_trans_ail_delete (ailp, (xfs_log_item_t *)iip); }else { -spin_unlock (&ip->i_mount->m_ail->xa_lock); +spin_unlock (&ailp->xa_lock); } }
@@ -1032,21 +1028,20 @@ voidxfs_iflush_abort ( xfs_inode_t *ip) { -xfs_inode_log_item_t *iip; +xfs_inode_log_item_t *iip = ip->i_itemp;xfs_mount_t *mp; iip = ip->i_itemp; mp = ip->i_mount;if (iip) { +struct xfs_ail *ailp = iip->ili_item.li_ailp;if (iip->ili_item.li_flags &XFS_LI_IN_AIL ) { -spin_lock (&mp->m_ail->xa_lock); +spin_lock (&ailp->xa_lock);if (iip->ili_item.li_flags &XFS_LI_IN_AIL ) { -/* -* xfs_trans_delete_ail() drops the AIL lock. -*/ -xfs_trans_delete_ail (mp, (xfs_log_item_t *)iip); +/* xfs_trans_ail_delete() drops the AIL lock. */ +xfs_trans_ail_delete (ailp, (xfs_log_item_t *)iip); }else -spin_unlock (&mp->m_ail->xa_lock); +spin_unlock (&ailp->xa_lock); } iip->ili_logged =0 ;/*
fs/xfs/xfs_log.c +1 -1
@@ -1412,7 +1412,7 @@ xlog_grant_push_ail(xfs_mount_t *mp,*/ if (threshold_lsn && !XLOG_FORCED_SHUTDOWN (log)) -xfs_trans_push_ail (mp, threshold_lsn); +xfs_trans_ail_push (log->l_ailp, threshold_lsn); }/* xlog_grant_push_ail */
fs/xfs/xfs_log_recover.c +5 -8
@@ -2683,9 +2683,9 @@ xlog_recover_do_efi_trans(spin_lock (&log->l_ailp->xa_lock);/* -* xfs_trans_update_ail() drops the AIL lock. +* xfs_trans_ail_update() drops the AIL lock. */ -xfs_trans_update_ail (mp, (xfs_log_item_t *)efip, lsn); +xfs_trans_ail_update (log->l_ailp, (xfs_log_item_t *)efip, lsn);return 0 ; }
@@ -2704,13 +2704,12 @@ xlog_recover_do_efd_trans( xlog_recover_item_t *item, int pass) { -xfs_mount_t *mp;xfs_efd_log_format_t *efd_formatp;xfs_efi_log_item_t *efip =NULL ;xfs_log_item_t *lip;__uint64_t efi_id;struct xfs_ail_cursor cur; -struct xfs_ail *ailp; +struct xfs_ail *ailp = log->l_ailp;if (pass ==XLOG_RECOVER_PASS1 ) {return ;
@@ -2727,8 +2726,6 @@ xlog_recover_do_efd_trans(* Search for the efi with the id in the efd format structure * in the AIL. */ - mp = log->l_mp; - ailp = log->l_ailp;spin_lock (&ailp->xa_lock); lip =xfs_trans_ail_cursor_first (ailp, &cur,0 );while (lip !=NULL ) {
@@ -2736,10 +2733,10 @@ xlog_recover_do_efd_trans( efip = (xfs_efi_log_item_t *)lip;if (efip->efi_format.efi_id == efi_id) {/* -* xfs_trans_delete_ail() drops the +* xfs_trans_ail_delete() drops the * AIL lock. */ -xfs_trans_delete_ail (mp, lip); +xfs_trans_ail_delete (ailp, lip);xfs_efi_item_free (efip);spin_lock (&ailp->xa_lock);break ;
fs/xfs/xfs_trans.c +2 -4
@@ -1387,7 +1387,6 @@ xfs_trans_chunk_committed( lidp = licp->lic_descs;for (i =0 ; i < licp->lic_unused; i++, lidp++) { -struct xfs_mount *mp;struct xfs_ail *ailp;if (xfs_lic_isfree (licp, i)) {
@@ -1426,7 +1425,6 @@ xfs_trans_chunk_committed(* This would cause the earlier transaction to fail * the test below. */ - mp = lip->li_mountp; ailp = lip->li_ailp;spin_lock (&ailp->xa_lock);if (XFS_LSN_CMP (item_lsn, lip->li_lsn) >0 ) {
@@ -1435,9 +1433,9 @@ xfs_trans_chunk_committed(* and update the position of the item in * the AIL. * -* xfs_trans_update_ail() drops the AIL lock. +* xfs_trans_ail_update() drops the AIL lock. */ -xfs_trans_update_ail (mp, lip, item_lsn); +xfs_trans_ail_update (ailp, lip, item_lsn); }else {spin_unlock (&ailp->xa_lock); }
fs/xfs/xfs_trans.h +0 -3
@@ -971,9 +971,6 @@ int _xfs_trans_commit(xfs_trans_t *,void xfs_trans_cancel (xfs_trans_t *,int );int xfs_trans_ail_init (struct xfs_mount *);void xfs_trans_ail_destroy (struct xfs_mount *); -void xfs_trans_push_ail (struct xfs_mount *,xfs_lsn_t ); -void xfs_trans_unlocked_item (struct xfs_mount *, -xfs_log_item_t *);xfs_log_busy_slot_t *xfs_trans_add_busy (xfs_trans_t *tp,xfs_agnumber_t ag,xfs_extlen_t idx);
fs/xfs/xfs_trans_ail.c +21 -20
104 lines not on this page · raw message
fs/xfs/xfs_trans_buf.c +3 -4
@@ -527,9 +527,8 @@ xfs_trans_brelse(xfs_trans_t *tp, lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);if (lip->li_type ==XFS_LI_BUF ) { bip = XFS_BUF_FSPRIVATE(bp,xfs_buf_log_item_t*); -xfs_trans_unlocked_item ( - bip->bli_item.li_mountp, - lip); +xfs_trans_unlocked_item (bip->bli_item.li_ailp, + lip); } }xfs_buf_relse (bp);
@@ -626,7 +625,7 @@ xfs_trans_brelse(xfs_trans_t *tp,* tell the AIL that the buffer is being unlocked. */ if (bip !=NULL ) { -xfs_trans_unlocked_item (bip->bli_item.li_mountp, +xfs_trans_unlocked_item (bip->bli_item.li_ailp, (xfs_log_item_t *)bip); }
fs/xfs/xfs_trans_priv.h +9 -6
@@ -85,12 +85,15 @@ struct xfs_ail {/* * From xfs_trans_ail.c */ -void xfs_trans_update_ail(struct xfs_mount *mp, - struct xfs_log_item *lip, xfs_lsn_t lsn) - __releases(mp->m_ail_lock); -void xfs_trans_delete_ail(struct xfs_mount *mp, - struct xfs_log_item *lip) - __releases(mp->m_ail_lock); +void xfs_trans_ail_update(struct xfs_ail *ailp, + struct xfs_log_item *lip, xfs_lsn_t lsn) + __releases(ailp->xa_lock); +void xfs_trans_ail_delete(struct xfs_ail *ailp, + struct xfs_log_item *lip) + __releases(ailp->xa_lock); +void xfs_trans_ail_push (struct xfs_ail *,xfs_lsn_t ); +void xfs_trans_unlocked_item (struct xfs_ail *, +xfs_log_item_t *);xfs_lsn_t xfs_trans_ail_tail (struct xfs_ail *ailp);
Signature · 1 line
1.5.6.5