Hi,

I've hit an issue with the free space cache. It looks like we miss writing
everything to disk on unmount under rough conditions.

Setup: git head cmason/master, /dev/sdv1 is a 55MB partition on an SSD. Run the
following script:

--
DEV=/dev/sdv1
MP=/mnt/scratch

umount $MP
mkfs.btrfs -M $DEV
mount -o inode_cache $DEV $MP

cat /dev/urandom | head -c 654321 > $MP/1
mkdir $MP/2
mv $MP/1 $MP/2/1

btrfs subvol snap $MP $MP/@1
rm $MP/2/1

umount $MP
mount -o inode_cache $DEV $MP

cat /dev/urandom | head -c 654321 > $MP/tempname-1

ls -li $MP/@1/2/1 $MP/tempname-1
--

Actual result:
> 257 -rw-r--r-- 1 root root 654321 Oct 16 15:04 /mnt/scratch/@1/2/1
> 259 -rw-r--r-- 1 root root 654321 Oct 16 15:04 /mnt/scratch/tempname-1

Expected result: Both files should have inode 257.

If I make any of the following changes, I get the expected results:
- omit umount/mount from the script
- replace SSD partition by spinning disk's partition of the same size
- use 266MB partition instead of a 55MB partition (still mixed mode)
- dump 554321 bytes into file "1" instead of 654321
- dump 7654321 bytes into file "1" instead of 654321

Despite being that fragile, with the above script the results are 100%
reproducible here. I wouldn't be surprised if on a different machine one would
need different parameter fine-tuning to trigger the problem. I'm happy to test
patches :-)

-Jan
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to