Bug 222876 - growfs messes with ufs filesystem size and checkums
Summary: growfs messes with ufs filesystem size and checkums
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-10-09 08:51 UTC by Sylvain Garrigues
Modified: 2017-10-10 19:23 UTC (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain Garrigues 2017-10-09 08:51:36 UTC
I just created an arm image with the usual steps found in https://github.com/freebsd/freebsd/blob/master/release/tools/arm.subr (cf arm_create_disk routine).

After first boot, growfs does its trick and df reports the partition is taking up the full space (32 GB in my case), but still my filesystem becomes full after a few package (original arm img size was 1.5 GB).

Additionally, I get hundreds of:
checksum failed: cg 19, cgp: 0x0 != bp: 0x61de29e7
on every boot now.
Comment 1 Edward Tomasz Napierala freebsd_committer freebsd_triage 2017-10-09 11:43:48 UTC
It looks like growfs(8) wasn't properly updated in r323923.  I'm guessing it should be rather easy to do, mostly copy/paste from fsck_ffs(8) code?
Comment 2 Konstantin Belousov freebsd_committer freebsd_triage 2017-10-09 12:20:22 UTC
(In reply to Edward Tomasz Napierala from comment #1)
Perhaps.  I do not have time to read growfs code now, so feel free to fix this.  The utility to (re)calculate the checksum is included into libufs.
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-10-09 13:29:30 UTC
A commit references this bug:

Author: pho
Date: Mon Oct  9 13:28:08 UTC 2017
New revision: 324428
URL: https://svnweb.freebsd.org/changeset/base/324428

Log:
  Added test scenario.

  PR:		222876
  Sponsored by:	Dell EMC Isilon

Changes:
  user/pho/stress2/misc/growfs.sh
Comment 4 Warner Losh freebsd_committer freebsd_triage 2017-10-09 14:57:40 UTC
I think this is the critical bit from pass5.c, ported over to the seemingly needlessly different conventions of growfs:

diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c
index 0aa4d4586e6..99b2034aae8 100644
--- a/sbin/growfs/growfs.c
+++ b/sbin/growfs/growfs.c
@@ -474,6 +474,13 @@ initcg(int cylno, time_t modtime, int fso, unsigned int Nflag)
                        sump[run]++;
                }
        }
+
+       if ((sblock.fs_metackhash & CK_CYLGRP) != 0) {
+               acg->cg_ckhash = 0;
+               acg->cg_ckhash =
+                   calculate_crc32c(~0L, (void *)newcg, fs->fs_cgsize);
+       }
+
        sblock.fs_cstotal.cs_ndir += acg.cg_cs.cs_ndir;
        sblock.fs_cstotal.cs_nffree += acg.cg_cs.cs_nffree;
        sblock.fs_cstotal.cs_nbfree += acg.cg_cs.cs_nbfree;
Comment 5 Warner Losh freebsd_committer freebsd_triage 2017-10-09 15:00:19 UTC
I think this is the critical bit from pass5.c, ported over to the seemingly needlessly different conventions of growfs:

diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c
index 0aa4d4586e6..99b2034aae8 100644
--- a/sbin/growfs/growfs.c
+++ b/sbin/growfs/growfs.c
@@ -474,6 +474,13 @@ initcg(int cylno, time_t modtime, int fso, unsigned int Nflag)
                        sump[run]++;
                }
        }
+
+       if ((sblock.fs_metackhash & CK_CYLGRP) != 0) {
+               acg->cg_ckhash = 0;
+               acg->cg_ckhash =
+                   calculate_crc32c(~0L, (void *)newcg, fs->fs_cgsize);
+       }
+
        sblock.fs_cstotal.cs_ndir += acg.cg_cs.cs_ndir;
        sblock.fs_cstotal.cs_nffree += acg.cg_cs.cs_nffree;
        sblock.fs_cstotal.cs_nbfree += acg.cg_cs.cs_nbfree;
Comment 6 Warner Losh freebsd_committer freebsd_triage 2017-10-10 19:21:31 UTC
kirk fixed this bug this morning after I sent an email yesterday asking about it...

https://svnweb.freebsd.org/base?view=revision&revision=324499
Comment 7 Sylvain Garrigues 2017-10-10 19:23:55 UTC
Thanks guys!