Re: BUG in ext2 file-system: extending a file using lseek()

Stephen C. Tweedie (sct@dcs.ed.ac.uk)
Tue, 17 Feb 1998 00:07:46 GMT


Hi,

On Sun, 15 Feb 1998 23:47:40 -0500, Chris Rankin <rankinc@bellsouth.net> said:

> I have been sweating blood trying to get my block quotas to agree on
> my ext2 partition recently - it seems that a file-system bug is partly
> responsible. I managed to produce this directory entry by extending a
> file using lseek() (according to the manual, this use of lseek is
> allowed):

> ...

> The guilty party here is the file TESTME. I trust you will agree that an
> 8016-byte file should use more than one block on a 1024 byte-blocksize
> filesystem (which I have)...

No!

Not all blocks within a file actually have to be allocated on disk. If
you lseek way beyond the end of file and write data, then the space
between the old end of file and the new data is completely unallocated
(it's termed a "hole" in the file). It will read as zeros if you try
to examine it.

Quotas count all of the blocks used by files *on disk*. Sometimes this
is less than the filesize, because of holes in the files. Sometimes it
is more than the filesize, because files larger than 12 blocks need to
have extra mapping blocks allocated on disk to identify where the data
blocks live, and these indirect blocks also get charged to quotas.

Cheers,
Stephen.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu