# BTRFS-errors only on kernels >=4.17

## DawgG

i run an up-to-date ~amd64-htpc-system. since upgrading the kernel to >4.17 the system would not run properly anymore, so i keep using 4.16.7 productively.

upon investigating this closer i found out that the younger kernels (4.18.6 now) produce btrfs-errors that do not occur when using the 4.16.7 kernel. it got so bad that when emerging something portage would not find the files, commands would not be executed etc. using 4.16.7 again the samt things worked flawlessly.

errors (dmesg) under 4.18.7:

```
SNIP

[   29.061725] BTRFS error (device sda2): bdev /dev/sda2 errs: wr 0, rd 1438725, flush 0, corrupt 0, gen 0

[   29.061774] attempt to access beyond end of device

[   29.061775] sda2: rw=0, want=113466360, limit=107426655

[   29.061777] BTRFS error (device sda2): bdev /dev/sda2 errs: wr 0, rd 1438726, flush 0, corrupt 0, gen 0

[   32.877529] attempt to access beyond end of device

[   32.877534] sda2: rw=2051, want=108620632, limit=107426655

[   32.887528] attempt to access beyond end of device

[   32.887534] sda2: rw=2051, want=108620696, limit=107426655

[   32.897527] attempt to access beyond end of device

[   32.897534] sda2: rw=2051, want=108621008, limit=107426655

hundreds of them!

SNIP

```

i ran fsck.btrfs from systemrescuecd - no errors.

i ran a btrfs scrub on 4.16.7: no errors

i ran a btrfs scrub on 4.18.6: many uncorrectable errors

i ran a btrfs balance on 4.16.7: finished

i ran a btrfs balance on 4.18.6: aborted

the disk is an SSD; 

```
smartctl -x
```

 reports "test passed." result:  https://paste.pound-python.org/show/crfR4PJZahMDS8YG2bvb/

i did an fstrim a couple of times, did not change anything.

```
emerge --info
```

 is here: https://paste.pound-python.org/show/9GKjRwaVGBo7f7w8Qlzb/

the system's pkgs are compiled in a chroot an a different host and emerged with -K but i am certain that this is not the issue here.

i do not understand what is wrong.

THX for your input!

----------

## Maitreya

I run btrfs and those kernels as well...

Let me do a quick check

----------

## Maitreya

Nothing here.

Are you sure the 18 kernel has the same storage modules loaded? 

The error sounds a bit like a misalignment.

----------

## DawgG

BTRFS is compiled in statically. also, the data-disk which as also BTRFS shows no errors at all.

the kernel-configs are the same regarding filesystems and partitions (it's kind of a single-use box: HTPC; the kconfs do not change (much) but are only adapted in a kernel-upgrade).

meanwhile, the errors persist (scrub failed again, ...).

i think stuff that is unreadable under 4.18. becomes readable once it gets rewritten (eg by re-emerging a PKG) under 4.16.7.

it's a really strange situation. maybe i will try and repartition the whole disk.

----------

## toralf

 *Maitreya wrote:*   

> Nothing here.
> 
> Are you sure the 18 kernel has the same storage modules loaded? 
> 
> The error sounds a bit like a misalignment.

 OTOH there's a handful BTRFS fixes in the stable queue: https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/commit/?id=ad70271651307094d0bdcb440becdc2bca8fae75

----------

## DawgG

well i'm really not a highly skilled filesystem or kernel developer, but at first glance there seems not be be anything related to my specific problems in these patches.

will these patches be included into gentoo-sources sometime?

----------

## Hu

If the patches are released as part of a Linux stable kernel, then they will be available in the next gentoo-sources based on that kernel.

----------

## DawgG

might there be a(nother) solution to this problem?

just tried to send a snapshot of the subvol to a backup-disk under 4.18.7:

```
/mnt/2/SNAPSHOTS # btrfs send -v gentoo-chroot-2018-09-13-1536841984 | btrfs receive -v /mnt/1/       

At subvol gentoo-chroot-2018-09-13-1536841984

At subvol gentoo-chroot-2018-09-13-1536841984

receiving subvol gentoo-chroot-2018-09-13-1536841984 uuid=2afacf7f-c2a3-f64e-817b-652a5fa23d1e, stransid=170081

ERROR: send ioctl failed with -5: Input/output error

ERROR: unexpected EOF in stream
```

whereas under 4.16.7. it works flawlessly

i'd hate to restructure the whole disk and have the same problems occur again.

----------

## DawgG

i re-structured the whole disk and created a new fs (from multi-partition-layout to just one btrfs-fs with subvols) and the errors "magically" disappeared. (in the meantime, btrfs-snaps created under 4.18 on the same disk would generate empty data-streams even when btrfs-sending them under booted systemrescuecd.)

i still do not understand this, but at least it works.

THX for your input!

----------

