summaryrefslogtreecommitdiffstats
path: root/sbin/growfs
diff options
context:
space:
mode:
authormjacob <mjacob@FreeBSD.org>2009-10-05 01:31:16 +0000
committermjacob <mjacob@FreeBSD.org>2009-10-05 01:31:16 +0000
commit148262ed9ab8034b431b125c9748ecbdb3b3f7aa (patch)
tree232addd561529e9358f3f9f79b853d6c9805dad6 /sbin/growfs
parent8b48b371755f684fe32f6668e143abb734b26ea0 (diff)
downloadFreeBSD-src-148262ed9ab8034b431b125c9748ecbdb3b3f7aa.zip
FreeBSD-src-148262ed9ab8034b431b125c9748ecbdb3b3f7aa.tar.gz
The cylinder group tag cg_initediblk needs to match the number of inodes
actually initialized. In the growfs case for UFS2, no inodes were actually being initialized and the number of inodes noted as initialized was the number of inodes per group. This created a filesystem that was deemed corrupted because the inodes thus added were full of garbage. MFC after: 1 month
Diffstat (limited to 'sbin/growfs')
-rw-r--r--sbin/growfs/growfs.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c
index 89b14da..96b5c6c 100644
--- a/sbin/growfs/growfs.c
+++ b/sbin/growfs/growfs.c
@@ -397,11 +397,17 @@ initcg(int cylno, time_t utime, int fso, unsigned int Nflag)
dupper += howmany(sblock.fs_cssize, sblock.fs_fsize);
cs = &fscs[cylno];
memset(&acg, 0, sblock.fs_cgsize);
+ /*
+ * Note that we do not set cg_initediblk at all.
+ * In this extension of a previous filesystem
+ * we have no inodes initialized for the cylinder
+ * group at all. The first access to that cylinder
+ * group will do the correct initialization.
+ */
acg.cg_time = utime;
acg.cg_magic = CG_MAGIC;
acg.cg_cgx = cylno;
acg.cg_niblk = sblock.fs_ipg;
- acg.cg_initediblk = sblock.fs_ipg;
acg.cg_ndblk = dmax - cbase;
if (sblock.fs_contigsumsize > 0)
acg.cg_nclusterblks = acg.cg_ndblk / sblock.fs_frag;
@@ -414,7 +420,6 @@ initcg(int cylno, time_t utime, int fso, unsigned int Nflag)
acg.cg_time = 0;
acg.cg_old_niblk = acg.cg_niblk;
acg.cg_niblk = 0;
- acg.cg_initediblk = 0;
acg.cg_old_btotoff = start;
acg.cg_old_boff = acg.cg_old_btotoff +
sblock.fs_old_cpg * sizeof(int32_t);
@@ -2217,6 +2222,7 @@ main(int argc, char **argv)
printf("Warning: %jd sector(s) cannot be allocated.\n",
(intmax_t)fsbtodb(&sblock, sblock.fs_size % sblock.fs_fpg));
sblock.fs_size = sblock.fs_ncg * sblock.fs_fpg;
+ maxino -= sblock.fs_ipg;
}
/*
OpenPOWER on IntegriCloud