Commit 6b789c33 authored by Brian Foster's avatar Brian Foster Committed by Darrick J. Wong

xfs: fix iclog release error check race with shutdown

Prior to commit df732b29 ("xfs: call xlog_state_release_iclog with
l_icloglock held"), xlog_state_release_iclog() always performed a
locked check of the iclog error state before proceeding into the
sync state processing code. As of this commit, part of
xlog_state_release_iclog() was open-coded into
xfs_log_release_iclog() and as a result the locked error state check
was lost.

The lockless check still exists, but this doesn't account for the
possibility of a race with a shutdown being performed by another
task causing the iclog state to change while the original task waits
on ->l_icloglock. This has reproduced very rarely via generic/475
and manifests as an assert failure in __xlog_state_release_iclog()
due to an unexpected iclog state.

Restore the locked error state check in xlog_state_release_iclog()
to ensure that an iclog state update via shutdown doesn't race with
the iclog release state processing code.

Fixes: df732b29 ("xfs: call xlog_state_release_iclog with l_icloglock held")
Reported-by: default avatarZorro Lang <zlang@redhat.com>
Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-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 98d54f81
...@@ -605,18 +605,23 @@ xfs_log_release_iclog( ...@@ -605,18 +605,23 @@ xfs_log_release_iclog(
struct xlog *log = mp->m_log; struct xlog *log = mp->m_log;
bool sync; bool sync;
if (iclog->ic_state == XLOG_STATE_IOERROR) { if (iclog->ic_state == XLOG_STATE_IOERROR)
xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR); goto error;
return -EIO;
}
if (atomic_dec_and_lock(&iclog->ic_refcnt, &log->l_icloglock)) { if (atomic_dec_and_lock(&iclog->ic_refcnt, &log->l_icloglock)) {
if (iclog->ic_state == XLOG_STATE_IOERROR) {
spin_unlock(&log->l_icloglock);
goto error;
}
sync = __xlog_state_release_iclog(log, iclog); sync = __xlog_state_release_iclog(log, iclog);
spin_unlock(&log->l_icloglock); spin_unlock(&log->l_icloglock);
if (sync) if (sync)
xlog_sync(log, iclog); xlog_sync(log, iclog);
} }
return 0; return 0;
error:
xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR);
return -EIO;
} }
/* /*
......
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