[PATCH v2 08/12] xfs_repair: process the log in no_modify mode

Brian Foster
2015-09-11T18:55:46Z

xfs_repair does not zero the log in no_modify mode. In doing so, it also
skips the function that scans the log, locates the head/tail blocks and
sets the current LSN. Now that the log state is used beyond phase 2, the
log scan must occur regardless of whether no_modify mode is enabled or
not.

Update phase 2 to always execute the log scanning code. Push down the
no_modify checks into the log clearing helper such that the log is still
not modified in no_modify mode.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
repair/phase2.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/repair/phase2.c b/repair/phase2.c
index 11504e3..72132ce 100644
--- a/repair/phase2.c
+++ b/repair/phase2.c
@@ -75,7 +75,7 @@ zero_log(xfs_mount_t *mp)
_("zero_log: head block %" PRId64 " tail block %" PRId64 "\n"),
head_blk, tail_blk);
}
- if (head_blk != tail_blk) {
+ if (!no_modify && head_blk != tail_blk) {
if (zap_log) {
do_warn(_(
"ALERT: The filesystem has valuable metadata changes in a log which is being\n"
@@ -93,6 +93,9 @@ zero_log(xfs_mount_t *mp)
}
}

+ if (no_modify)
+ return;
+
libxfs_log_clear(log->l_dev, XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
(xfs_extlen_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks),
&mp->m_sb.sb_uuid,
@@ -136,10 +139,8 @@ phase2(
do_log(_("Phase 2 - using internal log\n"));

/* Zero log if applicable */
- if (!no_modify) {
- do_log(_(" - zero log...\n"));
- zero_log(mp);
- }
+ do_log(_(" - zero log...\n"));
+ zero_log(mp);

do_log(_(" - scan filesystem freespace and inode maps...\n"));