]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs_repair: use libxfs function to calculate root inode location
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 27 Feb 2020 20:05:00 +0000 (15:05 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Thu, 27 Feb 2020 20:05:00 +0000 (15:05 -0500)
Use libxfs_ialloc_calc_rootino to compute the location of the root
inode, and improve the function comments while we're at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
repair/globals.c
repair/globals.h
repair/xfs_repair.c

index 8a60e706d94084cb66444f90a1c173774dd0a3e1..299bacd131329fb5a8d6842496da97a0ec22580a 100644 (file)
@@ -72,11 +72,6 @@ int  lost_uquotino;
 int    lost_gquotino;
 int    lost_pquotino;
 
-xfs_agino_t    first_prealloc_ino;
-xfs_agblock_t  bnobt_root;
-xfs_agblock_t  bcntbt_root;
-xfs_agblock_t  inobt_root;
-
 /* configuration vars -- fs geometry dependent */
 
 int            inodes_per_block;
index 2ed5c894643c86f4a46e5ac34fd248128ea97c68..953e3dfbb4f2a10cdd4422d45d0623e0e7238be7 100644 (file)
@@ -113,11 +113,6 @@ extern int         lost_uquotino;
 extern int             lost_gquotino;
 extern int             lost_pquotino;
 
-extern xfs_agino_t     first_prealloc_ino;
-extern xfs_agblock_t   bnobt_root;
-extern xfs_agblock_t   bcntbt_root;
-extern xfs_agblock_t   inobt_root;
-
 /* configuration vars -- fs geometry dependent */
 
 extern int             inodes_per_block;
index f8005f8a2962a79fe2981d76c20070ad39acd688..111306fe0e5dd9fdd75d1b7d6b87f05f407aa637 100644 (file)
@@ -426,79 +426,23 @@ _("would reset superblock %s inode pointer to %"PRIu64"\n"),
        *ino = expected_ino;
 }
 
+/*
+ * Make sure that the first 3 inodes in the filesystem are the root directory,
+ * the realtime bitmap, and the realtime summary, in that order.
+ */
 static void
-calc_mkfs(xfs_mount_t *mp)
+calc_mkfs(
+       struct xfs_mount        *mp)
 {
-       xfs_agblock_t   fino_bno;
-       int             do_inoalign;
-
-       do_inoalign = M_IGEO(mp)->ialloc_align;
-
-       /*
-        * Pre-calculate the geometry of ag 0. We know what it looks like
-        * because we know what mkfs does: 2 allocation btree roots (by block
-        * and by size), the inode allocation btree root, the free inode
-        * allocation btree root (if enabled) and some number of blocks to
-        * prefill the agfl.
-        *
-        * Because the current shape of the btrees may differ from the current
-        * shape, we open code the mkfs freelist block count here. mkfs creates
-        * single level trees, so the calculation is pertty straight forward for
-        * the trees that use the AGFL.
-        */
-       bnobt_root = howmany(4 * mp->m_sb.sb_sectsize, mp->m_sb.sb_blocksize);
-       bcntbt_root = bnobt_root + 1;
-       inobt_root = bnobt_root + 2;
-       fino_bno = inobt_root + (2 * min(2, mp->m_ag_maxlevels)) + 1;
-       if (xfs_sb_version_hasfinobt(&mp->m_sb))
-               fino_bno++;
-       if (xfs_sb_version_hasrmapbt(&mp->m_sb)) {
-               fino_bno += min(2, mp->m_rmap_maxlevels); /* agfl blocks */
-               fino_bno++;
-       }
-       if (xfs_sb_version_hasreflink(&mp->m_sb))
-               fino_bno++;
+       xfs_ino_t               rootino;
 
-       /*
-        * 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_logstart &&
-           XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == 0) {
+       rootino = libxfs_ialloc_calc_rootino(mp, mp->m_sb.sb_unit);
 
-               /*
-                * XXX(hch): verify that sb_logstart makes sense?
-                */
-                fino_bno += mp->m_sb.sb_logblocks;
-       }
-
-       /*
-        * ditto the location of the first inode chunks in the fs ('/')
-        */
-       if (xfs_sb_version_hasdalign(&mp->m_sb) && do_inoalign)  {
-               first_prealloc_ino = XFS_AGB_TO_AGINO(mp, roundup(fino_bno,
-                                       mp->m_sb.sb_unit));
-       } else if (xfs_sb_version_hasalign(&mp->m_sb) &&
-                                       mp->m_sb.sb_inoalignmt > 1)  {
-               first_prealloc_ino = XFS_AGB_TO_AGINO(mp,
-                                       roundup(fino_bno,
-                                               mp->m_sb.sb_inoalignmt));
-       } else  {
-               first_prealloc_ino = XFS_AGB_TO_AGINO(mp, fino_bno);
-       }
-
-       /*
-        * now the first 3 inodes in the system
-        */
-       validate_sb_ino(&mp->m_sb.sb_rootino, first_prealloc_ino,
+       validate_sb_ino(&mp->m_sb.sb_rootino, rootino,
                        _("root"));
-       validate_sb_ino(&mp->m_sb.sb_rbmino, first_prealloc_ino + 1,
+       validate_sb_ino(&mp->m_sb.sb_rbmino, rootino + 1,
                        _("realtime bitmap"));
-       validate_sb_ino(&mp->m_sb.sb_rsumino, first_prealloc_ino + 2,
+       validate_sb_ino(&mp->m_sb.sb_rsumino, rootino + 2,
                        _("realtime summary"));
 }