growing filesystems in 5-current

Terry Lambert tlambert2 at mindspring.com
Thu Apr 17 10:42:15 PDT 2003


Lukas Ertl wrote:
> Consider again this 32 MB vinum volume. If I newfs it with the default
> size of 65536 sectors I get this:
> 
> ---8<---
> # newfs -O2 -s 65536 /dev/vinum/mytest
> /dev/vinum/mytest: 32.0MB (65536 sectors) block size 16384, fragment size
> 2048
>         using 4 cylinder groups of 8.02MB, 513 blks, 1088 inodes.
> super-block backups (for fsck -b #) at:
>  160, 16576, 32992, 49408
> 
> # df -k /dev/vinum/mytest
> Filesystem          1K-blocks     Used    Avail Capacity  Mounted on
> /dev/vinum/mytest       31470        2    28952    0.%
> ---8<---
> 
> Four cg's with 8.02MB each? 513 blocks? Why's that? Shouldn't that be 8MB
> each and 512 blocks?

The short answer for the first question is that the MB calculation
is not what you think.

The short answer for the second question is "because of the frag size".

So the answer to the last question is "no".

As to the available capacity, you can only use even numbers of
cylinder groups, because there's a bitmap.


> If I growfs this one I get the behaviour I described in my first mail.
> 
> Now look at this:
> 
> ---8<---
> # newfs -O2 -s 65535 /dev/vinum/mytest
> /dev/vinum/mytest: 32.0MB (65532 sectors) block size 16384, fragment size
> 2048

The most important thing to note here is that, before, you told
it 65536, and it gave you 65536.  Here you are asking for 65535,
and getting 65532.  That's 3 less sectors to get to a 4 sector
boundary, so that you have an even multiple of the frag size of
2048 (512b * 4 = 2048).


>         using 4 cylinder groups of 8.00MB, 512 blks, 1024 inodes.
> super-block backups (for fsck -b #) at:
>  160, 16544, 32928, 49312
> 
> # df -k /dev/vinum/mytest
> Filesystem          1K-blocks     Used    Avail Capacity  Mounted on
> /dev/vinum/mytest       31532        2    29008    0.%
> ---8<---
> 
> So I explicitly make the FS one sector smaller than the default value, and
> I get not only 4 cg's with 8 MB and 512 blocks (which would seem correct
> to me), but I also get more space available on the FS.

If you want to know exactly where it comes from, you've added
additional frags, which are counted in the numbers, so you get
those additional "whole disk blocks.  We can do the math again:

	29008(1K) - 28952(1K) = 48(1K) = 24(2K) / 3 = 8(2K)

	...and you have a total of 8 cylinder groups.

Only whole file system blocks are considered for the calculation
of the free reserve, so you get "more free space" that's not tied
up in 16K disk blocks.


> And if I growfs this one, everything works as expected:

[ ... ]

> What the heck is going on here? newfs bug? Or did I get something wrong?

Nope; just power of two math, and an impedence mismatch in
rounding.  8-).

-- Terry


More information about the freebsd-fs mailing list