Commit b911ca04 authored by David Chinner's avatar David Chinner Committed by Lachlan McIlroy

[XFS] Sanitise xfs_log_force error checking.

xfs_log_force() is declared to return an error, but we almost never check
it. We don't need to check it in most cases; if there's a log I/O error
then we'll be shutting down the filesystem anyway and that means we'll
catch the error somewhere else.

However, on certain calls we should be returning an error - sync
transactions, fsync, sync writes, etc. so this isn't a pure black and
white distinction. Hence make xfs_log_force() a void function that issues
a warning to the syslog on error, and call _xfs_log_force() in all the
places where we actually care about the error status returned.

SGI-PV: 980084
SGI-Modid: xfs-linux-melb:xfs-kern:30832a
Signed-off-by: default avatarDavid Chinner <dgc@sgi.com>
Signed-off-by: default avatarNiv Sardi <xaiki@sgi.com>
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
parent 234f56ac
...@@ -382,7 +382,27 @@ _xfs_log_force( ...@@ -382,7 +382,27 @@ _xfs_log_force(
return xlog_state_sync_all(log, flags, log_flushed); return xlog_state_sync_all(log, flags, log_flushed);
else else
return xlog_state_sync(log, lsn, flags, log_flushed); return xlog_state_sync(log, lsn, flags, log_flushed);
} /* xfs_log_force */ } /* _xfs_log_force */
/*
* Wrapper for _xfs_log_force(), to be used when caller doesn't care
* about errors or whether the log was flushed or not. This is the normal
* interface to use when trying to unpin items or move the log forward.
*/
void
xfs_log_force(
xfs_mount_t *mp,
xfs_lsn_t lsn,
uint flags)
{
int error;
error = _xfs_log_force(mp, lsn, flags, NULL);
if (error) {
xfs_fs_cmn_err(CE_WARN, mp, "xfs_log_force: "
"error %d returned.", error);
}
}
/* /*
* Attaches a new iclog I/O completion callback routine during * Attaches a new iclog I/O completion callback routine during
...@@ -634,7 +654,8 @@ xfs_log_unmount_write(xfs_mount_t *mp) ...@@ -634,7 +654,8 @@ xfs_log_unmount_write(xfs_mount_t *mp)
if (mp->m_flags & XFS_MOUNT_RDONLY) if (mp->m_flags & XFS_MOUNT_RDONLY)
return 0; return 0;
xfs_log_force(mp, 0, XFS_LOG_FORCE|XFS_LOG_SYNC); error = _xfs_log_force(mp, 0, XFS_LOG_FORCE|XFS_LOG_SYNC, NULL);
ASSERT(error || !(XLOG_FORCED_SHUTDOWN(log)));
#ifdef DEBUG #ifdef DEBUG
first_iclog = iclog = log->l_iclog; first_iclog = iclog = log->l_iclog;
......
...@@ -142,8 +142,9 @@ int _xfs_log_force(struct xfs_mount *mp, ...@@ -142,8 +142,9 @@ int _xfs_log_force(struct xfs_mount *mp,
xfs_lsn_t lsn, xfs_lsn_t lsn,
uint flags, uint flags,
int *log_forced); int *log_forced);
#define xfs_log_force(mp, lsn, flags) \ void xfs_log_force(struct xfs_mount *mp,
_xfs_log_force(mp, lsn, flags, NULL); xfs_lsn_t lsn,
uint flags);
int xfs_log_mount(struct xfs_mount *mp, int xfs_log_mount(struct xfs_mount *mp,
struct xfs_buftarg *log_target, struct xfs_buftarg *log_target,
xfs_daddr_t start_block, xfs_daddr_t start_block,
......
...@@ -126,11 +126,11 @@ xfs_write_sync_logforce( ...@@ -126,11 +126,11 @@ xfs_write_sync_logforce(
* when we return. * when we return.
*/ */
if (iip && iip->ili_last_lsn) { if (iip && iip->ili_last_lsn) {
xfs_log_force(mp, iip->ili_last_lsn, error = _xfs_log_force(mp, iip->ili_last_lsn,
XFS_LOG_FORCE | XFS_LOG_SYNC); XFS_LOG_FORCE | XFS_LOG_SYNC, NULL);
} else if (xfs_ipincount(ip) > 0) { } else if (xfs_ipincount(ip) > 0) {
xfs_log_force(mp, (xfs_lsn_t)0, error = _xfs_log_force(mp, (xfs_lsn_t)0,
XFS_LOG_FORCE | XFS_LOG_SYNC); XFS_LOG_FORCE | XFS_LOG_SYNC, NULL);
} }
} else { } else {
......
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