Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jun 2003 19:38:36 +0200 (MEST)
From:      Per Kristian Hove <Per.Hove@math.ntnu.no>
To:        freebsd-current@freebsd.org
Subject:   Re: geom_vol_ffs problems
Message-ID:  <Pine.GSO.4.52.0306061813000.17732@abel.math.ntnu.no>
In-Reply-To: <Pine.GSO.4.52.0306041435020.6491@abel.math.ntnu.no>
References:  <Pine.GSO.4.52.0306041435020.6491@abel.math.ntnu.no>

next in thread | previous in thread | raw e-mail | index | archive | help
I've nailed it down to this: geom_vol_ffs assumes that a file system
is able to fill the partition completely. That's not a valid
assumption, since the file system size is a multiple of the file
system block size (in my case 16k bytes = 32 blocks), and the
partition size is/should be a multiple of the sectors/cylinder count
(in my case 1008).

For this assumption to be valid, the sectors/cylinder count would have
to be a multiple of the file system block size (measured in blocks),
and there's no guarantee that that's the case.

In my case, the size of the filesystem on ad0s3f (the one that does
not appear in /dev/vol/) is one block less than the size of ad0s3f
itself, so geom_vol_ffs refuses to create a provider for it (lines 96
and 102 in geom_vol_ffs.c):

	if (fs->fs_old_size * fs->fs_fsize !=
	    (int32_t) pp->mediasize) {
		g_free(fs);
		continue;
	}

Part of the problem here is my disklabel - it's hand-made, and the
size of the "f" partition (where geom_vol_ffs fails) is an odd number
- 3054277 - so that's impossible for the file system to fill it
completely.

I should create my disklabels so that the size of each partition is a
multiple of the number of sectors per cylinder. However, this is not
sufficient for geom_vol_ffs to do what it's supposed to, for the
reason explained above.

I think geom_vol_ffs.c at least should test for this instead:

	if ((fs->fs_old_size * fs->fs_fsize >
	     (int32_t) pp->mediasize) ||
	    ((int32_t) pp->mediasize - fs->fs_old_size * fs->fs_fsize >=
	     fs->fs_bsize)) {
		g_free(fs);
		continue;
	}

The (fs->fs_old_size * fs->fs_fsize > (int32_t) pp->mediasize) test is
probably not sufficient by itself, unless GEOM is modified to ignore
"c" partitions, that usually start with a valid UFS magic (unless the
partition with offset 0 is a swap partition, of course).

I would prefer telling GEOM to ignore "c" partitions, and test for
this:

	if (fs->fs_old_size * fs->fs_fsize >
	    (int32_t) pp->mediasize) {
		g_free(fs);
		continue;
	}

as that would make geom_vol_ffs continue to work even if you dd(1) an
existing file system from a small to a larger partition/disk, but that
may have other implications I'm not aware of?


-- 
Per Kristian Hove
Dept. of Mathematical Sciences
Norwegian University of Science and Technology



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.52.0306061813000.17732>