Btrfs: fix missing deleted items in btrfs_clean_quota_tree
authorWang Shilong <wangsl-fnst@cn.fujitsu.com>
Wed, 27 Feb 2013 11:16:57 +0000 (11:16 +0000)
committerJosef Bacik <jbacik@fusionio.com>
Fri, 1 Mar 2013 15:13:03 +0000 (10:13 -0500)
commit06b3a860dcf596bdc2bb1cca3252d3907b581938
tree9166d47ee4c0cc1c19521db17880b6a5b254c907
parentb8dae3138876080d4dd98cc438ff759338d632ef
Btrfs: fix missing deleted items in btrfs_clean_quota_tree

Steps to reproduce:

i=0
ncases=100

mkfs.btrfs <disk>
mount <disk> <mnt>
btrfs quota enable <mnt>
btrfs qgroup create 2/1 <mnt>
while [ $i -le $ncases ]
do
btrfs qgroup create 1/$i <mnt>
btrfs qgroup assign 1/$i 2/1 <mnt>
i=$(($i+1))
done

btrfs quota disable <mnt>
umount <mnt>
btrfsck <mnt>

You can also use the commands:
btrfs-debug-tree <disk> | grep QGROUP

You will find there are still items existed.The reasons why this happens
is because the original code just checks slots[0]==0 and returns.
We try to fix it by deleting the leaf one by one.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/qgroup.c