Skip to contentSkip to conversation

fstests: btrfs/179 call quota rescan

PATCH In review Anand Jain 3 participants 9 messages Feb 7, 2020 – Feb 10, 2020 Btrfs file system

lore
Share & tools
lore

Anand Jain

author
#0 lore raw

PATCH 1/1 fstests: btrfs/179 call quota rescan

On some systems btrfs/179 fails as the check finds that there is difference in the qgroup counts.

By the async nature of qgroup tree scan, the latest qgroup counts at the time of umount might not be upto date, if it isn't then the check will report the difference in count. The difference in qgroup counts are anyway updated in the following mount, so it is not a real issue that this test case is trying to verify. So make sure the qgroup counts are updated before unmount happens and make the check happy.

---
 tests/btrfs/179 | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/btrfs/179 +8 -0
index 4a24ea419a7e..74e91841eaa6 100755
@@ -109,6 +109,14 @@ wait $snapshot_pid
 kill $delete_pid
 wait $delete_pid
 
+# By the async nature of qgroup tree scan, the latest qgroup counts at the time
+# of umount might not be upto date, if it isn't then the check will report the
+# difference in count. The difference in qgroup counts are anyway updated in the
+# following mount, so it is not a real issue that this test case is trying to
+# verify. So make sure the qgroup counts are updated before unmount happens.
+
+$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
+
 # success, all done
 echo "Silence is golden"
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 5 lines · Anand Jain

On some systems btrfs/179 fails as the check finds that there is difference in the qgroup counts.

By the async nature of qgroup tree scan, the latest qgroup counts at the time of umount might not be upto date,

Yes, so far so good.

Quoted 4 lines

if it isn't then the check will
report the difference in count. The difference in qgroup counts are anyway updated in the following mount, so it is not a real issue that this test case is trying to verify.

No problem either.

Quoted 2 lines

So make sure the qgroup counts are updated
before unmount happens and make the check happy.

But the solution doesn't look correct to me.

We should either make btrfs-check to handle such half-dropped case better, or find a way to wait for all subvolume drop to be finished in test case.

Papering the test by rescan is not a good idea at all.
If one day we really hit some qgroup accounting problem, this papering way could hugely reduce the coverage.

Thanks,
Qu

Quoted 26 lines
---
 tests/btrfs/179 | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/btrfs/179 +8 -0
index 4a24ea419a7e..74e91841eaa6 100755
@@ -109,6 +109,14 @@ wait $snapshot_pid
 kill $delete_pid
 wait $delete_pid
 
+# By the async nature of qgroup tree scan, the latest qgroup counts at the time
+# of umount might not be upto date, if it isn't then the check will report the
+# difference in count. The difference in qgroup counts are anyway updated in the
+# following mount, so it is not a real issue that this test case is trying to
+# verify. So make sure the qgroup counts are updated before unmount happens.
+
+$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
+
 # success, all done
 echo "Silence is golden"
 
author
#2 lore raw
Quoted 18 lines · Qu Wenruo
Quoted 5 lines · Anand Jain

On some systems btrfs/179 fails as the check finds that there is difference in the qgroup counts.

By the async nature of qgroup tree scan, the latest qgroup counts at the time of umount might not be upto date,

Yes, so far so good.

Quoted 4 lines

if it isn't then the check will
report the difference in count. The difference in qgroup counts are anyway updated in the following mount, so it is not a real issue that this test case is trying to verify.

No problem either.

Quoted 7 lines
Quoted 2 lines

So make sure the qgroup counts are updated
before unmount happens and make the check happy.

But the solution doesn't look correct to me.

We should either make btrfs-check to handle such half-dropped case better,

Check is ok. The count as check counts matches with the count after
the mount. So what is recorded in the qgroup is not upto date.

Quoted 2 lines

or find a way to wait for all subvolume drop to be finished in test case.

Yes this is one way. Just wait for few seconds will do, test passes. Do you know any better way?

Thanks, Anand

Quoted 36 lines

Papering the test by rescan is not a good idea at all.
If one day we really hit some qgroup accounting problem, this papering way could hugely reduce the coverage.

Thanks,
Qu

Quoted 26 lines
---
  tests/btrfs/179 | 8 ++++++++
  1 file changed, 8 insertions(+)
tests/btrfs/179 +8 -0
index 4a24ea419a7e..74e91841eaa6 100755
@@ -109,6 +109,14 @@ wait $snapshot_pid
  kill $delete_pid
  wait $delete_pid
 
+# By the async nature of qgroup tree scan, the latest qgroup counts at the time
+# of umount might not be upto date, if it isn't then the check will report the
+# difference in count. The difference in qgroup counts are anyway updated in the
+# following mount, so it is not a real issue that this test case is trying to
+# verify. So make sure the qgroup counts are updated before unmount happens.
+
+$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
+
  # success, all done
  echo "Silence is golden"
 
#3 lore raw
Quoted 25 lines · Anand Jain
Quoted 22 lines · Qu Wenruo
Quoted 5 lines · Anand Jain

On some systems btrfs/179 fails as the check finds that there is difference in the qgroup counts.

By the async nature of qgroup tree scan, the latest qgroup counts at the time of umount might not be upto date,

Yes, so far so good.

Quoted 5 lines

if it isn't then the check will
report the difference in count. The difference in qgroup counts are anyway
updated in the following mount, so it is not a real issue that this test case is trying to verify.

No problem either.

Quoted 2 lines

So make sure the qgroup counts are updated
before unmount happens and make the check happy.

Quoted 7 lines
Quoted 4 lines

But the solution doesn't look correct to me.

We should either make btrfs-check to handle such half-dropped case better,

 Check is ok. The count as check counts matches with the count after the mount. So what is recorded in the qgroup is not upto date.

Nope. Qgroup records what's in commit tree. For unmounted fs, there is no difference in commit tree and current tree.

Thus the qgroup scan in btrfs-progs is different from kernel. Please go check how the btrfs-progs code to see how the difference comes.

Quoted 6 lines
Quoted 3 lines

or find a way to wait for all subvolume drop to be finished in test case.

Yes this is one way. Just wait for few seconds will do, test passes. Do you know any better way?

I didn't remember when, but it looks like btrfs fi sync used to wait for snapshot drop.
But not now. If we have a way to wait for cleaner to finish, we can solve it pretty easily.

Thanks,
Qu

Quoted 42 lines

Thanks, Anand

Quoted 39 lines

Papering the test by rescan is not a good idea at all.
If one day we really hit some qgroup accounting problem, this papering way could hugely reduce the coverage.

Thanks,
Qu

Quoted 29 lines

---
  tests/btrfs/179 | 8 ++++++++

  1 file changed, 8 insertions(+)
tests/btrfs/179 +0 -0
index 4a24ea419a7e..74e91841eaa6 100755
@@ -109,6 +109,14 @@ wait $snapshot_pid

  kill $delete_pid
  wait $delete_pid
  +# By the async nature of qgroup tree scan, the latest qgroup counts at the time
+# of umount might not be upto date, if it isn't then the check will report the
+# difference in count. The difference in qgroup counts are anyway updated in the
+# following mount, so it is not a real issue that this test case is trying to
+# verify. So make sure the qgroup counts are updated before unmount happens.

tests/btrfs/179 +3 -0
+
+$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
+

  # success, all done
  echo "Silence is golden"

author
#4 lore raw
Quoted 46 lines · Qu Wenruo
Quoted 25 lines · Anand Jain
Quoted 22 lines · Qu Wenruo
Quoted 5 lines · Anand Jain

On some systems btrfs/179 fails as the check finds that there is difference in the qgroup counts.

By the async nature of qgroup tree scan, the latest qgroup counts at the time of umount might not be upto date,

Yes, so far so good.

Quoted 5 lines

if it isn't then the check will
report the difference in count. The difference in qgroup counts are anyway
updated in the following mount, so it is not a real issue that this test case is trying to verify.

No problem either.

Quoted 2 lines

So make sure the qgroup counts are updated
before unmount happens and make the check happy.

Quoted 7 lines
Quoted 4 lines

But the solution doesn't look correct to me.

We should either make btrfs-check to handle such half-dropped case better,

 Check is ok. The count as check counts matches with the count after the
mount. So what is recorded in the qgroup is not upto date.

Nope. Qgroup records what's in commit tree. For unmounted fs, there is no difference in commit tree and current tree.

Thus the qgroup scan in btrfs-progs is different from kernel. Please go check how the btrfs-progs code to see how the difference comes.

Quoted 4 lines
Quoted 3 lines

or find a way to wait for all subvolume drop to be finished in test case.

Quoted 7 lines
Quoted 2 lines

Yes this is one way. Just wait for few seconds will do, test passes. Do you know any better way?

I didn't remember when, but it looks like btrfs fi sync used to wait for snapshot drop.
But not now. If we have a way to wait for cleaner to finish, we can solve it pretty easily.

A sleep at the end of the test case also makes it count consistent. As the intention of the test case is to test for the hang, so sleep 5 at the end of the test case is reasonable.

Thanks, Anand

Quoted 46 lines

Thanks,
Qu

Quoted 42 lines

Thanks, Anand

Quoted 39 lines

Papering the test by rescan is not a good idea at all.
If one day we really hit some qgroup accounting problem, this papering way could hugely reduce the coverage.

Thanks,
Qu

Quoted 29 lines
---
   tests/btrfs/179 | 8 ++++++++
   1 file changed, 8 insertions(+)
tests/btrfs/179 +0 -0
index 4a24ea419a7e..74e91841eaa6 100755
@@ -109,6 +109,14 @@ wait $snapshot_pid
   kill $delete_pid
   wait $delete_pid
   +# By the async nature of qgroup tree scan, the latest qgroup

counts at the time
+# of umount might not be upto date, if it isn't then the check will report the
+# difference in count. The difference in qgroup counts are anyway updated in the
+# following mount, so it is not a real issue that this test case is trying to
+# verify. So make sure the qgroup counts are updated before unmount happens.

tests/btrfs/179 +3 -0
+
+$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
+
   # success, all done
   echo "Silence is golden"
#5 lore raw
Quoted 55 lines · Anand Jain
Quoted 52 lines · Qu Wenruo
Quoted 27 lines · Anand Jain
Quoted 24 lines · Qu Wenruo
Quoted 6 lines · Anand Jain

On some systems btrfs/179 fails as the check finds that there is difference in the qgroup counts.

By the async nature of qgroup tree scan, the latest qgroup counts at the
time of umount might not be upto date,

Yes, so far so good.

Quoted 6 lines

if it isn't then the check will
report the difference in count. The difference in qgroup counts are anyway
updated in the following mount, so it is not a real issue that this test
case is trying to verify.

No problem either.

Quoted 2 lines

So make sure the qgroup counts are updated
before unmount happens and make the check happy.

Quoted 8 lines
Quoted 4 lines

But the solution doesn't look correct to me.

We should either make btrfs-check to handle such half-dropped case better,

  Check is ok. The count as check counts matches with the count after the
mount. So what is recorded in the qgroup is not upto date.

Nope. Qgroup records what's in commit tree. For unmounted fs, there is no difference in commit tree and current tree.

Thus the qgroup scan in btrfs-progs is different from kernel. Please go check how the btrfs-progs code to see how the difference comes.

Quoted 6 lines
Quoted 3 lines

or find a way to wait for all subvolume drop to be finished in test case.

Yes this is one way. Just wait for few seconds will do, test passes. Do you know any better way?

Quoted 8 lines
Quoted 4 lines

I didn't remember when, but it looks like btrfs fi sync used to wait for snapshot drop.
But not now. If we have a way to wait for cleaner to finish, we can solve it pretty easily.

A sleep at the end of the test case also makes it count consistent. As the intention of the test case is to test for the hang, so sleep 5 at the end of the test case is reasonable.

That looks like a valid workaround.

Although the immediate number 5 looks no that generic for all test environments.

I really hope to find a stable way to wait for all subvolume drops other than rely on some hard coded numbers.

Thanks,
Qu

Quoted 49 lines

Thanks, Anand

Quoted 46 lines

Thanks,
Qu

Quoted 42 lines

Thanks, Anand

Quoted 39 lines

Papering the test by rescan is not a good idea at all.
If one day we really hit some qgroup accounting problem, this papering way could hugely reduce the coverage.

Thanks,
Qu

Quoted 29 lines

---
   tests/btrfs/179 | 8 ++++++++

   1 file changed, 8 insertions(+)
tests/btrfs/179 +0 -0
index 4a24ea419a7e..74e91841eaa6 100755
@@ -109,6 +109,14 @@ wait $snapshot_pid

   kill $delete_pid
   wait $delete_pid
   +# By the async nature of qgroup tree scan, the latest qgroup counts at the time
+# of umount might not be upto date, if it isn't then the check will report the
+# difference in count. The difference in qgroup counts are anyway updated in the
+# following mount, so it is not a real issue that this test case is trying to
+# verify. So make sure the qgroup counts are updated before unmount happens.

tests/btrfs/179 +3 -0
+
+$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
+

   # success, all done
   echo "Silence is golden"

#6 lore raw
Quoted 67 lines · Qu Wenruo
Quoted 55 lines · Anand Jain
Quoted 52 lines · Qu Wenruo
Quoted 27 lines · Anand Jain
Quoted 24 lines · Qu Wenruo
Quoted 6 lines · Anand Jain

On some systems btrfs/179 fails as the check finds that there is difference in the qgroup counts.

By the async nature of qgroup tree scan, the latest qgroup counts at the
time of umount might not be upto date,

Yes, so far so good.

Quoted 6 lines

if it isn't then the check will
report the difference in count. The difference in qgroup counts are anyway
updated in the following mount, so it is not a real issue that this test
case is trying to verify.

No problem either.

Quoted 2 lines

So make sure the qgroup counts are updated
before unmount happens and make the check happy.

Quoted 8 lines
Quoted 4 lines

But the solution doesn't look correct to me.

We should either make btrfs-check to handle such half-dropped case better,

  Check is ok. The count as check counts matches with the count after the
mount. So what is recorded in the qgroup is not upto date.

Nope. Qgroup records what's in commit tree. For unmounted fs, there is no difference in commit tree and current tree.

Thus the qgroup scan in btrfs-progs is different from kernel. Please go check how the btrfs-progs code to see how the difference comes.

Quoted 6 lines
Quoted 3 lines

or find a way to wait for all subvolume drop to be finished in test case.

Yes this is one way. Just wait for few seconds will do, test passes. Do you know any better way?

Quoted 8 lines
Quoted 4 lines

I didn't remember when, but it looks like btrfs fi sync used to wait for snapshot drop.
But not now. If we have a way to wait for cleaner to finish, we can solve it pretty easily.

A sleep at the end of the test case also makes it count consistent. As the intention of the test case is to test for the hang, so sleep 5 at the end of the test case is reasonable.

Quoted 7 lines

That looks like a valid workaround.

Although the immediate number 5 looks no that generic for all test environments.

I really hope to find a stable way to wait for all subvolume drops other than rely on some hard coded numbers.

what about btrfs filesystem sync?

<snip>

#7 lore raw
Quoted 72 lines · Nikolay Borisov
Quoted 69 lines · Qu Wenruo
Quoted 55 lines · Anand Jain
Quoted 52 lines · Qu Wenruo
Quoted 27 lines · Anand Jain
Quoted 24 lines · Qu Wenruo
Quoted 6 lines · Anand Jain

On some systems btrfs/179 fails as the check finds that there is difference in the qgroup counts.

By the async nature of qgroup tree scan, the latest qgroup counts at the
time of umount might not be upto date,

Yes, so far so good.

Quoted 6 lines

if it isn't then the check will
report the difference in count. The difference in qgroup counts are anyway
updated in the following mount, so it is not a real issue that this test
case is trying to verify.

No problem either.

Quoted 2 lines

So make sure the qgroup counts are updated
before unmount happens and make the check happy.

Quoted 8 lines
Quoted 4 lines

But the solution doesn't look correct to me.

We should either make btrfs-check to handle such half-dropped case better,

  Check is ok. The count as check counts matches with the count after the
mount. So what is recorded in the qgroup is not upto date.

Nope. Qgroup records what's in commit tree. For unmounted fs, there is no difference in commit tree and current tree.

Thus the qgroup scan in btrfs-progs is different from kernel. Please go check how the btrfs-progs code to see how the difference comes.

Quoted 6 lines
Quoted 3 lines

or find a way to wait for all subvolume drop to be finished in test case.

Yes this is one way. Just wait for few seconds will do, test passes. Do you know any better way?

Quoted 8 lines
Quoted 4 lines

I didn't remember when, but it looks like btrfs fi sync used to wait for snapshot drop.
But not now. If we have a way to wait for cleaner to finish, we can solve it pretty easily.

A sleep at the end of the test case also makes it count consistent. As the intention of the test case is to test for the hang, so sleep 5 at the end of the test case is reasonable.

That looks like a valid workaround.

Quoted 7 lines
Quoted 5 lines

Although the immediate number 5 looks no that generic for all test environments.

I really hope to find a stable way to wait for all subvolume drops other than rely on some hard coded numbers.

what about btrfs filesystem sync?

The only cleaner related work of that ioctl is waking up transaction_kthread, which will also wake up cleaner_kthread.

It triggers clean up, but not wait for it.

And my first run of such added fi sync failed too, so not good enough I guess.

Thanks,
Qu

Quoted 4 lines

<snip>

#8 lore raw
Quoted 11 lines · Qu Wenruo
Quoted 10 lines
Quoted 8 lines

That looks like a valid workaround.

Although the immediate number 5 looks no that generic for all test environments.

I really hope to find a stable way to wait for all subvolume drops other than rely on some hard coded numbers.

what about btrfs filesystem sync?

Quoted 7 lines

The only cleaner related work of that ioctl is waking up transaction_kthread, which will also wake up cleaner_kthread.

It triggers clean up, but not wait for it.

And my first run of such added fi sync failed too, so not good enough I guess.

Although 'fi sync' does nothing better than vanilla sync, Nikolay also mentioned about 'subv sync', which does the trick!

Nikolay rocks!

That would be the proper way to solve the problem. And it's time to update the man page of btrfs-filesystme.

Thanks,
Qu

Quoted 9 lines

Thanks,
Qu

Quoted 4 lines

<snip>