提交 8804a686 编写于 作者: D Dave Chinner 提交者: Zheng Zengkai

xfs: convert XLOG_FORCED_SHUTDOWN() to xlog_is_shutdown()

mainline-inclusion
from mainline-v5.14-rc4
commit 2039a272
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4V7IK
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2039a272300b949c05888428877317b834c0b1fb

-------------------------------------------------

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: NDave Chinner <dchinner@redhat.com>
Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
Signed-off-by: NLihong Kou <koulihong@huawei.com>
Reviewed-by: Nguoxuenan <guoxuenan@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 d2e650b8
......@@ -239,7 +239,7 @@ xlog_grant_head_wait(
list_add_tail(&tic->t_queue, &head->waiters);
do {
if (XLOG_FORCED_SHUTDOWN(log))
if (xlog_is_shutdown(log))
goto shutdown;
xlog_grant_push_ail(log, need_bytes);
......@@ -253,7 +253,7 @@ xlog_grant_head_wait(
trace_xfs_log_grant_wake(log, tic);
spin_lock(&head->lock);
if (XLOG_FORCED_SHUTDOWN(log))
if (xlog_is_shutdown(log))
goto shutdown;
} while (xlog_space_left(log, &head->grant) < need_bytes);
......@@ -354,7 +354,7 @@ xfs_log_regrant(
int need_bytes;
int error = 0;
if (XLOG_FORCED_SHUTDOWN(log))
if (xlog_is_shutdown(log))
return -EIO;
XFS_STATS_INC(mp, xs_try_logspace);
......@@ -422,7 +422,7 @@ xfs_log_reserve(
ASSERT(client == XFS_TRANSACTION || client == XFS_LOG);
if (XLOG_FORCED_SHUTDOWN(log))
if (xlog_is_shutdown(log))
return -EIO;
XFS_STATS_INC(mp, xs_try_logspace);
......@@ -778,7 +778,7 @@ xlog_wait_on_iclog(
struct xlog *log = iclog->ic_log;
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_DIRTY) {
XFS_STATS_INC(log->l_mp, xs_log_force_sleep);
......@@ -787,7 +787,7 @@ xlog_wait_on_iclog(
spin_unlock(&log->l_icloglock);
}
if (XLOG_FORCED_SHUTDOWN(log))
if (xlog_is_shutdown(log))
return -EIO;
return 0;
}
......@@ -895,7 +895,7 @@ xfs_log_unmount_write(
xfs_log_force(mp, XFS_LOG_SYNC);
if (XLOG_FORCED_SHUTDOWN(log))
if (xlog_is_shutdown(log))
return;
/*
......@@ -995,7 +995,7 @@ xfs_log_space_wake(
struct xlog *log = mp->m_log;
int free_bytes;
if (XLOG_FORCED_SHUTDOWN(log))
if (xlog_is_shutdown(log))
return;
if (!list_empty_careful(&log->l_write_head.waiters)) {
......@@ -1465,7 +1465,7 @@ xlog_commit_record(
};
int error;
if (XLOG_FORCED_SHUTDOWN(log))
if (xlog_is_shutdown(log))
return -EIO;
error = xlog_write(log, &vec, ticket, lsn, iclog, XLOG_COMMIT_TRANS);
......@@ -1546,7 +1546,7 @@ xlog_grant_push_ail(
xfs_lsn_t threshold_lsn;
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;
/*
......@@ -2737,7 +2737,7 @@ xlog_state_do_callback(
cycled_icloglock = true;
spin_lock(&log->l_icloglock);
if (XLOG_FORCED_SHUTDOWN(log))
if (xlog_is_shutdown(log))
wake_up_all(&iclog->ic_force_wait);
else
xlog_state_clean_iclog(log, iclog);
......@@ -2789,7 +2789,7 @@ xlog_state_done_syncing(
* 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.
*/
if (!XLOG_FORCED_SHUTDOWN(log)) {
if (!xlog_is_shutdown(log)) {
ASSERT(iclog->ic_state == XLOG_STATE_SYNCING);
iclog->ic_state = XLOG_STATE_DONE_SYNC;
}
......@@ -2837,7 +2837,7 @@ xlog_state_get_iclog_space(
restart:
spin_lock(&log->l_icloglock);
if (XLOG_FORCED_SHUTDOWN(log)) {
if (xlog_is_shutdown(log)) {
spin_unlock(&log->l_icloglock);
return -EIO;
}
......@@ -3737,7 +3737,7 @@ xfs_log_force_umount(
* No need to get locks for this.
*/
if (logerror && log->l_iclog->ic_state == XLOG_STATE_IOERROR) {
ASSERT(XLOG_FORCED_SHUTDOWN(log));
ASSERT(xlog_is_shutdown(log));
return 1;
}
......
......@@ -612,7 +612,7 @@ xlog_cil_committed(
struct xfs_cil_ctx *ctx)
{
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.
......@@ -880,7 +880,7 @@ xlog_cil_push_work(
* shutdown, but then went back to sleep once already in the
* shutdown state.
*/
if (XLOG_FORCED_SHUTDOWN(log)) {
if (xlog_is_shutdown(log)) {
spin_unlock(&cil->xc_push_lock);
goto out_abort_free_ticket;
}
......@@ -1000,7 +1000,7 @@ xlog_cil_push_work(
out_abort_free_ticket:
xfs_log_ticket_ungrant(log, tic);
out_abort:
ASSERT(XLOG_FORCED_SHUTDOWN(log));
ASSERT(xlog_is_shutdown(log));
xlog_cil_committed(ctx);
}
......@@ -1168,7 +1168,7 @@ xlog_cil_commit(
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);
else
xfs_log_ticket_ungrant(log, tp->t_ticket);
......@@ -1260,7 +1260,7 @@ xlog_cil_force_seq(
* shutdown, but then went back to sleep once already in the
* shutdown state.
*/
if (XLOG_FORCED_SHUTDOWN(log))
if (xlog_is_shutdown(log))
goto out_shutdown;
if (ctx->sequence > sequence)
continue;
......
......@@ -456,8 +456,11 @@ struct xlog {
#define XLOG_BUF_CANCEL_BUCKET(log, blkno) \
((log)->l_buf_cancel_table + ((uint64_t)blkno % XLOG_BC_TABLE_SIZE))
#define XLOG_FORCED_SHUTDOWN(log) \
(unlikely((log)->l_flags & XLOG_IO_ERROR))
static inline bool
xlog_is_shutdown(struct xlog *log)
{
return (log->l_flags & XLOG_IO_ERROR);
}
/* common routines */
extern int
......
......@@ -143,7 +143,7 @@ xlog_do_io(
error = xfs_rw_bdev(log->l_targ->bt_bdev, log->l_logBBstart + blk_no,
BBTOB(nbblks), data, op);
if (error && !XFS_FORCED_SHUTDOWN(log->l_mp)) {
if (error && !xlog_is_shutdown(log)) {
xfs_alert(log->l_mp,
"log recovery %s I/O error at daddr 0x%llx len %d error %d",
op == REQ_OP_WRITE ? "write" : "read",
......@@ -3292,10 +3292,7 @@ xlog_do_recover(
if (error)
return error;
/*
* If IO errors happened during recovery, bail out.
*/
if (XFS_FORCED_SHUTDOWN(mp))
if (xlog_is_shutdown(log))
return -EIO;
/*
......@@ -3317,7 +3314,7 @@ xlog_do_recover(
xfs_buf_hold(bp);
error = _xfs_buf_read(bp, XBF_READ);
if (error) {
if (!XFS_FORCED_SHUTDOWN(mp)) {
if (!xlog_is_shutdown(log)) {
xfs_buf_ioerror_alert(bp, __this_address);
ASSERT(0);
}
......
......@@ -919,7 +919,7 @@ __xfs_trans_commit(
*/
xfs_trans_unreserve_and_mod_dquots(tp);
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);
else
xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册