Commit e9131e50 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: recovery of XLOG_UNMOUNT_TRANS leaks memory

The XLOG_UNMOUNT_TRANS case skips the transaction, despite the fact
an unmount record is always in a standalone transaction. Hence
whenever we come across one of these we need to free the transaction
structure associated with it as there is no commit record that
follows it.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent eeb11688
...@@ -3534,6 +3534,9 @@ xlog_recover_commit_trans( ...@@ -3534,6 +3534,9 @@ xlog_recover_commit_trans(
return error ? error : error2; return error ? error : error2;
} }
/*
* On error or completion, trans is freed.
*/
STATIC int STATIC int
xlog_recovery_process_trans( xlog_recovery_process_trans(
struct xlog *log, struct xlog *log,
...@@ -3543,7 +3546,8 @@ xlog_recovery_process_trans( ...@@ -3543,7 +3546,8 @@ xlog_recovery_process_trans(
unsigned int flags, unsigned int flags,
int pass) int pass)
{ {
int error = -EIO; int error = 0;
bool freeit = false;
/* mask off ophdr transaction container flags */ /* mask off ophdr transaction container flags */
flags &= ~XLOG_END_TRANS; flags &= ~XLOG_END_TRANS;
...@@ -3565,18 +3569,19 @@ xlog_recovery_process_trans( ...@@ -3565,18 +3569,19 @@ xlog_recovery_process_trans(
/* unexpected flag values */ /* unexpected flag values */
case XLOG_UNMOUNT_TRANS: case XLOG_UNMOUNT_TRANS:
/* just skip trans */
xfs_warn(log->l_mp, "%s: Unmount LR", __func__); xfs_warn(log->l_mp, "%s: Unmount LR", __func__);
error = 0; /* just skip trans */ freeit = true;
break; break;
case XLOG_START_TRANS: case XLOG_START_TRANS:
xfs_warn(log->l_mp, "%s: bad transaction", __func__);
ASSERT(0);
break;
default: default:
xfs_warn(log->l_mp, "%s: bad flag 0x%x", __func__, flags); xfs_warn(log->l_mp, "%s: bad flag 0x%x", __func__, flags);
ASSERT(0); ASSERT(0);
error = -EIO;
break; break;
} }
if (error || freeit)
xlog_recover_free_trans(trans);
return error; return error;
} }
...@@ -3620,7 +3625,6 @@ xlog_recover_process_ophdr( ...@@ -3620,7 +3625,6 @@ xlog_recover_process_ophdr(
int pass) int pass)
{ {
struct xlog_recover *trans; struct xlog_recover *trans;
int error;
unsigned int len; unsigned int len;
/* Do we understand who wrote this op? */ /* Do we understand who wrote this op? */
...@@ -3648,11 +3652,8 @@ xlog_recover_process_ophdr( ...@@ -3648,11 +3652,8 @@ xlog_recover_process_ophdr(
return 0; return 0;
} }
error = xlog_recovery_process_trans(log, trans, dp, len, return xlog_recovery_process_trans(log, trans, dp, len,
ohead->oh_flags, pass); ohead->oh_flags, pass);
if (error)
xlog_recover_free_trans(trans);
return error;
} }
/* /*
......
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