Bug in Newfs setting max-extend-size

Loren M. Lang lorenl at north-winds.org
Tue Aug 28 21:09:27 PDT 2007


I was reading through the newfs source code for FreeBSD 6.1-RELEASE and
noticed some oddities between the man page for newfs and it's source
related to max-extent-size (-d).  Newfs claims that the default is 16
times the filesystem blocksize. ("... It is presently limited to its
default value which is 16 times the file system blocksize.")  However,
in the source code, if maxbsize is not specified, it is assigned bsize,
not 16*bsize.
newfs.c:

        if (maxbsize == 0)
                maxbsize = bsize;

Also, in mkfs.c, mkfs() does some sanity checks on maxbsize, but in the
second if statement on line 211, it checks sblock.fs_maxbsize, not
maxbsize, but as far as I can tell, sblock.fs_maxbsize is not yet
initialized.
mkfs.c:

        if (maxbsize < bsize || !POWEROF2(maxbsize)) {
                sblock.fs_maxbsize = sblock.fs_bsize;
                printf("Extent size set to %d\n", sblock.fs_maxbsize);
        } else if (sblock.fs_maxbsize > FS_MAXCONTIG * sblock.fs_bsize) {
                sblock.fs_maxbsize = FS_MAXCONTIG * sblock.fs_bsize;
                printf("Extent size reduced to %d\n", sblock.fs_maxbsize);
        } else {
                sblock.fs_maxbsize = maxbsize;
        }

Unless I am misunderstanding something, the else if() should read:

        } else if (maxbsize > FS_MAXCONTIG * sblock.fs_bsize) {

This appears to be the same in FreeBSD-CURRENT as well.
-- 
Loren M. Lang
lorenl at north-winds.org
http://www.north-winds.org/


Public Key: ftp://ftp.north-winds.org/pub/lorenl_pubkey.asc
Fingerprint: CEE1 AAE2 F66C 59B5 34CA  C415 6D35 E847 0118 A3D2


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20070829/53165fe9/signature.pgp


More information about the freebsd-fs mailing list