Commit 2039a272 authored by Dave Chinner's avatar Dave Chinner Committed by Darrick J. Wong

xfs: convert XLOG_FORCED_SHUTDOWN() to xlog_is_shutdown()

Make it less shouty and a static inline before adding more calls
through the log code.

Also convert internal log code that uses XFS_FORCED_SHUTDOWN(mount)
to use xlog_is_shutdown(log) as well.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent edf27485
...@@ -246,7 +246,7 @@ xlog_grant_head_wait( ...@@ -246,7 +246,7 @@ xlog_grant_head_wait(
list_add_tail(&tic->t_queue, &head->waiters); list_add_tail(&tic->t_queue, &head->waiters);
do { do {
if (XLOG_FORCED_SHUTDOWN(log)) if (xlog_is_shutdown(log))
goto shutdown; goto shutdown;
xlog_grant_push_ail(log, need_bytes); xlog_grant_push_ail(log, need_bytes);
...@@ -260,7 +260,7 @@ xlog_grant_head_wait( ...@@ -260,7 +260,7 @@ xlog_grant_head_wait(
trace_xfs_log_grant_wake(log, tic); trace_xfs_log_grant_wake(log, tic);
spin_lock(&head->lock); spin_lock(&head->lock);
if (XLOG_FORCED_SHUTDOWN(log)) if (xlog_is_shutdown(log))
goto shutdown; goto shutdown;
} while (xlog_space_left(log, &head->grant) < need_bytes); } while (xlog_space_left(log, &head->grant) < need_bytes);
...@@ -365,7 +365,7 @@ xfs_log_writable( ...@@ -365,7 +365,7 @@ xfs_log_writable(
return false; return false;
if (xfs_readonly_buftarg(mp->m_log->l_targ)) if (xfs_readonly_buftarg(mp->m_log->l_targ))
return false; return false;
if (XFS_FORCED_SHUTDOWN(mp)) if (xlog_is_shutdown(mp->m_log))
return false; return false;
return true; return true;
} }
...@@ -382,7 +382,7 @@ xfs_log_regrant( ...@@ -382,7 +382,7 @@ xfs_log_regrant(
int need_bytes; int need_bytes;
int error = 0; int error = 0;
if (XLOG_FORCED_SHUTDOWN(log)) if (xlog_is_shutdown(log))
return -EIO; return -EIO;
XFS_STATS_INC(mp, xs_try_logspace); XFS_STATS_INC(mp, xs_try_logspace);
...@@ -450,7 +450,7 @@ xfs_log_reserve( ...@@ -450,7 +450,7 @@ xfs_log_reserve(
ASSERT(client == XFS_TRANSACTION || client == XFS_LOG); ASSERT(client == XFS_TRANSACTION || client == XFS_LOG);
if (XLOG_FORCED_SHUTDOWN(log)) if (xlog_is_shutdown(log))
return -EIO; return -EIO;
XFS_STATS_INC(mp, xs_try_logspace); XFS_STATS_INC(mp, xs_try_logspace);
...@@ -830,7 +830,7 @@ xlog_wait_on_iclog( ...@@ -830,7 +830,7 @@ xlog_wait_on_iclog(
struct xlog *log = iclog->ic_log; struct xlog *log = iclog->ic_log;
trace_xlog_iclog_wait_on(iclog, _RET_IP_); trace_xlog_iclog_wait_on(iclog, _RET_IP_);
if (!XLOG_FORCED_SHUTDOWN(log) && if (!xlog_is_shutdown(log) &&
iclog->ic_state != XLOG_STATE_ACTIVE && iclog->ic_state != XLOG_STATE_ACTIVE &&
iclog->ic_state != XLOG_STATE_DIRTY) { iclog->ic_state != XLOG_STATE_DIRTY) {
XFS_STATS_INC(log->l_mp, xs_log_force_sleep); XFS_STATS_INC(log->l_mp, xs_log_force_sleep);
...@@ -839,7 +839,7 @@ xlog_wait_on_iclog( ...@@ -839,7 +839,7 @@ xlog_wait_on_iclog(
spin_unlock(&log->l_icloglock); spin_unlock(&log->l_icloglock);
} }
if (XLOG_FORCED_SHUTDOWN(log)) if (xlog_is_shutdown(log))
return -EIO; return -EIO;
return 0; return 0;
} }
...@@ -940,7 +940,7 @@ xfs_log_unmount_write( ...@@ -940,7 +940,7 @@ xfs_log_unmount_write(
xfs_log_force(mp, XFS_LOG_SYNC); xfs_log_force(mp, XFS_LOG_SYNC);
if (XLOG_FORCED_SHUTDOWN(log)) if (xlog_is_shutdown(log))
return; return;
/* /*
...@@ -1063,7 +1063,7 @@ xfs_log_space_wake( ...@@ -1063,7 +1063,7 @@ xfs_log_space_wake(
struct xlog *log = mp->m_log; struct xlog *log = mp->m_log;
int free_bytes; int free_bytes;
if (XLOG_FORCED_SHUTDOWN(log)) if (xlog_is_shutdown(log))
return; return;
if (!list_empty_careful(&log->l_write_head.waiters)) { if (!list_empty_careful(&log->l_write_head.waiters)) {
...@@ -1154,7 +1154,7 @@ xfs_log_cover( ...@@ -1154,7 +1154,7 @@ xfs_log_cover(
ASSERT((xlog_cil_empty(mp->m_log) && xlog_iclogs_empty(mp->m_log) && ASSERT((xlog_cil_empty(mp->m_log) && xlog_iclogs_empty(mp->m_log) &&
!xfs_ail_min_lsn(mp->m_log->l_ailp)) || !xfs_ail_min_lsn(mp->m_log->l_ailp)) ||
XFS_FORCED_SHUTDOWN(mp)); xlog_is_shutdown(mp->m_log));
if (!xfs_log_writable(mp)) if (!xfs_log_writable(mp))
return 0; return 0;
...@@ -1614,7 +1614,7 @@ xlog_commit_record( ...@@ -1614,7 +1614,7 @@ xlog_commit_record(
}; };
int error; int error;
if (XLOG_FORCED_SHUTDOWN(log)) if (xlog_is_shutdown(log))
return -EIO; return -EIO;
error = xlog_write(log, &vec, ticket, lsn, iclog, XLOG_COMMIT_TRANS); error = xlog_write(log, &vec, ticket, lsn, iclog, XLOG_COMMIT_TRANS);
...@@ -1695,7 +1695,7 @@ xlog_grant_push_ail( ...@@ -1695,7 +1695,7 @@ xlog_grant_push_ail(
xfs_lsn_t threshold_lsn; xfs_lsn_t threshold_lsn;
threshold_lsn = xlog_grant_push_threshold(log, need_bytes); threshold_lsn = xlog_grant_push_threshold(log, need_bytes);
if (threshold_lsn == NULLCOMMITLSN || XLOG_FORCED_SHUTDOWN(log)) if (threshold_lsn == NULLCOMMITLSN || xlog_is_shutdown(log))
return; return;
/* /*
...@@ -2886,7 +2886,7 @@ xlog_state_do_callback( ...@@ -2886,7 +2886,7 @@ xlog_state_do_callback(
cycled_icloglock = true; cycled_icloglock = true;
spin_lock(&log->l_icloglock); spin_lock(&log->l_icloglock);
if (XLOG_FORCED_SHUTDOWN(log)) if (xlog_is_shutdown(log))
wake_up_all(&iclog->ic_force_wait); wake_up_all(&iclog->ic_force_wait);
else else
xlog_state_clean_iclog(log, iclog); xlog_state_clean_iclog(log, iclog);
...@@ -2938,7 +2938,7 @@ xlog_state_done_syncing( ...@@ -2938,7 +2938,7 @@ xlog_state_done_syncing(
* split log writes, on the second, we shut down the file system and * split log writes, on the second, we shut down the file system and
* no iclogs should ever be attempted to be written to disk again. * no iclogs should ever be attempted to be written to disk again.
*/ */
if (!XLOG_FORCED_SHUTDOWN(log)) { if (!xlog_is_shutdown(log)) {
ASSERT(iclog->ic_state == XLOG_STATE_SYNCING); ASSERT(iclog->ic_state == XLOG_STATE_SYNCING);
iclog->ic_state = XLOG_STATE_DONE_SYNC; iclog->ic_state = XLOG_STATE_DONE_SYNC;
} }
...@@ -2986,7 +2986,7 @@ xlog_state_get_iclog_space( ...@@ -2986,7 +2986,7 @@ xlog_state_get_iclog_space(
restart: restart:
spin_lock(&log->l_icloglock); spin_lock(&log->l_icloglock);
if (XLOG_FORCED_SHUTDOWN(log)) { if (xlog_is_shutdown(log)) {
spin_unlock(&log->l_icloglock); spin_unlock(&log->l_icloglock);
return -EIO; return -EIO;
} }
...@@ -3877,7 +3877,7 @@ xfs_log_force_umount( ...@@ -3877,7 +3877,7 @@ xfs_log_force_umount(
* No need to get locks for this. * No need to get locks for this.
*/ */
if (logerror && log->l_iclog->ic_state == XLOG_STATE_IOERROR) { if (logerror && log->l_iclog->ic_state == XLOG_STATE_IOERROR) {
ASSERT(XLOG_FORCED_SHUTDOWN(log)); ASSERT(xlog_is_shutdown(log));
return 1; return 1;
} }
......
...@@ -584,7 +584,7 @@ xlog_cil_committed( ...@@ -584,7 +584,7 @@ xlog_cil_committed(
struct xfs_cil_ctx *ctx) struct xfs_cil_ctx *ctx)
{ {
struct xfs_mount *mp = ctx->cil->xc_log->l_mp; struct xfs_mount *mp = ctx->cil->xc_log->l_mp;
bool abort = XLOG_FORCED_SHUTDOWN(ctx->cil->xc_log); bool abort = xlog_is_shutdown(ctx->cil->xc_log);
/* /*
* If the I/O failed, we're aborting the commit and already shutdown. * If the I/O failed, we're aborting the commit and already shutdown.
...@@ -862,7 +862,7 @@ xlog_cil_push_work( ...@@ -862,7 +862,7 @@ xlog_cil_push_work(
* shutdown, but then went back to sleep once already in the * shutdown, but then went back to sleep once already in the
* shutdown state. * shutdown state.
*/ */
if (XLOG_FORCED_SHUTDOWN(log)) { if (xlog_is_shutdown(log)) {
spin_unlock(&cil->xc_push_lock); spin_unlock(&cil->xc_push_lock);
goto out_abort_free_ticket; goto out_abort_free_ticket;
} }
...@@ -971,7 +971,7 @@ xlog_cil_push_work( ...@@ -971,7 +971,7 @@ xlog_cil_push_work(
out_abort_free_ticket: out_abort_free_ticket:
xfs_log_ticket_ungrant(log, tic); xfs_log_ticket_ungrant(log, tic);
out_abort: out_abort:
ASSERT(XLOG_FORCED_SHUTDOWN(log)); ASSERT(xlog_is_shutdown(log));
xlog_cil_committed(ctx); xlog_cil_committed(ctx);
} }
...@@ -1124,7 +1124,7 @@ xlog_cil_commit( ...@@ -1124,7 +1124,7 @@ xlog_cil_commit(
xlog_cil_insert_items(log, tp); xlog_cil_insert_items(log, tp);
if (regrant && !XLOG_FORCED_SHUTDOWN(log)) if (regrant && !xlog_is_shutdown(log))
xfs_log_ticket_regrant(log, tp->t_ticket); xfs_log_ticket_regrant(log, tp->t_ticket);
else else
xfs_log_ticket_ungrant(log, tp->t_ticket); xfs_log_ticket_ungrant(log, tp->t_ticket);
...@@ -1197,7 +1197,7 @@ xlog_cil_force_seq( ...@@ -1197,7 +1197,7 @@ xlog_cil_force_seq(
* shutdown, but then went back to sleep once already in the * shutdown, but then went back to sleep once already in the
* shutdown state. * shutdown state.
*/ */
if (XLOG_FORCED_SHUTDOWN(log)) if (xlog_is_shutdown(log))
goto out_shutdown; goto out_shutdown;
if (ctx->sequence > sequence) if (ctx->sequence > sequence)
continue; continue;
......
...@@ -464,8 +464,11 @@ struct xlog { ...@@ -464,8 +464,11 @@ struct xlog {
#define XLOG_BUF_CANCEL_BUCKET(log, blkno) \ #define XLOG_BUF_CANCEL_BUCKET(log, blkno) \
((log)->l_buf_cancel_table + ((uint64_t)blkno % XLOG_BC_TABLE_SIZE)) ((log)->l_buf_cancel_table + ((uint64_t)blkno % XLOG_BC_TABLE_SIZE))
#define XLOG_FORCED_SHUTDOWN(log) \ static inline bool
(unlikely((log)->l_flags & XLOG_IO_ERROR)) xlog_is_shutdown(struct xlog *log)
{
return (log->l_flags & XLOG_IO_ERROR);
}
/* common routines */ /* common routines */
extern int extern int
......
...@@ -146,7 +146,7 @@ xlog_do_io( ...@@ -146,7 +146,7 @@ xlog_do_io(
error = xfs_rw_bdev(log->l_targ->bt_bdev, log->l_logBBstart + blk_no, error = xfs_rw_bdev(log->l_targ->bt_bdev, log->l_logBBstart + blk_no,
BBTOB(nbblks), data, op); BBTOB(nbblks), data, op);
if (error && !XFS_FORCED_SHUTDOWN(log->l_mp)) { if (error && !xlog_is_shutdown(log)) {
xfs_alert(log->l_mp, xfs_alert(log->l_mp,
"log recovery %s I/O error at daddr 0x%llx len %d error %d", "log recovery %s I/O error at daddr 0x%llx len %d error %d",
op == REQ_OP_WRITE ? "write" : "read", op == REQ_OP_WRITE ? "write" : "read",
...@@ -3313,10 +3313,7 @@ xlog_do_recover( ...@@ -3313,10 +3313,7 @@ xlog_do_recover(
if (error) if (error)
return error; return error;
/* if (xlog_is_shutdown(log))
* If IO errors happened during recovery, bail out.
*/
if (XFS_FORCED_SHUTDOWN(mp))
return -EIO; return -EIO;
/* /*
...@@ -3338,7 +3335,7 @@ xlog_do_recover( ...@@ -3338,7 +3335,7 @@ xlog_do_recover(
xfs_buf_hold(bp); xfs_buf_hold(bp);
error = _xfs_buf_read(bp, XBF_READ); error = _xfs_buf_read(bp, XBF_READ);
if (error) { if (error) {
if (!XFS_FORCED_SHUTDOWN(mp)) { if (!xlog_is_shutdown(log)) {
xfs_buf_ioerror_alert(bp, __this_address); xfs_buf_ioerror_alert(bp, __this_address);
ASSERT(0); ASSERT(0);
} }
......
...@@ -905,7 +905,7 @@ __xfs_trans_commit( ...@@ -905,7 +905,7 @@ __xfs_trans_commit(
*/ */
xfs_trans_unreserve_and_mod_dquots(tp); xfs_trans_unreserve_and_mod_dquots(tp);
if (tp->t_ticket) { if (tp->t_ticket) {
if (regrant && !XLOG_FORCED_SHUTDOWN(mp->m_log)) if (regrant && !xlog_is_shutdown(mp->m_log))
xfs_log_ticket_regrant(mp->m_log, tp->t_ticket); xfs_log_ticket_regrant(mp->m_log, tp->t_ticket);
else else
xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket); xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket);
......
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