On Wed, 29 Nov 2000, Andreas Dilger wrote:

> What people who have the problem should be doing is:
> [desc snipped]
> > ls -li holed.file        # find inode number
> 10732 -rw-r--r--    1 root     root      6000000 Nov 29 16:17 holed.file
> > du -sk holed.file        # see what "stat" thinks
> 983k    holed.file
> > debugfs /dev/XXX
> debugfs> stats           # find out ext2 block size
> ...
> Block size = 1024, fragment size = 1024
> ...
> debugfs> stat <10732>  # (with < and >)
> Inode: 10732   Type: regular    Mode:  0644   Flags: 0x0   Generation:
> 4048594821
> User:     0   Group:     0   Size: 6000000
> File ACL: 0    Directory ACL: 0
> Links: 1   Blockcount: 1966
>                        ^^^^ these are 512-byte blocks, so / 2 for ~kB
>                           they include indirect blocks and such
> Fragment:  Address: 0    Number: 0    Size: 0
> ctime: 0x3a258e82 -- Wed Nov 29 16:17:22 2000
> atime: 0x3a258e82 -- Wed Nov 29 16:17:22 2000
> mtime: 0x3a258e82 -- Wed Nov 29 16:17:22 2000
> BLOCKS:
> 47512 47513 47514 47515 47516 47517 47518 47519 47520 ... 48723 48724
> TOTAL: 983
>        ^^^ these are ext2fs sized blocks, not necessarily kB
> 
> If what debugfs says doesn't match du, then it is du/libc/stat that is
> broken.  If debugfs says the file actually has 6000000 bytes of data,
> then it is the filesystem that is broken.

I just did what suggested, and it seems that DU reports correct values,
I have attached 'sript' log of the above example on my filesystem.
Here are some highlights:

[adam@pepsi /tmp]$ ls -lis holed.file
3085069 5872 -rw-rw-r--    1 adam     adam      6000000 Nov 30 09:11 holed.file

Block size = 4096, fragment size = 4096
Links: 1   Blockcount: 11744
TOTAL: 1468

so it seems DU reports correct values as :
        1966/2 =983
        11744/2=5872
and
        4096*1468=6012928
        1024*983 =1006592



-- 
Adam
http://www.eax.com      The Supreme Headquarters of the 32 bit registers

Script started on Thu Nov 30 09:11:40 2000
[adam@pepsi /tmp]$ dd if=/dev/zero of=holed.file bs=1000 seek=5000 count=1000
1000+0 records in
1000+0 records out
[adam@pepsi /tmp]$ ls -lis holed.file
3085069 5872 -rw-rw-r--    1 adam     adam      6000000 Nov 30 09:11 holed.file
[adam@pepsi /tmp]$ du -sh holed.file
5.7M    holed.file
[adam@pepsi /tmp]$ df .
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hde3             25474728  16986488   7173180  70% /
[adam@pepsi /tmp]$ su
Password: 
root@pepsi /tmp]# /usr/sbin/debugf /dev/hde3
debugfs 1.19, 13-Jul-2000 for EXT2 FS 0.5b, 95/08/09
debugfs:  stats
Filesystem is read-only
Volume name = (none)
Last mounted directory = (none)
Filesystem UUID = dacab8b6-cbae-11d3-867d-00200084fdb4
Filesystem features:(none)
Last mount time = Thu Nov 23 23:18:05 2000
Last write time = Thu Nov 30 09:12:56 2000
Mount counts = 1 (maximal = 20)
Filesystem OS type = Linux
Superblock size = 1024
Block size = 4096, fragment size = 4096
Inode size = 128
6579936 inodes, 6014036 free
6575310 blocks, 2122060 free, 328765 reserved, first block = 0
32768 blocks per group
32768 fragments per group
32736 inodes per group
201 groups (2 descriptors blocks)
 Group  0: block bitmap at 3, inode bitmap at 4, inode table at 5
           0 free blocks, 30118 free inodes, 106 used directories
 [....]
 Group 200: block bitmap at 6553603, inode bitmap at 6553604, inode table at 6553605
           13151 free blocks, 29887 free inodes, 334 used directories
debugfs:  stat <3085069>
Inode: 3085069   Type: regular    Mode:  0664   Flags: 0x0   Generation: 6660658
User:   500   Group:   500   Size: 6000000
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 11744
Fragment:  Address: 0    Number: 0    Size: 0
ctime: 0x3a266023 -- Thu Nov 30 09:11:47 2000
atime: 0x3a243c51 -- Tue Nov 28 18:14:25 2000
mtime: 0x3a266023 -- Thu Nov 30 09:11:47 2000
BLOCKS:
213226 [....] 167493 
TOTAL: 1468
debugfs:   quit
adam@pepsi: /tmp[root@pepsi /tmp]# exit
exit
adam@pepsi: /tmp[adam@pepsi /tmp]$ exit
exit
Script done on Thu Nov 30 09:16:27 2000

Reply via email to