NVSL / linux-nova

NOVA is a log-structured file system designed for byte-addressable non-volatile memories, developed at the University of California, San Diego.
http://nvsl.ucsd.edu/index.php?path=projects/nova
Other
421 stars 117 forks source link

XFSTests generic/422: stat returns a larger block count than it should #18

Closed stevenjswanson closed 7 years ago

stevenjswanson commented 7 years ago

The specific failure in in generic/422 is that du -h returns 72k for files that should be 64k.
df uses stat to compute the file size, so it would seem that this behavior from stat is the cause.

I thought possible source of bug is inode.c:1201, but that's not it. inode->i_blocks is too high. Run script below and watch dmesg.

# yes | head -100 | sudo su -c 'cat > /tmp/foo1'
# /usr/bin/stat  /tmp/foo1
  File: /tmp/foo1
  Size: 200         Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d  Inode: 288         Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-06-30 06:46:32.972508176 +0000
Modify: 2017-06-30 06:46:32.972508176 +0000
Change: 2017-06-30 06:46:32.972508176 +0000
 Birth: -

#  yes | head -100 | sudo su -c 'cat > /mnt/ramdisk/foo1 '
#  /usr/bin/stat  /mnt/ramdisk/foo1
  File: /mnt/ramdisk/foo1
  Size: 200         Blocks: 7992       IO Block: 4096   regular file
Device: 10301h/66305d   Inode: 43          Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-06-30 06:39:55.256860931 +0000
Modify: 2017-06-30 06:45:21.000000000 +0000
Change: 2017-06-30 06:45:21.000000000 +0000
 Birth: -

Useful script:

for i in /tmp/foo /mnt/ramdisk/foo; do 
    sudo dd if=/dev/zero of=$i bs=1k count=1 >/dev/null 2>/dev/null;    
    du $i;
done
4   /tmp/foo
316 /mnt/ramdisk/foo