From 148262ed9ab8034b431b125c9748ecbdb3b3f7aa Mon Sep 17 00:00:00 2001 From: mjacob Date: Mon, 5 Oct 2009 01:31:16 +0000 Subject: 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 --- sbin/growfs/growfs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sbin/growfs') 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; } /* -- cgit v1.1