Mysterious block count (reproducible)
Oliver Fromme
olli at lurza.secnetix.de
Mon Feb 5 15:28:49 UTC 2007
Bernd Walter wrote:
> Oliver Fromme wrote:
> > [...]
> > $ BLOCKSIZE=16K ls -s foo
> > 15 foo
> > # fsdb -r /dev/md0
> > [...]
> > 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?
(Meanwhile I found out that ls(1) doesn't really calculate
anything; it simply displays the st_blocks value from the
stat structure rounded to $BLOCKSIZE, of course.)
> Don't forget the block needed for the indirect table.
> fsdb only shows data blocks it seems.
Oh, OK ... I really assumed that fsdb would display them
as soon as they come into play. :-(
What I'm trying to do is to write a small script that
calculates the allocation vs. virtual size ratio of
sparse files. For that purpose I have to find out how
many blocks a file would require if it wasn't sparse.
Is there are an easy way to get that information?
I have currently hardcoded some information in the
script, but it's an ugly hack:
http://www.secnetix.de/~olli/scripts/sparsecheck
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
"IRIX is about as stable as a one-legged drunk with hypothermia
in a four-hundred mile per hour wind, balancing on a banana
peel on a greased cookie sheet -- when someone throws him an
elephant with bad breath and a worse temper."
-- Ralf Hildebrandt
More information about the freebsd-fs
mailing list