Mysterious block count (reproducible)

Oliver Fromme olli at lurza.secnetix.de
Fri Feb 2 20:05:58 UTC 2007


Hi

The following is on a standard UFS2 file system under
FreeBSD 6.2, block size 16 KB, fragsize 2 KB.  The
filesystems are perfectly ok and fsck-clean.  There
haven't been any physical disk errors either.

I've got a file on my home partition that's 214848 bytes.
According to math it should occupy 14 blocks.  However:

$ BLOCKSIZE=16K ls -s foo
 15 foo

I copied the file to /tmp (which is an mdfs, also UFS2
with default parameters).  Same result.  I created a
fresh file from /dev/zero of 214848 bytes.  The same.

Where does the 15th block come from?  Those additional
16 KB must be used for _something_ somewhere ...

fsdb(8) isn't helpful either:

   # fsdb -r /dev/md0
   fsdb (inum: 2)> ls
   [...]
   slot 7 ino 5 reclen 20: regular, `foo'
   fsdb (inum: 2)> inode 5
   current inode: regular file
   I=5 MODE=100600 SIZE=214848
           BTIME=Feb  2 20:46:02 2007 [0 nsec]
           MTIME=Feb  2 20:46:02 2007 [0 nsec]
           CTIME=Feb  2 20:46:02 2007 [0 nsec]
           ATIME=Feb  2 20:46:58 2007 [0 nsec]
   OWNER=root GRP=wheel LINKCNT=1 FLAGS=0 BLKCNT=1e0 GEN=ffffffffe2ca5220

0x1e0 is 224 (== 14 * 16).  So fsdb(8) doesn't see the
15th block either.  To confirm:

   fsdb (inum: 5)> blocks
   Blocks for inode 5:
   Direct blocks:
   2136, 2144, 2152, 2160, 2168, 2176, 2184, 2192, 2248, 2256, 2264, 2272
   Indirect blocks:
   2280, 2288,
   fsdb (inum: 5)> 

It lists 12 direct blocks and 2 indirect blocks, that's
still 14 blocks, not 15.

Where did the 15th block go?!?  Or is there a bug in
the calculation of ls -s output?

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606, USt-Id: DE204219783
Any opinions expressed in this message are personal to the author and may
not necessarily reflect the opinions of secnetix GmbH & Co KG in any way.
FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"Being really good at C++ is like being really good
at using rocks to sharpen sticks."
        -- Thant Tessman


More information about the freebsd-fs mailing list