]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
repair: handle filesystems with the log in allocation group 0
authorChristoph Hellwig <hch@lst.de>
Wed, 11 Jan 2012 18:52:21 +0000 (18:52 +0000)
committerChristoph Hellwig <hch@lst.de>
Wed, 11 Jan 2012 18:52:21 +0000 (18:52 +0000)
Sindre Skogen reported that repair chokes on a very small filesystem created
by mkfs.xfs from xfsprogs 2.9.4.  It turned out that for some reason this
filesystem had the log in allocation group 0 and thus repairs validation
of the root inode number was off.  Fix this by adding the log blocks if
the log is allocated in allocation group 0.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reported-by: Sindre Skogen <sindre@workzone.no>
Signed-off-by: Christoph Hellwig <hch@lst.de>
repair/xfs_repair.c

index 69b7eabf499bcf1bb82747115e5c94f851ed82ee..a30ff0d9d9e74709ae18a18b5477f0634618cdfc 100644 (file)
@@ -417,12 +417,16 @@ calc_mkfs(xfs_mount_t *mp)
        fino_bno = inobt_root + XFS_MIN_FREELIST_RAW(1, 1, mp) + 1;
 
        /*
-        * If we only have a single allocation group the log is also allocated
-        * in the first allocation group and we need to add the number of
-        * blocks used by the log to the above calculation.
-        * All this of course doesn't apply if we have an external log.
+        * If the log is allocated in the first allocation group we need to
+        * add the number of blocks used by the log to the above calculation.
+        *
+        * This can happens with filesystems that only have a single
+        * allocation group, or very odd geometries created by old mkfs
+        * versions on very small filesystems.
         */
-       if (mp->m_sb.sb_agcount == 1 && mp->m_sb.sb_logstart) {
+       if (mp->m_sb.sb_logstart &&
+           XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == 0) {
+
                /*
                 * XXX(hch): verify that sb_logstart makes sense?
                 */