Bug 90071 - 400 errors, nbytes wrong, isn't repaired by current btrfs check
Summary: 400 errors, nbytes wrong, isn't repaired by current btrfs check
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Josef Bacik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-19 00:50 UTC by Chris Murphy
Modified: 2016-03-20 11:20 UTC (History)
2 users (show)

See Also:
Kernel Version: 3.17.4-301.fc21.x86_64
Tree: Fedora
Regression: No


Attachments

Description Chris Murphy 2014-12-19 00:50:59 UTC
1. New F21 installation, during install remounted with options compress,ssd_spread; several boots later graphics didn't initialize so I just killed the VM. No subvolumes created or destroyed since successful installation.

2. Normal mount, no errors in dmesg.

3.
# btrfs check /dev/sda2
Checking filesystem on /dev/sda2
UUID: dda85f13-1aab-4f9b-87e6-be23358e0228
checking extents
checking free space cache
checking fs roots
root 259 inode 804 errors 400, nbytes wrong
found 1164160754 bytes used err is 1
total csum bytes: 2053428
total tree bytes: 176865280
total fs tree bytes: 168525824
total extent tree bytes: 5996544
btree space waste bytes: 25785567
file data blocks allocated: 3330990080
 referenced 3796365312
Btrfs v3.17.3

4.
# btrfs check --repair /dev/sda2
enabling repair mode
Fixed 0 roots.
Checking filesystem on /dev/sda2
UUID: dda85f13-1aab-4f9b-87e6-be23358e0228
checking extents
checking free space cache
cache and super generation don't match, space cache will be invalidated
checking fs roots
root 259 inode 804 errors 400, nbytes wrong
found 1164160754 bytes used err is 1
total csum bytes: 2053428
total tree bytes: 176865280
total fs tree bytes: 168525824
total extent tree bytes: 5996544
btree space waste bytes: 25785567
file data blocks allocated: 3330990080
 referenced 3796365312
Btrfs v3.17.3

5. Is still not fixed after repair
# btrfs check /dev/sda2
Checking filesystem on /dev/sda2
UUID: dda85f13-1aab-4f9b-87e6-be23358e0228
checking extents
checking free space cache
cache and super generation don't match, space cache will be invalidated
checking fs roots
root 259 inode 804 errors 400, nbytes wrong
found 1164160754 bytes used err is 1
total csum bytes: 2053428
total tree bytes: 176865280
total fs tree bytes: 168525824
total extent tree bytes: 5996544
btree space waste bytes: 25785567
file data blocks allocated: 3330990080
 referenced 3796365312
Btrfs v3.17.3


6. 
# mount /dev/sda2 /mnt
# btrfs inspect ino 804 /mnt
# ioctl ret=-1, error: No such file or directory

7.
# mount -o recovery /dev/sda2 /mnt
# umount
# btrfs check /dev/sda2
Checking filesystem on /dev/sda2
UUID: dda85f13-1aab-4f9b-87e6-be23358e0228
checking extents
checking free space cache
checking fs roots
root 259 inode 804 errors 400, nbytes wrong
found 1164160754 bytes used err is 1
total csum bytes: 2053428
total tree bytes: 176865280
total fs tree bytes: 168525824
total extent tree bytes: 5996544
btree space waste bytes: 25785567
file data blocks allocated: 3330990080
 referenced 3796365312
Btrfs v3.17.3


7.
# btrfs scrub start -BdrR /mnt
# scrub device /dev/sda2 (id 1) done
	scrub started at Thu Dec 18 19:45:43 2014 and finished after 11 seconds
	data_extents_scrubbed: 90144
	tree_extents_scrubbed: 21590
	data_bytes_scrubbed: 2111627264
	tree_bytes_scrubbed: 353730560
	read_errors: 0
	csum_errors: 0
	verify_errors: 0
	no_csum: 2177
	csum_discards: 3768
	super_errors: 0
	malloc_errors: 0
	uncorrectable_errors: 0
	unverified_errors: 0
	corrected_errors: 0
	last_physical: 5406457856

8.
# btrfs fi df /mnt
Data, single: total=3.01GiB, used=1.97GiB
System, DUP: total=8.00MiB, used=16.00KiB
System, single: total=4.00MiB, used=0.00B
Metadata, DUP: total=1.00GiB, used=168.66MiB
Metadata, single: total=8.00MiB, used=0.00B
GlobalReserve, single: total=48.00MiB, used=0.00B

9.
# btrfs fi show
Label: 'fedora'  uuid: dda85f13-1aab-4f9b-87e6-be23358e0228
	Total devices 1 FS bytes used 2.13GiB
	devid    1 size 80.00GiB used 5.04GiB path /dev/sda2

Btrfs v3.17.3

10. balance does not fix either, error still present from btrfs check and also inspect inode.
Comment 1 Chris Murphy 2014-12-19 00:53:44 UTC
btrfs-image 17MiB
https://drive.google.com/file/d/0B_2Asp8DGjJ9NXcwQXEyUndET3M/view?usp=sharing
Comment 2 Chris Murphy 2014-12-19 01:04:35 UTC
btrfs fi defrag -vr on each subvolume yielded no errors, nothing in dmesg reported


# btrfs sub list /mnt
ID 257 gen 193 top level 5 path boot
ID 258 gen 193 top level 5 path var
ID 259 gen 195 top level 5 path root
ID 260 gen 193 top level 5 path home

Aha!

# btrfs inspect inode 804 /mnt/root
/mnt/root/etc/shadow-

Interesting. I had to set the root password because, a.) installer doesn't require it, b.) systemd does require it even for single user mode. So I had to use boot param init=/bin/bash but reboot doesn't work in that environment. When I used exit I got a kernel panic. So this must have left the shadow file I'd successfully just written to in some intermittent state. It's not corrupted.

Copy the file to a new filename, delete original, rename, and now btrfs check comes up clean.

# btrfs check /dev/sda2
Checking filesystem on /dev/sda2
UUID: dda85f13-1aab-4f9b-87e6-be23358e0228
checking extents
checking free space cache
checking fs roots
checking csums
checking root refs
found 677011490 bytes used err is 0
total csum bytes: 3143492
total tree bytes: 178978816
total fs tree bytes: 168067072
total extent tree bytes: 6979584
btree space waste bytes: 29196237
file data blocks allocated: 3236896768
 referenced 3797020672
Btrfs v3.17.3

Still this is unexpected...
Comment 3 Qu Wenruo 2015-06-18 09:17:57 UTC
Checking the btrfs-image dump.
And I'll try to fix it if possible.

Btrfsck may repair this bug but the kernel reason causing the bug still needs investigation.

Thanks,
Qu
Comment 4 Qu Wenruo 2015-06-19 05:58:21 UTC
Now btrfsck can fix the error with the new patch:
https://patchwork.kernel.org/patch/6642891/

But the root cause in kernel is still under investigation.

Thanks,
Qu

Note You need to log in before you can comment on or make changes to this bug.