Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jun 2001 16:24:08 +0100
From:      Ian Dowse <iedowse@maths.tcd.ie>
To:        Nick Barnes <Nick.Barnes@pobox.com>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: FFS fs_maxfilesize 
Message-ID:   <200106141624.aa46907@salmon.maths.tcd.ie>
In-Reply-To: Your message of "Thu, 14 Jun 2001 14:11:57 BST." <9908.992524317@thrush.ravenbrook.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <9908.992524317@thrush.ravenbrook.com>, Nick Barnes writes:
>But when I try to create an exceedingly large file (by lseek()ing a
>long way and writing 4 bytes), it tops out with EFBIG at a little bit
>bigger than 2^24 (4 TB).  By my reckoning, this is also the maximum
>size of the actual filesystem (with default fsize (2^10) and
>ufs_daddr_t a 32-bit type).
>
>So should the computation of maxfilesize be corrected?

No, fs_maxfilesize correctly contains the maximum file size supported
by the filesystem; it is the kernel that currently cannot deal with
more than 2^31 logical blocks, so it further limits the file size.
It actually limits the file size to 2^30 logical blocks for safety
- I think Bruce Evans once mentioned some place in ffs_fsync()
where this helps avoid an overflow.

So the file-size limit that is actually enforced is the lesser of
the following two limits:

 1)	fs_maxfilesize, as determined by NIADDR, NDADDR, block size
	when the filesystem is first created. For NIADDR=3, NDADDR=12,
	block size B, this is:

		B*12 + B^2/4 + B^3/4^2 + B^4/4^3

 2)	The kernel limit of 2^30 logical blocks. For block size B that
	is:

		B * 2^30 - 1

For a filesystem with 8k blocks, these work out as 70403120791552
bytes (~64TB) and 8796093022207 bytes (~8TB) respectively. With 4k
blocks, the fs_maxfilesize limit is smaller than the LBN one.

The kernel code for limiting the file size is a bit strange - it
changes the value of fs_maxfilesize in the in-core superblock, and
changes it back before writing the superblock back to disk. The
relevant code is in ffs_vfsops.c:

        ump->um_savedmaxfilesize = fs->fs_maxfilesize;          /* XXX */
        maxfilesize = (u_int64_t)0x40000000 * fs->fs_bsize - 1; /* XXX */
        if (fs->fs_maxfilesize > maxfilesize)                   /* XXX */
                fs->fs_maxfilesize = maxfilesize;               /* XXX */

At some point, the kernel could be changed to allow files with
more than 2^31 logical blocks, so the superblock fs_maxfilesize
field should specify only the filesystem-induced limit and not
reflect the current kernel limitations.

Ian

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-fs" in the body of the message




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