I have a btrfs filesystem that I use as a target for send/receive incremental 
snapshots.  I use btrbk to perform hourly backups.

The target filesystem was offline for a few days.  When I mounted it today, the 
filesystem was read-only, with dmesg errors:

    …
    [  167.004684] BTRFS error (device sda2): unable to find ref byte nr 
40366194688 parent 0 root 6894  owner 1 offset 0
    [  167.004722] ------------[ cut here ]------------
    [  167.004735] WARNING: CPU: 0 PID: 1273 at 
/build/linux-E14mqW/linux-4.4.0/fs/btrfs/extent-tree.c:6553 
__btrfs_free_extent.isra.68+0x8ff/0xd30 [btrfs]()
    [  167.004736] BTRFS: Transaction aborted (error -2)
    …
    [  167.005011] BTRFS: error (device sda2) in __btrfs_free_extent:6553: 
errno=-2 No such entry
    [  167.005041] BTRFS info (device sda2): forced readonly
    [  167.005044] BTRFS: error (device sda2) in btrfs_run_delayed_refs:2930: 
errno=-2 No such entry
    …

Full dmesg: https://pastebin.com/XNKJbN15

I unmounted the filesystem and ran btrfs check.  I let it run overnight.  
Output:

    $ sudo btrfs check /dev/sda2
    Checking filesystem on /dev/sda2
    UUID: ea0dc14b-2a93-4721-bc9c-aa4ed069ee7d
    checking extents
    bad metadata [36962304, 36978688) crossing stripe boundary
    bad metadata [83689472, 83705856) crossing stripe boundary
    …
    ref mismatch on [24969854976 16384] extent item 0, found 1
    Backref 24969854976 parent 6894 root 6894 not found in extent tree
    backpointer mismatch on [24969854976 16384]
    …

Full btrfs check output: https://pastebin.com/9QxasQv5

Kernel version (Ubuntu 16.04 LTS):

    $ uname -a
    Linux oo-landfill1 4.4.0-127-generic #153-Ubuntu SMP Sat May 19 10:58:46 
UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Questions:

1) How can I repair the disk such that incremental backups can pick up where 
they left off?

2) Will "btrfs check --repair" fix this kind of error?

3) How can I dump a snapshot into a flat file that I can use to restore the 
snapshot into a clean btrfs partition such that send/receive can pick up with 
incremental backups based on that snapshot?

4) Suggestions on how to avoid this issue in the future?  (This is the primary 
use for my box so I'm willing to change to a different distribution or 
GNU/Linux version if it plays nicer with btrfs)

Thanks,
Shane


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to