- if ! $idle; then
- if $dryrun; then
- echo "$0: not idle. if this wasnt a dry run, btrfs scrub cancel $mnt"
- else
- btrfs scrub cancel $mnt &>/dev/null ||:
- continue
+ # Only run for $check, since it runs in parallel to non-check, avoid
+ # race condition.
+ if $check; then
+ if ! btrfs dev stats -c $mnt >$tmp; then
+ if diff -q $mnt/btrfs-dev-stats $tmp; then
+ diff -u $mnt/btrfs-dev-stats $tmp | mail -s "$HOSTNAME: error: btrfs dev stats -c $mnt" root@localhost
+ cat $tmp >$mnt/btrfs-dev-stats
+ fi