Commit 27af1bbf authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: remove xfs_trans_ail_delete_bulk

xfs_iflush_done uses an on-stack variable length array to pass the log
items to be deleted to xfs_trans_ail_delete_bulk.  On-stack VLAs are a
nasty gcc extension that can lead to unbounded stack allocations, but
fortunately we can easily avoid them by simply open coding
xfs_trans_ail_delete_bulk in xfs_iflush_done, which is the only caller
of it except for the single-item xfs_trans_ail_delete.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 3f88a15a
...@@ -731,22 +731,27 @@ xfs_iflush_done( ...@@ -731,22 +731,27 @@ xfs_iflush_done(
* holding the lock before removing the inode from the AIL. * holding the lock before removing the inode from the AIL.
*/ */
if (need_ail) { if (need_ail) {
struct xfs_log_item *log_items[need_ail]; bool mlip_changed = false;
int i = 0;
/* this is an opencoded batch version of xfs_trans_ail_delete */
spin_lock(&ailp->xa_lock); spin_lock(&ailp->xa_lock);
for (blip = lip; blip; blip = blip->li_bio_list) { for (blip = lip; blip; blip = blip->li_bio_list) {
iip = INODE_ITEM(blip); if (INODE_ITEM(blip)->ili_logged &&
if (iip->ili_logged && blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
blip->li_lsn == iip->ili_flush_lsn) { mlip_changed |= xfs_ail_delete_one(ailp, blip);
log_items[i++] = blip;
}
ASSERT(i <= need_ail);
} }
/* xfs_trans_ail_delete_bulk() drops the AIL lock. */
xfs_trans_ail_delete_bulk(ailp, log_items, i,
SHUTDOWN_CORRUPT_INCORE);
}
if (mlip_changed) {
if (!XFS_FORCED_SHUTDOWN(ailp->xa_mount))
xlog_assign_tail_lsn_locked(ailp->xa_mount);
if (list_empty(&ailp->xa_ail))
wake_up_all(&ailp->xa_empty);
}
spin_unlock(&ailp->xa_lock);
if (mlip_changed)
xfs_log_space_wake(ailp->xa_mount);
}
/* /*
* clean up and unlock the flush lock now we are done. We can clear the * clean up and unlock the flush lock now we are done. We can clear the
......
...@@ -684,8 +684,23 @@ xfs_trans_ail_update_bulk( ...@@ -684,8 +684,23 @@ xfs_trans_ail_update_bulk(
} }
} }
/* bool
* xfs_trans_ail_delete_bulk - remove multiple log items from the AIL xfs_ail_delete_one(
struct xfs_ail *ailp,
struct xfs_log_item *lip)
{
struct xfs_log_item *mlip = xfs_ail_min(ailp);
trace_xfs_ail_delete(lip, mlip->li_lsn, lip->li_lsn);
xfs_ail_delete(ailp, lip);
lip->li_flags &= ~XFS_LI_IN_AIL;
lip->li_lsn = 0;
return mlip == lip;
}
/**
* Remove a log items from the AIL
* *
* @xfs_trans_ail_delete_bulk takes an array of log items that all need to * @xfs_trans_ail_delete_bulk takes an array of log items that all need to
* removed from the AIL. The caller is already holding the AIL lock, and done * removed from the AIL. The caller is already holding the AIL lock, and done
...@@ -706,52 +721,36 @@ xfs_trans_ail_update_bulk( ...@@ -706,52 +721,36 @@ xfs_trans_ail_update_bulk(
* before returning. * before returning.
*/ */
void void
xfs_trans_ail_delete_bulk( xfs_trans_ail_delete(
struct xfs_ail *ailp, struct xfs_ail *ailp,
struct xfs_log_item **log_items, struct xfs_log_item *lip,
int nr_items,
int shutdown_type) __releases(ailp->xa_lock) int shutdown_type) __releases(ailp->xa_lock)
{ {
xfs_log_item_t *mlip; struct xfs_mount *mp = ailp->xa_mount;
int mlip_changed = 0; bool mlip_changed;
int i;
mlip = xfs_ail_min(ailp); if (!(lip->li_flags & XFS_LI_IN_AIL)) {
spin_unlock(&ailp->xa_lock);
for (i = 0; i < nr_items; i++) { if (!XFS_FORCED_SHUTDOWN(mp)) {
struct xfs_log_item *lip = log_items[i]; xfs_alert_tag(mp, XFS_PTAG_AILDELETE,
if (!(lip->li_flags & XFS_LI_IN_AIL)) { "%s: attempting to delete a log item that is not in the AIL",
struct xfs_mount *mp = ailp->xa_mount; __func__);
xfs_force_shutdown(mp, shutdown_type);
spin_unlock(&ailp->xa_lock);
if (!XFS_FORCED_SHUTDOWN(mp)) {
xfs_alert_tag(mp, XFS_PTAG_AILDELETE,
"%s: attempting to delete a log item that is not in the AIL",
__func__);
xfs_force_shutdown(mp, shutdown_type);
}
return;
} }
return;
trace_xfs_ail_delete(lip, mlip->li_lsn, lip->li_lsn);
xfs_ail_delete(ailp, lip);
lip->li_flags &= ~XFS_LI_IN_AIL;
lip->li_lsn = 0;
if (mlip == lip)
mlip_changed = 1;
} }
mlip_changed = xfs_ail_delete_one(ailp, lip);
if (mlip_changed) { if (mlip_changed) {
if (!XFS_FORCED_SHUTDOWN(ailp->xa_mount)) if (!XFS_FORCED_SHUTDOWN(mp))
xlog_assign_tail_lsn_locked(ailp->xa_mount); xlog_assign_tail_lsn_locked(mp);
if (list_empty(&ailp->xa_ail)) if (list_empty(&ailp->xa_ail))
wake_up_all(&ailp->xa_empty); wake_up_all(&ailp->xa_empty);
spin_unlock(&ailp->xa_lock); }
spin_unlock(&ailp->xa_lock);
if (mlip_changed)
xfs_log_space_wake(ailp->xa_mount); xfs_log_space_wake(ailp->xa_mount);
} else {
spin_unlock(&ailp->xa_lock);
}
} }
int int
......
...@@ -106,18 +106,9 @@ xfs_trans_ail_update( ...@@ -106,18 +106,9 @@ xfs_trans_ail_update(
xfs_trans_ail_update_bulk(ailp, NULL, &lip, 1, lsn); xfs_trans_ail_update_bulk(ailp, NULL, &lip, 1, lsn);
} }
void xfs_trans_ail_delete_bulk(struct xfs_ail *ailp, bool xfs_ail_delete_one(struct xfs_ail *ailp, struct xfs_log_item *lip);
struct xfs_log_item **log_items, int nr_items, void xfs_trans_ail_delete(struct xfs_ail *ailp, struct xfs_log_item *lip,
int shutdown_type) int shutdown_type) __releases(ailp->xa_lock);
__releases(ailp->xa_lock);
static inline void
xfs_trans_ail_delete(
struct xfs_ail *ailp,
xfs_log_item_t *lip,
int shutdown_type) __releases(ailp->xa_lock)
{
xfs_trans_ail_delete_bulk(ailp, &lip, 1, shutdown_type);
}
static inline void static inline void
xfs_trans_ail_remove( xfs_trans_ail_remove(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment