From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, alex@zadara.com
Subject: [PATCH 5/6] xfs_repair: use libxfs function to calculate root inode location
Date: Wed, 04 Dec 2019 09:04:56 -0800 [thread overview]
Message-ID: <157547909625.974712.1367837692462388821.stgit@magnolia> (raw)
In-Reply-To: <157547906289.974712.8933333382010386076.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
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>
---
repair/globals.c | 5 ---
repair/globals.h | 5 ---
repair/xfs_repair.c | 78 +++++++--------------------------------------------
3 files changed, 10 insertions(+), 78 deletions(-)
diff --git a/repair/globals.c b/repair/globals.c
index 8a60e706..299bacd1 100644
--- a/repair/globals.c
+++ b/repair/globals.c
@@ -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;
diff --git a/repair/globals.h b/repair/globals.h
index 2ed5c894..953e3dfb 100644
--- a/repair/globals.h
+++ b/repair/globals.h
@@ -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;
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index 94673750..abd568c9 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -426,79 +426,21 @@ _("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++;
-
- /*
- * 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) {
-
- /*
- * 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);
- }
+ xfs_ino_t rootino = libxfs_ialloc_calc_rootino(mp, -1);
- /*
- * now the first 3 inodes in the system
- */
- ensure_fixed_ino(&mp->m_sb.sb_rootino, first_prealloc_ino,
+ ensure_fixed_ino(&mp->m_sb.sb_rootino, rootino,
_("root"));
- ensure_fixed_ino(&mp->m_sb.sb_rbmino, first_prealloc_ino + 1,
+ ensure_fixed_ino(&mp->m_sb.sb_rbmino, rootino + 1,
_("realtime bitmap"));
- ensure_fixed_ino(&mp->m_sb.sb_rsumino, first_prealloc_ino + 2,
+ ensure_fixed_ino(&mp->m_sb.sb_rsumino, rootino + 2,
_("realtime summary"));
}
next prev parent reply other threads:[~2019-12-04 17:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-04 17:04 [PATCH v2 0/6] xfs_repair: do not trash valid root dirs Darrick J. Wong
2019-12-04 17:04 ` [PATCH 1/6] xfs: don't commit sunit/swidth updates to disk if that would cause repair failures Darrick J. Wong
2019-12-04 17:04 ` [PATCH 2/6] mkfs: check root inode location Darrick J. Wong
2019-12-05 14:36 ` Brian Foster
2019-12-04 17:04 ` [PATCH 3/6] xfs_repair: enforce that inode btree chunks can't point to AG headers Darrick J. Wong
2019-12-05 14:37 ` Brian Foster
2019-12-05 16:28 ` Darrick J. Wong
2019-12-06 16:00 ` Brian Foster
2019-12-12 19:11 ` Eric Sandeen
2019-12-12 20:38 ` Eric Sandeen
2019-12-12 22:10 ` Darrick J. Wong
2019-12-04 17:04 ` [PATCH 4/6] xfs_repair: refactor fixed inode location checks Darrick J. Wong
2019-12-05 14:37 ` Brian Foster
2019-12-04 17:04 ` Darrick J. Wong [this message]
2019-12-05 14:37 ` [PATCH 5/6] xfs_repair: use libxfs function to calculate root inode location Brian Foster
2019-12-04 17:05 ` [PATCH 6/6] xfs_repair: check plausibility of root dir pointer before trashing it Darrick J. Wong
2019-12-05 14:38 ` Brian Foster
2019-12-12 22:46 ` [PATCH 6/6] xfs_repair: check plausibility of root dir pointer before trashing it\ Darrick J. Wong
2019-12-13 11:19 ` Brian Foster
2019-12-16 16:34 ` Darrick J. Wong
2019-12-17 11:32 ` Brian Foster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=157547909625.974712.1367837692462388821.stgit@magnolia \
--to=darrick.wong@oracle.com \
--cc=alex@zadara.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).