Giter VIP home page Giter VIP logo

bcachefs-tools's People

Contributors

arachsys avatar bczhc avatar bertschingert avatar breavyn avatar elvishjerricco avatar firestack avatar fleiner avatar fougner avatar g2p avatar holmanb avatar iav avatar jpsollie avatar kloenk avatar koverstreet avatar leahneukirchen avatar mic92 avatar modelrockettier avatar nadalle avatar raitobezarius avatar rlndvt avatar rmillner avatar rolffokkens avatar sandeen avatar sithglan avatar stintel avatar tasleson avatar thoughtpolice avatar truongsinh avatar yellowonion avatar yshui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bcachefs-tools's Issues

e0a51ccc build error: "error: format not a string literal and no format arguments [-Werror=format-security]"

Commit e0a51cc fails building with:

cc -march=native -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -std=gnu89 -O2 -g -MMD -Wall -fPIC -Wno-pointer-sign -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-571-ge0a51cc"'  -Wno-unused-but-set-variable -Wno-stringop-overflow -Wno-zero-length-bounds -Wno-missing-braces  -Wno-shift-overflow -Wno-enum-conversion -I/usr/include/blkid -I/usr/include/uuid    -c -o libbcachefs/util.o libbcachefs/util.c
libbcachefs/util.c: In function ‘pr_name_and_units’:
libbcachefs/util.c:436:9: error: format not a string literal and no format arguments [-Werror=format-security]
  436 |         prt_printf(out, name);
      |         ^~~~~~~~~~

error "block size too small" on software raid device starting from linux 6.2

I have a bcachefs device which was formatted with a 512 byte block size:

External UUID:                              297427bf-7336-4e74-ab85-6bb076f446d0
Internal UUID:                              47da8004-3826-413c-a6a2-173d533cfa94
Device index:                               9
Label:                                      securestorage
Version:                                    fragmentation_lru
Oldest version on disk:                     bucket_gens
Created:                                    Thu Dec 15 09:18:56 2022
Sequence number:                            282
Superblock size:                            8256
Clean:                                      0
Devices:                                    11
Sections:                                   members,replicas_v0,disk_groups,clean,journal_seq_blacklist,journal_v2,counters                                    Features:                                   journal_seq_blacklist_v3,new_siphash,inline_data,new_extent_overwrite,btree_ptr_v2,extents_above_btree_updates,btree_updates_journalled,new_varint,journal_no_flush,alloc_v2,extents_across_btree_nodes
Compat features:                            alloc_info,alloc_metadata,extents_above_btree_updates_done,bformat_overflow_done
Options:
block_size:                               512 B
btree_node_size:                          256 KiB
errors:                                   continue [ro] panic
metadata_replicas:                        3
data_replicas:                            1
metadata_replicas_required:               1
data_replicas_required:                   1
encoded_extent_max:                       64.0 KiB
metadata_checksum:                        none crc32c crc64 [xxhash]
data_checksum:                            none crc32c crc64 [xxhash]                                                                                           compression:                              [none] lz4 gzip zstd
background_compression:                   [none] lz4 gzip zstd
str_hash:                                 crc32c crc64 [siphash]
metadata_target:                          SSDM
foreground_target:                        SSDC
background_target:                        HDD
promote_target:                           SSDC
erasure_code:                             0
inodes_32bit:                             1
shard_inode_numbers:                      1 
inodes_use_key_cache:                     1
gc_reserve_percent:                       8
gc_reserve_bytes:                         0 B
root_reserve_percent:                     0
wide_macs:                                0
acl:                                      1
usrquota:                                 0
grpquota:                                 0
prjquota:                                 0
journal_flush_delay:                      1000
journal_flush_disabled:                   0
journal_reclaim_delay:                    100
journal_transaction_names:                0
nocow:                                    0

in linux 6.2, md reports the physical block size of the background target as 4096, whereas it used to be 512 (when formatting).
This change in API makes bcachefs tools completely unusable, whereas the kernel is still OK:
When I mount with eg fsck, there's no issue, when running bcachefs fsck, it fails.
I tried modifying the BLKPBZGET ioctl to BLKSZGET (to ignore the physical block size and use logical one instead), but that didn't help.
Any ideas about how to work around this issue?

set-state syntax incorrect in documentation.

documentation (man bcachefs) says:

     bcachefs device set-state [options] device new-state

but when I run:

# bcachefs device set-state /dev/nvme0n1p3 rw
Bad device state /dev/nvme0n1p3

# bcachefs device set-state rw /dev/nvme0n1p3

bcachefs: libbcachefs/btree_update_leaf.c:1358: bch2_trans_update: Assertion `!(!iter->path->should_be_locked)' failed.

bcache fsck can't fix extent in missing inodeand also it can't reclaim space after file deletion.

 # time bcachefs fsck -y /dev/sdd
recovering from clean shutdown, journal seq 3318732
journal read done, 0 keys in 1 entries, seq 3318733
starting mark and sweep
starting fsck
fsck counted i_sectors wrong: got 263628400 should be 8
extent in missing inode:
  u64s 7 type extent 4114:128:U32_MAX len 128 ver 0: crc: c_size 112 size 128 offset 0 nonce 0 csum crc32c compress lz4 ptr: 0:9103588752 gen 2, fixing
bcachefs: libbcachefs/btree_update_leaf.c:1358: bch2_trans_update: Assertion `!(!iter->path->should_be_locked)' failed.
Przerwane (zrzut pamięci)

bt:

Core was generated by `bcachefs fsck -y /dev/sdd'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
49      ../sysdeps/unix/sysv/linux/raise.c: Nie ma takiego pliku ani katalogu.
[Current thread is 1 (Thread 0x7fb6033ed000 (LWP 6749))]
(gdb) #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007fb603410536 in __GI_abort () at abort.c:79
#2  0x00007fb60341041f in __assert_fail_base (fmt=0x7fb603570a68 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55c597dadef0 "!(!iter->path->should_be_locked)", file=0x55c597dadb98 "libbcachefs/btree_update_leaf.c", line=1358, function=<optimized out>) at assert.c:92
#3  0x00007fb60341efa2 in __GI___assert_fail (assertion=assertion@entry=0x55c597dadef0 "!(!iter->path->should_be_locked)", file=file@entry=0x55c597dadb98 "libbcachefs/btree_update_leaf.c", line=line@entry=1358,
    function=function@entry=0x55c597dae0c0 <__PRETTY_FUNCTION__.3> "bch2_trans_update") at assert.c:101
#4  0x000055c597d40c4c in bch2_trans_update (trans=<optimized out>, iter=<optimized out>, k=<optimized out>, flags=<optimized out>) at libbcachefs/btree_update_leaf.c:1358
#5  0x000055c597d3fc25 in bch2_btree_delete_at (trans=trans@entry=0x7ffda5448c00, iter=iter@entry=0x7ffda5448b90, update_flags=update_flags@entry=1) at libbcachefs/btree_update_leaf.c:1475
#6  0x000055c597d528c5 in check_extent (trans=trans@entry=0x7ffda5448c00, iter=iter@entry=0x7ffda5448b90, inode=inode@entry=0x7ffda5448b30, s=s@entry=0x7ffda5448b60) at libbcachefs/fsck.c:1215
#7  0x000055c597d52c5b in check_extents (c=c@entry=0x7fb603373000) at libbcachefs/fsck.c:1290
#8  0x000055c597d535d4 in bch2_fsck_full (c=c@entry=0x7fb603373000) at libbcachefs/fsck.c:2342
#9  0x000055c597d7f408 in bch2_fs_recovery (c=c@entry=0x7fb603373000) at libbcachefs/recovery.c:1201
#10 0x000055c597cfccdb in bch2_fs_start (c=0x7fb603373000) at libbcachefs/super.c:918
#11 0x000055c597cfe904 in bch2_fs_open (devices=devices@entry=0x7ffda5449298, nr_devices=nr_devices@entry=1, opts=...) at libbcachefs/super.c:1985
#12 0x000055c597ce9427 in cmd_fsck (argc=1, argc@entry=3, argv=0x7ffda5449298, argv@entry=0x7ffda5449288) at cmd_fsck.c:90
#13 0x000055c597cd71bd in main (argc=<optimized out>, argv=0x7ffda5449288) at bcachefs.c:197

and bt full:

Core was generated by `bcachefs fsck -y /dev/sdd'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
49      ../sysdeps/unix/sysv/linux/raise.c: Nie ma takiego pliku ani katalogu.
[Current thread is 1 (Thread 0x7fb6033ed000 (LWP 6749))]
(gdb) #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
        set = {__val = {0, 140727376185456, 120, 140419715720758, 4222451712, 94307159824384, 94307159824485, 94307159824384, 94307159824384, 94307159824504, 94307159824684, 94307159824384, 94307159824684, 0, 0, 0}}                                                                               pid = <optimized out>
        tid = <optimized out>
        ret = <optimized out>
#1  0x00007fb603410536 in __GI_abort () at abort.c:79
        save_stage = 1
        act = {__sigaction_handler = {sa_handler = 0x55c597dadb98, sa_sigaction = 0x55c597dadb98}, sa_mask = {__val = {1358, 94307159956592, 7, 7, 94307159824384, 0, 0, 0, 5769110852760737792, 3, 18446744073709550416, 11, 94307144620952, 1358, 94307144621808, 140419714723840}},
          sa_flags = 55001124, sa_restorer = 0x7fb60359e520 <_IO_file_jumps>}
        sigs = {__val = {32, 1358, 94307144621808, 140419714723840, 140419715223552, 140419715681828, 140419714723840, 140419715567998, 94307144622272, 140419716811368, 94307144620952, 140419715682158, 206158430232, 140727376185440, 140727376185248, 5769110852760737792}}
#2  0x00007fb60341041f in __assert_fail_base (fmt=0x7fb603570a68 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55c597dadef0 "!(!iter->path->should_be_locked)", file=0x55c597dadb98 "libbcachefs/btree_update_leaf.c", line=1358, function=<optimized out>) at assert.c:92
        str = 0x55c598c4dc70 "=0\235\304\300U"
        total = 4096
#3  0x00007fb60341efa2 in __GI___assert_fail (assertion=assertion@entry=0x55c597dadef0 "!(!iter->path->should_be_locked)", file=file@entry=0x55c597dadb98 "libbcachefs/btree_update_leaf.c", line=line@entry=1358,
    function=function@entry=0x55c597dae0c0 <__PRETTY_FUNCTION__.3> "bch2_trans_update") at assert.c:101
No locals.
#4  0x000055c597d40c4c in bch2_trans_update (trans=<optimized out>, iter=<optimized out>, k=<optimized out>, flags=<optimized out>) at libbcachefs/btree_update_leaf.c:1358
        i = <optimized out>
        n = {flags = 2772732384, bkey_type = 253 '\375', btree_id = 127, level = 0 '\000', cached = false, insert_trigger_run = false, overwrite_trigger_run = false, k = 0x7ffda5448b90, path = 0x7ffda5448c00, ip_allocated = 1}
        __PRETTY_FUNCTION__ = "bch2_trans_update"
#5  0x000055c597d3fc25 in bch2_btree_delete_at (trans=trans@entry=0x7ffda5448c00, iter=iter@entry=0x7ffda5448b90, update_flags=update_flags@entry=1) at libbcachefs/btree_update_leaf.c:1475
        k = <optimized out>
#6  0x000055c597d528c5 in check_extent (trans=trans@entry=0x7ffda5448c00, iter=iter@entry=0x7ffda5448b90, inode=inode@entry=0x7ffda5448b30, s=s@entry=0x7ffda5448b60) at libbcachefs/fsck.c:1215
        c = 0x7fb603373000
        k = <optimized out>
        i = <optimized out>
        buf = "u64s 7 type extent 4114:128:U32_MAX len 128 ver 0: crc: c_size 112 size 128 offset 0 nonce 0 csum crc32c compress lz4 ptr: 0:9103588752 gen 2\000\377\377\377\377\377\377\000\000\000\000\000\000\000\360\377\377\377\377\000\000\000\020\000\000\000\000\001\000\000\000\375\1
77\000\000\000\000\000\000\001\000\000\000\377\377\377\a\000\000\000\000\376\377\377\377\200\000\000"
        ret = 2147483647
        fsck_err = <optimized out>
#7  0x000055c597d52c5b in check_extents (c=c@entry=0x7fb603373000) at libbcachefs/fsck.c:1290
        _ret = <optimized out>
        w = {first_this_inode = true, cur_inum = 4114, nr = 0, size = 8, d = 0x55c6706d5400}
        s = {pos = {snapshot = 4294967293, offset = 128, inode = 4114}, nr = 1, size = 256, d = 0x55c60add5400}
        trans = {c = 0x7fb603373000, fn = 0x55c597db1348 <__func__.15> "check_extents", list = {next = 0x7fb603375d70, prev = 0x7fb603375d70}, locking = 0x0, locking_path_idx = 0, locking_pos = {snapshot = 0, offset = 0, inode = 0}, locking_btree_id = 0 '\000',
          locking_level = 0 '\000', pid = 0, srcu_idx = 0, nr_sorted = 4 '\004', nr_updates = 0 '\000', used_mempool = false, in_traverse_all = false, restarted = false, journal_transaction_names = false, extra_journal_res = 0, paths_allocated = 15, mem_top = 40, mem_bytes = 64,
          mem = 0x55c598e03c40, sorted = "\000\001\002\003\004", '\000' <repeats 58 times>, paths = 0x55c59a59f000, updates = 0x55c59a5a1000, hooks = 0x0, extra_journal_entries = 0x0, extra_journal_entry_u64s = 0, journal_pin = 0x0, journal_res = {ref = false, idx = 0 '\000',
            u64s = 0, offset = 0, seq = 0}, journal_preres = {u64s = 0}, journal_seq = 0x0, disk_res = 0x0, flags = 5, journal_u64s = 0, journal_preres_u64s = 0, fs_usage_deltas = 0x0}
        iter = {trans = 0x7ffda5448c00, path = 0x55c59a59f080, btree_id = BTREE_ID_extents, min_depth = 0, flags = 8198, snapshot = 0, pos = {snapshot = 4294967295, offset = 128, inode = 4114}, pos_after_commit = {snapshot = 4294967295, offset = 33031, inode = 0}, k = {u64s = 7 '\a',
            format = 1 '\001', needs_whiteout = 1 '\001', type = 6 '\006', pad = "", version = {lo = 0, hi = 0}, size = 128, p = {snapshot = 4294967295, offset = 128, inode = 4114}}}
        ret = <optimized out>
        __func__ = "check_extents"
#8  0x000055c597d535d4 in bch2_fsck_full (c=c@entry=0x7fb603373000) at libbcachefs/fsck.c:2342
No locals.
#9  0x000055c597d7f408 in bch2_fs_recovery (c=c@entry=0x7fb603373000) at libbcachefs/recovery.c:1201
        err = 0x55c597db6963 "error in fsck"
        clean = 0x55c598c35800
        last_journal_entry = <optimized out>
        blacklist_seq = 3318733
        journal_seq = 3318733
        write_sb = false
        ret = <optimized out>
        __func__ = "bch2_fs_recovery"
#10 0x000055c597cfccdb in bch2_fs_start (c=0x7fb603373000) at libbcachefs/super.c:918
        mi = 0x55c598bc22f0
        ca = 0x0
        now = 1641469761
        i = 1
        ret = -22
        __PRETTY_FUNCTION__ = "bch2_fs_start"
#11 0x000055c597cfe904 in bch2_fs_open (devices=devices@entry=0x7ffda5449298, nr_devices=nr_devices@entry=1, opts=...) at libbcachefs/super.c:1985
        sb = 0x55c598bbf040
        c = 0x7fb603373000
        mi = 0x7fb6033952f0
        i = 1
        best_sb = <optimized out>
        err = 0x55c597da63be "insufficient devices"
        _errbuf = 0x55c598bbe000 ""
        errbuf = <optimized out>
        ret = <optimized out>
        __func__ = "bch2_fs_open"
#12 0x000055c597ce9427 in cmd_fsck (argc=1, argc@entry=3, argv=0x7ffda5449298, argv@entry=0x7ffda5449288) at cmd_fsck.c:90
        longopts = {{name = 0x55c597da2ded "reconstruct_alloc", has_arg = 0, flag = 0x0, val = 82}, {name = 0x0, has_arg = 0, flag = 0x0, val = 0}}
        opts = {block_size_defined = 0, btree_node_size_defined = 0, errors_defined = 0, metadata_replicas_defined = 0, data_replicas_defined = 0, metadata_replicas_required_defined = 0, data_replicas_required_defined = 0, encoded_extent_max_defined = 0,
          metadata_checksum_defined = 0, data_checksum_defined = 0, compression_defined = 0, background_compression_defined = 0, str_hash_defined = 0, metadata_target_defined = 0, foreground_target_defined = 0, background_target_defined = 0, promote_target_defined = 0,
          erasure_code_defined = 0, inodes_32bit_defined = 0, shard_inode_numbers_defined = 0, inodes_use_key_cache_defined = 0, btree_node_mem_ptr_optimization_defined = 0, gc_reserve_percent_defined = 0, gc_reserve_bytes_defined = 0, root_reserve_percent_defined = 0,
          wide_macs_defined = 0, inline_data_defined = 0, acl_defined = 0, usrquota_defined = 0, grpquota_defined = 0, prjquota_defined = 0, degraded_defined = 1, very_degraded_defined = 0, discard_defined = 0, verbose_defined = 0, journal_flush_delay_defined = 0,
          journal_flush_disabled_defined = 0, journal_reclaim_delay_defined = 0, fsck_defined = 1, fix_errors_defined = 1, ratelimit_errors_defined = 0, nochanges_defined = 0, norecovery_defined = 0, rebuild_replicas_defined = 0, keep_journal_defined = 0,
          read_entire_journal_defined = 0, journal_transaction_names_defined = 0, noexcl_defined = 0, sb_defined = 0, read_only_defined = 0, nostart_defined = 0, reconstruct_alloc_defined = 0, version_upgrade_defined = 0, project_defined = 0, fs_size_defined = 0, bucket_defined = 0,
          durability_defined = 0, block_size = 0, btree_node_size = 0, errors = 0 '\000', metadata_replicas = 0 '\000', data_replicas = 0 '\000', metadata_replicas_required = 0 '\000', data_replicas_required = 0 '\000', encoded_extent_max = 0, metadata_checksum = 0 '\000',
data_checksu--Type <RET> for more, q to quit, c to continue without paging--          m = 0 '\000', compression = 0 '\000', background_compression = 0 '\000', str_hash = 0 '\000', metadata_target = 0, foreground_target = 0, background_target = 0, promote_target = 0, erasure_code = 0, i
nodes_32bit = 0 '\000', shard_inode_numbers = 0 '\000',
          inodes_use_key_cache = 0 '\000', btree_node_mem_ptr_optimization = 0 '\000', gc_reserve_percent = 0 '\000', gc_reserve_bytes = 0, root_reserve_percent = 0 '\000', wide_macs = 0 '\000', inline_data = 0 '\000', acl = 0 '\000', usrquota = 0 '\000', grpquota = 0 '\000',
          prjquota = 0 '\000', degraded = 1 '\001', very_degraded = 0 '\000', discard = 0 '\000', verbose = 0 '\000', journal_flush_delay = 0, journal_flush_disabled = 0 '\000', journal_reclaim_delay = 0, fsck = 1 '\001', fix_errors = 1 '\001', ratelimit_errors = 0 '\000',
          nochanges = 0 '\000', norecovery = 0 '\000', rebuild_replicas = 0 '\000', keep_journal = 0 '\000', read_entire_journal = 0 '\000', journal_transaction_names = 0 '\000', noexcl = 0 '\000', sb = 0, read_only = 0 '\000', nostart = 0 '\000', reconstruct_alloc = 0 '\000',
          version_upgrade = 0 '\000', project = 0 '\000', fs_size = 0, bucket = 0, durability = 0 '\000'}
        i = 1
        opt = <optimized out>
        ret = 0
        c = <optimized out>
#13 0x000055c597cd71bd in main (argc=<optimized out>, argv=0x7ffda5449288) at bcachefs.c:197
        cmd = 0x7ffda544b2ff "fsck"

-tools are on commit #47c554c31

data on this filesystem are not important.

Cannot mount using the mount command anymore

Hello,

I have been using bcachefs for some time now and the latest updates have done something to the mounting procedure. Previously, I have used the following command to mount my two-drive system:

sudo mount -t bcachefs -o noatime,errors=continue,verbose /dev/disk1:/dev/disk2 /mnt/mountpoint

Alas, this command does not work for me anymore and what I get as a response is the following:

error: invalid value 'mount' for '<UUID>': invalid character: expected an optional prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `m` at 1

For more information, try '--help'.

I do not know what this exactly means. I have ever only used uuid when mounting using fstab, but from what I remember bcachefs was not greatly compatible with this syntax because of multiple disks and the fstab parser (using : as the delimiter). How do I mount my disks again? If uuid is the way forward for mounting, what uuid do I use? One of the disks, the external uuid, ...?

Thank you very much for your work on bcachefs, I will live through these growing pains.

smoketest fails on AARCH64 platform

Smoketest fails on latest master commit 32aabbc on AARCH64 platform

-- Verify dependencies --
OK
-- Test: default --
Building.
Running tests.
-- Test: debug --
Building.
Running tests.
============================= test session starts ==============================
platform linux -- Python 3.9.2, pytest-6.0.2, py-1.10.0, pluggy-0.13.0
rootdir: /root/bcachefs-tools
plugins: forked-1.3.0, xdist-2.2.0
gw0 I / gw1 I / gw2 I / gw3 I / gw4 I / gw5 I
gw0 [28] / gw1 [28] / gw2 [28] / gw3 [28] / gw4 [28] / gw5 [28]

..ssss.F.sssssssss.s.s.s....                                             [100%]
=================================== FAILURES ===================================
_________________________________ test_format __________________________________
[gw1] linux -- Python 3.9.2 /usr/bin/python3

tmpdir = local('/tmp/pytest-of-root/pytest-8/popen-gw1/test_format0')

    def test_format(tmpdir):
        dev = util.device_1g(tmpdir)
        ret = util.run_bch('format', dev, valgrind=True)
    
>       assert ret.returncode == 0
E       AssertionError: assert 1 == 0
E        +  where 1 = CompletedProcess(args=['/root/bcachefs-tools/bcachefs', 'format', PosixPath('/tmp/pytest-of-root/pytest-8/popen-gw1/te...\nIO error\n', stderr='error opening /tmp/pytest-of-root/pytest-8/popen-gw1/test_format0/dev-1g: Input/output error\n').returncode

tests/test_basic.py:19: AssertionError
----------------------------- Captured stdout call -----------------------------
Running '['/root/bcachefs-tools/bcachefs', 'format', PosixPath('/tmp/pytest-of-root/pytest-8/popen-gw1/test_format0/dev-1g')]'
=========================== short test summary info ============================
FAILED tests/test_basic.py::test_format - AssertionError: assert 1 == 0
=================== 1 failed, 11 passed, 16 skipped in 3.92s ===================

FAILED.

type mismach error building mount.bcachefs on armhf (32 bit)

make mount.bcachefs on armhf platform, cargo v.1.60 produces errors:

LIBBCACHEFS_LIB=/root/bcachefs-tools \
LIBBCACHEFS_INCLUDE=/root/bcachefs-tools \
cargo  build --release --manifest-path rust-src/mount/Cargo.toml
warning: `extern` block uses type `bch_option__bindgen_ty_1__bindgen_ty_1`, which is not FFI-safe
 --> /root/bcachefs-tools/rust-src/mount/target/release/build/bch_bindgen-2a69a3c6add74005/out/bcachefs.rs:3:288247
  |
3 | ...n __bch2_opt_set_sb ( arg1 : * mut bch_sb , arg2 : * const bch_option , arg3 : u64_ ) ; } extern "C" { pub fn bch2_opt_set_sb ( arg1 :...
  |                                                       ^^^^^^^^^^^^^^^^^^ not FFI-safe
  |
  = note: `#[warn(improper_ctypes)]` on by default
  = help: consider adding a member to this struct
  = note: this struct has no fields
note: the type is defined here
 --> /root/bcachefs-tools/rust-src/mount/target/release/build/bch_bindgen-2a69a3c6add74005/out/bcachefs.rs:3:281352
  |
3 | ...ult , Copy , Clone , PartialEq , Eq ) ] pub struct bch_option__bindgen_ty_1__bindgen_ty_1 { } # [ test ] fn bindgen_test_layout_bch_op...
  |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: `extern` block uses type `bch_option__bindgen_ty_1__bindgen_ty_1`, which is not FFI-safe
 --> /root/bcachefs-tools/rust-src/mount/target/release/build/bch_bindgen-2a69a3c6add74005/out/bcachefs.rs:3:288353
  |
3 | ... fn bch2_opt_set_sb ( arg1 : * mut bch_fs , arg2 : * const bch_option , arg3 : u64_ ) ; } extern "C" { pub fn bch2_opt_lookup ( arg1 :...
  |                                                       ^^^^^^^^^^^^^^^^^^ not FFI-safe
  |
  = help: consider adding a member to this struct
  = note: this struct has no fields
note: the type is defined here
 --> /root/bcachefs-tools/rust-src/mount/target/release/build/bch_bindgen-2a69a3c6add74005/out/bcachefs.rs:3:281352
  |
3 | ...ult , Copy , Clone , PartialEq , Eq ) ] pub struct bch_option__bindgen_ty_1__bindgen_ty_1 { } # [ test ] fn bindgen_test_layout_bch_op...
  |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: `extern` block uses type `bch_option__bindgen_ty_1__bindgen_ty_1`, which is not FFI-safe
 --> /root/bcachefs-tools/rust-src/mount/target/release/build/bch_bindgen-2a69a3c6add74005/out/bcachefs.rs:3:288560
  |
3 | ...; } extern "C" { pub fn bch2_opt_validate ( arg1 : * const bch_option , arg2 : u64_ , arg3 : * mut printbuf ) -> :: std :: os :: raw :...
  |                                                       ^^^^^^^^^^^^^^^^^^ not FFI-safe
  |
  = help: consider adding a member to this struct
  = note: this struct has no fields
note: the type is defined here
 --> /root/bcachefs-tools/rust-src/mount/target/release/build/bch_bindgen-2a69a3c6add74005/out/bcachefs.rs:3:281352
  |
3 | ...ult , Copy , Clone , PartialEq , Eq ) ] pub struct bch_option__bindgen_ty_1__bindgen_ty_1 { } # [ test ] fn bindgen_test_layout_bch_op...
  |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: `extern` block uses type `bch_option__bindgen_ty_1__bindgen_ty_1`, which is not FFI-safe
 --> /root/bcachefs-tools/rust-src/mount/target/release/build/bch_bindgen-2a69a3c6add74005/out/bcachefs.rs:3:288721
  |
3 | ...b fn bch2_opt_parse ( arg1 : * mut bch_fs , arg2 : * const bch_option , arg3 : * const :: std :: os :: raw :: c_char , arg4 : * mut u6...
  |                                                       ^^^^^^^^^^^^^^^^^^ not FFI-safe
  |
  = help: consider adding a member to this struct
  = note: this struct has no fields
note: the type is defined here
 --> /root/bcachefs-tools/rust-src/mount/target/release/build/bch_bindgen-2a69a3c6add74005/out/bcachefs.rs:3:281352
  |
3 | ...ult , Copy , Clone , PartialEq , Eq ) ] pub struct bch_option__bindgen_ty_1__bindgen_ty_1 { } # [ test ] fn bindgen_test_layout_bch_op...
  |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: `extern` block uses type `bch_option__bindgen_ty_1__bindgen_ty_1`, which is not FFI-safe
 --> /root/bcachefs-tools/rust-src/mount/target/release/build/bch_bindgen-2a69a3c6add74005/out/bcachefs.rs:3:288983
  |
3 | ...arg2 : * mut bch_fs , arg3 : * mut bch_sb , arg4 : * const bch_option , arg5 : u64_ , arg6 : :: std :: os :: raw :: c_uint ) ; } exter...
  |                                                       ^^^^^^^^^^^^^^^^^^ not FFI-safe
  |
  = help: consider adding a member to this struct
  = note: this struct has no fields
note: the type is defined here
 --> /root/bcachefs-tools/rust-src/mount/target/release/build/bch_bindgen-2a69a3c6add74005/out/bcachefs.rs:3:281352
  |
3 | ...ult , Copy , Clone , PartialEq , Eq ) ] pub struct bch_option__bindgen_ty_1__bindgen_ty_1 { } # [ test ] fn bindgen_test_layout_bch_op...
  |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: `bch_bindgen` (lib) generated 5 warnings
   Compiling bcachefs-mount v0.3.1 (/root/bcachefs-tools/rust-src/mount)
error[E0308]: mismatched types
   --> src/filesystem.rs:105:45
    |
105 |         unsafe { libc::mount(src, target, fstype, mountflags, data) }
    |                                                   ^^^^^^^^^^ expected `u32`, found `u64`
    |
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
    |
105 |         unsafe { libc::mount(src, target, fstype, mountflags.try_into().unwrap(), data) }
    |                                                             ++++++++++++++++++++

error[E0308]: mismatched types
  --> src/key.rs:60:4
   |
60 |             std::mem::size_of::<bch_encrypted_key>() as u64,
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
   |
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
   |
60 |             (std::mem::size_of::<bch_encrypted_key>() as u64).try_into().unwrap(),
   |             +                                               +++++++++++++++++++++

error[E0308]: mismatched types
  --> src/key.rs:74:5
   |
74 |                 std::mem::size_of::<bch_key>() as u64,
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
   |
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
   |
74 |                 (std::mem::size_of::<bch_key>() as u64).try_into().unwrap(),
   |                 +                                     +++++++++++++++++++++

error[E0308]: mismatched types
   --> src/filesystem.rs:154:3
    |
154 |         flags,
    |         ^^^^^ expected `u64`, found `u32`
    |
help: you can convert a `u32` to a `u64`
    |
154 |         flags.into(),
    |              +++++++

For more information about this error, try `rustc --explain E0308`.
error: could not compile `bcachefs-mount` due to 4 previous errors
make: *** [Makefile:122: mount.bcachefs] Error 101

mkfs.bcachefs: --encoded_extent_max doesn't accept value 2M but it should

Hi,
mkfs.bcachfs doesnt accept value 2M but help states that should:

... --encoded_extent_max=2097152
Invalid option encoded_extent_max: too big (max 2097152)

and next, help is not consistent:

... --encoded_extent_max=2097151
Invalid option encoded_extent_max: not a multiple of 512

but valid message should be:
Invalid option encoded_extent_max: must be a power of two

compilation errors on hardened gcc-10

On commit 967c870 , repo evilpiepirate.org.

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-10.2.0-r5/work/gcc-10.2.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/10.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include/g++-v10 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/10.2.0/python --enable-languages=c,c++,jit,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 10.2.0-r5 p6' --enable-esp --enable-libstdcxx-time --with-build-config=bootstrap-lto --disable-libstdcxx-pch --enable-host-shared --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --with-multilib-list=m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (Gentoo Hardened 10.2.0-r5 p6)

First:

cc -O2 -march=westmere -mtune=native -ggdb3 -gdwarf-4         -fvar-tracking-assignments -ftracer -pipe -Wno-maybe-uninitialized -std=gnu89 -MMD -Wall -Wno-pointer-sign -Wno-zero-length-bounds -Wno-stringop
-overflow -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO
_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-296-g967c870+"'  -Wno-unused-but-set-variable -Werror -DCONFIG_BCACHEFS_DEBUG=y -DCONFIG_VALGRIND=y -I/usr/include/blkid -I/usr
/include/uuid   -c -o linux/bio.o linux/bio.c
In file included from /usr/include/string.h:519,
                 from include/linux/slab.h:6,
                 from include/linux/mempool.h:9,
                 from include/linux/bio.h:23,
                 from linux/bio.c:18:
In function ‘memset’,
    inlined from ‘bio_init’ at include/linux/bio.h:444:2,
    inlined from ‘bio_alloc_bioset’ at linux/bio.c:309:2:
/usr/include/bits/string_fortified.h:56:10: error: ‘__builtin_memset’ offset [0, 103] is out of the bounds [0, 0] [-Werror=array-bounds]
   56 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [<builtin>: linux/bio.o] Error 1

another one:

cc -O2 -march=westmere -mtune=native -ggdb3 -gdwarf-4         -fvar-tracking-assignments -ftracer -pipe -Wno-maybe-uninitialized -std=gnu89 -MMD -Wall -Wno-pointer-sign -Wno-zero-length-bounds -Wno-stringop
-overflow -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO
_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-296-g967c870+"'  -Wno-unused-but-set-variable -Werror -DCONFIG_BCACHEFS_DEBUG=y -DCONFIG_VALGRIND=y -I/usr/include/blkid -I/usr
/include/uuid   -c -o libbcachefs/btree_io.o libbcachefs/btree_io.c
In file included from libbcachefs/btree_io.c:15:
libbcachefs/btree_io.c: In function ‘bch2_btree_node_read_done’:
libbcachefs/error.h:112:13: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  112 |  int _fix = bch2_fsck_err(c, _flags, msg, ##__VA_ARGS__);\
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libbcachefs/error.h:137:2: note: in expansion of macro ‘__fsck_err’
  137 |  __fsck_err(c, FSCK_CAN_FIX, ##__VA_ARGS__)
      |  ^~~~~~~~~~
libbcachefs/btree_io.c:518:3: note: in expansion of macro ‘mustfix_fsck_err’
  518 |   mustfix_fsck_err(c, "%s", _buf2);   \
      |   ^~~~~~~~~~~~~~~~
libbcachefs/btree_io.c:559:43: note: in expansion of macro ‘btree_err’
  559 | #define btree_err_on(cond, ...) ((cond) ? btree_err(__VA_ARGS__) : false)
      |                                           ^~~~~~~~~
libbcachefs/btree_io.c:881:3: note: in expansion of macro ‘btree_err_on’
  881 |   btree_err_on(blacklisted && first,
      |   ^~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [<builtin>: libbcachefs/btree_io.o] Error 1

[BUG] fuse build broken

BCACHEFS_FUSE build fails since e61b61c03bf1f1eedc5e2dbd6887f77e45144a31

cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -std=gnu89 -O2 -g -MMD -Wall -Wno-pointer-sign -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-362-gd214908"'  -Wno-unused-but-set-variable -Wno-stringop-overflow -Wno-zero-length-bounds -Wno-missing-braces  -Wno-shift-overflow -Wno-enum-conversion -DBCACHEFS_FUSE -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/fuse3    -c -o cmd_key.o cmd_key.c
cmd_fusemount.c: In function ‘bcachefs_fuse_lookup’:
cmd_fusemount.c:108:42: error: incompatible type for argument 2 of ‘bch2_inode_find_by_inum’
  108 |         ret = bch2_inode_find_by_inum(c, dir, &bi);
      |                                          ^~~
      |                                          |
      |                                          fuse_ino_t {aka long unsigned int}
In file included from libbcachefs/str_hash.h:9,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
libbcachefs/inode.h:79:46: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   79 | int bch2_inode_find_by_inum(struct bch_fs *, subvol_inum,
      |                                              ^~~~~~~~~~~
cmd_fusemount.c:116:38: error: incompatible type for argument 2 of ‘bch2_dirent_lookup’
  116 |         inum = bch2_dirent_lookup(c, dir, &hash_info, &qstr);
      |                                      ^~~
      |                                      |
      |                                      fuse_ino_t {aka long unsigned int}
In file included from cmd_fusemount.c:19:
libbcachefs/dirent.h:60:41: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   60 | u64 bch2_dirent_lookup(struct bch_fs *, subvol_inum,
      |                                         ^~~~~~~~~~~
cmd_fusemount.c:116:16: error: too few arguments to function ‘bch2_dirent_lookup’
  116 |         inum = bch2_dirent_lookup(c, dir, &hash_info, &qstr);
      |                ^~~~~~~~~~~~~~~~~~
In file included from cmd_fusemount.c:19:
libbcachefs/dirent.h:60:5: note: declared here
   60 | u64 bch2_dirent_lookup(struct bch_fs *, subvol_inum,
      |     ^~~~~~~~~~~~~~~~~~
cmd_fusemount.c:126:42: error: incompatible type for argument 2 of ‘bch2_inode_find_by_inum’
  126 |         ret = bch2_inode_find_by_inum(c, inum, &bi);
      |                                          ^~~~
      |                                          |
      |                                          u64 {aka long long unsigned int}
In file included from libbcachefs/str_hash.h:9,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
libbcachefs/inode.h:79:46: note: expected ‘subvol_inum’ but argument is of type ‘u64’ {aka ‘long long unsigned int’}
   79 | int bch2_inode_find_by_inum(struct bch_fs *, subvol_inum,
      |                                              ^~~~~~~~~~~
cmd_fusemount.c: In function ‘bcachefs_fuse_getattr’:
cmd_fusemount.c:154:42: error: incompatible type for argument 2 of ‘bch2_inode_find_by_inum’
  154 |         ret = bch2_inode_find_by_inum(c, inum, &bi);
      |                                          ^~~~
      |                                          |
      |                                          fuse_ino_t {aka long unsigned int}
In file included from libbcachefs/str_hash.h:9,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
libbcachefs/inode.h:79:46: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   79 | int bch2_inode_find_by_inum(struct bch_fs *, subvol_inum,
      |                                              ^~~~~~~~~~~
cmd_fusemount.c: In function ‘bcachefs_fuse_setattr’:
cmd_fusemount.c:188:56: error: incompatible type for argument 4 of ‘bch2_inode_peek’
  188 |         ret = bch2_inode_peek(&trans, &iter, &inode_u, inum, BTREE_ITER_INTENT);
      |                                                        ^~~~
      |                                                        |
      |                                                        fuse_ino_t {aka long unsigned int}
In file included from libbcachefs/str_hash.h:9,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
libbcachefs/inode.h:61:50: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   61 |                     struct bch_inode_unpacked *, subvol_inum, unsigned);
      |                                                  ^~~~~~~~~~~
In file included from libbcachefs/str_hash.h:6,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
cmd_fusemount.c: In function ‘do_create’:
cmd_fusemount.c:241:33: error: incompatible type for argument 2 of ‘bch2_create_trans’
  241 |                                 dir, &dir_u,
      |                                 ^~~
      |                                 |
      |                                 u64 {aka long long unsigned int}
libbcachefs/btree_update.h:110:25: note: in definition of macro ‘lockrestart_do’
  110 |                 _ret = (_do);                                           \
      |                         ^~~
libbcachefs/btree_update.h:126:16: note: in expansion of macro ‘__bch2_trans_do’
  126 |         _ret = __bch2_trans_do(&trans, _disk_res, _journal_seq, _flags, \
      |                ^~~~~~~~~~~~~~~
cmd_fusemount.c:239:16: note: in expansion of macro ‘bch2_trans_do’
  239 |         return bch2_trans_do(c, NULL, NULL, 0,
      |                ^~~~~~~~~~~~~
In file included from cmd_fusemount.c:21:
libbcachefs/fs-common.h:12:45: note: expected ‘subvol_inum’ but argument is of type ‘u64’ {aka ‘long long unsigned int’}
   12 | int bch2_create_trans(struct btree_trans *, subvol_inum,
      |                                             ^~~~~~~~~~~
In file included from libbcachefs/str_hash.h:6,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
cmd_fusemount.c:240:25: error: too few arguments to function ‘bch2_create_trans’
  240 |                         bch2_create_trans(&trans,
      |                         ^~~~~~~~~~~~~~~~~
libbcachefs/btree_update.h:110:25: note: in definition of macro ‘lockrestart_do’
  110 |                 _ret = (_do);                                           \
      |                         ^~~
libbcachefs/btree_update.h:126:16: note: in expansion of macro ‘__bch2_trans_do’
  126 |         _ret = __bch2_trans_do(&trans, _disk_res, _journal_seq, _flags, \
      |                ^~~~~~~~~~~~~~~
cmd_fusemount.c:239:16: note: in expansion of macro ‘bch2_trans_do’
  239 |         return bch2_trans_do(c, NULL, NULL, 0,
      |                ^~~~~~~~~~~~~
In file included from cmd_fusemount.c:21:
libbcachefs/fs-common.h:12:5: note: declared here
   12 | int bch2_create_trans(struct btree_trans *, subvol_inum,
      |     ^~~~~~~~~~~~~~~~~
In file included from libbcachefs/str_hash.h:6,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
cmd_fusemount.c: In function ‘bcachefs_fuse_unlink’:
cmd_fusemount.c:292:55: error: incompatible type for argument 2 of ‘bch2_unlink_trans’
  292 |                             bch2_unlink_trans(&trans, dir, &dir_u,
      |                                                       ^~~
      |                                                       |
      |                                                       fuse_ino_t {aka long unsigned int}
libbcachefs/btree_update.h:110:25: note: in definition of macro ‘lockrestart_do’
  110 |                 _ret = (_do);                                           \
      |                         ^~~
libbcachefs/btree_update.h:126:16: note: in expansion of macro ‘__bch2_trans_do’
  126 |         _ret = __bch2_trans_do(&trans, _disk_res, _journal_seq, _flags, \
      |                ^~~~~~~~~~~~~~~
cmd_fusemount.c:291:15: note: in expansion of macro ‘bch2_trans_do’
  291 |         ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_NOFAIL,
      |               ^~~~~~~~~~~~~
In file included from cmd_fusemount.c:21:
libbcachefs/fs-common.h:26:45: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   26 | int bch2_unlink_trans(struct btree_trans *, subvol_inum,
      |                                             ^~~~~~~~~~~
In file included from libbcachefs/str_hash.h:6,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
cmd_fusemount.c:292:29: error: too few arguments to function ‘bch2_unlink_trans’
  292 |                             bch2_unlink_trans(&trans, dir, &dir_u,
      |                             ^~~~~~~~~~~~~~~~~
libbcachefs/btree_update.h:110:25: note: in definition of macro ‘lockrestart_do’
  110 |                 _ret = (_do);                                           \
      |                         ^~~
libbcachefs/btree_update.h:126:16: note: in expansion of macro ‘__bch2_trans_do’
  126 |         _ret = __bch2_trans_do(&trans, _disk_res, _journal_seq, _flags, \
      |                ^~~~~~~~~~~~~~~
cmd_fusemount.c:291:15: note: in expansion of macro ‘bch2_trans_do’
  291 |         ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_NOFAIL,
      |               ^~~~~~~~~~~~~
In file included from cmd_fusemount.c:21:
libbcachefs/fs-common.h:26:5: note: declared here
   26 | int bch2_unlink_trans(struct btree_trans *, subvol_inum,
      |     ^~~~~~~~~~~~~~~~~
In file included from libbcachefs/str_hash.h:6,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
cmd_fusemount.c: In function ‘bcachefs_fuse_rename’:
cmd_fusemount.c:330:35: error: incompatible type for argument 2 of ‘bch2_rename_trans’
  330 |                                   src_dir, &src_dir_u,
      |                                   ^~~~~~~
      |                                   |
      |                                   fuse_ino_t {aka long unsigned int}
libbcachefs/btree_update.h:110:25: note: in definition of macro ‘lockrestart_do’
  110 |                 _ret = (_do);                                           \
      |                         ^~~
libbcachefs/btree_update.h:126:16: note: in expansion of macro ‘__bch2_trans_do’
  126 |         _ret = __bch2_trans_do(&trans, _disk_res, _journal_seq, _flags, \
      |                ^~~~~~~~~~~~~~~
cmd_fusemount.c:328:15: note: in expansion of macro ‘bch2_trans_do’
  328 |         ret = bch2_trans_do(c, NULL, NULL, 0,
      |               ^~~~~~~~~~~~~
In file included from cmd_fusemount.c:21:
libbcachefs/fs-common.h:32:23: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   32 |                       subvol_inum, struct bch_inode_unpacked *,
      |                       ^~~~~~~~~~~
In file included from libbcachefs/str_hash.h:6,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
cmd_fusemount.c:331:35: error: incompatible type for argument 4 of ‘bch2_rename_trans’
  331 |                                   dst_dir, &dst_dir_u,
      |                                   ^~~~~~~
      |                                   |
      |                                   fuse_ino_t {aka long unsigned int}
libbcachefs/btree_update.h:110:25: note: in definition of macro ‘lockrestart_do’
  110 |                 _ret = (_do);                                           \
      |                         ^~~
libbcachefs/btree_update.h:126:16: note: in expansion of macro ‘__bch2_trans_do’
  126 |         _ret = __bch2_trans_do(&trans, _disk_res, _journal_seq, _flags, \
      |                ^~~~~~~~~~~~~~~
cmd_fusemount.c:328:15: note: in expansion of macro ‘bch2_trans_do’
  328 |         ret = bch2_trans_do(c, NULL, NULL, 0,
      |               ^~~~~~~~~~~~~
In file included from cmd_fusemount.c:21:
libbcachefs/fs-common.h:33:23: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   33 |                       subvol_inum, struct bch_inode_unpacked *,
      |                       ^~~~~~~~~~~
In file included from libbcachefs/str_hash.h:6,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
cmd_fusemount.c: In function ‘bcachefs_fuse_link’:
cmd_fusemount.c:353:53: error: incompatible type for argument 2 of ‘bch2_link_trans’
  353 |                             bch2_link_trans(&trans, newparent,
      |                                                     ^~~~~~~~~
      |                                                     |
      |                                                     fuse_ino_t {aka long unsigned int}
libbcachefs/btree_update.h:110:25: note: in definition of macro ‘lockrestart_do’
  110 |                 _ret = (_do);                                           \
      |                         ^~~
libbcachefs/btree_update.h:126:16: note: in expansion of macro ‘__bch2_trans_do’
  126 |         _ret = __bch2_trans_do(&trans, _disk_res, _journal_seq, _flags, \
      |                ^~~~~~~~~~~~~~~
cmd_fusemount.c:352:15: note: in expansion of macro ‘bch2_trans_do’
  352 |         ret = bch2_trans_do(c, NULL, NULL, 0,
      |               ^~~~~~~~~~~~~
In file included from cmd_fusemount.c:21:
libbcachefs/fs-common.h:22:21: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   22 |                     subvol_inum, struct bch_inode_unpacked *,
      |                     ^~~~~~~~~~~
In file included from libbcachefs/str_hash.h:6,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
cmd_fusemount.c:354:45: warning: passing argument 3 of ‘bch2_link_trans’ makes pointer from integer without a cast [-Wint-conversion]
  354 |                                             inum, &dir_u, &inode_u, &qstr));
      |                                             ^~~~
      |                                             |
      |                                             fuse_ino_t {aka long unsigned int}
libbcachefs/btree_update.h:110:25: note: in definition of macro ‘lockrestart_do’
  110 |                 _ret = (_do);                                           \
      |                         ^~~
libbcachefs/btree_update.h:126:16: note: in expansion of macro ‘__bch2_trans_do’
  126 |         _ret = __bch2_trans_do(&trans, _disk_res, _journal_seq, _flags, \
      |                ^~~~~~~~~~~~~~~
cmd_fusemount.c:352:15: note: in expansion of macro ‘bch2_trans_do’
  352 |         ret = bch2_trans_do(c, NULL, NULL, 0,
      |               ^~~~~~~~~~~~~
In file included from cmd_fusemount.c:21:
libbcachefs/fs-common.h:22:34: note: expected ‘struct bch_inode_unpacked *’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   22 |                     subvol_inum, struct bch_inode_unpacked *,
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from libbcachefs/str_hash.h:6,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
cmd_fusemount.c:354:51: error: incompatible type for argument 4 of ‘bch2_link_trans’
  354 |                                             inum, &dir_u, &inode_u, &qstr));
      |                                                   ^~~~~~
      |                                                   |
      |                                                   struct bch_inode_unpacked *
libbcachefs/btree_update.h:110:25: note: in definition of macro ‘lockrestart_do’
  110 |                 _ret = (_do);                                           \
      |                         ^~~
libbcachefs/btree_update.h:126:16: note: in expansion of macro ‘__bch2_trans_do’
  126 |         _ret = __bch2_trans_do(&trans, _disk_res, _journal_seq, _flags, \
      |                ^~~~~~~~~~~~~~~
cmd_fusemount.c:352:15: note: in expansion of macro ‘bch2_trans_do’
  352 |         ret = bch2_trans_do(c, NULL, NULL, 0,
      |               ^~~~~~~~~~~~~
In file included from cmd_fusemount.c:21:
libbcachefs/fs-common.h:23:21: note: expected ‘subvol_inum’ but argument is of type ‘struct bch_inode_unpacked *’
   23 |                     subvol_inum, struct bch_inode_unpacked *,
      |                     ^~~~~~~~~~~
cmd_fusemount.c: In function ‘get_inode_io_opts’:
cmd_fusemount.c:388:40: error: incompatible type for argument 2 of ‘bch2_inode_find_by_inum’
  388 |         if (bch2_inode_find_by_inum(c, inum, &inode))
      |                                        ^~~~
      |                                        |
      |                                        u64 {aka long long unsigned int}
In file included from libbcachefs/str_hash.h:9,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
libbcachefs/inode.h:79:46: note: expected ‘subvol_inum’ but argument is of type ‘u64’ {aka ‘long long unsigned int’}
   79 | int bch2_inode_find_by_inum(struct bch_fs *, subvol_inum,
      |                                              ^~~~~~~~~~~
cmd_fusemount.c: In function ‘read_aligned’:
cmd_fusemount.c:473:53: error: incompatible type for argument 3 of ‘bch2_read’
  473 |         bch2_read(c, rbio_init(&rbio.bio, io_opts), inum);
      |                                                     ^~~~
      |                                                     |
      |                                                     fuse_ino_t {aka long unsigned int}
In file included from cmd_fusemount.c:23:
libbcachefs/io.h:165:42: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
  165 |                              subvol_inum inum)
      |                              ~~~~~~~~~~~~^~~~
cmd_fusemount.c: In function ‘bcachefs_fuse_read’:
cmd_fusemount.c:491:46: error: incompatible type for argument 2 of ‘bch2_inode_find_by_inum’
  491 |         int ret = bch2_inode_find_by_inum(c, inum, &bi);
      |                                              ^~~~
      |                                              |
      |                                              fuse_ino_t {aka long unsigned int}
In file included from libbcachefs/str_hash.h:9,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
libbcachefs/inode.h:79:46: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   79 | int bch2_inode_find_by_inum(struct bch_fs *, subvol_inum,
      |                                              ^~~~~~~~~~~
cmd_fusemount.c: In function ‘inode_update_times’:
cmd_fusemount.c:535:56: error: incompatible type for argument 4 of ‘bch2_inode_peek’
  535 |         ret = bch2_inode_peek(&trans, &iter, &inode_u, inum, BTREE_ITER_INTENT);
      |                                                        ^~~~
      |                                                        |
      |                                                        fuse_ino_t {aka long unsigned int}
In file included from libbcachefs/str_hash.h:9,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
libbcachefs/inode.h:61:50: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   61 |                     struct bch_inode_unpacked *, subvol_inum, unsigned);
      |                                                  ^~~~~~~~~~~
cmd_fusemount.c: In function ‘bcachefs_fuse_readlink’:
cmd_fusemount.c:751:46: error: incompatible type for argument 2 of ‘bch2_inode_find_by_inum’
  751 |         int ret = bch2_inode_find_by_inum(c, inum, &bi);
      |                                              ^~~~
      |                                              |
      |                                              fuse_ino_t {aka long unsigned int}
In file included from libbcachefs/str_hash.h:9,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
libbcachefs/inode.h:79:46: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   79 | int bch2_inode_find_by_inum(struct bch_fs *, subvol_inum,
      |                                              ^~~~~~~~~~~
cmd_fusemount.c: In function ‘bcachefs_fuse_readdir’:
cmd_fusemount.c:921:42: error: incompatible type for argument 2 of ‘bch2_inode_find_by_inum’
  921 |         ret = bch2_inode_find_by_inum(c, dir, &bi);
      |                                          ^~~
      |                                          |
      |                                          fuse_ino_t {aka long unsigned int}
In file included from libbcachefs/str_hash.h:9,
                 from libbcachefs/dirent.h:5,
                 from cmd_fusemount.c:19:
libbcachefs/inode.h:79:46: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   79 | int bch2_inode_find_by_inum(struct bch_fs *, subvol_inum,
      |                                              ^~~~~~~~~~~
cmd_fusemount.c:933:31: error: incompatible type for argument 2 of ‘bch2_readdir’
  933 |         ret = bch2_readdir(c, dir, &ctx.ctx);
      |                               ^~~
      |                               |
      |                               fuse_ino_t {aka long unsigned int}
In file included from cmd_fusemount.c:19:
libbcachefs/dirent.h:65:35: note: expected ‘subvol_inum’ but argument is of type ‘fuse_ino_t’ {aka ‘long unsigned int’}
   65 | int bch2_readdir(struct bch_fs *, subvol_inum, struct dir_context *);
      |                                   ^~~~~~~~~~~
make: *** [<builtin>: cmd_fusemount.o] Error 1

There might be a bug in adding a device?

I formatted a few drives to test bcachefs. Evacuating a drive works like a charm, but adding a device always yields the following error:

blocksize too small: 8, must be greater than device blocksize 512

I know that all of my drives have the same sector size and bcachefs show-super tells me that the block size for the filesystem is 4.0k. This is confusing because there should not be any problems. I noted that the number 8 is not random (I think it was 0 in previous testing a long time ago, on same drives) but a factor of 4.0k. I started perusing the source code and by making the following change to the file cmd_device.c, line 122:

before:
read_file_u64(fs.sysfs_fd, "options/block_size"));

after:
read_file_u64(fs.sysfs_fd, "block_size"));

It seems that the block_size inside options is the multiple of 512 sized sectors, while the upper directory contains the real block size for the filesystem. This change allowed me to add devices and everything functions perfectly!

I thought about posting a pull request to change this but decided that doing so wasn't the best approach. I do not have kernel engineering experience (neither C language or specific development standards) and I do not know if that is even the proper fix for the problem. Perhaps one of those variables is in the process of being deprecated and that's why the tool behaves like it does. However, without this modification I just could not add any devices to an existing filesystem. It was a genuine problem for me and for which I think there should be an upstream solution.

Edit: pretty sure this was due to version differences with tools and kernel.

Error compiling `mount`

Error trying to build mount command

rust build run after finish of building other bcachefs-tools with make, make finished without errors.
error message:

   Compiling tempfile v3.1.0
   Compiling bcachefs-mount v0.1.0 (/root/bcachefs-tools/mount)
warning: unused import: `std::process::Command`
 --> build.rs:3:6
  |
3 |     use std::process::Command;
  |         ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused variable: `libbcachefs_dir`
  --> build.rs:12:6
   |
12 |     let libbcachefs_dir = top_dir.join("libbcachefs").join("libbcachefs");
   |         ^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_libbcachefs_dir`
   |
   = note: `#[warn(unused_variables)]` on by default

   Compiling parse-display v0.1.1
   Compiling gag v0.1.10
warning: `bcachefs-mount` (build script) generated 2 warnings
   Compiling structopt-derive v0.4.7
   Compiling getset v0.1.0
error: failed to run custom build command for `bcachefs-mount v0.1.0 (/root/bcachefs-tools/mount)`

Caused by:
  process didn't exit successfully: `/root/bcachefs-tools/mount/target/debug/build/bcachefs-mount-bea579e2929e0c06/build-script-build` (exit status: 101)
  --- stdout
  /root/bcachefs-tools/mount/libbcachefs

  --- stderr
  /root/bcachefs-tools/mount/src/libbcachefs_wrapper.h:1:10: fatal error: '../libbcachefs/super-io.h' file not found
  /root/bcachefs-tools/mount/src/libbcachefs_wrapper.h:1:10: fatal error: '../libbcachefs/super-io.h' file not found, err: true
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ()', build.rs:49:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

build performed on x64 platform, linux, in docker,
Dockerfille:

FROM rust:bullseye as rust
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update; apt-get install -y pkg-config libaio-dev libblkid-dev libkeyutils-dev \
        liblz4-dev libscrypt-dev libsodium-dev liburcu-dev libzstd-dev \
        uuid-dev zlib1g-dev valgrind libudev-dev llvm-dev build-essential \
        python3 python3-docutils \
        python3-pytest devscripts debhelper mc \
        libclang-dev
WORKDIR /root
RUN git clone https://github.com/koverstreet/bcachefs-tools.git
WORKDIR bcachefs-tools
run make
WORKDIR mount
RUN cargo build

fs usage reports no free data space (backpointers)

not tested on previous versions
Creation of filesystem with backpointers:

bcachefs format --fs_label multimedia --data_checksum=none --metadata_checksum=xxhash --label HDD --data_allowed user /dev/sdm --label SSDM --discard --data_allowed sb,journal,btree $(for i in /dev/disk/by-partlabel/*mulmeta*; do echo $i; done) --label SSDC --discard --data_allowed cached,user $(for i in /dev/disk/by-partlabel/*mulcache*; do echo $i; done) --foreground_target=SSDC --metadata_target=SSDM --background_target=HDD --promote_target=SSDC --metadata_replicas=3
External UUID:                  99b5c54a-aa10-4a14-880a-03756a9838f1
Internal UUID:                  63865b47-78ee-454c-a863-8e87092fb0b2
Device index:                   11
Label:                          multimedia
Version:                        backpointers
Oldest version on disk:         backpointers
Created:                        Fri Jun 17 15:20:56 2022
Sequence number:                0
Superblock size:                1584
Clean:                          0
Devices:                        12
Sections:                       members,disk_groups
Features:                       new_siphash,new_extent_overwrite,btree_ptr_v2,extents_above_btree_updates,btree_updates_journalled,new_varint,journal_no_flush,alloc_v2,extents_across_btree_nodes
Compat features:                

Options:
  block_size:                   512 B
  btree_node_size:              256 KiB
  errors:                       continue [ro] panic
  metadata_replicas:            3
  data_replicas:                1
  metadata_replicas_required:   1
  data_replicas_required:       1
  encoded_extent_max:           64.0 KiB
  metadata_checksum:            none crc32c crc64 [xxhash]
  data_checksum:                [none] crc32c crc64 xxhash
  compression:                  [none] lz4 gzip zstd
  background_compression:       [none] lz4 gzip zstd
  str_hash:                     crc32c crc64 [siphash]
  metadata_target:              SSDM
  foreground_target:            SSDC
  background_target:            HDD
  promote_target:               SSDC
  erasure_code:                 0
  inodes_32bit:                 1
  shard_inode_numbers:          1
  inodes_use_key_cache:         1
  gc_reserve_percent:           8
  gc_reserve_bytes:             0 B
  root_reserve_percent:         0
  wide_macs:                    0
  acl:                          1
  usrquota:                     0
  grpquota:                     0
  prjquota:                     0
  journal_flush_delay:          1000
  journal_flush_disabled:       0
  journal_reclaim_delay:        100

members (size 680):
  Device:                       0
    UUID:                       85b8436f-6724-47af-810a-d081bf7474ea
    Size:                       16.3 TiB
    Bucket size:                512 KiB
    First bucket:               0
    Buckets:                    34283500
    Last mount:                 (never)
    State:                      rw
    Label:                      HDD (0)
    Data allowed:               user
    Has data:                   (none)
    Discard:                    0
    Freespace initialized:      0
  Device:                       1
    UUID:                       f718ddb6-0829-43c6-a566-e779a3a75bda
    Size:                       37.3 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    152588
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDM (1)
    Data allowed:               sb,journal,btree
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
  Device:                       2
    UUID:                       d4e6f980-9e0f-4125-ab67-907a59d6f96f
    Size:                       37.3 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    152576
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDM (1)
    Data allowed:               sb,journal,btree
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
  Device:                       3
    UUID:                       d845c737-b7a6-4b45-abc8-d5537502440a
    Size:                       37.3 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    152588
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDM (1)
    Data allowed:               sb,journal,btree
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
  Device:                       4
    UUID:                       45ec1466-e1fa-4660-afd8-d7681d9fc5a6
    Size:                       37.3 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    152588
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDM (1)
    Data allowed:               sb,journal,btree
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
  Device:                       5
    UUID:                       be5115c0-5810-45b6-b7c5-580f7a7daea9
    Size:                       37.3 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    152588
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDM (1)
    Data allowed:               sb,journal,btree
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
  Device:                       6
    UUID:                       b9507d8a-c7f2-4857-af51-b8e2676edeb4
    Size:                       37.3 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    152588
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDM (1)
    Data allowed:               sb,journal,btree
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
  Device:                       7
    UUID:                       7287e804-6a1c-457b-936f-0592d47d8ded
    Size:                       93.1 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    381468
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDC (2)
    Data allowed:               user
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
  Device:                       8
    UUID:                       83f74f37-80d7-44c4-b5bc-b67334acf2bc
    Size:                       32.6 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    133516
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDC (2)
    Data allowed:               user
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
  Device:                       9
    UUID:                       8f339088-f858-466b-94fc-9ad9b01a119e
    Size:                       37.3 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    152588
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDC (2)
    Data allowed:               user
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
  Device:                       10
    UUID:                       49c05cf8-b4d9-440e-9a97-37e3aa889c95
    Size:                       37.3 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    152588
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDC (2)
    Data allowed:               user
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
  Device:                       11
    UUID:                       d0fe3d74-4877-4353-a562-355dd16a6646
    Size:                       37.3 GiB
    Bucket size:                256 KiB
    First bucket:               0
    Buckets:                    152588
    Last mount:                 (never)
    State:                      rw
    Label:                      SSDC (2)
    Data allowed:               user
    Has data:                   (none)
    Discard:                    1
    Freespace initialized:      0
initializing new filesystem
going read-write
initializing freespace
mounted version=backpointers opts=metadata_replicas=3,metadata_checksum=xxhash,data_checksum=none,metadata_target=SSDM,foreground_target=SSDC,background_target=HDD,promote_target=SSDC,noinodes_use_key_cache

mounting it & performing a 1TB rsync, while running:

bcachefs fs usage /data/multimedia/
Filesystem: 99b5c54a-aa10-4a14-880a-03756a9838f1
Size:                 16991870748160
Used:                    36173727744
Online reserved:          3124152320

Data type       Required/total  Devices
btree:          1/3             [nvme0n1p2 nvme1n1p2 sdd2]    786432
btree:          1/3             [sdl2 sdc2 sdd2]            38535168
btree:          1/3             [nvme1n1p2 sdc2 sdd2]        2359296
btree:          1/3             [nvme0n1p2 nvme1n1p2 sdi2]  47972352
btree:          1/3             [nvme0n1p2 sdi2 sdl2]        2359296
user:           1/1             [sdi4]                    3137470464
user:           1/1             [sdc5]                    3137701888
user:           1/1             [nvme0n1p5]               7846791168
user:           1/1             [sdl4]                    3136883200
user:           1/1             [sdm]                     4702457344
user:           1/1             [nvme1n1p5]               2744433664
cached:         1/1             [nvme1n1p5]                645874688
cached:         1/1             [sdl4]                     738006016
cached:         1/1             [nvme0n1p5]               1843361792
cached:         1/1             [sdi4]                     737641984
cached:         1/1             [sdc5]                     737572864

HDD (device 0):                  sdm              rw
                                data         buckets      fragmented
  free:                            0        34266331
  sb:                        3149824               7          520192
  journal:                4294967296            8192
  btree:                           0               0
  user:                   4702457344            8970          406016
  cached:                          0               0
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:           17974427648000        34283500

SSDC (device 7):           nvme0n1p5              rw
                                data         buckets      fragmented
  free:                            0          341510
  sb:                        3149824              13          258048
  journal:                 781189120            2980
  btree:                           0               0
  user:                   7846791168           29943         2586624
  cached:                 1843361792            7022
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              99999547392          381468

SSDC (device 8):           nvme1n1p5              rw
                                data         buckets      fragmented
  free:                            0          119527
  sb:                        3149824              13          258048
  journal:                 273416192            1043
  btree:                           0               0
  user:                   2744433664           10472          738304
  cached:                  645874688            2461
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              35000418304          133516

SSDC (device 11):               sdc5              rw
                                data         buckets      fragmented
  free:                            0          136600
  sb:                        3149824              13          258048
  journal:                 312475648            1192
  btree:                           0               0
  user:                   3137701888           11973          948224
  cached:                  737572864            2810
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              40000028672          152588

SSDC (device 9):                sdi4              rw
                                data         buckets      fragmented
  free:                            0          136600
  sb:                        3149824              13          258048
  journal:                 312475648            1192
  btree:                           0               0
  user:                   3137470464           11974         1441792
  cached:                  737641984            2809
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              40000028672          152588

SSDC (device 10):               sdl4              rw
                                data         buckets      fragmented
  free:                            0          136601
  sb:                        3149824              13          258048
  journal:                 312475648            1192
  btree:                           0               0
  user:                   3136883200           11972         1504768
  cached:                  738006016            2810
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              40000028672          152588

SSDM (device 1):           nvme0n1p2              rw
                                data         buckets      fragmented
  free:                            0          151318
  sb:                        3149824              13          258048
  journal:                 312475648            1192
  btree:                    17039360              65
  user:                            0               0
  cached:                          0               0
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              40000028672          152588

SSDM (device 2):           nvme1n1p2              rw
                                data         buckets      fragmented
  free:                            0          151306
  sb:                        3149824              13          258048
  journal:                 312475648            1192
  btree:                    17039360              65
  user:                            0               0
  cached:                          0               0
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              39996882944          152576

SSDM (device 5):                sdc2              rw
                                data         buckets      fragmented
  free:                            0          151331
  sb:                        3149824              13          258048
  journal:                 312475648            1192
  btree:                    13631488              52
  user:                            0               0
  cached:                          0               0
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              40000028672          152588

SSDM (device 6):                sdd2              rw
                                data         buckets      fragmented
  free:                            0          151330
  sb:                        3149824              13          258048
  journal:                 312475648            1192
  btree:                    13893632              53
  user:                            0               0
  cached:                          0               0
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              40000028672          152588

SSDM (device 3):                sdi2              rw
                                data         buckets      fragmented
  free:                            0          151319
  sb:                        3149824              13          258048
  journal:                 312475648            1192
  btree:                    16777216              64
  user:                            0               0
  cached:                          0               0
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              40000028672          152588

SSDM (device 4):                sdl2              rw
                                data         buckets      fragmented
  free:                            0          151331
  sb:                        3149824              13          258048
  journal:                 312475648            1192
  btree:                    13631488              52
  user:                            0               0
  cached:                          0               0
  parity:                          0               0
  stripe:                          0               0
  need_gc_gens:                    0               0
  need_discard:                    0               0
  erasure coded:                   0               0
  capacity:              40000028672          152588

... as you can see, no free space on any device.
Minor issue, but "something that would be nice to fix"

compilation error: libbcachefs/fsck.c:176:17: error: unused variable ‘c’

On commit 967c8704989f6194dc40ea884b5d0f713d4fb74c , repo evilpiepirate.org.

gcc-9.3.0 -O2 -march=westmere -mtune=native -ggdb3 -gdwarf-4         -fvar-tracking-assignments -ftracer -pipe -Wno-maybe-uninitialized -std=gnu89 -MMD -Wall -Wno-pointer-sign -Wno-zero-length-bounds -Wno-stringop-overflow -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-296-g967c870+"'  -Wno-unused-but-set-variable -Werror -DCONFIG_BCACHEFS_DEBUG=y -DCONFIG_VALGRIND=y -I/usr/include/blkid -I/usr/include/uuid   -c -o libbcachefs/fsck.o libbcachefs/fsck.c
libbcachefs/fsck.c: In function ‘reattach_inode’:
libbcachefs/fsck.c:176:17: error: unused variable ‘c’ [-Werror=unused-variable]
  176 |  struct bch_fs *c = trans->c;
      |                 ^
libbcachefs/fsck.c: At top level:
cc1: error: unrecognized command line option ‘-Wno-zero-length-bounds’ [-Werror]
cc1: all warnings being treated as errors
make: *** [<builtin>: libbcachefs/fsck.o] Error 1

FP: DMesg errors, emergency read only file system after setattr

I attempted to reduce the number of copies for a directory using

❯ bcachefs setattr --data_replicas=1 games/

After then trying to use the filesystem I found it was readonly and found the following in dmesg

  [132933.771729] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6): Superblock modified by another process
  [132933.771751] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6): emergency read only
  [132933.782837] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6 inum 945177): write error -30 from btree update
  [132933.782850] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6 inum 945177): write error -30 from btree update
  [132933.783045] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6 inum 945177): write error -30 from btree update
  [132933.783135] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6 inum 945177): write error -30 from btree update
  [132933.783145] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6 inum 945177): write error -30 from btree update
  [132933.783249] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6 inum 945177): write error -30 from btree update
  [132933.783329] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6 inum 945177): write error -30 from btree update
  [132933.783489] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6 inum 945177): write error -30 from btree update
  [132933.789771] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6 inum 945177): write error -30 from btree update
  [132933.796642] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6 inum 945177): write error -30 from btree update
  [132933.821974] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6): Superblock modified by another process
  [132933.889619] bcachefs (cbac7e42-7068-4843-a484-6093a854bea6): Superblock modified by another process
❯ s bcachefs fsck /dev/sdb /dev/sdd /dev/sde /dev/sda /dev/sdc /dev/nvme0n1 -n
bcachefs: bch2_read_super() error reading default superblock: Not a bcachefs superblock
bcachefs: bch2_read_super() error reading superblock: Not a bcachefs superblock layout
error opening /dev/sdb: Invalid argument

and attempting to remount via the rust(custom logging modifications, no logic modifications) tool

$ RUST_LOG="trace" s mount.bcachefs cbac7e42-7068-4843-a484-6093a854bea6 /media/bfs
Oct 05 10:46:39.984 TRACE main: bcachefs_mount: opt=Options { key_location: KeyLoc(None), uuid: cbac7e42-7068-4843-a484-6093a854bea6, mountpoint: Some("/media/bfs"), options: "" }
Oct 05 10:46:39.984 TRACE main:probe_filesystems: bcachefs_mount::filesystem: enumerating udev devices
Oct 05 10:46:39.986 TRACE main:probe_filesystems:read_super{path="/dev/nvme0n1"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: Not a bcachefs superblock
bcachefs: bch2_read_super() error reading superblock: Not a bcachefs superblock layout
Oct 05 10:46:39.986 TRACE main:probe_filesystems:read_super{path="/dev/nvme0n1"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:39.987 TRACE main:probe_filesystems:read_super{path="/dev/nvme1n1"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: Not a bcachefs superblock
bcachefs: bch2_read_super() error reading superblock: Not a bcachefs superblock layout
Oct 05 10:46:39.993 TRACE main:probe_filesystems:read_super{path="/dev/nvme1n1"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:39.993 TRACE main:probe_filesystems:read_super{path="/dev/nvme1n1p1"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: Not a bcachefs superblock
bcachefs: bch2_read_super() error reading superblock: Not a bcachefs superblock layout
Oct 05 10:46:39.993 TRACE main:probe_filesystems:read_super{path="/dev/nvme1n1p1"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:39.993 TRACE main:probe_filesystems:read_super{path="/dev/nvme1n1p2"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: Not a bcachefs superblock
bcachefs: bch2_read_super() error reading superblock: Not a bcachefs superblock layout
Oct 05 10:46:39.993 TRACE main:probe_filesystems:read_super{path="/dev/nvme1n1p2"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:39.993 TRACE main:probe_filesystems:read_super{path="/dev/nvme1n1p5"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: Not a bcachefs superblock
bcachefs: bch2_read_super() error reading superblock: Not a bcachefs superblock layout
Oct 05 10:46:39.994 TRACE main:probe_filesystems:read_super{path="/dev/nvme1n1p5"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:39.994 TRACE main:probe_filesystems:read_super{path="/dev/sdb"}: rlibbcachefs::rs: entering libbcachefs
Oct 05 10:46:39.995 TRACE main:probe_filesystems:read_super{path="/dev/sdb"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:39.995 DEBUG main:probe_filesystems: bcachefs_mount::filesystem: found="bcachefs superblock" devnode="/dev/sdb" uuid=cbac7e42-7068-4843-a484-6093a854bea6
Oct 05 10:46:39.995  INFO main:probe_filesystems: bcachefs_mount::filesystem: msg="found bcachefs pool" uuid=cbac7e42-7068-4843-a484-6093a854bea6
Oct 05 10:46:39.995 TRACE main:probe_filesystems:read_super{path="/dev/sda"}: rlibbcachefs::rs: entering libbcachefs
Oct 05 10:46:39.998 TRACE main:probe_filesystems:read_super{path="/dev/sda"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:39.998 DEBUG main:probe_filesystems: bcachefs_mount::filesystem: found="bcachefs superblock" devnode="/dev/sda" uuid=cbac7e42-7068-4843-a484-6093a854bea6
Oct 05 10:46:39.998 TRACE main:probe_filesystems:read_super{path="/dev/sdc"}: rlibbcachefs::rs: entering libbcachefs
Oct 05 10:46:40.000 TRACE main:probe_filesystems:read_super{path="/dev/sdc"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.000 DEBUG main:probe_filesystems: bcachefs_mount::filesystem: found="bcachefs superblock" devnode="/dev/sdc" uuid=cbac7e42-7068-4843-a484-6093a854bea6
Oct 05 10:46:40.000 TRACE main:probe_filesystems:read_super{path="/dev/sdd"}: rlibbcachefs::rs: entering libbcachefs
Oct 05 10:46:40.001 TRACE main:probe_filesystems:read_super{path="/dev/sdd"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.001 DEBUG main:probe_filesystems: bcachefs_mount::filesystem: found="bcachefs superblock" devnode="/dev/sdd" uuid=cbac7e42-7068-4843-a484-6093a854bea6
Oct 05 10:46:40.001 TRACE main:probe_filesystems:read_super{path="/dev/sde"}: rlibbcachefs::rs: entering libbcachefs
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/sde"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.002 DEBUG main:probe_filesystems: bcachefs_mount::filesystem: found="bcachefs superblock" devnode="/dev/sde" uuid=cbac7e42-7068-4843-a484-6093a854bea6
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop0"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: IO error
bcachefs: bch2_read_super() error reading superblock: IO error
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop0"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop1"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: IO error
bcachefs: bch2_read_super() error reading superblock: IO error
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop1"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop2"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: IO error
bcachefs: bch2_read_super() error reading superblock: IO error
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop2"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop3"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: IO error
bcachefs: bch2_read_super() error reading superblock: IO error
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop3"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop4"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: IO error
bcachefs: bch2_read_super() error reading superblock: IO error
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop4"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop5"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: IO error
bcachefs: bch2_read_super() error reading superblock: IO error
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop5"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.002 TRACE main:probe_filesystems:read_super{path="/dev/loop6"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: IO error
bcachefs: bch2_read_super() error reading superblock: IO error
Oct 05 10:46:40.003 TRACE main:probe_filesystems:read_super{path="/dev/loop6"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.003 TRACE main:probe_filesystems:read_super{path="/dev/loop7"}: rlibbcachefs::rs: entering libbcachefs
bcachefs: bch2_read_super() error reading default superblock: IO error
bcachefs: bch2_read_super() error reading superblock: IO error
Oct 05 10:46:40.003 TRACE main:probe_filesystems:read_super{path="/dev/loop7"}: rlibbcachefs::rs: result=0 log=
Oct 05 10:46:40.003  INFO main:probe_filesystems: bcachefs_mount::filesystem: msg="found filesystems" count=1
Oct 05 10:46:40.003  INFO main: bcachefs_mount: msg="found filesystem" fs=cbac7e42-7068-4843-a484-6093a854bea6: locked?=false (/dev/sdb:/dev/sda:/dev/sdc:/dev/sdd:/dev/sde)
Oct 05 10:46:40.003 DEBUG main:mount:parse_mount_options: bcachefs_mount::filesystem: msg="parsing mount options" options=""
Oct 05 10:46:40.003  INFO main:mount: bcachefs_mount::filesystem: msg="mounting bcachefs filesystem" target=/media/bfs
Oct 05 10:46:40.003  INFO main:mount:libc::mount: bcachefs_mount::filesystem: mounting filesystem
Oct 05 10:46:40.197 ERROR mount_bcachefs: err=Invalid argument

I'm not sure what to run strace/gdb on to get more info.
Let me know what else might be needed

Tracking issue for zero-out-new-reflink-p-fields

I'm opening this issue to track logs and movement of filesystem errors related to reflink-p-fields

1 fsck zero -vn
bcachefs: bch2_fs_open() 
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_fs_alloc() 
bcachefs: bch2_fs_journal_init() 
bcachefs: bch2_fs_journal_init() ret 0
bcachefs: bch2_fs_btree_cache_init() 
bcachefs: bch2_fs_btree_cache_init() ret 0
bcachefs: bch2_fs_encryption_init() 
bcachefs: bch2_fs_encryption_init() ret 0
bcachefs: __bch2_fs_compress_init() 
bcachefs: __bch2_fs_compress_init() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_fs_alloc() ret 0
journal read done, 0 keys in 1 entries, seq 1226852
starting alloc read
alloc read done
starting stripes_read
stripes_read done
starting mark and sweep
reflink key has wrong refcount:
  u64s 46 type indirect_inline_data 0:424:0 len 8 ver 0: refcount 1 datalen 320:                        0x8b0b690hN
  should be 11, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:5720:0 len 8 ver 0: refcount: 1 crc: c_size 8 size 8 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833424 gen 1 ptr: 2:5850547504 gen 1 ptr: 4:694477776 gen 2 cached ptr: 5:4
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:5800:0 len 80 ver 0: refcount: 1 crc: c_size 80 size 80 offset 0 nonce 0 csum 5 compress 0 ptr: 5:44769832 gen 2 cached ptr: 4:694477616 gen 2 cached ptr: 2:5850547344 gen 1 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:5848:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 5:44769912 gen 2 cached ptr: 4:694477696 gen 2 cached ptr: 1:2395833344 gen 1 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:5880:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833392 gen 1 ptr: 2:5850547472 gen 1 ptr: 4:694477744 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:5928:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491173208 gen 1 ptr: 1:2395832888 gen 1 ptr: 5:44600272 gen 2 cached ptr: 4
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6056:0 len 128 ver 0: refcount: 1 crc: c_size 128 size 128 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491173256 gen 1 ptr: 1:2395832936 gen 1 ptr: 4:694477064 gen 2 cached pt
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6104:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491173384 gen 1 ptr: 1:2395833064 gen 1 ptr: 4:694477192 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6168:0 len 64 ver 0: refcount: 1 crc: c_size 64 size 64 offset 0 nonce 0 csum 5 compress 0 ptr: 5:44769624 gen 2 cached ptr: 4:694477408 gen 2 cached ptr: 3:4491173600 gen 1 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6232:0 len 64 ver 0: refcount: 1 crc: c_size 64 size 64 offset 0 nonce 0 csum 5 compress 0 ptr: 5:44769688 gen 2 cached ptr: 4:694477472 gen 2 cached ptr: 2:5850547200 gen 1 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6312:0 len 80 ver 0: refcount: 1 crc: c_size 80 size 80 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850547264 gen 1 ptr: 3:4491173728 gen 1 ptr: 4:694477536 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6440:0 len 128 ver 0: refcount: 1 crc: c_size 128 size 128 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491173432 gen 1 ptr: 1:2395833112 gen 1 ptr: 4:694477240 gen 2 cached pt
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6480:0 len 40 ver 0: refcount: 1 crc: c_size 40 size 40 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491173560 gen 1 ptr: 1:2395833240 gen 1 ptr: 4:694477368 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6568:0 len 88 ver 0: refcount: 1 crc: c_size 88 size 88 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491173888 gen 1 ptr: 2:5850548448 gen 1 ptr: 4:694478456 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6592:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549824 gen 1 ptr: 1:2395835168 gen 1 ptr: 4:694479808 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6600:0 len 8 ver 0: refcount: 1 crc: c_size 8 size 8 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549880 gen 1 ptr: 1:2395835224 gen 1 ptr: 4:694479864 gen 2 cached ptr: 5:4
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6608:0 len 8 ver 0: refcount: 1 crc: c_size 8 size 8 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549888 gen 1 ptr: 1:2395835232 gen 1 ptr: 5:44772088 gen 2 cached ptr: 0:88
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6632:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549920 gen 1 ptr: 1:2395835264 gen 1 ptr: 5:44772120 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6672:0 len 40 ver 0: refcount: 1 crc: c_size 40 size 40 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174952 gen 1 ptr: 2:5850550088 gen 1 ptr: 5:44772288 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6704:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833440 gen 1 ptr: 2:5850547520 gen 1 ptr: 4:694477792 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6816:0 len 112 ver 0: refcount: 1 crc: c_size 112 size 112 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833472 gen 1 ptr: 2:5850547552 gen 1 ptr: 5:44770040 gen 2 cached ptr
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6888:0 len 72 ver 0: refcount: 1 crc: c_size 72 size 72 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549976 gen 1 ptr: 1:2395835320 gen 1 ptr: 5:44772176 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6936:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549664 gen 1 ptr: 1:2395835008 gen 1 ptr: 4:694479648 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:6984:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833888 gen 1 ptr: 2:5850547968 gen 1 ptr: 0:880390048 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7040:0 len 56 ver 0: refcount: 1 crc: c_size 56 size 56 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395834504 gen 1 ptr: 3:4491174824 gen 1 ptr: 4:694479144 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7120:0 len 80 ver 0: refcount: 1 crc: c_size 80 size 80 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174408 gen 1 ptr: 2:5850548968 gen 1 ptr: 5:44771208 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7128:0 len 8 ver 0: refcount: 1 crc: c_size 8 size 8 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174272 gen 1 ptr: 2:5850548832 gen 1 ptr: 4:694478840 gen 2 cached ptr: 5:4
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7256:0 len 128 ver 0: refcount: 1 crc: c_size 128 size 128 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174280 gen 1 ptr: 2:5850548840 gen 1 ptr: 5:44771080 gen 2 cached ptr
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7344:0 len 88 ver 0: refcount: 1 crc: c_size 88 size 88 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174552 gen 1 ptr: 2:5850549112 gen 1 ptr: 0:880390416 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7400:0 len 56 ver 0: refcount: 1 crc: c_size 56 size 56 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174168 gen 1 ptr: 2:5850548728 gen 1 ptr: 4:694478736 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7416:0 len 16 ver 0: refcount: 1 crc: c_size 16 size 16 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549864 gen 1 ptr: 1:2395835208 gen 1 ptr: 4:694479848 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7432:0 len 16 ver 0: refcount: 1 crc: c_size 16 size 16 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549848 gen 1 ptr: 1:2395835192 gen 1 ptr: 4:694479832 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7504:0 len 72 ver 0: refcount: 1 crc: c_size 72 size 72 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850548312 gen 1 ptr: 1:2395834232 gen 1 ptr: 4:694478320 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7520:0 len 16 ver 0: refcount: 1 crc: c_size 16 size 16 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549896 gen 1 ptr: 1:2395835240 gen 1 ptr: 5:44772096 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7536:0 len 16 ver 0: refcount: 1 crc: c_size 16 size 16 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549808 gen 1 ptr: 1:2395835152 gen 1 ptr: 4:694479792 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7568:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549632 gen 1 ptr: 1:2395834976 gen 1 ptr: 4:694479616 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7592:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549768 gen 1 ptr: 1:2395835112 gen 1 ptr: 4:694479752 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7616:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833864 gen 1 ptr: 2:5850547944 gen 1 ptr: 0:880390024 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7664:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395834000 gen 1 ptr: 2:5850548080 gen 1 ptr: 4:694478088 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7728:0 len 64 ver 0: refcount: 1 crc: c_size 64 size 64 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833664 gen 1 ptr: 2:5850547744 gen 1 ptr: 5:44770232 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7760:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395834080 gen 1 ptr: 2:5850548160 gen 1 ptr: 4:694478168 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7808:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174640 gen 1 ptr: 2:5850549200 gen 1 ptr: 0:880390504 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7856:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174024 gen 1 ptr: 2:5850548584 gen 1 ptr: 4:694478592 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7904:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174224 gen 1 ptr: 2:5850548784 gen 1 ptr: 4:694478792 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7928:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549744 gen 1 ptr: 1:2395835088 gen 1 ptr: 4:694479728 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7952:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833784 gen 1 ptr: 2:5850547864 gen 1 ptr: 0:880389944 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:7992:0 len 40 ver 0: refcount: 1 crc: c_size 40 size 40 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549464 gen 1 ptr: 1:2395834808 gen 1 ptr: 4:694479448 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8016:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833840 gen 1 ptr: 2:5850547920 gen 1 ptr: 0:880390000 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8048:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549600 gen 1 ptr: 1:2395834944 gen 1 ptr: 4:694479584 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8144:0 len 96 ver 0: refcount: 1 crc: c_size 96 size 96 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174072 gen 1 ptr: 2:5850548632 gen 1 ptr: 4:694478640 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8168:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833760 gen 1 ptr: 2:5850547840 gen 1 ptr: 0:880389920 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8216:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395834368 gen 1 ptr: 3:4491174688 gen 1 ptr: 0:880390552 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8248:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549504 gen 1 ptr: 1:2395834848 gen 1 ptr: 4:694479488 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8256:0 len 8 ver 0: refcount: 1 crc: c_size 8 size 8 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549912 gen 1 ptr: 1:2395835256 gen 1 ptr: 5:44772112 gen 2 cached ptr: 0:88
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8296:0 len 40 ver 0: refcount: 1 crc: c_size 40 size 40 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174488 gen 1 ptr: 2:5850549048 gen 1 ptr: 5:44771288 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8320:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174528 gen 1 ptr: 2:5850549088 gen 1 ptr: 0:880390392 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8352:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 5:44770432 gen 2 cached ptr: 4:694478200 gen 2 cached ptr: 1:2395834112 gen 1 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8440:0 len 88 ver 0: refcount: 1 crc: c_size 88 size 88 offset 0 nonce 0 csum 5 compress 0 ptr: 5:44770464 gen 2 cached ptr: 4:694478232 gen 2 cached ptr: 2:5850548224 gen 1 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8496:0 len 56 ver 0: refcount: 1 crc: c_size 56 size 56 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395834416 gen 1 ptr: 3:4491174736 gen 1 ptr: 0:880390600 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8528:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395834472 gen 1 ptr: 3:4491174792 gen 1 ptr: 4:694479112 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8576:0 len 48 ver 0: refcount: 1 crc: c_size 48 size 48 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491173976 gen 1 ptr: 2:5850548536 gen 1 ptr: 4:694478544 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8592:0 len 16 ver 0: refcount: 1 crc: c_size 16 size 16 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833968 gen 1 ptr: 2:5850548048 gen 1 ptr: 0:880390128 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8608:0 len 16 ver 0: refcount: 1 crc: c_size 16 size 16 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833984 gen 1 ptr: 2:5850548064 gen 1 ptr: 4:694478072 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8688:0 len 80 ver 0: refcount: 1 crc: c_size 80 size 80 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833584 gen 1 ptr: 2:5850547664 gen 1 ptr: 5:44770152 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8728:0 len 40 ver 0: refcount: 1 crc: c_size 40 size 40 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549328 gen 1 ptr: 1:2395834672 gen 1 ptr: 4:694479312 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8760:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 5:44771416 gen 2 cached ptr: 4:694479200 gen 2 cached ptr: 1:2395834560 gen 1 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8776:0 len 16 ver 0: refcount: 1 crc: c_size 16 size 16 offset 0 nonce 0 csum 5 compress 0 ptr: 5:44771448 gen 2 cached ptr: 4:694479232 gen 2 cached ptr: 2:5850549248 gen 1 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8840:0 len 64 ver 0: refcount: 1 crc: c_size 64 size 64 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850548384 gen 1 ptr: 1:2395834304 gen 1 ptr: 4:694478392 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8856:0 len 16 ver 0: refcount: 1 crc: c_size 16 size 16 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549792 gen 1 ptr: 1:2395835136 gen 1 ptr: 4:694479776 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8864:0 len 8 ver 0: refcount: 1 crc: c_size 8 size 8 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833728 gen 1 ptr: 2:5850547808 gen 1 ptr: 5:44770296 gen 2 cached ptr: 0:88
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8888:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833736 gen 1 ptr: 2:5850547816 gen 1 ptr: 0:880389896 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8920:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833808 gen 1 ptr: 2:5850547888 gen 1 ptr: 0:880389968 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:8984:0 len 64 ver 0: refcount: 1 crc: c_size 64 size 64 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549264 gen 1 ptr: 1:2395834608 gen 1 ptr: 4:694479248 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9016:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549368 gen 1 ptr: 1:2395834712 gen 1 ptr: 4:694479352 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9080:0 len 64 ver 0: refcount: 1 crc: c_size 64 size 64 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549536 gen 1 ptr: 1:2395834880 gen 1 ptr: 4:694479520 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9096:0 len 16 ver 0: refcount: 1 crc: c_size 16 size 16 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549944 gen 1 ptr: 1:2395835288 gen 1 ptr: 5:44772144 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9128:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395834048 gen 1 ptr: 2:5850548128 gen 1 ptr: 4:694478136 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9168:0 len 40 ver 0: refcount: 1 crc: c_size 40 size 40 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174912 gen 1 ptr: 2:5850550048 gen 1 ptr: 5:44772248 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9232:0 len 64 ver 0: refcount: 1 crc: c_size 64 size 64 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549400 gen 1 ptr: 1:2395834744 gen 1 ptr: 4:694479384 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9248:0 len 16 ver 0: refcount: 1 crc: c_size 16 size 16 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549960 gen 1 ptr: 1:2395835304 gen 1 ptr: 5:44772160 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9280:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 2:5850549712 gen 1 ptr: 1:2395835056 gen 1 ptr: 4:694479696 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9312:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833936 gen 1 ptr: 2:5850548016 gen 1 ptr: 0:880390096 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9408:0 len 96 ver 0: refcount: 1 crc: c_size 96 size 96 offset 0 nonce 0 csum 5 compress 0 ptr: 4:694479896 gen 2 cached ptr: 0:880390944 gen 2 cached ptr: 3:4491175040 gen 1
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9440:0 len 32 ver 0: refcount: 1 crc: c_size 32 size 32 offset 0 nonce 0 csum 5 compress 0 ptr: 4:694479992 gen 2 cached ptr: 0:880391040 gen 2 cached ptr: 1:2395835392 gen 1
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9536:0 len 96 ver 0: refcount: 1 crc: c_size 96 size 96 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395835424 gen 1 ptr: 3:4491175168 gen 1 ptr: 0:880391072 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9664:0 len 128 ver 0: refcount: 1 crc: c_size 128 size 128 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395835520 gen 1 ptr: 3:4491175264 gen 1 ptr: 4:694480120 gen 2 cached pt
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9792:0 len 128 ver 0: refcount: 1 crc: c_size 128 size 128 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395835648 gen 1 ptr: 3:4491175392 gen 1 ptr: 4:694480248 gen 2 cached pt
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9816:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395835776 gen 1 ptr: 3:4491175520 gen 1 ptr: 4:694480376 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9840:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491174992 gen 1 ptr: 2:5850550128 gen 1 ptr: 5:44772328 gen 2 cached ptr: 0
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9864:0 len 24 ver 0: refcount: 1 crc: c_size 24 size 24 offset 0 nonce 0 csum 5 compress 0 ptr: 3:4491175016 gen 1 ptr: 2:5850550152 gen 1 ptr: 0:880390920 gen 2 cached ptr: 
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9872:0 len 8 ver 0: refcount: 1 crc: c_size 8 size 8 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395833432 gen 1 ptr: 2:5850547512 gen 1 ptr: 4:694477784 gen 2 cached ptr: 5:4
  should be 2, fixing
reflink key has wrong refcount:
  u64s 11 type reflink_v 0:9880:0 len 8 ver 0: refcount: 1 crc: c_size 8 size 8 offset 0 nonce 0 csum 5 compress 0 ptr: 1:2395835800 gen 1 ptr: 3:4491175544 gen 1 ptr: 4:694480400 gen 2 cached ptr: 5:4
  should be 2, fixing
reflink key has wrong refcount:
  u64s 25 type indirect_inline_data 0:10024:0 len 8 ver 0: refcount 1 datalen 152:                        0x8b0e908hN
  should be 15, fixing
bucket 0:9758 gen 1 data type user has wrong cached_sectors: got 16, should be 8, fixing
bucket 0:9759 gen 1 data type user has wrong data_type: got 4, should be 0, fixing
bucket 0:9759 gen 1 data type none has wrong cached_sectors: got 96, should be 0, fixing
bucket 0:1502797 gen 2 data type user has wrong cached_sectors: got 24, should be 16, fixing
bucket 0:1719541 gen 2 data type user has wrong cached_sectors: got 88, should be 8, fixing
dev 0 has wrong user fragmented: got 23002592, should be 23002272, fixing
dev 0 has wrong cached buckets: got 1746814, should be 1746813, fixing
dev 0 has wrong cached sectors: got 871381480, should be 871381288, fixing
bucket 1:2339683 gen 1 data type user has wrong dirty_sectors: got 768, should be 712, fixing
dev 1 has wrong user sectors: got 1183696248, should be 1183696192, fixing
dev 1 has wrong user fragmented: got 17837048, should be 17837104, fixing
bucket 2:5713428 gen 1 data type user has wrong dirty_sectors: got 160, should be 80, fixing
bucket 2:7239777 gen 1 data type user has wrong dirty_sectors: got 1016, should be 904, fixing
dev 2 has wrong user sectors: got 1223666896, should be 1223666704, fixing
dev 2 has wrong user fragmented: got 17778408, should be 17778600, fixing
bucket 3:4385913 gen 1 data type user has wrong dirty_sectors: got 952, should be 928, fixing
bucket 3:5441391 gen 1 data type user has wrong dirty_sectors: got 1016, should be 904, fixing
dev 3 has wrong user sectors: got 675879568, should be 675879432, fixing
dev 3 has wrong user fragmented: got 13255760, should be 13255896, fixing
bucket 4:283952 gen 1 data type user has wrong cached_sectors: got 192, should be 80, fixing
dev 4 has wrong user fragmented: got 36049440, should be 36049552, fixing
dev 4 has wrong cached sectors: got 1107180592, should be 1107180480, fixing
bucket 5:43749 gen 2 data type user has wrong cached_sectors: got 168, should be 88, fixing
bucket 5:1507675 gen 1 data type user has wrong cached_sectors: got 192, should be 80, fixing
dev 5 has wrong user fragmented: got 39897256, should be 39897448, fixing
dev 5 has wrong cached sectors: got 1343544648, should be 1343544456, fixing
fs has wrong data: got 3248408784, should be 3248408400, fixing
fs has wrong cached: got 3685918552, should be 3685918056, fixing
fs has wrong user: 1/2 [2 3]: got 415508896, should be 415508624, fixing
fs has wrong cached: 1/1 [0]: got 871381480, should be 871381288, fixing
fs has wrong cached: 1/1 [4]: got 1107180592, should be 1107180480, fixing
fs has wrong user: 1/2 [1 2]: got 1220742848, should be 1220742736, fixing
fs has wrong cached: 1/1 [5]: got 1343544648, should be 1343544456, fixing
mark and sweep done
starting journal replay
going read-write
journal replay done
writing allocation info
alloc write done
reading snapshots table
reading snapshots done
starting fsck
checking extents
checking dirents
checking xattrs
checking root directory
checking inode nlinks
594583:8 len 8 points to nonexistent indirect extent 10008
emergency read only
Error in recovery: error in fsck (-5)
shutting down
flushing journal and stopping allocators
flushing journal and stopping allocators complete
shutdown complete
bcachefs: bch2_fs_open() ret -5
2 fsck zero -vn
bcachefs: bch2_fs_open() 
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_fs_alloc() 
bcachefs: bch2_fs_journal_init() 
bcachefs: bch2_fs_journal_init() ret 0
bcachefs: bch2_fs_btree_cache_init() 
bcachefs: bch2_fs_btree_cache_init() ret 0
bcachefs: bch2_fs_encryption_init() 
bcachefs: bch2_fs_encryption_init() ret 0
bcachefs: __bch2_fs_compress_init() 
bcachefs: __bch2_fs_compress_init() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_fs_alloc() ret 0
journal read done, 35 keys in 1 entries, seq 1229043
starting alloc read
alloc read done
starting stripes_read
stripes_read done
starting mark and sweep
594583:8 len 8 points to nonexistent indirect extent 10008, not fixing
594584:8 len 8 points to nonexistent indirect extent 10000, not fixing
594585:8 len 8 points to nonexistent indirect extent 9880, not fixing
594586:8 len 8 points to nonexistent indirect extent 9944, not fixing
594588:8 len 8 points to nonexistent indirect extent 9976, not fixing
594589:8 len 8 points to nonexistent indirect extent 9920, not fixing
594591:8 len 8 points to nonexistent indirect extent 9888, not fixing
594592:8 len 8 points to nonexistent indirect extent 9896, not fixing
594593:8 len 8 points to nonexistent indirect extent 9928, not fixing
594594:8 len 8 points to nonexistent indirect extent 9992, not fixing
594595:8 len 8 points to nonexistent indirect extent 9968, not fixing
594596:8 len 8 points to nonexistent indirect extent 9904, not fixing
594597:8 len 8 points to nonexistent indirect extent 9936, not fixing
656042:8 len 8 points to nonexistent indirect extent 256, not fixing
656043:8 len 8 points to nonexistent indirect extent 264, not fixing
656044:8 len 8 points to nonexistent indirect extent 272, not fixing
656046:8 len 8 points to nonexistent indirect extent 280, not fixing
656047:8 len 8 points to nonexistent indirect extent 288, not fixing
656056:88 len 88 points to nonexistent indirect extent 296, not fixing
656058:8 len 8 points to nonexistent indirect extent 384, not fixing
656059:8 len 8 points to nonexistent indirect extent 392, not fixing
656060:8 len 8 points to nonexistent indirect extent 400, not fixing
656066:8 len 8 points to nonexistent indirect extent 408, not fixing
reflink key has wrong refcount:
  u64s 46 type indirect_inline_data 0:424:0 len 8 ver 0: refcount 11 datalen 320:                        0xc08a690hN
  should be 1, not fixing
reflink key has wrong refcount:
  u64s 25 type indirect_inline_data 0:10024:0 len 8 ver 0: refcount 15 datalen 152:                        0xc08d908hN
  should be 2, not fixing
mark and sweep done
starting journal replay
going read-write
journal replay done
reading snapshots table
reading snapshots done
starting fsck
checking extents
checking dirents
checking xattrs
checking root directory
checking inode nlinks
594583:8 len 8 points to nonexistent indirect extent 10008
emergency read only
Error in recovery: error in fsck (-5)
shutting down
flushing journal and stopping allocators
flushing journal and stopping allocators complete
shutdown complete
bcachefs: bch2_fs_open() ret -5
3 fsck zero -vy
bcachefs: bch2_fs_open() 
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super() 
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_fs_alloc() 
bcachefs: bch2_fs_journal_init() 
bcachefs: bch2_fs_journal_init() ret 0
bcachefs: bch2_fs_btree_cache_init() 
bcachefs: bch2_fs_btree_cache_init() ret 0
bcachefs: bch2_fs_encryption_init() 
bcachefs: bch2_fs_encryption_init() ret 0
bcachefs: __bch2_fs_compress_init() 
bcachefs: __bch2_fs_compress_init() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc() 
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_fs_alloc() ret 0
journal read done, 35 keys in 1 entries, seq 1229053
starting alloc read
alloc read done
starting stripes_read
stripes_read done
starting mark and sweep
594583:8 len 8 points to nonexistent indirect extent 10008, fixing
594584:8 len 8 points to nonexistent indirect extent 10000, fixing
594585:8 len 8 points to nonexistent indirect extent 9880, fixing
594586:8 len 8 points to nonexistent indirect extent 9944, fixing
594588:8 len 8 points to nonexistent indirect extent 9976, fixing
594589:8 len 8 points to nonexistent indirect extent 9920, fixing
594591:8 len 8 points to nonexistent indirect extent 9888, fixing
594592:8 len 8 points to nonexistent indirect extent 9896, fixing
594593:8 len 8 points to nonexistent indirect extent 9928, fixing
594594:8 len 8 points to nonexistent indirect extent 9992, fixing
594595:8 len 8 points to nonexistent indirect extent 9968, fixing
594596:8 len 8 points to nonexistent indirect extent 9904, fixing
594597:8 len 8 points to nonexistent indirect extent 9936, fixing
656042:8 len 8 points to nonexistent indirect extent 256, fixing
656043:8 len 8 points to nonexistent indirect extent 264, fixing
656044:8 len 8 points to nonexistent indirect extent 272, fixing
656046:8 len 8 points to nonexistent indirect extent 280, fixing
656047:8 len 8 points to nonexistent indirect extent 288, fixing
656056:88 len 88 points to nonexistent indirect extent 296, fixing
656058:8 len 8 points to nonexistent indirect extent 384, fixing
656059:8 len 8 points to nonexistent indirect extent 392, fixing
656060:8 len 8 points to nonexistent indirect extent 400, fixing
656066:8 len 8 points to nonexistent indirect extent 408, fixing
reflink key has wrong refcount:
  u64s 46 type indirect_inline_data 0:424:0 len 8 ver 0: refcount 11 datalen 320:                        0xa5f3690hN
  should be 1, fixing
reflink key has wrong refcount:
  u64s 25 type indirect_inline_data 0:10024:0 len 8 ver 0: refcount 15 datalen 152:                        0xa5f6908hN
  should be 2, fixing
mark and sweep done
starting journal replay
going read-write
invalid bkey u64s 5 type deleted 594583:8:U32_MAX len 8 ver 0 on insert from 0x434ed2s -> 0x434f5cs: nonzero size field

emergency read only
journal replay: error -22 while replaying key at btree extents level 0
Error in recovery: journal replay failed (-22)
shutting down
flushing journal and stopping allocators
flushing journal and stopping allocators complete
shutdown complete
bcachefs: bch2_fs_open() ret -22
dmesg bcachefs mount after fsck, err
Oct 19 07:13:32 etoix sudo[1720112]:     buny : TTY=pts/1 ; PWD=/home/buny/srcbak/bcachefs-tools ; USER=root ; COMMAND=./result/bin/bcachefs fsck /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/nvme0n1 -vy
Oct 19 07:21:09 etoix sudo[1720793]:     buny : TTY=pts/1 ; PWD=/home/buny/srcbak/bcachefs-tools ; USER=root ; COMMAND=/run/current-system/sw/bin/mount.bcachefs cbac7e42-7068-4843-a484-6093a854bea6 /media/bfs
Oct 19 07:21:57 etoix kernel: bcachefs (cbac7e42-7068-4843-a484-6093a854bea6): journal read done, 35 keys in 2 entries, seq 1229062
Oct 19 07:21:58 etoix kernel: bcachefs (cbac7e42-7068-4843-a484-6093a854bea6): going read-write
Oct 19 07:21:59 etoix kernel: bcachefs (cbac7e42-7068-4843-a484-6093a854bea6): mounted with opts: metadata_replicas=2,data_replicas=2,metadata_target=ssd,foreground_target=ssd,background_target=hdd,promote_target=ssd,noshard_inode_numbers
Oct 19 07:22:01 etoix kernel: bcachefs (cbac7e42-7068-4843-a484-6093a854bea6): error validating btree node at btree extents level 0/2
                                u64s 12 type btree_ptr_v2 595006:1616:U32_MAX len 0 ver 0: seq 2865e72ab10c3bd4 written 328 min_key 593911:737569:0 ptr: 5:671625216 gen 2 ptr: 4:959230976 gen 2
                                node offset 328 bset u64s 15200: invalid bkey u64s 7 type reflink_p 594282:48:U32_MAX len 48 ver 0: idx 5880: idx < front_pad
Oct 19 07:22:01 etoix kernel: bcachefs (cbac7e42-7068-4843-a484-6093a854bea6): emergency read only

possible typo on btree_iter.c @ line 924

I noticed the following 2 (very similar) lines:

bch2_bpos_to_text(&PBUF(buf3), b->data->min_key); 
bch2_bpos_to_text(&PBUF(buf3), b->data->max_key);

is it possible the latter one needs to point to buf4? this one was allocated, a few lines above, but never used

fsck confusing output

[root@gaming:~]# bcachefs fsck /dev/nvme0n1p1
recovering from clean shutdown, journal seq 93788
journal read done, 0 keys in 1 entries, seq 93788
starting mark and sweep
starting fsck
mounted with opts: degraded,fsck,fix_errors

i guess it don't has to recover from "clean shutdown" (there is no problem here. i just test the command)

mounted with opts

it is not mounted and even when it don't make sense to mount as degraded

[root@gaming:~]# mount
devtmpfs on /dev type devtmpfs (rw,nosuid,size=1641180k,nr_inodes=4100643,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=3,mode=620,ptmxmode=666)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,size=8205884k,mode=755)
none on /run/keys type ramfs (rw,nosuid,nodev,relatime,mode=750)
tmpfs on /run/wrappers type tmpfs (rw,nodev,relatime,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
/dev/sda2 on / type ext4 (rw,noatime,discard)
/dev/sda2 on /nix/store type ext4 (ro,noatime,discard)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,nr_inodes=409600)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=3282352k,nr_inodes=820588,mode=700,uid=1000,gid=100)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)

so the output here is confusing and probably wrong


NixOS 21.03.git.9bf997125cd
bcachefs from 2020-11-17 (git rev 6a505b63ed3003faf5000f19fd08bbd477d93fbc)

deadlock after "going read-write" with reconstruct_alloc

using bcachefs tool version v0.1-521-g7ae670e+, compiled using "make debug"
The command I used:

bcachefs fsck -y -f --reconstruct_alloc /dev/disk/by-id/scsi-2347466f100d00000 ... (metadata, foreground & background partitions)

The fsck operation does not continue (or at least it seems that way) after "going read-write".
The system load (user/sys/waiting) is almost 0,
I do not see any progress. From time to time, there is a little CPU activity, but that's it.
The filesystem is big, it contains almost 2TB of data, the reconstruct_alloc operation takes 40% of the available RAM memory (more or less 14GB), but currently, it seems to be waiting for something. I attached GDB, made a backtrace, then after 1 second a 2nd, and waited a few mins, and made a third one (+ a info threads):

Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) attach 11632
Attaching to process 11632
[New LWP 11633]
[New LWP 11634]
[New LWP 11635]
[New LWP 11636]
[New LWP 11637]
[New LWP 11638]
[New LWP 11639]
[New LWP 11640]
[New LWP 11641]
[New LWP 11642]
[New LWP 11643]
[New LWP 11644]
[New LWP 11645]
[New LWP 11646]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
#1  0x0000558079a96091 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:72
#2  schedule () at linux/sched.c:41
#3  0x0000558079a91c95 in __closure_sync (cl=cl@entry=0x7fff215b4790) at linux/closure.c:128
#4  0x0000558079a548e8 in closure_sync (cl=0x7fff215b4790) at include/linux/closure.h:185
#5  __bch2_journal_preres_get (j=j@entry=0x7f20dece29a8, res=res@entry=0x7fff215b4b88, new_u64s=new_u64s@entry=12, flags=flags@entry=0) at libbcachefs/journal.c:496
#6  0x0000558079a7e657 in bch2_journal_preres_get (flags=0, new_u64s=12, res=0x7fff215b4b88, j=0x7f20dece29a8) at libbcachefs/journal.h:466
#7  bch2_journal_preres_get (flags=0, new_u64s=12, res=0x7fff215b4b88, j=0x7f20dece29a8) at libbcachefs/journal.h:452
#8  bch2_trans_journal_preres_get_cold (trace_ip=<optimized out>, u64s=12, trans=0x7fff215b4a90) at libbcachefs/btree_update_leaf.c:279
#9  do_bch2_trans_commit (trace_ip=<optimized out>, stopped_at=<synthetic pointer>, trans=0x7fff215b4a90) at libbcachefs/btree_update_leaf.c:911
#10 __bch2_trans_commit (trans=trans@entry=0x7fff215b4a90) at libbcachefs/btree_update_leaf.c:1154
#11 0x0000558079a01556 in bch2_trans_commit (flags=<optimized out>, journal_seq=0x0, disk_res=0x0, trans=0x7fff215b4a90) at libbcachefs/btree_update.h:106
#12 bch2_journal_replay (c=0x7f20decc4000) at libbcachefs/recovery.c:627
#13 bch2_fs_recovery (c=0x7f20decc4000) at libbcachefs/recovery.c:1264
#14 0x0000558079a68a7d in bch2_fs_start (c=c@entry=0x7f20decc4000) at libbcachefs/super.c:897
#15 0x0000558079a6afcf in bch2_fs_open (devices=devices@entry=0x7fff215b50f8, nr_devices=nr_devices@entry=8, opts=...) at libbcachefs/super.c:1904
#16 0x0000558079aa7ac5 in cmd_fsck (argc=8, argc@entry=12, argv=0x7fff215b50f8, argv@entry=0x7fff215b50d8) at cmd_fsck.c:90
#17 0x00005580799e91e6 in main (argc=<optimized out>, argv=0x7fff215b50d8) at bcachefs.c:197
(gdb) continue
Continuing.
^C
Thread 1 "bcachefs" received signal SIGINT, Interrupt.
0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
#1  0x0000558079a96091 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:72
#2  schedule () at linux/sched.c:41
#3  0x0000558079a91c95 in __closure_sync (cl=cl@entry=0x7fff215b4790) at linux/closure.c:128
#4  0x0000558079a548e8 in closure_sync (cl=0x7fff215b4790) at include/linux/closure.h:185
#5  __bch2_journal_preres_get (j=j@entry=0x7f20dece29a8, res=res@entry=0x7fff215b4b88, new_u64s=new_u64s@entry=12, flags=flags@entry=0) at libbcachefs/journal.c:496
#6  0x0000558079a7e657 in bch2_journal_preres_get (flags=0, new_u64s=12, res=0x7fff215b4b88, j=0x7f20dece29a8) at libbcachefs/journal.h:466
#7  bch2_journal_preres_get (flags=0, new_u64s=12, res=0x7fff215b4b88, j=0x7f20dece29a8) at libbcachefs/journal.h:452
#8  bch2_trans_journal_preres_get_cold (trace_ip=<optimized out>, u64s=12, trans=0x7fff215b4a90) at libbcachefs/btree_update_leaf.c:279
#9  do_bch2_trans_commit (trace_ip=<optimized out>, stopped_at=<synthetic pointer>, trans=0x7fff215b4a90) at libbcachefs/btree_update_leaf.c:911
#10 __bch2_trans_commit (trans=trans@entry=0x7fff215b4a90) at libbcachefs/btree_update_leaf.c:1154
#11 0x0000558079a01556 in bch2_trans_commit (flags=<optimized out>, journal_seq=0x0, disk_res=0x0, trans=0x7fff215b4a90) at libbcachefs/btree_update.h:106
#12 bch2_journal_replay (c=0x7f20decc4000) at libbcachefs/recovery.c:627
#13 bch2_fs_recovery (c=0x7f20decc4000) at libbcachefs/recovery.c:1264
#14 0x0000558079a68a7d in bch2_fs_start (c=c@entry=0x7f20decc4000) at libbcachefs/super.c:897
#15 0x0000558079a6afcf in bch2_fs_open (devices=devices@entry=0x7fff215b50f8, nr_devices=nr_devices@entry=8, opts=...) at libbcachefs/super.c:1904
#16 0x0000558079aa7ac5 in cmd_fsck (argc=8, argc@entry=12, argv=0x7fff215b50f8, argv@entry=0x7fff215b50d8) at cmd_fsck.c:90
#17 0x00005580799e91e6 in main (argc=<optimized out>, argv=0x7fff215b50d8) at bcachefs.c:197
(gdb) continue
Continuing.
^C
Thread 1 "bcachefs" received signal SIGINT, Interrupt.
0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
#1  0x0000558079a96091 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:72
#2  schedule () at linux/sched.c:41
#3  0x0000558079a91c95 in __closure_sync (cl=cl@entry=0x7fff215b4790) at linux/closure.c:128
#4  0x0000558079a548e8 in closure_sync (cl=0x7fff215b4790) at include/linux/closure.h:185
#5  __bch2_journal_preres_get (j=j@entry=0x7f20dece29a8, res=res@entry=0x7fff215b4b88, new_u64s=new_u64s@entry=12, flags=flags@entry=0) at libbcachefs/journal.c:496
#6  0x0000558079a7e657 in bch2_journal_preres_get (flags=0, new_u64s=12, res=0x7fff215b4b88, j=0x7f20dece29a8) at libbcachefs/journal.h:466
#7  bch2_journal_preres_get (flags=0, new_u64s=12, res=0x7fff215b4b88, j=0x7f20dece29a8) at libbcachefs/journal.h:452
#8  bch2_trans_journal_preres_get_cold (trace_ip=<optimized out>, u64s=12, trans=0x7fff215b4a90) at libbcachefs/btree_update_leaf.c:279
#9  do_bch2_trans_commit (trace_ip=<optimized out>, stopped_at=<synthetic pointer>, trans=0x7fff215b4a90) at libbcachefs/btree_update_leaf.c:911
#10 __bch2_trans_commit (trans=trans@entry=0x7fff215b4a90) at libbcachefs/btree_update_leaf.c:1154
#11 0x0000558079a01556 in bch2_trans_commit (flags=<optimized out>, journal_seq=0x0, disk_res=0x0, trans=0x7fff215b4a90) at libbcachefs/btree_update.h:106
#12 bch2_journal_replay (c=0x7f20decc4000) at libbcachefs/recovery.c:627
#13 bch2_fs_recovery (c=0x7f20decc4000) at libbcachefs/recovery.c:1264
#14 0x0000558079a68a7d in bch2_fs_start (c=c@entry=0x7f20decc4000) at libbcachefs/super.c:897
#15 0x0000558079a6afcf in bch2_fs_open (devices=devices@entry=0x7fff215b50f8, nr_devices=nr_devices@entry=8, opts=...) at libbcachefs/super.c:1904
#16 0x0000558079aa7ac5 in cmd_fsck (argc=8, argc@entry=12, argv=0x7fff215b50f8, argv@entry=0x7fff215b50d8) at cmd_fsck.c:90
#17 0x00005580799e91e6 in main (argc=<optimized out>, argv=0x7fff215b50d8) at bcachefs.c:197
(gdb) info threads
  Id   Target Id                                           Frame 
* 1    Thread 0x7f20ded55000 (LWP 11632) "bcachefs"        0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  2    Thread 0x7f20df204600 (LWP 11633) "aio_completion"  0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  3    Thread 0x7f20df1fb600 (LWP 11634) "events"          0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  4    Thread 0x7f20ded53600 (LWP 11635) "events_highpri"  0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  5    Thread 0x7f20ded4a600 (LWP 11636) "events_long"     0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  6    Thread 0x7f20ded41600 (LWP 11637) "events_unbound"  0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  7    Thread 0x7f20ded38600 (LWP 11638) "events_freezabl" 0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  8    Thread 0x7f20ded2f600 (LWP 11639) "timers"          0x00007f20deddba46 in ?? () from /lib64/libc.so.6
  9    Thread 0x7f20decc2600 (LWP 11640) "bcachefs"        0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  10   Thread 0x7f20decb9600 (LWP 11641) "bcachefs_btree_" 0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  11   Thread 0x7f20decb0600 (LWP 11642) "bcachefs_copygc" 0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  12   Thread 0x7f20deca7600 (LWP 11643) "bcachefs_io"     0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  13   Thread 0x7f20de1fa600 (LWP 11644) "btree_update"    0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  14   Thread 0x7f20da0a1600 (LWP 11645) "bch-reclaim/f7a" 0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
  15   Thread 0x7f2093ffd600 (LWP 11646) "events"          0x00007f20dee502c9 in syscall () from /lib64/libc.so.6
(gdb) 

I'll attach a dump of all threads, guess most of them don't need to be pasted
threads.txt

__bch2_fs_read_only in ininite loop

bcachefs fsck never completes,
it hangs after
flushing journal and stopping allocators complete
I investigated it with gdb:

(gdb) info threads
  Id   Target Id                                           Frame 
* 1    Thread 0x7fb07c46db80 (LWP 21551) "bcachefs"        0x0000555c9826db2b in __bch2_fs_read_only (c=c@entry=0x7fb07c428000) at libbcachefs/super.c:283
  2    Thread 0x7fb07c8eb700 (LWP 21552) "aio_completion"  0x00007fb07c5ff24a in ?? () from /lib64/libaio.so.1
  3    Thread 0x7fb07c8e2700 (LWP 21553) "events"          0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  4    Thread 0x7fb07c8d9700 (LWP 21554) "events_highpri"  0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  5    Thread 0x7fb07c46c700 (LWP 21555) "events_long"     0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  6    Thread 0x7fb07c463700 (LWP 21556) "events_unbound"  0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  7    Thread 0x7fb07c45a700 (LWP 21557) "events_freezabl" 0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  8    Thread 0x7fb07c451700 (LWP 21558) "timers"          0x00007fb07c62c9e7 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
  9    Thread 0x7fb07c426700 (LWP 21559) "bcachefs"        0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  10   Thread 0x7fb07c41d700 (LWP 21560) "bcache_copygc"   0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  11   Thread 0x7fb07c414700 (LWP 21561) "bcache_journal"  0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  12   Thread 0x7fb07bbd9700 (LWP 21562) "btree_update"    0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  13   Thread 0x7fb058eca700 (LWP 21589) "events"          0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  14   Thread 0x7fb07c209700 (LWP 21615) "bch_alloc[/dev/" preempt_disable () at linux/preempt.c:31
  15   Thread 0x7fb07c200700 (LWP 21616) "bch_alloc[/dev/" 0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
  16   Thread 0x7fb07c1f7700 (LWP 21617) "bch_alloc[/dev/" 0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6

I suspect the error to be at super.c:283, as I set a breakpoint at 288 and it never reached it.

#0  0x00007fb07c565bd9 in syscall () from /lib64/libc.so.6
#1  0x0000555c982dc809 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x0000555c982db51d in wait_for_completion (x=x@entry=0x555c98579fa8) at linux/wait.c:235
#4  0x0000555c982db82c in kthread_stop (p=p@entry=0x555c98579f80) at linux/kthread.c:121
#5  0x0000555c9828c705 in bch2_dev_allocator_stop (ca=<optimized out>) at libbcachefs/alloc_background.c:1394
#6  0x0000555c9826db2b in __bch2_fs_read_only (c=c@entry=0x7fb07c428000) at libbcachefs/super.c:283
#7  0x0000555c982703f6 in bch2_fs_read_only (c=c@entry=0x7fb07c428000) at libbcachefs/super.c:351
#8  0x0000555c98270700 in bch2_fs_stop (c=0x7fb07c428000) at libbcachefs/super.c:571
#9  0x0000555c982e2f07 in cmd_fsck (argc=<optimized out>, argv=0x7ffd28d3b580) at cmd_fsck.c:90
#10 0x0000555c98251f6e in main (argc=<optimized out>, argv=0x7ffd28d3b558) at bcachefs.c:165

further digging into the main tread may have shown the error:

gdb) info frame
Stack level 6, frame at 0x7ffd28d3b2f0:
 rip = 0x555c9826db2b in __bch2_fs_read_only (libbcachefs/super.c:283); saved rip = 0x555c982703f6
 called by frame at 0x7ffd28d3b340, caller of frame at 0x7ffd28d3b250
 source language c.
 Arglist at 0x7ffd28d3b248, args: c=c@entry=0x7fb07c428000
 Locals at 0x7ffd28d3b248, Previous frame's sp is 0x7ffd28d3b2f0
 Saved registers:
  rbx at 0x7ffd28d3b2b8, rbp at 0x7ffd28d3b2c0, r12 at 0x7ffd28d3b2c8, r13 at 0x7ffd28d3b2d0, r14 at 0x7ffd28d3b2d8, r15 at 0x7ffd28d3b2e0, rip at 0x7ffd28d3b2e8
(gdb) info locals
ca = 0x555c984f8000
wrote = true
i = 0
clean_passes = <optimized out>
ret = <optimized out>
(gdb) info args
c = 0x7fb07c428000
(gdb) print ca
$1 = (struct bch_dev *) 0x555c984f8000
(gdb) print *ca
$2 = {kobj = {parent = 0x0, kset = 0x0, ktype = 0x555c9833e5e0 <bch2_dev_ktype>, sd = 0x0, ref = {counter = 1}, state_initialized = 1, state_in_sysfs = 0, 
    state_add_uevent_sent = 0, state_remove_uevent_sent = 0, uevent_suppress = 0}, ref = {count = {counter = 2}, release = 0x555c9826ceb0 <bch2_dev_ref_complete>, 
    confirm_switch = 0x0}, ref_completion = {done = 0, wait = {lock = {count = 0}, task_list = {next = 0x555c984f8050, prev = 0x555c984f8050}}}, io_ref = {count = {
      counter = 1}, release = 0x555c9826cea0 <bch2_dev_io_ref_complete>, confirm_switch = 0x0}, io_ref_completion = {done = 0, wait = {lock = {count = 0}, task_list = {
        next = 0x555c984f8088, prev = 0x555c984f8088}}}, fs = 0x7fb07c428000, dev_idx = 0 '\000', mi = {nbuckets = 366304, first_bucket = 0, bucket_size = 512, group = 1, 
    state = 0 '\000', replacement = 0 '\000', discard = 1 '\001', data_allowed = 28 '\034', durability = 1 '\001', valid = 1 '\001'}, uuid = {
    b = "<ҧ\251!\270E\220\217`!\326tu\215)"}, name = "/dev/disk/by-partuuid/07bb2c48-", disk_sb = {sb = 0x555c98447000, bdev = 0x555c98444150, bio = 0x555c98444300, 
    page_order = 2, mode = 131, have_layout = 1, have_bio = 1, fs_sb = 0, seq = 82}, sb_read_scratch = 0x555c984fa000, sb_write_error = 0, self = {d = {1}}, 
  replica_set = {front_pad = 40}, buckets = {0x7fb07b3d0000, 0x0}, buckets_nouse = 0x555c984fc000, bucket_lock = {lock = {__data = {__readers = 0, __writers = 0, 
        __wrphase_futex = 0, __writers_futex = 0, __pad3 = 0, __pad4 = 0, __cur_writer = 0, __shared = 0, __rwelision = 0 '\000', __pad1 = "\000\000\000\000\000\000", 
        __pad2 = 0, __flags = 0}, __size = '\000' <repeats 55 times>, __align = 0}}, usage = {0x555c9845cf40, 0x0}, alloc_thread = 0x0, free = {{front = 0, back = 7, 
      size = 7, mask = 7, data = 0x555c9844ef40}, {front = 0, back = 1501, size = 2861, mask = 4095, data = 0x555c9850d000}, {front = 185, back = 900, size = 715, 
      mask = 1023, data = 0x555c98516000}}, free_inc = {front = 2408, back = 2495, size = 89, mask = 127, data = 0x555c98498400}, open_buckets_partial = {
    0 <repeats 1024 times>}, open_buckets_partial_nr = 0, fifo_last_bucket = 0, max_last_bucket_io = {62, 89}, inc_gen_needs_gc = 0, inc_gen_really_needs_gc = 0, 
  allocator_state = ALLOCATOR_RUNNING, alloc_heap = {size = 1430, used = 2, data = 0x555c98519000}, copygc_thread = 0x0, copygc_heap = {size = 2861, used = 0, 
    data = 0x555c9852a000}, copygc_pd = {rate = {next = 13306909197746, rate = 4294967295}, last_update = 13227428, last_actual = 0, smoothed_derivative = 0, 
    p_term_inverse = 6000, d_smooth = 30, d_term = 0, last_derivative = 0, last_proportional = 0, last_change = 0, last_target = 0, backpressure = true}, 
  copygc_write_point = {node = {next = 0x0, prev = 0x0}, lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, 
          __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, last_used = 0, write_point = 0, type = BCH_DATA_USER, 
    is_ec = false, sectors_free = 0, ptrs = {nr = 0, v = {0 <repeats 15 times>}}, stripe = {next_alloc = {0 <repeats 64 times>}}}, copygc_threshold = 1469952, 
  rebalance_work = {counter = 0}, journal = {bucket_seq = 0x555c98572000, sectors_free = 75, discard_idx = 654, dirty_idx_ondisk = 654, dirty_idx = 654, cur_idx = 654, 
    nr = 1024, buckets = 0x555c9857a000, bio = 0x555c98575000, read = {{{wq = 0x0, s = 0x555c984f8dd0, list = {next = 0x555c984f8dd0}, fn = 0x0}, work = {data = {
            counter = 0}, entry = {next = 0x555c984f8dd0, prev = 0x555c984f8dd0}, func = 0x0}}, parent = 0x7ffd28d3b0c0, remaining = {counter = 0}}}, io_error_work = {
    data = {counter = 0}, entry = {next = 0x555c984f8e00, prev = 0x555c984f8e00}, func = 0x555c9827fb20 <bch2_io_error_work>}, cur_latency = {{counter = 0}, {
      counter = 221382}}, io_latency = {{lock = {count = 0}, count = 0, average_duration = 0, average_frequency = 0, max_duration = 0, last_event = 0, quantiles = {
        entries = {{m = 0, step = 0} <repeats 15 times>}}, buffer = 0x0}, {lock = {count = 0}, count = 293, average_duration = 216274, average_frequency = 133702799802, 
      max_duration = 907092, last_event = 13307762416075, quantiles = {entries = {{m = 205779, step = 96}, {m = 102947, step = 6434}, {m = 0, step = 0}, {m = 11986, 
            step = 27}, {m = 0, step = 0}, {m = 0, step = 0}, {m = 0, step = 0}, {m = 9798, step = 150}, {m = 0, step = 0}, {m = 0, step = 0}, {m = 0, step = 0}, {m = 0, 
            step = 0}, {m = 0, step = 0}, {m = 0, step = 0}, {m = 0, step = 0}}}, buffer = 0x0}}, congested = {counter = 1024}, congested_last = 13307762416075, 
  io_done = 0x555c984b6390}

the ref->completion->wait->task_list values seem inconsistent:

(gdb) print ca->ref_completion->wait->task_list->next->next
$9 = (struct cds_list_head *) 0x555c984f8050
(gdb) print ca->ref_completion->wait->task_list->next
$10 = (struct cds_list_head *) 0x555c984f8050
(gdb) print ca->ref_completion->wait->task_list->next->next->next
$11 = (struct cds_list_head *) 0x555c984f8050
(gdb) print ca->ref_completion->wait->task_list->prev
$12 = (struct cds_list_head *) 0x555c984f8050
(gdb) print ca->ref_completion->wait->task_list->prev->prev
$13 = (struct cds_list_head *) 0x555c984f8050

EDIT: I don't like ca->journal->read either:

print ca->journal->read
$4 = {{{wq = 0x0, s = 0x555a2a85ddf0, list = {next = 0x555a2a85ddf0}, fn = 0x0}, work = {data = {counter = 0}, entry = {next = 0x555a2a85ddf0, prev = 0x555a2a85ddf0}, 
      func = 0x0}}, parent = 0x7ffdb89ca830, remaining = {counter = 0}}

@koverstreet : should I look further? or do you have enough info?

evacuate device - cannot disable or remove it

I wanted to take a foreground/background cache device in a group (SSD, has 2 members) offline so I can use it somewhere else.

bcachefs device evacuate /dev/disk/by-partlabel/sassoftcache

This worked like a charm, but then:

bcachefs device remove /dev/disk/by-partlabel/sassoftcache 
BCH_IOCTL_DISK_REMOVE ioctl error: Invalid argument

and

bcachefs device offline /dev/disk/by-partlabel/sassoftcache
BCH_IOCTL_DISK_OFFLINE ioctl error: Invalid argument

Am I missing something?

[rust] mount can't mount lv volume defined in fstab

fs is defined in fstab like below:
/dev/vg-tmp-filmy-Z1P07DKL/syncthing /dane/media/gry/NOWE/SYNCTHING bcachefs relatime,nofail,verbose,auto 0 0

mount written in rust throws:

error: invalid value '/dev/mapper/vg--tmp--filmy--Z1P07DKL-syncthing' for '<UUID>': invalid character: expected an optional prefix of `urn:uuid:` followed by [0-9a-zA-Z], found `/` at 1

For more information, try '--help'.```

bcachefs format --btree_node_size=512 results in infinite loop

command:

./bcachefs format -L test --acl --btree_node_size=512 -g SSD --discard /dev/disk/by-id/ata-KINGSTON_SA400S37240G_50026B768229124F-part4 /dev/disk/by-id/nvme-GIGABYTE_GP-GSM2NE3256GNTD_SN193808935753-part2 /dev/disk/by-id/scsi-35000cca01307d518-part1 /dev/disk/by-id/scsi-35000cca01306e894-part2 -g HDD /dev/sdd --foreground_target=SSD --background_target=HDD --promote_target=SSD

output:

External UUID:                  9f0d4297-7aee-4864-983e-99bfcdd25091
Internal UUID:                  b25a0d16-2625-49fb-93d5-5fd2243c38ff
Label:                          test
Version:                        11
Created:                        Thu Jul 16 09:35:36 2020
Squence number:                 0
Block_size:                     512
Btree node size:                512
Error action:                   remount-ro
Clean:                          0
Features:
Metadata replicas:              1
Data replicas:                  1
Metadata checksum type:         crc32c (1)
Data checksum type:             crc32c (1)
Compression type:               none (0)
Foreground write target:        Group 0 (SSD)
Background write target:        Group 1 (HDD)
Promote target:                 Group 0 (SSD)
String hash type:               siphash (2)
32 bit inodes:                  0
GC reserve percentage:          8%
Root reserve percentage:        0%
Devices:                        5 live, 5 total
Sections:                       members,disk_groups
Superblock size:                1144

Members (size 288):
  Device 0:
    UUID:                       df44a8eb-4c66-4e42-8b99-a97296f0ab0e
    Size:                       37.3G
    Bucket size:                256.0K
    First bucket:               0
    Buckets:                    152588
    Last mount:                 (never)
    State:                      readwrite
    Group:                      SSD (0)
    Data allowed:               journal,btree,data
    Has data:                   (none)
    Replacement policy:         lru
    Discard:                    1
  Device 1:
    UUID:                       293a774a-758b-46de-b7ff-f6effeb0c7c3
    Size:                       107.3G
    Bucket size:                256.0K
    First bucket:               0
    Buckets:                    439556
    Last mount:                 (never)
    State:                      readwrite
    Group:                      SSD (0)
    Data allowed:               journal,btree,data
    Has data:                   (none)
    Replacement policy:         lru
    Discard:                    1
  Device 2:
    UUID:                       11d46e77-d1d4-438a-ad3c-96ed7eee8c62
    Size:                       89.4G
    Bucket size:                256.0K
    First bucket:               0
    Buckets:                    366296
    Last mount:                 (never)
    State:                      readwrite
    Group:                      SSD (0)
    Data allowed:               journal,btree,data
    Has data:                   (none)
    Replacement policy:         lru
    Discard:                    1
  Device 3:
    UUID:                       d9fb0a11-80f0-4f4e-887a-dc0591edf1a9
    Size:                       88.5G
    Bucket size:                256.0K
    First bucket:               0
    Buckets:                    362388
    Last mount:                 (never)
    State:                      readwrite
    Group:                      SSD (0)
    Data allowed:               journal,btree,data
    Has data:                   (none)
    Replacement policy:         lru
    Discard:                    1
  Device 4:
    UUID:                       28979577-925a-4ec5-ab67-dac8786872b9
    Size:                       36.4T
    Bucket size:                512.0K
    First bucket:               0
    Buckets:                    76287980
    Last mount:                 (never)
    State:                      readwrite
    Group:                      HDD (1)
    Data allowed:               journal,btree,data
    Has data:                   (none)
    Replacement policy:         lru
    Discard:                    0
initializing new filesystem
WARNING at libbcachefs/journal.c:379: JOURNAL_RES_GET_RESERVED set but journal full

...and the program hangs. The warning occurs after some time. It does not do anything. PS aux output (truncated):

root      4031 40.1 17.7 5019796 4363092 pts/0 SLl+ 09:35   7:23 ./bcachefs format -L test --acl --btree_node_size=512 -g SSD --discard /dev/disk/by-id/ata-KINGSTON_SA400S37240G_50026B768

vmstat info( unneccesary disks left out to skip unneccessary info:

linuxserver /home/janpieter # vmstat -w
procs -----------------------memory---------------------- ---swap-- -----io---- -system-- --------cpu--------
 r  b         swpd         free         buff        cache   si   so    bi    bo   in   cs  us  sy  id  wa  st
 1  0            0     14859440      3988284       342920    0    0    53    59   49  297   0   1  99   0   0
linuxserver /home/janpieter # vmstat -wd
disk- -------------------reads------------------- -------------------writes------------------ ------IO-------
          total    merged     sectors          ms     total    merged     sectors          ms     cur     sec
nvme0n1    454013         3     3676202       15454     16540    508041     4149408       34099       0     313
sdb      159202         0     1332802        6560     10637    217905     1771722        3801       0     141
sdd        2405         0       31392       20772     11200    127641     1045720      487219       0     565
sdh      374991         0     3384820       45822     14845    430197     3503625       13043       0     284
sdj      379237         0     3598858       47027     14874    434224     3536095        8403       0     283
(waiting +-15s)
linuxserver /home/janpieter # vmstat -wd
disk- -------------------reads------------------- -------------------writes------------------ ------IO-------
          total    merged     sectors          ms     total    merged     sectors          ms     cur     sec
nvme0n1    462169         3     3741450       15697     16853    517677     4227808       34639       0     319
sdb      162082         0     1355842        6668     10813    220740     1794818        3846       0     143
sdd        2453         0       31776       21356     11444    130665     1070488      498974       0     578
sdh      381799         0     3439284       46640     15141    438382     3570281       13167       0     290
sdj      386110         0     3653842       47855     15171    442600     3604287        8531       0     288

then, finally, the gdb output (as complete as possible, did twice with exactly same results):

(gdb) info threads
  Id   Target Id                                          Frame
* 1    Thread 0x7f4426938b80 (LWP 4031) "bcachefs"        0x00007f4426afb15b in __lll_lock_wait () from /lib64/libpthread.so.0
  2    Thread 0x7f4426db6700 (LWP 4032) "aio_completion"  0x00007f4426aca24a in ?? () from /lib64/libaio.so.1
  3    Thread 0x7f4426dad700 (LWP 4033) "events"          0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  4    Thread 0x7f4426da4700 (LWP 4034) "events_highpri"  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  5    Thread 0x7f4426937700 (LWP 4035) "events_long"     0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  6    Thread 0x7f442692e700 (LWP 4036) "events_unbound"  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  7    Thread 0x7f4426925700 (LWP 4037) "events_freezabl" 0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  8    Thread 0x7f442691c700 (LWP 4038) "timers"          0x00007f4426af7d0d in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
  9    Thread 0x7f4426913700 (LWP 4045) "bcachefs"        0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  10   Thread 0x7f442690a700 (LWP 4046) "bcache_copygc"   0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  11   Thread 0x7f4426901700 (LWP 4047) "bcache_journal"  0x00007f4426a2bfc7 in __close_nocancel () from /lib64/libc.so.6
  12   Thread 0x7f44266f6700 (LWP 4048) "btree_update"    0x00007f4426a26fec in read () from /lib64/libc.so.6
  13   Thread 0x7f43a1897700 (LWP 4052) "bch_alloc[/dev/" 0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  14   Thread 0x7f43a188e700 (LWP 4053) "bch_alloc[/dev/" 0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  15   Thread 0x7f439bfff700 (LWP 4054) "bch_alloc[/dev/" 0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  16   Thread 0x7f43a1885700 (LWP 4055) "bch_alloc[/dev/" 0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  17   Thread 0x7f43a187c700 (LWP 4056) "bch_alloc[/dev/" 0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
  18   Thread 0x7f43a17ef700 (LWP 4061) "events"          0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6

(gdb) bt
#0  0x00007f4426afb15b in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00007f4426af39e3 in pthread_mutex_lock () from /lib64/libpthread.so.0
#2  0x000055ecc36ca5ca in bch2_journal_reclaim_work (work=0x55ecc38f6e10) at libbcachefs/journal_reclaim.c:552
#3  0x000055ecc36893a8 in journal_preres_available (j=j@entry=0x55ecc38f6090, res=res@entry=0x55ecc7e5f878, new_u64s=new_u64s@entry=120, flags=flags@entry=0) at libbcachefs/journal.c:437
#4  0x000055ecc368ac42 in __bch2_journal_preres_get (j=j@entry=0x55ecc38f6090, res=res@entry=0x55ecc7e5f878, new_u64s=new_u64s@entry=120, flags=flags@entry=0) at libbcachefs/journal.h:482
#5  0x000055ecc36d3087 in bch2_journal_preres_get (new_u64s=120, flags=0, res=0x55ecc7e5f878, j=0x55ecc38f6090) at libbcachefs/journal.h:457
#6  bch2_journal_preres_get (new_u64s=120, flags=0, res=0x55ecc7e5f878, j=0x55ecc38f6090) at libbcachefs/journal.h:443
#7  bch2_btree_update_start (trans=trans@entry=0x7ffdd8839df0, id=<optimized out>, nr_nodes=<optimized out>, flags=flags@entry=24, cl=cl@entry=0x7ffdd8839ca0)
    at libbcachefs/btree_update_interior.c:914
#8  0x000055ecc36d5900 in bch2_btree_split_leaf (c=c@entry=0x55ecc38e2000, iter=0x55ecc3a39000, flags=24) at libbcachefs/btree_update_interior.h:183
#9  0x000055ecc36aa2eb in bch2_trans_commit_error (i=<optimized out>, ret=1, trans=0x7ffdd8839df0) at libbcachefs/btree_update_leaf.c:593
#10 __bch2_trans_commit (trans=trans@entry=0x7ffdd8839df0) at libbcachefs/btree_update_leaf.c:970
#11 0x000055ecc36ab187 in bch2_trans_commit (flags=8, journal_seq=0x0, disk_res=0x0, trans=0x7ffdd8839df0) at libbcachefs/btree_update.h:103
#12 bch2_btree_insert (c=c@entry=0x55ecc38e2000, id=id@entry=BTREE_ID_INODES, k=k@entry=0x7ffdd883a230, disk_res=disk_res@entry=0x0, journal_seq=journal_seq@entry=0x0, flags=flags@entry=8)
    at libbcachefs/btree_update_leaf.c:1079
#13 0x000055ecc3705909 in bch2_fs_initialize (c=c@entry=0x55ecc38e2000) at libbcachefs/recovery.c:1277
#14 0x000055ecc36a1634 in bch2_fs_start (c=c@entry=0x55ecc38e2000) at libbcachefs/bcachefs_format.h:1242
#15 0x000055ecc36a35ae in bch2_fs_open (devices=devices@entry=0x55ecc388dc50, nr_devices=nr_devices@entry=5, opts=...) at libbcachefs/super.c:1912
#16 0x000055ecc371f8ff in cmd_format (argc=<optimized out>, argv=<optimized out>) at libbcachefs/opts.h:358
#17 0x000055ecc367efcf in main (argc=<optimized out>, argv=0x7ffdd883ac38) at bcachefs.c:160

(gdb) thread 2
[Switching to thread 2 (Thread 0x7f4426db6700 (LWP 4032))]
#0  0x00007f4426aca24a in ?? () from /lib64/libaio.so.1
(gdb) bt
#0  0x00007f4426aca24a in ?? () from /lib64/libaio.so.1
#1  0x000055ecc371972c in aio_completion_thread (arg=<optimized out>) at linux/blkdev.c:245
#2  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc388c320) at linux/kthread.c:25
#3  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#4  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 3
[Switching to thread 3 (Thread 0x7f4426dad700 (LWP 4033))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc371a60b in worker_thread (arg=0x55ecc388c540) at linux/workqueue.c:252
#4  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc388c5e0) at linux/kthread.c:25
#5  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#6  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 4
[Switching to thread 4 (Thread 0x7f4426da4700 (LWP 4034))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc371a60b in worker_thread (arg=0x55ecc388c800) at linux/workqueue.c:252
#4  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc388c8a0) at linux/kthread.c:25
#5  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#6  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 5
[Switching to thread 5 (Thread 0x7f4426937700 (LWP 4035))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc371a60b in worker_thread (arg=0x55ecc388cac0) at linux/workqueue.c:252
#4  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc388cb60) at linux/kthread.c:25
#5  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#6  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 6
[Switching to thread 6 (Thread 0x7f442692e700 (LWP 4036))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc371a60b in worker_thread (arg=0x55ecc388cd80) at linux/workqueue.c:252
#4  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc388ce20) at linux/kthread.c:25
#5  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#6  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 7
[Switching to thread 7 (Thread 0x7f4426925700 (LWP 4037))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc371a60b in worker_thread (arg=0x55ecc388d040) at linux/workqueue.c:252
#4  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc388d0e0) at linux/kthread.c:25
#5  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#6  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 8
[Switching to thread 8 (Thread 0x7f442691c700 (LWP 4038))]
#0  0x00007f4426af7d0d in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
(gdb) bt
#0  0x00007f4426af7d0d in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x000055ecc371d0a6 in timer_thread (arg=<optimized out>) at linux/timer.c:292
#2  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc388d6f0) at linux/kthread.c:25
#3  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#4  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 9
[Switching to thread 9 (Thread 0x7f4426913700 (LWP 4045))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc371a60b in worker_thread (arg=0x55ecc38909c0) at linux/workqueue.c:252
#4  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc3890a60) at linux/kthread.c:25
#5  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#6  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 10
[Switching to thread 10 (Thread 0x7f442690a700 (LWP 4046))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc371a60b in worker_thread (arg=0x55ecc3890c80) at linux/workqueue.c:252
#4  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc3890d20) at linux/kthread.c:25
#5  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#6  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 11
[Switching to thread 11 (Thread 0x7f4426901700 (LWP 4047))]
#0  0x00007f4426a2bfc7 in __close_nocancel () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a2bfc7 in __close_nocancel () from /lib64/libc.so.6
#1  0x00007f44269c216c in _IO_file_close_it () from /lib64/libc.so.6
#2  0x00007f44269b5305 in fclose () from /lib64/libc.so.6
#3  0x000055ecc371a30c in read_meminfo () at linux/shrinker.c:63
#4  run_shrinkers () at linux/shrinker.c:79
#5  0x000055ecc36d2923 in kmalloc (flags=0, size=2896) at include/linux/slab.h:21
#6  mempool_alloc (gfp_mask=0, pool=0x55ecc38e5f70) at include/linux/mempool.h:38
#7  bch2_btree_update_start (trans=trans@entry=0x7f4426900680, id=BTREE_ID_ALLOC, nr_nodes=3, flags=flags@entry=438, cl=cl@entry=0x7f4426900480) at libbcachefs/btree_update_interior.c:892
#8  0x000055ecc36d5900 in bch2_btree_split_leaf (c=c@entry=0x55ecc38e2000, iter=0x7f4374002000, flags=438) at libbcachefs/btree_update_interior.h:183
#9  0x000055ecc36aa2eb in bch2_trans_commit_error (i=<optimized out>, ret=1, trans=0x7f4426900680) at libbcachefs/btree_update_leaf.c:593
#10 __bch2_trans_commit (trans=trans@entry=0x7f4426900680) at libbcachefs/btree_update_leaf.c:970
#11 0x000055ecc3683969 in bch2_trans_commit (flags=439, journal_seq=0x0, disk_res=0x0, trans=0x7f4426900680) at libbcachefs/btree_update.h:103
#12 btree_key_cache_flush_pos (trans=trans@entry=0x7f4426900680, key=..., journal_seq=journal_seq@entry=1, evict=evict@entry=false) at libbcachefs/btree_key_cache.c:338
#13 0x000055ecc3683d56 in btree_key_cache_journal_flush (j=0x55ecc38f6090, pin=0x7f437c001290, seq=1) at libbcachefs/btree_key_cache.c:404
#14 0x000055ecc36c8e23 in journal_flush_pins (j=0x55ecc38f6090, seq_to_flush=0, min_nr=0) at libbcachefs/journal_reclaim.c:457
#15 0x000055ecc36ca44a in bch2_journal_reclaim (j=j@entry=0x55ecc38f6090) at libbcachefs/journal_reclaim.c:540
#16 0x000055ecc36ca5d2 in bch2_journal_reclaim_work (work=0x55ecc38f6e10) at libbcachefs/journal_reclaim.c:553
#17 0x000055ecc371a5c5 in worker_thread (arg=0x55ecc3890f40) at linux/workqueue.c:262
#18 0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc38df420) at linux/kthread.c:25
#19 0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#20 0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 12
[Switching to thread 12 (Thread 0x7f44266f6700 (LWP 4048))]
#0  0x00007f4426a26fec in read () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a26fec in read () from /lib64/libc.so.6
#1  0x00007f44269c2b52 in _IO_file_underflow () from /lib64/libc.so.6
#2  0x00007f44269b6998 in getdelim () from /lib64/libc.so.6
#3  0x000055ecc371a2b3 in getline (__stream=0x7f437c000b60, __n=0x7f44266f5588, __lineptr=0x7f44266f5590) at /usr/include/bits/stdio.h:120
#4  read_meminfo () at linux/shrinker.c:55
#5  run_shrinkers () at linux/shrinker.c:79
#6  0x000055ecc3690c3e in kmalloc (flags=1, size=160) at include/linux/slab.h:21
#7  bch2_fs_usage_scratch_get (c=c@entry=0x55ecc38e2000) at libbcachefs/buckets.c:164
#8  0x000055ecc36a98a8 in bch2_trans_commit_write_locked (stopped_at=<synthetic pointer>, trans=0x7f44266f5710) at libbcachefs/btree_update_leaf.c:423
#9  do_bch2_trans_commit (stopped_at=<synthetic pointer>, trans=0x7f44266f5710) at libbcachefs/btree_update_leaf.c:541
#10 __bch2_trans_commit (trans=trans@entry=0x7f44266f5710) at libbcachefs/btree_update_leaf.c:944
#11 0x000055ecc36d125d in bch2_trans_commit (flags=438, journal_seq=0x7f44266f56f8, disk_res=0x7f434dc96868, trans=0x7f44266f5710) at libbcachefs/btree_update.h:103
#12 btree_update_nodes_written (as=as@entry=0x7f434dc96800) at libbcachefs/btree_update_interior.c:540
#13 0x000055ecc36d19fb in btree_interior_update_work (work=0x55ecc38e5fe8) at libbcachefs/btree_update_interior.c:633
#14 0x000055ecc371a5c5 in worker_thread (arg=0x55ecc392cf80) at linux/workqueue.c:262
#15 0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc38915a0) at linux/kthread.c:25
#16 0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#17 0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 13
[Switching to thread 13 (Thread 0x7f43a1897700 (LWP 4052))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc36bef76 in push_invalidated_bucket (bucket=2370, ca=0x55ecc3940000, c=0x55ecc38e2000) at libbcachefs/alloc_background.c:1057
#4  discard_invalidated_buckets (ca=<optimized out>, c=<optimized out>) at libbcachefs/alloc_background.c:1080
#5  bch2_allocator_thread (arg=0x55ecc3940000) at libbcachefs/alloc_background.c:1113
#6  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc3891180) at linux/kthread.c:25
#7  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#8  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 14
[Switching to thread 14 (Thread 0x7f43a188e700 (LWP 4053))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc36bef76 in push_invalidated_bucket (bucket=6134, ca=0x55ecc3954000, c=0x55ecc38e2000) at libbcachefs/alloc_background.c:1057
#4  discard_invalidated_buckets (ca=<optimized out>, c=<optimized out>) at libbcachefs/alloc_background.c:1080
#5  bch2_allocator_thread (arg=0x55ecc3954000) at libbcachefs/alloc_background.c:1113
#6  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc3891300) at linux/kthread.c:25
#7  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#8  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 15
[Switching to thread 15 (Thread 0x7f439bfff700 (LWP 4054))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc36bef76 in push_invalidated_bucket (bucket=5282, ca=0x55ecc38d0000, c=0x55ecc38e2000) at libbcachefs/alloc_background.c:1057
#4  discard_invalidated_buckets (ca=<optimized out>, c=<optimized out>) at libbcachefs/alloc_background.c:1080
#5  bch2_allocator_thread (arg=0x55ecc38d0000) at libbcachefs/alloc_background.c:1113
#6  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc3915190) at linux/kthread.c:25
#7  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#8  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 16
[Switching to thread 16 (Thread 0x7f43a1885700 (LWP 4055))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc36bef76 in push_invalidated_bucket (bucket=5236, ca=0x55ecc39a6000, c=0x55ecc38e2000) at libbcachefs/alloc_background.c:1057
#4  discard_invalidated_buckets (ca=<optimized out>, c=<optimized out>) at libbcachefs/alloc_background.c:1080
#5  bch2_allocator_thread (arg=0x55ecc39a6000) at libbcachefs/alloc_background.c:1113
#6  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc3915e80) at linux/kthread.c:25
#7  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#8  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 17
[Switching to thread 17 (Thread 0x7f43a187c700 (LWP 4056))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x000055ecc371cc39 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:66
#2  schedule () at linux/sched.c:41
#3  0x000055ecc36bef76 in push_invalidated_bucket (bucket=150025, ca=0x55ecc39e9000, c=0x55ecc38e2000) at libbcachefs/alloc_background.c:1057
#4  discard_invalidated_buckets (ca=<optimized out>, c=<optimized out>) at libbcachefs/alloc_background.c:1080
#5  bch2_allocator_thread (arg=0x55ecc39e9000) at libbcachefs/alloc_background.c:1113
#6  0x000055ecc371ba19 in kthread_start_fn (data=0x55ecc3933dd0) at linux/kthread.c:25
#7  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#8  0x00007f4426a3428f in clone () from /lib64/libc.so.6
(gdb) thread 18
[Switching to thread 18 (Thread 0x7f43a17ef700 (LWP 4061))]
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f4426a30bd9 in syscall () from /lib64/libc.so.6
#1  0x00007f4426d34d82 in call_rcu_thread () from /usr/lib64/liburcu.so.6
#2  0x00007f4426af0ff7 in start_thread () from /lib64/libpthread.so.0
#3  0x00007f4426a3428f in clone () from /lib64/libc.so.6

... and that's everything I got. If you want more info, let me know

Error when trying to add new device to pool

Hello,

I have a six disk pool where one of my devices failed. The mount was formatted using the following command:

bcachefs format --discard --compression zstd --group hdds \
    /dev/disk/by-id/ata-ST6000VN001-2BB186_ZR11JBDV \
    /dev/disk/by-id/ata-ST6000VN001-2BB186_ZR11JBCN \
    /dev/disk/by-id/ata-ST8000DM004-2CX188_WCT0AZ6B \
    /dev/disk/by-id/ata-ST3000DM008-2DM166_ZA50G8L1 \
    /dev/disk/by-id/ata-ST3000DM008-2DM166_Z504L42L \
    /dev/disk/by-id/ata-ST3000DM001-1ER166_Z502TSH6 \
    --group ssds /dev/disk/by-id/nvme-WDS100T3X0C-00SJG0_204181800486 \
    --foreground_target=ssds --background_target=hdds \
    --promote_target=ssds --data_replicas=2 --metadata_replicas=2 --label=Bigdata

The 1ER166 device completely disappeared and the mount went read only at runtime. The only way I was able to recover the mount was to reboot and mount with "-o rw,very_degraded". I used this FS for a few weeks while waiting for the time to add the new disk to my system.

Unfortunately, I am now unable to add the new device to the pool:

The device: Seagate Iron Wolf 8TB HDD (marked /dev/sdf)

The new device is un-formatted.

sudo bcachefs device set-state failed /dev/disk/by-id/ata-ST3000DM001-1ER166_Z502TSH6 /mnt/data
sudo bcachefs device remove 5 /mnt/data (the failed device, took 10 minutes)
sudo bcachefs device add /mnt/data /dev/sdf -f

read_file_u64: error parsing options/block_size (got 4.0k)           (<--- THE ERROR --->)

The fs still mounts just fine, and the data seems fine, but I am unable to add my new device.

System details

Distro: Arch Linux
linux-bcachefs-git version: v5.15.11.arch2.r1045987.0f2596564327-1
bcachefs-tools-git version: 816-1
kernel: Linux lithium 5.15.11-arch2-1-bcachefs-git-384112-g0f2596564327 #1 SMP PREEMPT Tue, 28 Dec 2021 04:43:43 +0000 x86_64 GNU/Linux
bcachfs version: bcachefs tool version v0.1-436-g07b1801 (I do not think this is being set correctly during build)

segfault

Hello

I had to remove one drive of my array (because of a deffect), then I mounted the filesystem (-o degraded) and removed the drive from the filesystem. And i got an error while umounting it. now I cannot mount it And when running fsck it finds many "invalid journal entry dev usage: bad dev" then it says journal read done and dropped unflushed entries and then segfaults.

kernel commit is d2e08891288
bcachefs-tools commit is 941075c

BUG: Assertion Failed in `bcachefs: libbcachefs/btree_iter.c:1760: bch2_btree_path_peek_slot`

I've been hitting the following bug when running fsck since commit 2b8c1bb0910534e8687ea3e5abf6d8bbba758247

twice since running fsck I've hit a what seems to be early exit from fsck because of this bugcheck

❯ sudo bcachefs fsck /dev/sdb /dev/sdd /dev/sde /dev/sda /dev/sdc /dev/nvme0n1 -v -p
bcachefs: bch2_fs_open()
bcachefs: bch2_read_super()
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super()
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super()
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super()
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super()
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_read_super()
bcachefs: bch2_read_super() ret 0
bcachefs: bch2_fs_alloc()
bcachefs: bch2_fs_journal_init()
bcachefs: bch2_fs_journal_init() ret 0
bcachefs: bch2_fs_btree_cache_init()
bcachefs: bch2_fs_btree_cache_init() ret 0
bcachefs: bch2_fs_encryption_init()
bcachefs: bch2_fs_encryption_init() ret 0
bcachefs: __bch2_fs_compress_init()
bcachefs: __bch2_fs_compress_init() ret 0
bcachefs: bch2_dev_alloc()
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc()
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc()
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc()
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc()
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_dev_alloc()
bcachefs: bch2_dev_alloc() ret 0
bcachefs: bch2_fs_alloc() ret 0
recovering from clean shutdown, journal seq 389740
journal read done, 0 keys in 1 entries, seq 389741
starting alloc read
alloc read done
starting stripes_read
stripes_read done
starting mark and sweep
mark and sweep done
starting journal replay
journal replay done
starting fsck
checking extents
checking dirents
going read-write
bcachefs: libbcachefs/btree_iter.c:1760: bch2_btree_path_peek_slot: Assertion `!(path->uptodate != BTREE_ITER_UPTODATE)' failed.
fish: Job 1, 'sudo bcachefs fsck /dev/sdb /de…' terminated by signal SIGABRT (Abort)

should I expect data loss? what should I provide to help debugging or fix this? ( I didn't see anything in the site or repo about debugging issues or other expected info with debug reports. I'm sorry if I've missed something)

Error if build on aarch64

Trying to build on arm64(aarch64) platform got an error:

rock:~/bcachefs-tools$ make
cc -std=gnu89 -O2 -g -MMD -Wall -Wno-pointer-sign -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-233-g487ddeb"'  -Wno-unused-but-set-variable -DCONFIG_VALGRIND=y -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/aarch64-linux-gnu   -c -o bcachefs.o bcachefs.c
In file included from tools-util.h:17,
                 from cmds.h:10,
                 from bcachefs.c:26:
include/linux/log2.h: In function ‘get_order’:
include/linux/log2.h:281:27: error: ‘PAGE_SHIFT’ undeclared (first use in this function); did you mean ‘PAGE_SIZE’?
  281 |    return BITS_PER_LONG - PAGE_SHIFT;
      |                           ^~~~~~~~~~
      |                           PAGE_SIZE
include/linux/log2.h:281:27: note: each undeclared identifier is reported only once for each function it appears in
make: *** [<builtin>: bcachefs.o] Error 1
rock:~/bcachefs-tools$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal

rock:~/bcachefs-tools$ uname -a
Linux rock 5.8.10-rockchip64 #20.08.3 SMP PREEMPT Fri Sep 18 11:05:12 CEST 2020 aarch64 aarch64 aarch64 GNU/Linux

rock:~/bcachefs-tools$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/9/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2) 

Consider implement `bachefs backup`

Ratio / feature request

Since Snapshots hit the ground of bcachfs this issue arises quite naturaly form the point of administration of a bcachefs driven production system.

Imaging the common szenario:

  • the production system is servering data trunks
  • the trunks are organized as read-write subvolumes on the given drive-pool
    (eg: data, home, var, usr).
  • A backup strategy needs to take care that all relevant data are saved on a regular, timedriven scedule
    And of course, dealing as a carfull administrator we like to asure, that we have a media brake in our backup plan (reading: disk-to-disk-to-tape).

bcachefs right now offers all needed building blocks, missing conceptually the backup strategy.

A reference

Coming from a btrfs environment, I personaly use dsnap-sync. This is a simple posix-shell implemented tool, that is consuming btrfs-send/btrfs-receive to transfer snapshots and snapper to handle the needed snapshot. snapper is a c++ service/library, that organizes snaphosts building attributed configs.

snapper

The key feature of snapper is its ability to offer / define config specific timer and cleanup rules. This rules take care to manage config applicable backup rules (e.g: create hourly sanpshots during the day, keep a snaphost per day (max 6), keep a snaphost per week (max 3), keep a snapshot per month (max 11), keep a snapshot per year (max 2).
snapper itself is using btrfs ro-snapshots as it target objects. It will transfer incremental data differences using btrfs-send and btrfs-receive. The take away: snapper is implementing a subsystem that offers continious snapshots.

dsnap-sync

The development of snapper has never evolved to implement a backup command, that enables the transfer to remote targets. This is a pitty. A feature request is hanging around for almost two years. Others have requested that kind of functionality, too (feature-request).

snapper is saving the snapshots of a subvolume inside a hardcoded subdir (.snapshots). Metadata are written in an xml-file, beside the taken snapshot.
Sadly, dsnap-sync is needed to heel the missing gab of transfering snapper managed snaphosts to a remote target. It is coding the needed procedures to implement disk2disk2tape.

A typical dsnap-sync disk2disk run will scan for the last snapshot on the source and transfer the latest delta to the target (consuming btrfs-send and btrfs-receive, combined with ssh). It will find the relevant snapshots using snapper managed metadata (awk). If the target, that obviously need to offer a valid btrfs filesystem/subvolume, is missing the snapper alike structure, dsnap-sync will create this structure on the fly. Then the data-transfer itself is issued.
The next disk2disk job will only transfer the delta between the latest source snapshot and the latest target snapshot. The goal: minimise data volume, since we can calculate the differences between the snapshots on source and on target.

Let us asume, the infrastucture is layed out correct, you are able to consume snapper functionality on the target as well, enabling the admin to implement a config rules for the backup.
And since we have ro-snapshots on the target, we can use dsnap-sync again, to implement disk2tape. Source is the latest snapshot of the target config, saving this data to an lto/ltfs tape.

bachefs implementation

dsnap-sync is just a proove of concept project. Beside the fact that i do use it (lagging a better solution) it has its shortcommings. The key aspect (at least from my point of view) is the need to implement that kind of snapshot management inside the filesystem tools itself. That will render any kind of wrappers obsolete and makes error handling quite a bit more reliable.

Where we are now

bcachefs is a roling stone. But wouldn't it make sence to take the lessons learned from btrfs and realize a better solution, overcomming this shortcummings? bcachefs doesn't have a conceptual design problem with large amounts of subvolume/snapshot combinations. And a chain of ro-snaphosts will make you sleep well, if you know there is a working backup strategy.

It would be a strong argument to switch from btrfs to bcachefs, if bachefs is implementing a backup command as a first class citizen of bcachefs-tools. As far a i did understand the branch, all needed ground work is in place. No dought, stability is a must for production use. But hey, you have to start somewhere

Where we should go

Implement a btrfs-send and btrfs-receive synonym that is used by a backup command offering attributed snapshot listings.

Conclusion

This feature request is witten as a draft. It should start a discussion, targeting the realization of a practical solution to solve the issue.

bcachefs goes into read only mode after first read from system idle

I am using freshly built (as of Jan 8) bcachefs-tools and bcachefs kernel.

The filesystem is going into read only mode when I read from it after the system being idle over night. I believe one of the hard disks is going to sleep, at least, I see the "zzz" icon next to one of my disks in the gnome program "Disks".

Jan 09 11:40:47 lithium kernel: ata2.00: exception Emask 0x11 SAct 0x10000000 SErr 0x400000 action 0x6 frozen
Jan 09 11:40:47 lithium kernel: ata2.00: irq_stat 0x48000008, interface fatal error
Jan 09 11:40:47 lithium kernel: ata2: SError: { Handshk }
Jan 09 11:40:47 lithium kernel: ata2.00: failed command: WRITE FPDMA QUEUED
Jan 09 11:40:47 lithium kernel: ata2.00: cmd 61/08:e0:88:51:34/00:00:8d:02:00/40 tag 28 ncq dma 4096 out
                                         res 40/00:e0:88:51:34/00:00:8d:02:00/40 Emask 0x10 (ATA bus error)
Jan 09 11:40:47 lithium kernel: ata2.00: status: { DRDY }
Jan 09 11:40:47 lithium kernel: ata2: hard resetting link
Jan 09 11:40:48 lithium kernel: ata2: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Jan 09 11:40:48 lithium kernel: ata2.00: configured for UDMA/133
Jan 09 11:40:48 lithium kernel: ata2: EH complete
Jan 09 11:40:48 lithium kernel: ata2.00: exception Emask 0x11 SAct 0x100 SErr 0x400000 action 0x6 frozen
Jan 09 11:40:48 lithium kernel: ata2.00: irq_stat 0x48000008, interface fatal error
Jan 09 11:40:48 lithium kernel: ata2: SError: { Handshk }
Jan 09 11:40:48 lithium kernel: ata2.00: failed command: WRITE FPDMA QUEUED
Jan 09 11:40:48 lithium kernel: ata2.00: cmd 61/08:40:88:51:34/00:00:8d:02:00/40 tag 8 ncq dma 4096 out
                                         res 40/00:40:88:51:34/00:00:8d:02:00/40 Emask 0x10 (ATA bus error)
Jan 09 11:40:48 lithium kernel: ata2.00: status: { DRDY }
Jan 09 11:40:48 lithium kernel: ata2: hard resetting link
Jan 09 11:40:48 lithium kernel: ata2: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Jan 09 11:40:48 lithium kernel: ata2.00: configured for UDMA/133
Jan 09 11:40:48 lithium kernel: ata2: EH complete
Jan 09 11:40:48 lithium kernel: ata2.00: exception Emask 0x11 SAct 0x400000 SErr 0x400000 action 0x6 frozen
Jan 09 11:40:48 lithium kernel: ata2.00: irq_stat 0x48000008, interface fatal error
Jan 09 11:40:48 lithium kernel: ata2: SError: { Handshk }
Jan 09 11:40:48 lithium kernel: ata2.00: failed command: WRITE FPDMA QUEUED
Jan 09 11:40:48 lithium kernel: ata2.00: cmd 61/08:b0:88:51:34/00:00:8d:02:00/40 tag 22 ncq dma 4096 out
                                         res 40/00:b0:88:51:34/00:00:8d:02:00/40 Emask 0x10 (ATA bus error)
Jan 09 11:40:48 lithium kernel: ata2.00: status: { DRDY }
Jan 09 11:40:48 lithium kernel: ata2: hard resetting link
Jan 09 11:40:49 lithium kernel: ata2: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Jan 09 11:40:49 lithium kernel: ata2.00: configured for UDMA/133
Jan 09 11:40:49 lithium kernel: ata2: EH complete
Jan 09 11:40:49 lithium kernel: ata2: limiting SATA link speed to 1.5 Gbps
Jan 09 11:40:49 lithium kernel: ata2.00: exception Emask 0x11 SAct 0x1000000 SErr 0x400000 action 0x6 frozen
Jan 09 11:40:49 lithium kernel: ata2.00: irq_stat 0x48000008, interface fatal error
Jan 09 11:40:49 lithium kernel: ata2: SError: { Handshk }
Jan 09 11:40:49 lithium kernel: ata2.00: failed command: WRITE FPDMA QUEUED
Jan 09 11:40:49 lithium kernel: ata2.00: cmd 61/08:c0:88:51:34/00:00:8d:02:00/40 tag 24 ncq dma 4096 out
                                         res 40/00:c0:88:51:34/00:00:8d:02:00/40 Emask 0x10 (ATA bus error)
Jan 09 11:40:49 lithium kernel: ata2.00: status: { DRDY }
Jan 09 11:40:49 lithium kernel: ata2: hard resetting link
Jan 09 11:40:51 lithium kernel: ata2: SATA link down (SStatus 1 SControl 310)
Jan 09 11:40:51 lithium kernel: ata2: hard resetting link
Jan 09 11:40:53 lithium kernel: ata2: SATA link down (SStatus 1 SControl 310)
Jan 09 11:40:53 lithium kernel: ata2: hard resetting link
Jan 09 11:40:55 lithium kernel: ata2: SATA link down (SStatus 1 SControl 310)
Jan 09 11:40:55 lithium kernel: ata2.00: disabled
Jan 09 11:40:55 lithium kernel: sd 1:0:0:0: [sdb] tag#24 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=8s
Jan 09 11:40:55 lithium kernel: sd 1:0:0:0: [sdb] tag#24 Sense Key : Not Ready [current]
Jan 09 11:40:55 lithium kernel: sd 1:0:0:0: [sdb] tag#24 Add. Sense: Logical unit not ready, hard reset required
Jan 09 11:40:55 lithium kernel: sd 1:0:0:0: [sdb] tag#24 CDB: Write(16) 8a 00 00 00 00 02 8d 34 51 88 00 00 00 08 00 00
Jan 09 11:40:55 lithium kernel: blk_update_request: I/O error, dev sdb, sector 10958950792 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
Jan 09 11:40:55 lithium kernel: bcachefs (sdb): btree write error: I/O
Jan 09 11:40:55 lithium kernel: ata2: EH complete
Jan 09 11:40:55 lithium kernel: sd 1:0:0:0: rejecting I/O to offline device
Jan 09 11:40:55 lithium kernel: blk_update_request: I/O error, dev sdb, sector 0 op 0x2:(FLUSH) flags 0x0 phys_seg 0 prio class 0
Jan 09 11:40:55 lithium kernel: bcachefs (sdb): error writing journal entry 681298: I/O
Jan 09 11:40:55 lithium kernel: blk_update_request: I/O error, dev sdb, sector 10959058624 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
Jan 09 11:40:55 lithium kernel: bcachefs (sdb): btree write error: I/O
Jan 09 11:40:55 lithium kernel: ata2.00: detaching (SCSI 1:0:0:0)
Jan 09 11:40:56 lithium kernel: bcachefs (sdb): btree write error: I/O
Jan 09 11:40:56 lithium kernel: sd 1:0:0:0: [sdb] Stopping disk
Jan 09 11:40:56 lithium kernel: ata2: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
Jan 09 11:40:56 lithium kernel: ata2.00: ATA-10: ST6000VN001-2BB186, SC60, max UDMA/133
Jan 09 11:40:56 lithium kernel: ata2.00: 11721045168 sectors, multi 16: LBA48 NCQ (depth 32), AA
Jan 09 11:40:56 lithium kernel: ata2.00: configured for UDMA/133
Jan 09 11:40:56 lithium kernel: blk_update_request: I/O error, dev sdb, sector 10959926512 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
Jan 09 11:40:56 lithium kernel: bcachefs (sdb): btree write error: I/O
Jan 09 11:40:56 lithium kernel: blk_update_request: I/O error, dev sdb, sector 10960288440 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
Jan 09 11:40:56 lithium kernel: bcachefs (sdb): btree write error: I/O
Jan 09 11:40:56 lithium kernel: blk_update_request: I/O error, dev sdb, sector 10959254488 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
Jan 09 11:40:56 lithium kernel: bcachefs (sdb): btree write error: I/O
Jan 09 11:40:56 lithium kernel: blk_update_request: I/O error, dev sdb, sector 10959692056 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
Jan 09 11:40:56 lithium kernel: bcachefs (sdb): btree write error: I/O
Jan 09 11:40:56 lithium kernel: blk_update_request: I/O error, dev sdb, sector 10960237528 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
Jan 09 11:40:57 lithium kernel: bcachefs (sdb): btree write error: I/O
Jan 09 11:40:57 lithium kernel: blk_update_request: I/O error, dev sdb, sector 10960243000 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
Jan 09 11:40:57 lithium kernel: bcachefs (sdb): btree write error: I/O
Jan 09 11:40:57 lithium kernel: blk_update_request: I/O error, dev sdb, sector 10960231872 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
Jan 09 11:40:57 lithium kernel: bcachefs (sdb): btree write error: I/O
Jan 09 11:40:57 lithium kernel: bcachefs (sdb): error writing journal entry 681299: I/O
Jan 09 11:40:57 lithium kernel: scsi 1:0:0:0: Direct-Access     ATA      ST6000VN001-2BB1 SC60 PQ: 0 ANSI: 5
Jan 09 11:40:57 lithium kernel: sd 1:0:0:0: [sdg] 11721045168 512-byte logical blocks: (6.00 TB/5.46 TiB)
Jan 09 11:40:57 lithium kernel: sd 1:0:0:0: [sdg] 4096-byte physical blocks
Jan 09 11:40:57 lithium kernel: sd 1:0:0:0: [sdg] Write Protect is off
Jan 09 11:40:57 lithium kernel: sd 1:0:0:0: [sdg] Mode Sense: 00 3a 00 00
Jan 09 11:40:57 lithium kernel: sd 1:0:0:0: [sdg] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Jan 09 11:40:57 lithium kernel: sd 1:0:0:0: Attached scsi generic sg1 type 0
Jan 09 11:40:57 lithium dbus-daemon[811]: [system] Activating via systemd: service name='org.freedesktop.Avahi' unit='dbus-org.freedesktop.Avahi.service' requested by ':1.253' (uid=971 pid=234529 comm="/usr/lib/colord-sane ")
Jan 09 11:40:57 lithium dbus-daemon[811]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.Avahi.service': Unit dbus-org.freedesktop.Avahi.service not found.
Jan 09 11:40:59 lithium kernel: bcachefs (sdb): error writing journal entry 681300: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb): error writing journal entry 681301: I/O
Jan 09 11:41:00 lithium kernel: sd 1:0:0:0: [sdg] Attached SCSI disk
Jan 09 11:41:00 lithium kernel: bcachefs (sdb): error writing journal entry 681302: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb inum 83899478 offset 1024): data write error: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb inum 83899478 offset 1016): data write error: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb inum 83899478 offset 1576): data write error: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb inum 83899478 offset 3064): data write error: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb inum 83899478 offset 3624): data write error: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb inum 83899478 offset 5104): data write error: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb inum 83899478 offset 5096): data write error: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb inum 83899478 offset 5672): data write error: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb inum 83899478 offset 7152): data write error: I/O
Jan 09 11:41:00 lithium kernel: bcachefs (sdb inum 83899478 offset 7136): data write error: I/O
Jan 09 11:41:01 lithium kernel: bcachefs (sdb): superblock write error: I/O
Jan 09 11:41:01 lithium kernel: bcachefs (000000003b19194f): Unable to write superblock to sufficient devices (from bch2_mark_replicas_slowpath [bcachefs])
Jan 09 11:41:01 lithium kernel: bcachefs (000000003b19194f): emergency read only
Jan 09 11:41:01 lithium kernel: bcachefs (000000003b19194f inum 83899478): write error -30 from btree update
Jan 09 11:41:01 lithium kernel: bcachefs (000000003b19194f inum 83899478): write error -30 from btree update
Jan 09 11:41:01 lithium kernel: bcachefs (000000003b19194f inum 83899478): write error -30 from btree update
Jan 09 11:41:01 lithium kernel: bcachefs (000000003b19194f inum 83899478): write error -30 from btree update
Jan 09 11:41:01 lithium kernel: bcachefs (000000003b19194f inum 83899478): write error -30 from btree update
Jan 09 11:41:01 lithium kernel: bcachefs (000000003b19194f inum 83899478): write error -30 from btree update

bcachefs fsck could not write journal error

related to koverstreet/bcachefs#189
I'll post necessary info here to help finding the problem in userspace.
GDB backtrace for Error in recovery: journal replay failed:

(gdb) bt
#0  bch2_journal_write (cl=0x7ffff7ac6008) at libbcachefs/journal_io.c:1503
#1  0x0000555555562cc5 in worker_thread (arg=0x555555774800) at linux/workqueue.c:262
#2  0x000055555555f1f9 in kthread_start_fn (data=0x5555557748a0) at linux/kthread.c:25
#3  0x00007ffff7cc2fde in start_thread () from /lib64/libpthread.so.0
#4  0x00007ffff7c0573f in clone () from /lib64/libc.so.6

Some variables which might be useful for debugging:

(gdb) print ret
$1 = -30
(gdb) print *j
$3 = {flags = 55, reservations = {{counter = {counter = 29360814}}, {v = 29360814}, {cur_entry_offset = 686, idx = 0, unwritten_idx = 3, buf0_count = 1, buf1_count = 0, buf2_count = 0, buf3_count = 0}}, cur_entry_u64s = 130745, 
  cur_entry_sectors = 1024, cur_entry_error = cur_entry_ok, prereserved = {{counter = {counter = 56998682783911060}}, {v = 56998682783911060}, {reserved = 3220, remaining = 13271040}}, entry_u64s_reserved = 320, 
  buf_size_want = 2097152, buf = {{data = 0x7ffe8848f000, {key = {_data = 0x7ffff7ac4e20, {{u64s = 5 '\005'}, {k = {u64s = 5 '\005', format = 1 '\001', needs_whiteout = 0 '\000', type = 6 '\006', pad = "", version = {lo = 0, hi = 0}, 
                size = 0, p = {snapshot = 0, offset = 0, inode = 0}}, v = {__nothing = 0x7ffff7ac4e48}}}}, key_pad = {1125899910053889, 0, 0, 0}}, wait = {list = {first = 0x0}}, buf_size = 1048576, sectors = 2048, 
      disk_sectors = 4294965760, u64s_reserved = 320, noflush = false, must_flush = false, separate_flush = false, has_inode = {0 <repeats 67 times>, 68719476736, 0 <repeats 60 times>}}, {data = 0x7ffe88590000, {key = {
          _data = 0x7ffff7ac5290, {{u64s = 6 '\006'}, {k = {u64s = 6 '\006', format = 1 '\001', needs_whiteout = 0 '\000', type = 6 '\006', pad = "", version = {lo = 0, hi = 0}, size = 0, p = {snapshot = 0, offset = 0, inode = 0}}, 
              v = {__nothing = 0x7ffff7ac52b8}}}}, key_pad = {1125899910037505, 0, 0, 0}}, wait = {list = {first = 0x0}}, buf_size = 1048576, sectors = 0, disk_sectors = 4294966784, u64s_reserved = 320, noflush = false, 
      must_flush = false, separate_flush = true, has_inode = {1, 0 <repeats 66 times>, 68719476736, 0 <repeats 29 times>, 1125899906842624, 0 <repeats 30 times>}}, {data = 0x7ffe88691000, {key = {_data = 0x7ffff7ac5700, {{
              u64s = 6 '\006'}, {k = {u64s = 6 '\006', format = 1 '\001', needs_whiteout = 0 '\000', type = 6 '\006', pad = "", version = {lo = 0, hi = 0}, size = 0, p = {snapshot = 0, offset = 0, inode = 0}}, v = {
                __nothing = 0x7ffff7ac5728}}}}, key_pad = {1125899910021121, 0, 0, 0}}, wait = {list = {first = 0x0}}, buf_size = 1048576, sectors = 0, disk_sectors = 4294966784, u64s_reserved = 320, noflush = false, 
      must_flush = false, separate_flush = true, has_inode = {1, 0 <repeats 47 times>, 144115188075855872, 0 <repeats 18 times>, 68719476736, 0 <repeats 60 times>}}, {data = 0x7ffe88792000, {key = {_data = 0x7ffff7ac5b70, {{
              u64s = 5 '\005'}, {k = {u64s = 5 '\005', format = 1 '\001', needs_whiteout = 0 '\000', type = 6 '\006', pad = "", version = {lo = 0, hi = 0}, size = 0, p = {snapshot = 0, offset = 0, inode = 0}}, v = {
                __nothing = 0x7ffff7ac5b98}}}}, key_pad = {1125899910070273, 0, 0, 0}}, wait = {list = {first = 0x0}}, buf_size = 2097152, sectors = 0, disk_sectors = 4294966784, u64s_reserved = 320, noflush = false, 
      must_flush = false, separate_flush = false, has_inode = {1, 0 <repeats 17 times>, 8796093022208, 0 <repeats 48 times>, 68719476736, 0 <repeats 60 times>}}}, lock = {count = 0}, blocked = 0, wait = {lock = {count = 0}, 
    task_list = {next = 0x7ffff7ac5fe8, prev = 0x7ffff7ac5fe8}}, async_wait = {list = {first = 0x0}}, preres_wait = {list = {first = 0x0}}, io = {{{wq = 0x0, s = 0x7ffff7ac6010, list = {next = 0x7ffff7ac6010}, 
        fn = 0x55555560d730 <bch2_journal_write>}, work = {data = {counter = 0}, entry = {next = 0x7ffff7ac6010, prev = 0x7ffff7ac6010}, func = 0x55555560d730 <bch2_journal_write>}}, parent = 0x0, remaining = {counter = -2147483647}}, 
  write_work = {work = {data = {counter = 1}, entry = {next = 0x7ffff7ac6040, prev = 0x7ffff7ac6040}, func = 0x5555555cda30 <journal_write_work>}, timer = {expires = 24338323, function = 0x555555562e00 <delayed_work_timer_fn>, 
      pending = true}, wq = 0x555555775040}, seq = {counter = 1484028}, seq_ondisk = 1484026, flushed_seq_ondisk = 1484026, last_seq_ondisk = 1483417, err_seq = 0, last_empty_seq = 0, pin = {front = 1483419, back = 1484029, 
    size = 32768, mask = 32767, data = 0x7ffff789e000}, space = {{next_entry = 1024, total = 543744}, {next_entry = 1024, total = 543744}, {next_entry = 1024, total = 545792}, {next_entry = 1024, total = 1048576}}, 
  replay_journal_seq = 0, replay_journal_seq_end = 1483984, wp = {node = {next = 0x0, prev = 0x0}, lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {
            __prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, last_used = 0, write_point = 0, type = BCH_DATA_none, sectors_free = 0, ptrs = {nr = 0, v = {0 <repeats 15 times>}}, stripe = {next_alloc = {
        1251336411, 54533930, 812405510, 3326604933, 14468065, 0 <repeats 59 times>}}}, err_lock = {count = 0}, reclaim_lock = {lock = {__data = {__lock = 2, __count = 0, __owner = 7978, __nusers = 1, __kind = 0, __spins = 0, 
        __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = "\002\000\000\000\000\000\000\000*\037\000\000\001", '\000' <repeats 26 times>, __align = 2}}, reclaim_thread = 0x555555929860, reclaim_kicked = true, 
  nr_direct_reclaim = 0, nr_background_reclaim = 0, last_flushed = 24337325, flush_in_progress = 0x55568bb17210, pin_flush_wait = {lock = {count = 0}, task_list = {next = 0x7ffff7ac63d8, prev = 0x7ffff7ac63d8}}, discard_lock = {
    lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, can_discard = false, 
  write_delay_ms = 1000, reclaim_delay_ms = 100, last_flush_write = 24337323, res_get_blocked_start = 0, need_write_time = 24337323522917, write_start_time = 24337323914735, nr_flush_writes = 44, nr_noflush_writes = 0, 
  write_time = 0x7ffff7ac7190, delay_time = 0x7ffff7ac72b8, blocked_time = 0x7ffff7ac7508, flush_seq_time = 0x7ffff7ac73e0}
(gdb) print *cl
$4 = {{{wq = 0x0, s = 0x7ffff7ac6010, list = {next = 0x7ffff7ac6010}, fn = 0x55555560d730 <bch2_journal_write>}, work = {data = {counter = 0}, entry = {next = 0x7ffff7ac6010, prev = 0x7ffff7ac6010}, 
      func = 0x55555560d730 <bch2_journal_write>}}, parent = 0x0, remaining = {counter = -2147483647}}
(gdb) print *end
$8 = {u64s = 0, btree_id = 0 '\000', level = 0 '\000', type = 0 '\000', pad = "\000\000", {start = 0x7ffe88891e58, _data = 0x7ffe88891e58}}
(gdb) print sectors
$9 = 1756
(gdb) print nr_rw_members
$11 = 0

That's it for now ... I hope I can gather more info soon :)

bcachefs show-super errors

I saw an issue when I performed a "show-super" on the HDD device (bcachefs show-super /dev/sdb1):

`External UUID: 9cac6a05-1bd9-422a-9b93-2a2c53dc6e51
Internal UUID: 0781f15e-09b0-4ef2-967a-fb499dd0f9ac
Label:
Version: 11
Created: Wed May 20 08:01:51 2020
Block_size: 512
Btree node size: 256.0K
Error action: remount-ro
Clean: 0
Features: atomic_nlink,new_siphash,new_extent_overwrite,btree_ptr_v2,extents_above_btree_updates,btree_updates_journalled
Metadata replicas: 1
Data replicas: 1
Metadata checksum type: crc32c (1)
Data checksum type: crc32c (1)
Compression type: none (0)
Foreground write target: Group 0 (ssd)
Background write target: Group 1 (hdd)
Promote target: Group 0 (ssd)
String hash type: siphash (2)
32 bit inodes: 0
GC reserve percentage: 8%
Root reserve percentage: 0%
Devices: 2 live, 2 total
Sections: journal,members,replicas_v0,disk_groups,clean
Superblock size: 11128

Members (size 120):
Device 0:
UUID: b544ac1f-de93-4555-bd71-4724bd6f641c
Size: 107.3G
Bucket size: 256.0K
First bucket: 0
Buckets: 439556
Last mount: Wed May 20 08:14:01 2020
State: readwrite
Group: ssd (0)
Data allowed: journal,btree,data
Has data: (none)
Replacement policy: lru
Discard: 1
Device 1:
UUID: 3970eff4-f633-43f0-9933-fdf0f39e092f
Size: 3.6T
Bucket size: 512.0K
First bucket: 0
Buckets: 7618540
Last mount: Wed May 20 08:14:01 2020
State: readwrite
Group: hdd (1)
Data allowed: journal,btree,data
Has data: (none)
Replacement policy: lru
Discard: 1
`
To summarize: Discard is not active for HDD. I am 100% sure I did not enter that when performing the format operation0. Did format make the error? or is it an error in show-super?

Use compat branch to fix?

I'm not able to mount my volume on 5.11, and when I run bcachefs fsck it says there may be incompatible nodes and to run fsck with "compat branch" to fix. I haven't had much luck finding out what it means by this. I get this error even when going back to 5.10, although I can still mount it, so I figure this is the place to post this.

bcache format throws: bcachefs: libbcachefs/btree_io.c:1852: __bch2_btree_node_write: Assertion `!((b->will_make_reachable != 0) != !b->written)' failed.

Hi,
I tried to format ext4 fs, bcachefs throws assertion every time:

# gdb -q /sbin/bcachefs
Reading symbols from /sbin/bcachefs...
Reading symbols from /usr/lib/debug//sbin/bcachefs.debug...
(gdb) set args format --acl --discard --wide_macs --compression=lz4 /dev/mapper/vg--ssd--1833E14DA86F-testowycache
(gdb) run
Starting program: /sbin/bcachefs format --acl --discard --wide_macs --compression=lz4 /dev/mapper/vg--ssd--1833E14DA86F-testowycache
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff7fbe600 (LWP 6119)]
[New Thread 0x7ffff7bec600 (LWP 6120)]
[New Thread 0x7ffff7be3600 (LWP 6121)]
[New Thread 0x7ffff7bda600 (LWP 6122)]
[New Thread 0x7ffff7bd1600 (LWP 6123)]
[New Thread 0x7ffff7bc3600 (LWP 6124)]
[New Thread 0x7ffff7bba600 (LWP 6125)]
External UUID:                              a5dcb286-d38f-4fe1-b0af-967f44c3b090
Internal UUID:                              4d4323d3-d3c8-4228-a640-577aae15110d
Device index:                               0
Label:
Version:                                    backpointers
Oldest version on disk:                     backpointers
Created:                                    Wed Oct 12 09:13:56 2022
Sequence number:                            0
Superblock size:                            816
Clean:                                      0
Devices:                                    1
Sections:                                   members
Features:                                   new_siphash,new_extent_overwrite,btree_ptr_v2,extents_above_btree_updates,btree_updates_journalled,new_varint,journal_no_flush,a
lloc_v2,extents_across_btree_nodes
Compat features:

Options:
  block_size:                               4.00 KiB
  btree_node_size:                          256 KiB
  errors:                                   continue [ro] panic
  metadata_replicas:                        1
  data_replicas:                            1
  metadata_replicas_required:               1
  data_replicas_required:                   1
  encoded_extent_max:                       64.0 KiB
  metadata_checksum:                        none [crc32c] crc64 xxhash
  data_checksum:                            none [crc32c] crc64 xxhash
  compression:                              none [lz4] gzip zstd
  background_compression:                   [none] lz4 gzip zstd
  str_hash:                                 crc32c crc64 [siphash]
  metadata_target:                          none
  foreground_target:                        none
  background_target:                        none
  promote_target:                           none
  erasure_code:                             0
  inodes_32bit:                             1
  shard_inode_numbers:                      1
  inodes_use_key_cache:                     1
  gc_reserve_percent:                       8
  gc_reserve_bytes:                         0 B
  root_reserve_percent:                     0
  wide_macs:                                1
  acl:                                      1
  usrquota:                                 0
  grpquota:                                 0
  prjquota:                                 0
  journal_flush_delay:                      1000
  journal_flush_disabled:                   0
  journal_reclaim_delay:                    100

members (size 64):
  Device:                                   0
    UUID:                                   5f470ef7-6761-4692-8ca2-d392133f2528
    Size:                                   280 GiB
    Bucket size:                            256 KiB
    First bucket:                           0
    Buckets:                                1146880
    Last mount:                             (never)
    State:                                  rw
    Label:                                  (none)
    Data allowed:                           journal,btree,user
    Has data:                               (none)
    Discard:                                1
    Freespace initialized:                  0
[New Thread 0x7ffff7b6f600 (LWP 6127)]
[New Thread 0x7ffff7b66600 (LWP 6128)]
[New Thread 0x7ffff7b5d600 (LWP 6130)]
[New Thread 0x7ffff7b54600 (LWP 6131)]
[New Thread 0x7ffff70a9600 (LWP 6132)]
initializing new filesystem
[New Thread 0x7ffff7707600 (LWP 6133)]
going read-write
[New Thread 0x7ffff6e9e600 (LWP 6134)]
bcachefs: libbcachefs/btree_io.c:1852: __bch2_btree_node_write: Assertion `!((b->will_make_reachable != 0) != !b->written)' failed.

Thread 1 "bcachefs" received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44      pthread_kill.c: Nie ma takiego pliku ani katalogu.
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff7c8012f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff7c34732 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff7c1f469 in __GI_abort () at abort.c:79
#4  0x00007ffff7c1f395 in __assert_fail_base (fmt=0x7ffff7da8cc0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=0x555555655f38 "!((b->will_make_reachable != 0) != !b->written)", file=0x5555556554c4 "libbcachefs/btree_io.c", line=1852, function=<optimized out>)
    at assert.c:92
#5  0x00007ffff7c2da12 in __GI___assert_fail (assertion=assertion@entry=0x555555655f38 "!((b->will_make_reachable != 0) != !b->written)",
    file=file@entry=0x5555556554c4 "libbcachefs/btree_io.c", line=line@entry=1852,
    function=function@entry=0x555555655290 <__PRETTY_FUNCTION__.9> "__bch2_btree_node_write") at assert.c:101
#6  0x00005555555aa8a9 in __bch2_btree_node_write (c=c@entry=0x7ffff7b71000, b=b@entry=0x5555557f2c00, flags=flags@entry=0) at libbcachefs/btree_io.c:1852
#7  0x0000555555574c9d in bch2_btree_cache_scan (shrink=0x7ffff7b72050, sc=<optimized out>) at libbcachefs/btree_cache.c:352
#8  0x000055555562ccd8 in run_shrinkers (gfp_mask=gfp_mask@entry=2, allocation_failed=allocation_failed@entry=false) at linux/shrinker.c:125
#9  0x00005555556318eb in kmalloc (size=size@entry=256, flags=flags@entry=2) at include/linux/slab.h:27
#10 0x00005555556319f4 in krealloc (flags=2, size=256, old=0x555555853080) at include/linux/slab.h:48
#11 printbuf_make_room (out=out@entry=0x7fffffffce80, extra=47, extra@entry=46) at linux/printbuf.c:36
#12 0x000055555562aabc in prt_vprintf (out=0x7fffffffce80, fmt=0x55555565be50 "path: idx %2u ref %u:%u %c %c btree=%s l=%u pos ", args=0x7fffffffcd40)
    at linux/printbuf_userspace.c:15
#13 0x000055555562ac1c in prt_printf (out=out@entry=0x7fffffffce80, fmt=fmt@entry=0x55555565be50 "path: idx %2u ref %u:%u %c %c btree=%s l=%u pos ")
    at linux/printbuf_userspace.c:27
#14 0x00005555555dd4e6 in bch2_btree_path_to_text (out=0x7fffffffce80, path=0x555555919180) at libbcachefs/btree_iter.c:1377
#15 0x00005555555dd559 in bch2_trans_paths_to_text (out=0x7fffffffce80, trans=0x7fffffffd2c0) at libbcachefs/btree_iter.c:1398
#16 0x00005555555dd602 in bch2_trans_update_max_paths (trans=0x7fffffffd2c0) at libbcachefs/btree_iter.c:1419
#17 0x00005555555dea12 in btree_path_alloc (pos=0x555555919280, trans=0x7fffffffd2c0) at libbcachefs/btree_iter.c:1454
#18 btree_path_clone (trans=trans@entry=0x7fffffffd2c0, src=src@entry=0x555555919280, intent=<optimized out>) at libbcachefs/btree_iter.c:1177
#19 0x00005555555deb40 in bch2_btree_path_make_mut (ip=<optimized out>, intent=<optimized out>, path=0x555555919280, trans=0x7fffffffd2c0) at libbcachefs/btree_iter.c:1191
#20 bch2_btree_path_set_pos (trans=0x7fffffffd2c0, path=0x555555919280, new_pos=..., intent=<optimized out>, ip=<optimized out>) at libbcachefs/btree_iter.c:1217
#21 0x00005555555e10d3 in bch2_path_get (trans=trans@entry=0x7fffffffd2c0, btree_id=BTREE_ID_alloc, pos=..., locks_want=1, level=0, flags=flags@entry=8196,
    ip=<optimized out>) at libbcachefs/btree_iter.c:1497
#22 0x00005555555ec731 in get_unlocked_mut_path (trans=trans@entry=0x7fffffffd2c0, btree_id=<optimized out>, level=<optimized out>, pos=...)
    at libbcachefs/btree_update_interior.c:38
#23 0x00005555555efd7b in btree_split (as=as@entry=0x55555591e000, trans=trans@entry=0x7fffffffd2c0, path=path@entry=0x555555919080, b=b@entry=0x5555557e1800,
    keys=keys@entry=0x0, flags=flags@entry=0) at libbcachefs/btree_update_interior.c:1538
#24 0x00005555555f18fb in bch2_btree_split_leaf (trans=trans@entry=0x7fffffffd2c0, path=0x555555919080, flags=0) at libbcachefs/btree_update_interior.c:1765
#25 0x00005555555f6caf in bch2_trans_commit_error (trans=trans@entry=0x7fffffffd2c0, i=<optimized out>, ret=ret@entry=1, trace_ip=<optimized out>)
    at libbcachefs/btree_update_leaf.c:883
#26 0x00005555555f977f in __bch2_trans_commit (trans=trans@entry=0x7fffffffd2c0) at libbcachefs/btree_update_leaf.c:1088
#27 0x00005555556178e7 in bch2_trans_commit (flags=0, journal_seq=0x0, disk_res=0x0, trans=0x7fffffffd2c0) at libbcachefs/btree_update.h:105
#28 bch2_trans_mark_metadata_bucket (trans=0x7fffffffd2c0, ca=0x5555558f6800, b=2900, type=BCH_DATA_journal, sectors=512) at libbcachefs/buckets.c:1868
#29 0x0000555555617b40 in __bch2_trans_mark_dev_sb (trans=trans@entry=0x7fffffffd2c0, ca=ca@entry=0x5555558f6800) at libbcachefs/buckets.c:1934
#30 0x0000555555617bdf in bch2_trans_mark_dev_sb (c=c@entry=0x7ffff7b71000, ca=ca@entry=0x5555558f6800) at libbcachefs/buckets.c:1946
#31 0x00005555555afffc in bch2_fs_initialize (c=c@entry=0x7ffff7b71000) at libbcachefs/recovery.c:1509
#32 0x0000555555571047 in bch2_fs_start (c=0x7ffff7b71000) at libbcachefs/super.c:900
#33 0x0000555555572b0b in bch2_fs_open (devices=0x5555557b1c20, nr_devices=1, opts=...) at libbcachefs/super.c:1895
#34 0x000055555563e338 in cmd_format (argc=<optimized out>, argc@entry=6, argv=argv@entry=0x7fffffffe038) at cmd_format.c:268
#35 0x00005555555602fd in main (argc=<optimized out>, argv=0x7fffffffe038) at bcachefs.c:196

bcachefs version

bcachefs tool version v0.1-569-gab392d3c+

stuck in bch2_journal_read_device

I let sudo bcachefs list_journal -a /dev/sdb /dev/sdd /dev/sde > bcachefs-list_journal.txt run for about 6 hours and bloat to 4GB ram usage before killing it.

Built latest commit 7f77afa with debug enabled.

Program output only shows: recovering from clean shutdown, journal seq 7866100

perf top shows

99.47%  bcachefs          [.] bch2_journal_read_device

Note that without debug enabled, perf top shows usage split between two symbols:

  46.36%  bcachefs          [.] 0x000000000004c9f3
  45.16%  bcachefs          [.] 0x000000000004c96c
   4.88%  bcachefs          [.] 0x000000000004c97f
   2.46%  bcachefs          [.] 0x000000000004c9e0

strace shows:

strace: Process 17001 attached
futex(0x5575513792bc, FUTEX_WAIT_PRIVATE, 2, NULL

Note: bcachefs dump -j works fine

Let me know what other info I can get for you.

mkfs: Unable to write superblock

mkfs on fresh 50GB nvme partition give errors:

# ./mkfs.bcachefs /dev/nvme0n1p5
[...]
initializing new filesystem
going read-write
initializing freespace
Unable to write superblock to sufficient devices (from 0x56173c7ff1b1s)
fatal error - emergency read only
mounted version=backpointers opts=noinodes_use_key_cache

full output https://0x0.st/ou7G.log
tools version/commit: ff2ebf3f75814bc45353013782ebeb1556adfc05

however i can mount normally without any problem

segmention fault while format disks

Hello,
I try to run the following command, but I got an (not very usefull) error:

bcachefs format --group=ssd_read /dev/disk/by-id/dm-name-mpathb --group=ssd_write /dev/disk/by-id/dm-name-mpatha /dev/disk/by-id/dm-name-mpathm --group hdd=/dev/disk/by-id/dm-name-mpathc /dev/disk/by-id/dm-name-mpathd /dev/disk/by-id/dm-name-mpathe /dev/disk/by-id/dm-name-mpathf /dev/disk/by-id/dm-name-mpathg /dev/disk/by-id/dm-name-mpathh /dev/disk/by-id/dm-name-mpathi /dev/disk/by-id/dm-name-mpathj /dev/disk/by-id/dm-name-mpathk /dev/disk/by-id/dm-name-mpathl /dev/disk/by-id/dm-name-mpathn /dev/disk/by-id/dm-name-mpatho /dev/disk/by-id/dm-name-mpathp /dev/disk/by-id/dm-name-mpathq /dev/disk/by-id/dm-name-mpathr /dev/disk/by-id/dm-name-mpaths /dev/disk/by-id/dm-name-mpatht /dev/disk/by-id/dm-name-mpathu --replicas=2 --foreground_target=ssd_write --promote_target=ssd_read --background_target=hdd
Segmentation fault

mkfs.bcachefs should not use O_DIRECT

O_DIRECT does not work for filesystem images stored on tmpfs.
This leads to test failures like #127.

Other mkfs tools don't need O_DIRECT, so mkfs.bcachefs should also be able to do without.

Segfault when running bcachefs fsck

using bcachefs tool version v0.1-521-g7ae670e+, compiled using "make debug"
this may be similar to #117: I have troubles updating a filesystem, which was formatted like this:

bcachefs format --fs_label family_fotos --inodes_32bit --data_checksum=xxhash --metadata_checksum=xxhash --label HDD /dev/disk/by-id/scsi-2ae2956f000d00000 --label SSDM --discard /dev/disk/by-partlabel/satamultmeta1 /dev/disk/by-partlabel/sataM2multmeta2 /dev/disk/by-partlabel/satamultmeta3 /dev/disk/by-partlabel/sasmultmeta4 --label SSDC --discard /dev/disk/by-partlabel/satammcache1 /dev/disk/by-partlabel/nvmMMCache /dev/disk/by-partlabel/sasmmcache3 --foreground_target=SSDC --metadata_target=SSDM --background_target=HDD --promote_target=SSDC --metadata_replicas=2

after upgrading, the filesystem has troubles & caused a kernel process to deadlock (but not sure what happened, that's another story)
running bcachefs fsck causes a segfault in bcachefs executable:

[22906.790509] events_unbound[15556]: segfault at 55f7b6255ff8 ip 000055efb5eea94a sp 00007effeaf05840 error 4 in bcachefs[55efb5e71000+cd000]
[22906.790518] Code: 8d 35 27 78 06 00 bf 01 00 00 00 e8 70 69 f8 ff 41 8b 46 e8 48 89 ee bf 01 00 00 00 8d 4c 03 ff 49 8b 46 d0 83 c3 01 48 89 ca <48> 8b 0c c8 31 c0 e8 4b 69 f8 ff 83 fb 03 75 d6 41 c7 46 d8 00 00

gdb tells the following:

(gdb) run fsck -y -f -v --reconstruct_alloc /dev/disk/by-id/scsi-2ae2956f000d00000 /dev/disk/by-partlabel/satamultmeta1 /dev/disk/by-partlabel/sataM2multmeta2 /dev/disk/by-partlabel/satamultmeta3 /dev/disk/by-partlabel/sasmultmeta4 /dev/disk/by-partlabel/satammcache1 /dev/disk/by-partlabel/nvmMMCache /dev/disk/by-partlabel/sasmmcache3
Starting program: /home/janpieter/bcachetools/bcachefs-tools/bcachefs fsck -y -f -v --reconstruct_alloc /dev/disk/by-id/scsi-2ae2956f000d00000 /dev/disk/by-partlabel/satamultmeta1 /dev/disk/by-partlabel/sataM2multmeta2 /dev/disk/by-partlabel/satamultmeta3 /dev/disk/by-partlabel/sasmultmeta4 /dev/disk/by-partlabel/satammcache1 /dev/disk/by-partlabel/nvmMMCache /dev/disk/by-partlabel/sasmmcache3
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff7fbf600 (LWP 15849)]
[New Thread 0x7ffff7fb6600 (LWP 15850)]
[New Thread 0x7ffff7b0e600 (LWP 15851)]
[New Thread 0x7ffff7b05600 (LWP 15852)]
[New Thread 0x7ffff7afc600 (LWP 15853)]
[New Thread 0x7ffff7af3600 (LWP 15854)]
[New Thread 0x7ffff7aea600 (LWP 15855)]
bch2_fs_open() 
bch2_read_super() 
bch2_read_super() ret 0
bch2_read_super() 
bch2_read_super() ret 0
bch2_read_super() 
bch2_read_super() ret 0
bch2_read_super() 
bch2_read_super() ret 0
bch2_read_super() 
bch2_read_super() ret 0
bch2_read_super() 
bch2_read_super() ret 0
bch2_read_super() 
bch2_read_super() ret 0
bch2_read_super() 
bch2_read_super() ret 0
bch2_fs_alloc() 
[New Thread 0x7ffff7a9f600 (LWP 15856)]
[New Thread 0x7ffff7a96600 (LWP 15857)]
[New Thread 0x7ffff7a8d600 (LWP 15858)]
[New Thread 0x7ffff7a84600 (LWP 15859)]
bch2_fs_journal_init() 
bch2_fs_journal_init() ret 0
bch2_fs_btree_cache_init() 
bch2_fs_btree_cache_init() ret 0
[New Thread 0x7ffff6fd7600 (LWP 15860)]
bch2_fs_encryption_init() 
bch2_fs_encryption_init() ret 0
__bch2_fs_compress_init() 
__bch2_fs_compress_init() ret 0
bch2_dev_alloc() 
bch2_dev_alloc() ret 0
bch2_dev_alloc() 
bch2_dev_alloc() ret 0
bch2_dev_alloc() 
bch2_dev_alloc() ret 0
bch2_dev_alloc() 
bch2_dev_alloc() ret 0
bch2_dev_alloc() 
bch2_dev_alloc() ret 0
bch2_dev_alloc() 
bch2_dev_alloc() ret 0
bch2_dev_alloc() 
bch2_dev_alloc() ret 0
bch2_dev_alloc() 
bch2_dev_alloc() ret 0
bch2_fs_alloc() ret 0
recovering from clean shutdown, journal seq 48010
starting journal read
journal read done on device /dev/disk/by-id/scsi-2ae2956f00, ret 0
journal read done on device /dev/disk/by-partlabel/satamult, ret 0
journal read done on device /dev/disk/by-partlabel/sataM2mu, ret 0
journal read done on device /dev/disk/by-partlabel/satamult, ret 0
journal read done on device /dev/disk/by-partlabel/sasmultm, ret 0
ja->sectors_free == ca->mi.bucket_size
cur_idx 0/1192

Thread 6 "events_unbound" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7afc600 (LWP 15853)]
bch2_journal_read_device (cl=<optimized out>) at libbcachefs/journal_io.c:993
993                             bch_err(c, "bucket_seq[%u] = %llu", idx, ja->bucket_seq[idx]);

so I guess we need thread 6 here:

(gdb) info threads
  Id   Target Id                                           Frame 
  1    Thread 0x7ffff7b10000 (LWP 15848) "bcachefs"        0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
  2    Thread 0x7ffff7fbf600 (LWP 15849) "aio_completion"  0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
  3    Thread 0x7ffff7fb6600 (LWP 15850) "events"          0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
  4    Thread 0x7ffff7b0e600 (LWP 15851) "events_highpri"  0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
  5    Thread 0x7ffff7b05600 (LWP 15852) "events_long"     0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
* 6    Thread 0x7ffff7afc600 (LWP 15853) "events_unbound"  bch2_journal_read_device (cl=<optimized out>) at libbcachefs/journal_io.c:993
  7    Thread 0x7ffff7af3600 (LWP 15854) "events_freezabl" 0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
  8    Thread 0x7ffff7aea600 (LWP 15855) "timers"          0x00007ffff7b96a46 in ?? () from /lib64/libc.so.6
  9    Thread 0x7ffff7a9f600 (LWP 15856) "bcachefs"        0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
  10   Thread 0x7ffff7a96600 (LWP 15857) "bcachefs_btree_" 0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
  11   Thread 0x7ffff7a8d600 (LWP 15858) "bcachefs_copygc" 0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
  12   Thread 0x7ffff7a84600 (LWP 15859) "bcachefs_io"     0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
  13   Thread 0x7ffff6fd7600 (LWP 15860) "btree_update"    0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6

(gdb) bt
#0  bch2_journal_read_device (cl=<optimized out>) at libbcachefs/journal_io.c:993
#1  0x000055555560d04d in worker_thread (arg=0x55555578ee00) at linux/workqueue.c:262
#2  0x0000555555609033 in kthread_start_fn (data=0x55555578eec0) at linux/kthread.c:25
#3  0x00007ffff7b99d77 in ?? () from /lib64/libc.so.6
#4  0x00007ffff7c0fa9c in ?? () from /lib64/libc.so.6
(gdb) print *cl
value has been optimized out

Nothing useful here, so maybe main bcachefs tells something:

(gdb) thread 1
[Switching to thread 1 (Thread 0x7ffff7b10000 (LWP 15848))]
#0  0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7c0b2c9 in syscall () from /lib64/libc.so.6
#1  0x000055555560b091 in futex (val3=0, uaddr2=0x0, timeout=0x0, val=<optimized out>, op=128, uaddr=<optimized out>) at /usr/include/urcu/futex.h:72
#2  schedule () at linux/sched.c:41
#3  0x0000555555606c95 in __closure_sync (cl=cl@entry=0x7fffffffd450) at linux/closure.c:128
#4  0x00005555555d979e in closure_sync (cl=0x7fffffffd450) at include/linux/closure.h:185
#5  bch2_journal_read (c=c@entry=0x7ffff7aa1000, blacklist_seq=blacklist_seq@entry=0x7fffffffd530, start_seq=start_seq@entry=0x7fffffffd538) at libbcachefs/journal_io.c:1073
#6  0x0000555555574e0e in bch2_fs_recovery (c=0x7ffff7aa1000) at libbcachefs/recovery.c:1108
#7  0x00005555555dda7d in bch2_fs_start (c=c@entry=0x7ffff7aa1000) at libbcachefs/super.c:897
#8  0x00005555555dffcf in bch2_fs_open (devices=devices@entry=0x7fffffffdce0, nr_devices=nr_devices@entry=8, opts=...) at libbcachefs/super.c:1904
#9  0x000055555561cac5 in cmd_fsck (argc=8, argc@entry=13, argv=0x7fffffffdce0, argv@entry=0x7fffffffdcb8) at cmd_fsck.c:90
#10 0x000055555555e1e6 in main (argc=<optimized out>, argv=0x7fffffffdcb8) at bcachefs.c:197

and the bch_fs + jlist at frame 5 will tell probably what needs to be known. I did not C/P all values, but I guess most closure related info is in there:

(gdb) frame 5
#5  bch2_journal_read (c=c@entry=0x7ffff7aa1000, blacklist_seq=blacklist_seq@entry=0x7fffffffd530, start_seq=start_seq@entry=0x7fffffffd538) at libbcachefs/journal_io.c:1073
1073            closure_sync(&jlist.cl);
(gdb) print *c
value of type `bch_fs' requires 134416 bytes, which is more than max-value-size
(gdb) print *blacklist_seq
$1 = 140737488344416
(gdb) print *start_seq
$2 = 140737349328323
(gdb) print c->cl
$3 = {{{wq = 0x0, s = 0x0, list = {next = 0x0}, fn = 0x0}, work = {data = {counter = 0}, entry = {next = 0x0, prev = 0x0}, func = 0x0}}, parent = 0x0, remaining = {counter = 1073741825}}
(gdb) print c->chardev
$4 = (struct device *) 0x0
(gdb) print c->name
$5 = "7267c89c-caf5-41f9-9961-9266ab1f8492\000\000\000"
(gdb) print c->sb_write
$6 = {{{wq = 0x0, s = 0x0, list = {next = 0x0}, fn = 0x0}, work = {data = {counter = 0}, entry = {next = 0x0, prev = 0x0}, func = 0x0}}, parent = 0x0, remaining = {counter = 0}}
(gdb) print c->sb_lock
$7 = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}
(gdb) print c->freelist_wait
$8 = {list = {first = 0x0}}
(gdb) print c->fsck_errors
$9 = {next = 0x7ffff7abf708, prev = 0x7ffff7abf708}
(gdb) print c->fsck_error_lock
$10 = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}
(gdb) print c->fsck_alloc_err
$11 = false
(gdb) print c->sb
$12 = {uuid = {b = "}\225\335\300\335\330NʗO\262\362(\347ѷ"}, user_uuid = {b = "rgȜ\312\365A\371\231a\222f\253\037\204\222"}, version = 21, version_min = 19, nr_devices = 8 '\b', clean = 1 '\001', encryption_type = 0 '\000', 
  time_base_lo = 1648470256241715989, time_base_hi = 0, time_units_per_sec = 1000000000, nsec_per_time_unit = 1, features = 494560, compat = 15}
(gdb) print *c->devs[0]
$22 = {kobj = {parent = 0x0, kset = 0x0, ktype = 0x55555568b6a0 <bch2_dev_ktype>, sd = 0x0, ref = {counter = 1}, state_initialized = 1, state_in_sysfs = 0, state_add_uevent_sent = 0, state_remove_uevent_sent = 0, uevent_suppress = 0}, 
  ref = {count = {counter = 1}, release = 0x5555555da520 <bch2_dev_ref_complete>, confirm_switch = 0x0}, ref_completion = {done = 0, wait = {lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, 
            __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, task_list = {next = 0x55555589d870, prev = 0x55555589d870}}}, io_ref = {count = {counter = 1}, 
    release = 0x5555555da510 <bch2_dev_io_ref_complete>, confirm_switch = 0x0}, io_ref_completion = {done = 0, wait = {lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, 
            __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, task_list = {next = 0x55555589d8c8, prev = 0x55555589d8c8}}}, fs = 0x7ffff7aa1000, dev_idx = 0 '\000', mi = {
    nbuckets = 28569580, first_bucket = 0, bucket_size = 1024, group = 1, state = 0 '\000', discard = 0 '\000', data_allowed = 28 '\034', durability = 1 '\001', freespace_initialized = 1 '\001', valid = 1 '\001'}, uuid = {
    b = "\272I-\363\324@@ֽ\227\270\f(\226d."}, name = "/dev/disk/by-id/scsi-2ae2956f00", disk_sb = {sb = 0x555555792000, bdev = 0x555555791350, bio = 0x555555791d80, buffer_size = 8192, mode = 131, have_layout = 1, have_bio = 1, 
    fs_sb = 0, seq = 47}, sb_read_scratch = 0x55555589f000, sb_write_error = 0, dev = 2224, self = {d = {1}}, replica_set = {front_pad = 48, back_pad = 0, bio_pool = {lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, 
            __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, min_nr = 4, curr_nr = 4, elements = 0x5555557acf80, pool_data = 0x98, 
      alloc = 0x555555610070 <mempool_kmalloc>, free = 0x555555610080 <mempool_kfree>, wait = {lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {
                __prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, task_list = {next = 0x55555589da00, prev = 0x55555589da00}}}, bvec_pool = {lock = {lock = {__data = {__lock = 0, __count = 0, 
            __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, min_nr = 4, curr_nr = 4, elements = 0x55555579d480, 
      pool_data = 0x1000, alloc = 0x555555610070 <mempool_kmalloc>, free = 0x555555610080 <mempool_kfree>, wait = {lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, 
              __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, task_list = {next = 0x55555589da88, prev = 0x55555589da88}}}}, buckets_gc = 0x0, bucket_gens = 0x7ffff4fce000, oldest_gen = 0x0, 
  buckets_nouse = 0x0, bucket_lock = {lock = {__data = {__readers = 0, __writers = 0, __wrphase_futex = 0, __writers_futex = 0, __pad3 = 0, __pad4 = 0, __cur_writer = 0, __shared = 0, __rwelision = 0 '\000', 
        __pad1 = "\000\000\000\000\000\000", __pad2 = 0, __flags = 0}, __size = '\000' <repeats 55 times>, __align = 0}}, usage_base = 0x555555809480, usage = {0x555555809820, 0x555555809c20, 0x55555580a020, 0x55555580a420}, 
  usage_gc = 0x0, new_fs_bucket_idx = 0, nr_open_buckets = 0, nr_btree_reserve = 14, open_buckets_partial = {0 <repeats 1024 times>}, open_buckets_partial_nr = 0, inc_gen_needs_gc = 0, inc_gen_really_needs_gc = 0, 
  buckets_waiting_on_journal = 0, rebalance_work = {counter = 0}, journal = {bucket_seq = 0x5555558f6000, sectors_free = 514, discard_idx = 1909, dirty_idx_ondisk = 1909, dirty_idx = 1909, cur_idx = 1908, nr = 8192, 
    buckets = 0x55555590c000, bio = 0x555555907000, read = {{{wq = 0x0, s = 0x55555589e390, list = {next = 0x55555589e390}, fn = 0x0}, work = {data = {counter = 0}, entry = {next = 0x55555589e390, prev = 0x55555589e390}, func = 0x0}}, 
      parent = 0x7fffffffd450, remaining = {counter = 0}}}, prev_journal_sector = 0, io_error_work = {data = {counter = 0}, entry = {next = 0x55555589e3c8, prev = 0x55555589e3c8}, func = 0x555555564ee0 <bch2_io_error_work>}, 
  cur_latency = {{counter = 0}, {counter = 0}}, io_latency = {{lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, 
          __size = '\000' <repeats 39 times>, __align = 0}}, count = 0, average_duration = 0, average_frequency = 0, max_duration = 0, last_event = 0, quantiles = {entries = {{m = 0, step = 0} <repeats 15 times>}}, buffer = 0x0}, {
      lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, count = 0, 
      average_duration = 0, average_frequency = 0, max_duration = 0, last_event = 0, quantiles = {entries = {{m = 0, step = 0} <repeats 15 times>}}, buffer = 0x0}}, congested = {counter = 0}, congested_last = 0, 
  io_done = 0x5555557b3750}
(gdb) print jlist.cl
$23 = {{{wq = 0x0, s = 0x7fffffffd330, list = {next = 0x0}, fn = 0x555555606840 <closure_sync_fn>}, work = {data = {counter = 0}, entry = {next = 0x7fffffffd330, prev = 0x0}, func = 0x555555606840 <closure_sync_fn>}}, parent = 0x0, 
  remaining = {counter = 3}}


If you need a show-super output of one or more devices, let me know

io_submit err: Resource temporarily unavailable

recovering from unclean shutdown
version no_bps_in_alloc_keys (28) prior to snapshot_trees (29), upgrade and fsck required


...



bucket 0:1127617 gen 7 data type user has wrong dirty_sectors: got 0, should be 61, fixing
bucket 0:1128501 gen 42 has wrong data_type: got free, should be user, fixing
bucket 0:1128501 gen 42 data type user has wrong gen: got 0, should be 42, fixing
bucket 0:1128501 gen 42 data type user has wrong dirty_sectors: got 0, should be 46, fixing
bucket 0:1128932 gen 111 has wrong data_type: got free, should be user, fixing
bucket 0:1128932 gen 111 data type user has wrong gen: got 0, should be 111, fixing
bucket 0:1128932 gen 111 data type user has wrong dirty_sectors: got 0, should be 83, fixing
bucket 0:1130693 gen 23 has wrong data_type: got free, should be user, fixing
bucket 0:1130693 gen 23 data type user has wrong gen: got 0, should be 23, fixing
bucket 0:1130693 gen 23 data type user has wrong dirty_sectors: got 0, should be 77, fixing
bucket 0:1132444 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:1132444 gen 0 data type sb has wrong dirty_sectors: got 0, should be 512, fixing
bucket 0:1132445 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:1132445 gen 0 data type sb has wrong dirty_sectors: got 0, should be 512, fixing
bucket 0:1132446 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:1132446 gen 0 data type sb has wrong dirty_sectors: got 0, should be 512, fixing
bucket 0:1132447 gen 0 has wrong data_type: got free, should be sb, fixing
bucket 0:1132447 gen 0 data type sb has wrong dirty_sectors: got 0, should be 512, fixing
starting journal replay, 5995942 keys
going read-write
io_submit err: Resource temporarily unavailable

bcachefs format --discard scope

The--discard parameter scope does not start at the begin of a new group:

linuxserver /home/janpieter # bcachefs format -g SSD --discard /dev/disk/by-partuuid/f8d16ed7-eddc-4ef1-84b7-bc3b74e8b3ca -g HDD /dev/sdd --foreground_target=SSD --promote_target=SSD --background_target=HDD                        External UUID:4ad9b6a6-4911-4b9c-9d05-3c4091e973b4
Internal UUID:df5a0103-6c83-4193-abf3-9602ca9e1b96
Label:
Version:11
Created:Sat Jun 13 07:21:38 2020
Block_size:512
Btree node size:256.0K
Error action:remount-ro
Clean:0
Features:
Metadata replicas:1
Data replicas:1
Metadata checksum type:crc32c (1)
Data checksum type:crc32c (1)
Compression type:none (0)
Foreground write target:Group 0 (SSD)
Background write target:Group 1 (HDD)
Promote target:Group 0 (SSD)
String hash type:siphash (2)
32 bit inodes:0
GC reserve percentage:8%
Root reserve percentage:0%
Devices:2 live, 2 total
Sections:members,disk_groups
Superblock size:976

Members (size 120):
  Device 0:
    UUID:9c41e5d3-979a-467d-b9f5-ac0a31e1d57a
    Size:107.3G
    Bucket size:256.0K
    First bucket:0
    Buckets:439556
    Last mount:(never)
    State:readwrite
    Group:SSD (0)
    Data allowed:journal,btree,data
    Has data:(none)
    Replacement policy:lru
    Discard:1
  Device 1:
    UUID:c2f801f4-b323-4947-bf0b-9921ba482b39
    Size:3.6T
    Bucket size:512.0K
    First bucket:0
    Buckets:7618540
    Last mount:(never)
    State:readwrite
    Group:HDD (1)
    Data allowed:journal,btree,data
    Has data:(none)
    Replacement policy:lru
    Discard:1
initializing new filesystem
mounted with opts: foreground_target=SSD,background_target=HDD,promote_target=SSD
linuxserver /home/janpieter # bcachefs format -g HDD /dev/sdd -g SSD --discard /dev/disk/by-partuuid/f8d16ed7-eddc-4ef1-84b7-bc3b74e8b3ca --foreground_target=SSD --promote_target=SSD --background_target=HDD
External UUID:5044a9f4-27e4-4b73-bb89-4e104ab370eb
Internal UUID:b916dfed-a454-4d55-ac63-c79733474949
Label:
Version:11
Created:Sat Jun 13 07:23:34 2020
Block_size:512
Btree node size:256.0K
Error action:remount-ro
Clean:0
Features:
Metadata replicas:1
Data replicas:1
Metadata checksum type:crc32c (1)
Data checksum type:crc32c (1)
Compression type:none (0)
Foreground write target:Group 1 (SSD)
Background write target:Group 0 (HDD)
Promote target:Group 1 (SSD)
String hash type:siphash (2)
32 bit inodes:0
GC reserve percentage:8%
Root reserve percentage:0%
Devices:2 live, 2 total
Sections:members,disk_groups
Superblock size:976

Members (size 120):
  Device 0:
    UUID:bcce3afc-d31b-49d5-b9f0-bb3231e6431f
    Size:3.6T
    Bucket size:512.0K
    First bucket:0
    Buckets:7618540
    Last mount:(never)
    State:readwrite
    Group:HDD (0)
    Data allowed:journal,btree,data
    Has data:(none)
    Replacement policy:lru
    Discard:0
  Device 1:
    UUID:000c018b-05a0-46e1-b535-e04ae00f70b6
    Size:107.3G
    Bucket size:256.0K
    First bucket:0
    Buckets:439556
    Last mount:(never)
    State:readwrite
    Group:SSD (1)
    Data allowed:journal,btree,data
    Has data:(none)
    Replacement policy:lru
    Discard:1
initializing new filesystem
mounted with opts: foreground_target=SSD,background_target=HDD,promote_target=SSD
linuxserver /home/janpieter #

As a result, all SSD devices have to be specified as the final ones, otherwise the discard flag is taken over by the HDD group.

bcachefs data job {copygy,rebalance}

Maybe it could be useful to have someting like "bcachefs data job {copygc,rebalance}" to be able to run them with cron/timers at non-busy times.

mount.bcachefs in crontab @reboot

I try to automatic mount my bcachefs volume at boottime. For this I use this command in my crontab
@reboot /usr/local/sbin/mount.bcachefs.sh 2ed7796d-94ce-44e8-a7eb-0126113a1275 /mnt/data/ 2>&1 >> /home/falk/bootmount.log.
In the logfile is an errormessage uuid 2ed7796d-94ce-44e8-a7eb-0126113a1275 not found. If I call this command with sudo after I am logged in, it works without problems.
Did someone know what the problem could be? Could it be that the storage controller driver is not already loaded?

AssertionError: assert 101 == 97

make check shows AssertionError: assert 101 == 97:

make check
cc -std=gnu89 -O2 -g -MMD -Wall -Wno-pointer-sign -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-364-gba69a1b"'  -Wno-unused-but-set-variable -Wno-stringop-overflow -Wno-zero-length-bounds -Wno-missing-braces  -Wno-shift-overflow -Wno-enum-conversion -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/aarch64-linux-gnu   -c -o tests/test_helper.o tests/test_helper.c
cc -std=gnu89 -O2 -g -MMD -Wall -Wno-pointer-sign -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-364-gba69a1b"'  -Wno-unused-but-set-variable -Wno-stringop-overflow -Wno-zero-length-bounds -Wno-missing-braces  -Wno-shift-overflow -Wno-enum-conversion -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/aarch64-linux-gnu   -c -o tests/test_helper_trick.o tests/test_helper_trick.c
cc -std=gnu89 -O2 -g -MMD -Wall -Wno-pointer-sign -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-364-gba69a1b"'  -Wno-unused-but-set-variable -Wno-stringop-overflow -Wno-zero-length-bounds -Wno-missing-braces  -Wno-shift-overflow -Wno-enum-conversion -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/aarch64-linux-gnu   tests/test_helper.o tests/test_helper_trick.o  -lblkid -luuid -lurcu-common -lurcu -lsodium -lz -llz4 -lzstd -ludev -lm -lpthread -lrt -lscrypt -lkeyutils -laio -ldl  -o tests/test_helper
cd tests; pytest-3
============================= test session starts ==============================
platform linux -- Python 3.9.2, pytest-6.0.2, py-1.10.0, pluggy-0.13.0
rootdir: /root/bcachefs-tools/tests
collected 28 items

test_basic.py ...F..                                                     [ 21%]
test_fixture.py ....ssssss..                                             [ 64%]
test_fuse.py ssssssssss                                                  [100%]

=================================== FAILURES ===================================
__________________________________ test_list ___________________________________

tmpdir = local('/tmp/pytest-of-root/pytest-0/test_list0')

    def test_list(tmpdir):
        dev = util.format_1g(tmpdir)

        ret = util.run_bch('list', dev, valgrind=True)

        assert ret.returncode == 0
        assert len(ret.stderr) == 0
        assert "recovering from clean shutdown" in ret.stdout

        # Totally arbitrary, feel free to update or remove after inspecting.
>       assert len(ret.stdout.splitlines()) == 97
E       AssertionError: assert 101 == 97
E        +  where 101 = len(['recovering from clean shutdown, journal seq 4', 'mounted with opts: errors=continue,degraded,nochanges,norecovery', ...dest_gen 0 data_type sb read_time 0 write_time 0 dirty_sectors 256 cached_sectors 0 stripe 0 stripe_redundancy 0', ...])
E        +    where ['recovering from clean shutdown, journal seq 4', 'mounted with opts: errors=continue,degraded,nochanges,norecovery', ...dest_gen 0 data_type sb read_time 0 write_time 0 dirty_sectors 256 cached_sectors 0 stripe 0 stripe_redundancy 0', ...] = <built-in method splitlines of str object at 0x1b98f050>()
E        +      where <built-in method splitlines of str object at 0x1b98f050> = 'recovering from clean shutdown, journal seq 4\nmounted with opts: errors=continue,degraded,nochanges,norecovery\nu64s...id 4294967295\nu64s 8 type snapshot 0:4294967295:0 len 0 ver 0: is_subvol 1 deleted 0 parent 0 children 0 0 subvol 1\n'.splitlines
E        +        where 'recovering from clean shutdown, journal seq 4\nmounted with opts: errors=continue,degraded,nochanges,norecovery\nu64s...id 4294967295\nu64s 8 type snapshot 0:4294967295:0 len 0 ver 0: is_subvol 1 deleted 0 parent 0 children 0 0 subvol 1\n' = CompletedProcess(args=[PosixPath('../bcachefs'), 'list', PosixPath('/tmp/pytest-of-root/pytest-0/test_list0/dev-1g')],...5\nu64s 8 type snapshot 0:4294967295:0 len 0 ver 0: is_subvol 1 deleted 0 parent 0 children 0 0 subvol 1\n', stderr='').stdout

test_basic.py:42: AssertionError
----------------------------- Captured stdout call -----------------------------
Running '[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_list0/dev-1g')]'
Running '[PosixPath('../bcachefs'), 'list', PosixPath('/tmp/pytest-of-root/pytest-0/test_list0/dev-1g')]'
=========================== short test summary info ============================
FAILED test_basic.py::test_list - AssertionError: assert 101 == 97
=================== 1 failed, 11 passed, 16 skipped in 1.95s ===================
make: *** [Makefile:88: check] Error 1

bcachefs fsck after upgrading to livetree never completes

the title says it all ...
Tried with release code, debug code, -f, -v and --reconstruct-alloc, but in vain: after "going read-write", it ends in an infinite loop.
The output of -f -v:

bch2_fs_open()                                                                                                                                       
bch2_read_super()                                                                                                                                    
bch2_read_super() ret 0                                                                                                                              
bch2_read_super()                                                                                                                                    
bch2_read_super() ret 0                                                                                                                              
bch2_read_super()                                                                                                                                    
bch2_read_super() ret 0                                                                                                                              
bch2_read_super()                                                                                                                                    
bch2_read_super() ret 0                                                                                                                              
bch2_read_super()                                                                                                                                    
bch2_read_super() ret 0                                                                                                                              
bch2_read_super()                                                                                                                                    
bch2_read_super() ret 0                                                                                                                              
bch2_read_super()                                                                                                                                    
bch2_read_super() ret 0                                                                                                                              
bch2_read_super()                                                                                                                                    
bch2_read_super() ret 0                                                                                                                              
bch2_fs_alloc()                                                                                                                                      
bch2_fs_journal_init()                                                                                                                               
bch2_fs_journal_init() ret 0                                                                                                                         
bch2_fs_btree_cache_init()                                                                                                                           
bch2_fs_btree_cache_init() ret 0                                                                                                                     
bch2_fs_encryption_init()                                                                                                                            
bch2_fs_encryption_init() ret 0                                                                                                                      
__bch2_fs_compress_init()                                                                                                                            
__bch2_fs_compress_init() ret 0                                                                                                                      
bch2_dev_alloc()                                                                                                                                     
bch2_dev_alloc() ret 0                                                                                                                               
bch2_dev_alloc()                                                                                                                                     
bch2_dev_alloc() ret 0                                                                                                                               
bch2_dev_alloc()                                                                                                                                     
bch2_dev_alloc() ret 0                                                                                                                               
bch2_dev_alloc()                                                                                                                                     
bch2_dev_alloc() ret 0                                                                                                                               
bch2_dev_alloc()                                                                                                                                     
bch2_dev_alloc() ret 0                                                                                                                               
bch2_dev_alloc()                                                                                                                                     
bch2_dev_alloc() ret 0                                                                                                                               
bch2_dev_alloc()                                                                                                                                     
bch2_dev_alloc() ret 0                                                                                                                               
bch2_dev_alloc()                                                                                                                                     
bch2_dev_alloc() ret 0                                                                                                                               
bch2_fs_alloc() ret 0                                                                                                                                
recovering from unclean shutdown                                                                                                                     
starting journal read                                                                                                                                
journal read done on device /dev/disk/by-id/scsi-2347466f10, ret 0                                                                                   
journal read done on device /dev/disk/by-partlabel/satavidm, ret 0                                                                                   
journal read done on device /dev/disk/by-partlabel/sataM2vi, ret 0                                                                                   
journal read done on device /dev/disk/by-partlabel/satavidm, ret 0                                                                                   
journal read done on device /dev/disk/by-partlabel/sasvidme, ret 0                                                                                   
journal read done on device /dev/disk/by-partlabel/nvmVideo, ret 0                                                                                   
journal read done on device /dev/disk/by-partlabel/satavide, ret 0                                                                                   
ja->sectors_free == ca->mi.bucket_size                                                                                                               
cur_idx 1/1286                                                                                                                                       
bucket_seq[0] = 0                                                                                                                                    
bucket_seq[1] = 143256                                                                                                                               
bucket_seq[2] = 0                                                                                                                                    
journal read done on device /dev/disk/by-partlabel/sasvidca, ret 0                                                                                   
journal read done, 1601518 keys in 413 entries, seq 628691                                                                                           
dropped unflushed entries 628688-628690                                                                                                              
starting alloc read                                                                                                                                  
alloc read done                                                                                                                                      
starting stripes_read                                                                                                                                
stripes_read done                                                                                                                                    
checking allocations                                                                                                                                 
bucket 5:10698 gen 1 data type user has wrong cached_sectors: got 512, should be 19, fixing                                                          
dev 1 has wrong buckets_unavailable: got 7926, should be 8726, fixing                                                                                
dev 1 has wrong btree buckets: got 7150, should be 7950, fixing                                                                                      
dev 1 has wrong btree sectors: got 3660800, should be 4070400, fixing                                                                                
dev 1 has wrong cached buckets: got 0, should be 87090, fixing                                                                                       
dev 1 has wrong cached sectors: got 0, should be 44590080, fixing                                                                                    
dev 2 has wrong buckets_unavailable: got 7859, should be 8661, fixing                                                                                
dev 2 has wrong btree buckets: got 7083, should be 7885, fixing                                                                                      
dev 2 has wrong btree sectors: got 3626496, should be 4037120, fixing                                                                                
dev 2 has wrong cached buckets: got 0, should be 87180, fixing                                                                                       
dev 2 has wrong cached sectors: got 0, should be 44636160, fixing                                                                                    
dev 3 has wrong buckets_unavailable: got 7604, should be 8416, fixing                                                                                
dev 3 has wrong btree buckets: got 6828, should be 7640, fixing                                                                                      
dev 3 has wrong btree sectors: got 3495936, should be 3911680, fixing                                                                                
dev 3 has wrong cached buckets: got 0, should be 87267, fixing                                                                                       
dev 3 has wrong cached sectors: got 0, should be 44680704, fixing                                                                                    
dev 4 has wrong buckets_unavailable: got 8033, should be 8836, fixing                                                                                
dev 4 has wrong btree buckets: got 7257, should be 8060, fixing                                                                                      
dev 4 has wrong btree sectors: got 3715584, should be 4126720, fixing                                                                                
dev 4 has wrong cached buckets: got 0, should be 87020, fixing                                                                                       
dev 4 has wrong cached sectors: got 0, should be 44554240, fixing                                                                                    
dev 5 has wrong cached buckets: got 0, should be 235168, fixing                                                                                      
dev 5 has wrong cached sectors: got 0, should be 120400840, fixing                                                                                   
dev 6 has wrong cached buckets: got 0, should be 148696, fixing                                                                                      
dev 6 has wrong cached sectors: got 0, should be 76129504, fixing                                                                                    
dev 7 has wrong buckets_unavailable: got 1299, should be 1302, fixing                                                                                
dev 7 has wrong btree buckets: got 0, should be 3, fixing                                                                                            
dev 7 has wrong btree sectors: got 0, should be 1536, fixing                                                                                         
dev 7 has wrong cached buckets: got 0, should be 160510, fixing                                                                                      
dev 7 has wrong cached sectors: got 0, should be 82178520, fixing                                                                                    
fs has wrong btree: got 14498816, should be 16147456, fixing                                                                                         
fs has wrong cached: got 0, should be 457170048, fixing                                                                                              
fs has wrong btree: 1/2 [1 2]: got 2226176, should be 2420736, fixing                                                                                
fs has wrong btree: 1/2 [2 4]: got 2367488, should be 2625536, fixing                                                                                
fs has wrong cached: 1/1 [4]: got 0, should be 44554240, fixing                                                                                      
fs has wrong btree: 1/2 [1 4]: got 2913280, should be 3274752, fixing                                                                                
fs has wrong cached: 1/1 [2]: got 0, should be 44636160, fixing                                                                                      
fs has wrong cached: 1/1 [6]: got 0, should be 76129504, fixing                                                                                      
fs has wrong btree: 1/2 [1 3]: got 2182144, should be 2445312, fixing                                                                                
fs has wrong btree: 1/2 [2 3]: got 2659328, should be 3027968, fixing                                                                                
fs has wrong btree: 1/2 [3 4]: got 2150400, should be 2350080, fixing                                                                                
fs has wrong btree: 1/2 [4 7]: got 0, should be 3072, fixing                                                                                         
fs has wrong cached: 1/1 [1]: got 0, should be 44590080, fixing                                                                                      
fs has wrong cached: 1/1 [3]: got 0, should be 44680704, fixing                                                                                      
fs has wrong cached: 1/1 [5]: got 0, should be 120400840, fixing                                                                                     
fs has wrong cached: 1/1 [7]: got 0, should be 82178520, fixing                                                                                      
done checking allocations                                                                                                                            
checking need_discard and freespace btrees                                                                                                           
done 
checking need_discard and freespace btrees                                                                                                      
starting journal replay, 1597161 keys                                                                                                                
going read-write

this is what gdb says:

(gdb) bt                                                                                                                                             
#0  0x00007f089c0deb8b in ?? () from /lib64/libc.so.6                                                                                                
#1  0x00007f089c0e519a in pthread_mutex_lock () from /lib64/libc.so.6                                                                                
#2  0x00005652cbff8a39 in raw_spin_lock (lock=0x7f089bfe5bb8) at include/linux/spinlock.h:20                                                         
#3  bch2_journal_pin_set (j=0x7f089bfe5908, seq=628259, pin=0x5652cca73f40, flush_fn=0x5652cbfca0c0 <bch2_btree_key_cache_journal_flush>)                at libbcachefs/journal_reclaim.c:380                                                                                                             
#4  0x00005652cbfcca78 in bch2_journal_pin_update (flush_fn=0x5652cbfca0c0 <bch2_btree_key_cache_journal_flush>, pin=<optimized out>,                    seq=<optimized out>, j=0x7f089bfe5908) at libbcachefs/journal_reclaim.h:66                                                                       
#5  bch2_btree_insert_key_cached (trans=trans@entry=0x7fffa462f760, path=<optimized out>, insert=<optimized out>)                                        at libbcachefs/btree_key_cache.c:550                                                                                                             
#6  0x00005652cbfec778 in do_btree_insert_one (i=0x5652cd26e200, trans=0x7fffa462f760) at libbcachefs/btree_update_leaf.c:410                        
#7  bch2_trans_commit_write_locked (trace_ip=<optimized out>, stopped_at=<synthetic pointer>, trans=0x7fffa462f760)                                      at libbcachefs/btree_update_leaf.c:744                                                                                                           
#8  do_bch2_trans_commit (trace_ip=<optimized out>, stopped_at=<synthetic pointer>, trans=0x7fffa462f760) at libbcachefs/btree_update_leaf.c:922     
#9  __bch2_trans_commit (trans=trans@entry=0x7fffa462f760) at libbcachefs/btree_update_leaf.c:1154                                                   
#10 0x00005652cbf6f056 in bch2_trans_commit (flags=<optimized out>, journal_seq=0x0, disk_res=0x0, trans=0x7fffa462f760)                                 at libbcachefs/btree_update.h:102                                                                                                                
#11 bch2_journal_replay (c=0x7f089bfc7000) at libbcachefs/recovery.c:563                                                                             
#12 bch2_fs_recovery (c=<optimized out>) at libbcachefs/recovery.c:1209                                                                              
#13 0x00005652cbfd5add in bch2_fs_start (c=c@entry=0x7f089bfc7000) at libbcachefs/super.c:897                                                        
#14 0x00005652cbfd7fef in bch2_fs_open (devices=devices@entry=0x7fffa462fdc8, nr_devices=nr_devices@entry=8, opts=...) at libbcachefs/super.c:1905   
#15 0x00005652cc014275 in cmd_fsck (argc=8, argc@entry=12, argv=0x7fffa462fdc8, argv@entry=0x7fffa462fda8) at cmd_fsck.c:90                          
#16 0x00005652cbf571ce in main (argc=<optimized out>, argv=0x7fffa462fda8) at bcachefs.c:197

EDIT: and the struct journal j from frame 3:

(gdb) print *j                                                                                                                                       
$2 = {flags = 6, reservations = {{counter = {counter = 18014398526259198}}, {v = 18014398526259198}, {cur_entry_offset = 1048574, idx = 3,                 unwritten_idx = 3, buf0_count = 0, buf1_count = 0, buf2_count = 0, buf3_count = 1}}, watermark = JOURNAL_WATERMARK_any,                          cur_entry_u64s = 7676, cur_entry_sectors = 512, cur_entry_error = JOURNAL_ERR_ok, prereserved = {{counter = {counter = 57997039341928448}}, {            v = 57997039341928448}, {waiting = 0, reserved = 0, remaining = 13503488}}, entry_u64s_reserved = 509, buf_size_want = 131072, buf = {{              data = 0x5652cc1c5000, {key = {_data = 0x7f089bfe5940, {{u64s = 0 '\000'}, {k = {u64s = 0 '\000', format = 0 '\000',                                           needs_whiteout = 0 '\000', type = 0 '\000', pad = "", version = {lo = 0, hi = 0}, size = 0, p = {snapshot = 0, offset = 0,                             inode = 0}}, v = {__nothing = 0x7f089bfe5968}}}}, key_pad = {0, 0, 0, 0}}, devs_written = {nr = 0 '\000',                                  devs = '\000' <repeats 15 times>}, wait = {list = {first = 0x0}}, last_seq = 0, expires = 0, flush_time = 0, buf_size = 65536, sectors = 0,        disk_sectors = 0, u64s_reserved = 509, noflush = false, must_flush = false, separate_flush = false}, {data = 0x5652cc1d6000, {key = {                    _data = 0x7f089bfe59e0, {{u64s = 0 '\000'}, {k = {u64s = 0 '\000', format = 0 '\000', needs_whiteout = 0 '\000', type = 0 '\000',                          pad = "", version = {lo = 0, hi = 0}, size = 0, p = {snapshot = 0, offset = 0, inode = 0}}, v = {__nothing = 0x7f089bfe5a08}}}},             key_pad = {0, 0, 0, 0}}, devs_written = {nr = 0 '\000', devs = '\000' <repeats 15 times>}, wait = {list = {first = 0x0}}, last_seq = 0,            expires = 0, flush_time = 0, buf_size = 65536, sectors = 0, disk_sectors = 0, u64s_reserved = 0, noflush = false, must_flush = false,                separate_flush = false}, {data = 0x5652cc1e7000, {key = {_data = 0x7f089bfe5a80, {{u64s = 0 '\000'}, {k = {u64s = 0 '\000',                                    format = 0 '\000', needs_whiteout = 0 '\000', type = 0 '\000', pad = "", version = {lo = 0, hi = 0}, size = 0, p = {snapshot = 0,                      offset = 0, inode = 0}}, v = {__nothing = 0x7f089bfe5aa8}}}}, key_pad = {0, 0, 0, 0}}, devs_written = {nr = 0 '\000',                      devs = '\000' <repeats 15 times>}, wait = {list = {first = 0x0}}, last_seq = 0, expires = 0, flush_time = 0, buf_size = 65536, sectors = 0,        disk_sectors = 0, u64s_reserved = 0, noflush = false, must_flush = false, separate_flush = false}, {data = 0x5652cc1f8000, {key = {                      _data = 0x7f089bfe5b20, {{u64s = 5 '\005'}, {k = {u64s = 5 '\005', format = 1 '\001', needs_whiteout = 0 '\000', type = 6 '\006',                          pad = "", version = {lo = 0, hi = 0}, size = 0, p = {snapshot = 0, offset = 0, inode = 0}}, v = {__nothing = 0x7f089bfe5b48}}}},             key_pad = {0, 0, 0, 0}}, devs_written = {nr = 0 '\000', devs = '\000' <repeats 15 times>}, wait = {list = {first = 0x0}},                          last_seq = 628257, expires = 208185073, flush_time = 0, buf_size = 65536, sectors = 128, disk_sectors = 512, u64s_reserved = 509,                    noflush = false, must_flush = false, separate_flush = false}}, lock = {lock = {__data = {__lock = 2, __count = 0, __owner = 30660,                     __nusers = 1, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}},                                                      __size = "\002\000\000\000\000\000\000\000\304w\000\000\001", '\000' <repeats 26 times>, __align = 2}}, blocked = 0, wait = {lock = {lock = {          __data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0,                            __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, task_list = {next = 0x7f089bfe5c10, prev = 0x7f089bfe5c10}},            async_wait = {list = {first = 0x0}}, preres_wait = {list = {first = 0x0}}, io = {{{wq = 0x0, s = 0x0, list = {next = 0x0}, fn = 0x0}, work = {             data = {counter = 0}, entry = {next = 0x0, prev = 0x0}, func = 0x0}}, parent = 0x0, remaining = {counter = 0}}, write_work = {work = {             data = {counter = 1}, entry = {next = 0x7f089bfe5c68, prev = 0x7f089bfe5c68}, func = 0x5652cbfc1770 <journal_write_work>}, timer = {                 expires = 208185073, function = 0x5652cc004b20 <delayed_work_timer_fn>, pending = false}, wq = 0x5652cc19af80}, seq = {counter = 628699},        seq_ondisk = 628698, flushed_seq_ondisk = 628698, last_seq_ondisk = 628257, err_seq = 0, last_empty_seq = 0, pin = {front = 628257,                    back = 628700, size = 32768, mask = 32767, data = 0x7f089bb5f000}, space = {{next_entry = 512, total = 964608}, {next_entry = 512,                     total = 964608}, {next_entry = 512, total = 964608}, {next_entry = 512, total = 965120}}, replay_journal_seq = 628259,                           replay_journal_seq_end = 628699, wp = {node = {next = 0x0, prev = 0x0}, lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0,                      __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>,                  __align = 0}}, last_used = 0, write_point = 0, data_type = BCH_DATA_none, sectors_free = 0, ptrs = {nr = 0, v = {0 <repeats 15 times>}},     
--Type <RET> for more, q to quit, c to continue without paging--
stripe = {next_alloc = {0 <repeats 64 times>}}}, err_lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0,           __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, reclaim_lock = {          lock = {__data = {__lock = 1, __count = 0, __owner = 30660, __nusers = 1, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0,                  __next = 0x0}}, __size = "\001\000\000\000\000\000\000\000\304w\000\000\001", '\000' <repeats 26 times>, __align = 1}}, reclaim_wait = {       lock = {lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0,                __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}}, task_list = {next = 0x7f089bfe6010, prev = 0x7f089bfe6010}},            reclaim_thread = 0x5652cc34fdd0, reclaim_kicked = false, next_reclaim = 208185113, nr_direct_reclaim = 0, nr_background_reclaim = 766,               last_flushed = 208184113, flush_in_progress = 0x5652cc39a940, flush_in_progress_dropped = false, pin_flush_wait = {lock = {lock = {__data = {                __lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}},                __size = '\000' <repeats 39 times>, __align = 0}}, task_list = {next = 0x7f089bfe6088, prev = 0x7f089bfe6088}}, discard_lock = {lock = {           __data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}},        __size = '\000' <repeats 39 times>, __align = 0}}, can_discard = false, last_flush_write = 208056827, res_get_blocked_start = 0,                 write_start_time = 0, nr_flush_writes = 0, nr_noflush_writes = 0, flush_write_time = 0x7f089bfe74b8, noflush_write_time = 0x7f089bfe7600,            blocked_time = 0x7f089bfe7890, flush_seq_time = 0x7f089bfe7748}

`make check` failed on 32 bit arm platform

I want to build for arm 32 bit.
Doing this using qemu-user-static and docker buildx tool to get arm32 environment.
make shows a lot of warnings, but finishes.
make check returns errors.
make check output:

cd tests; pytest-3
============================================================ test session starts =============================================================
platform linux -- Python 3.7.3, pytest-3.10.1, py-1.7.0, pluggy-0.8.0
rootdir: /root/bcachefs-tools/tests, inifile:
collected 28 items                                                                                                                           

test_basic.py FFFFFF                                                                                                                   [ 21%]
test_fixture.py ....ssssss..                                                                                                           [ 64%]
test_fuse.py ssssssssss                                                                                                                [100%]

================================================================== FAILURES ==================================================================
_________________________________________________________________ test_help __________________________________________________________________

    def test_help():
        ret = util.run_bch(valgrind=True)
    
        assert ret.returncode == 1
>       assert "missing command" in ret.stdout
E       AssertionError: assert 'missing command' in ''
E        +  where '' = CompletedProcess(args=[PosixPath('../bcachefs')], returncode=1, stdout='', stderr='io_setup() error: Cannot allocate memory\n').stdout

test_basic.py:12: AssertionError
------------------------------------------------------------ Captured stdout call ------------------------------------------------------------
Running '[PosixPath('../bcachefs')]'
________________________________________________________________ test_format _________________________________________________________________

tmpdir = local('/tmp/pytest-of-root/pytest-0/test_format0')

    def test_format(tmpdir):
        dev = util.device_1g(tmpdir)
        ret = util.run_bch('format', dev, valgrind=True)
    
>       assert ret.returncode == 0
E       AssertionError: assert 1 == 0
E        +  where 1 = CompletedProcess(args=[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_format0/dev-1g')], returncode=1, stdout='', stderr='io_setup() error: Cannot allocate memory\n').returncode

test_basic.py:19: AssertionError
------------------------------------------------------------ Captured stdout call ------------------------------------------------------------
Running '[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_format0/dev-1g')]'
_________________________________________________________________ test_fsck __________________________________________________________________

tmpdir = local('/tmp/pytest-of-root/pytest-0/test_fsck0')

    def test_fsck(tmpdir):
>       dev = util.format_1g(tmpdir)

test_basic.py:24: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
util.py:91: in format_1g
    run_bch('format', dev, check=True)
util.py:70: in run_bch
    return run(*cmds, **kwargs)
util.py:60: in run
    encoding='utf-8', check=check)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

input = None, capture_output = False, timeout = None, check = True
popenargs = ([PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_fsck0/dev-1g')],)
kwargs = {'encoding': 'utf-8', 'stderr': -1, 'stdout': -1}, process = <subprocess.Popen object at 0xfe978510>, stdout = ''
stderr = 'io_setup() error: Cannot allocate memory\n', retcode = 1

    def run(*popenargs,
            input=None, capture_output=False, timeout=None, check=False, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
    
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
    
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
    
        If timeout is given, and the process takes too long, a TimeoutExpired
        exception will be raised.
    
        There is an optional argument "input", allowing you to
        pass bytes or a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
    
        By default, all communication is in bytes, and therefore any "input" should
        be bytes, and the stdout and stderr will be bytes. If in text mode, any
        "input" should be a string, and stdout and stderr will be strings decoded
        according to locale encoding, or by "encoding" if set. Text mode is
        triggered by setting any of text, encoding, errors or universal_newlines.
    
        The other arguments are the same as for the Popen constructor.
        """
        if input is not None:
            if 'stdin' in kwargs:
                raise ValueError('stdin and input arguments may not both be used.')
            kwargs['stdin'] = PIPE
    
        if capture_output:
            if ('stdout' in kwargs) or ('stderr' in kwargs):
                raise ValueError('stdout and stderr arguments may not be used '
                                 'with capture_output.')
            kwargs['stdout'] = PIPE
            kwargs['stderr'] = PIPE
    
        with Popen(*popenargs, **kwargs) as process:
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired:
                process.kill()
                stdout, stderr = process.communicate()
                raise TimeoutExpired(process.args, timeout, output=stdout,
                                     stderr=stderr)
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
                raise CalledProcessError(retcode, process.args,
>                                        output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command '[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_fsck0/dev-1g')]' returned non-zero exit status 1.

/usr/lib/python3.7/subprocess.py:487: CalledProcessError
------------------------------------------------------------ Captured stdout call ------------------------------------------------------------
Running '[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_fsck0/dev-1g')]'
_________________________________________________________________ test_list __________________________________________________________________

tmpdir = local('/tmp/pytest-of-root/pytest-0/test_list0')

    def test_list(tmpdir):
>       dev = util.format_1g(tmpdir)

test_basic.py:33: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
util.py:91: in format_1g
    run_bch('format', dev, check=True)
util.py:70: in run_bch
    return run(*cmds, **kwargs)
util.py:60: in run
    encoding='utf-8', check=check)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

input = None, capture_output = False, timeout = None, check = True
popenargs = ([PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_list0/dev-1g')],)
kwargs = {'encoding': 'utf-8', 'stderr': -1, 'stdout': -1}, process = <subprocess.Popen object at 0xfe8d9c70>, stdout = ''
stderr = 'io_setup() error: Cannot allocate memory\n', retcode = 1

    def run(*popenargs,
            input=None, capture_output=False, timeout=None, check=False, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
    
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
    
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
    
        If timeout is given, and the process takes too long, a TimeoutExpired
        exception will be raised.
    
        There is an optional argument "input", allowing you to
        pass bytes or a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
    
        By default, all communication is in bytes, and therefore any "input" should
        be bytes, and the stdout and stderr will be bytes. If in text mode, any
        "input" should be a string, and stdout and stderr will be strings decoded
        according to locale encoding, or by "encoding" if set. Text mode is
        triggered by setting any of text, encoding, errors or universal_newlines.
    
        The other arguments are the same as for the Popen constructor.
        """
        if input is not None:
            if 'stdin' in kwargs:
                raise ValueError('stdin and input arguments may not both be used.')
            kwargs['stdin'] = PIPE
    
        if capture_output:
            if ('stdout' in kwargs) or ('stderr' in kwargs):
                raise ValueError('stdout and stderr arguments may not be used '
                                 'with capture_output.')
            kwargs['stdout'] = PIPE
            kwargs['stderr'] = PIPE
    
        with Popen(*popenargs, **kwargs) as process:
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired:
                process.kill()
                stdout, stderr = process.communicate()
                raise TimeoutExpired(process.args, timeout, output=stdout,
                                     stderr=stderr)
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
                raise CalledProcessError(retcode, process.args,
>                                        output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command '[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_list0/dev-1g')]' returned non-zero exit status 1.

/usr/lib/python3.7/subprocess.py:487: CalledProcessError
------------------------------------------------------------ Captured stdout call ------------------------------------------------------------
Running '[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_list0/dev-1g')]'
______________________________________________________________ test_list_inodes ______________________________________________________________

tmpdir = local('/tmp/pytest-of-root/pytest-0/test_list_inodes0')

    def test_list_inodes(tmpdir):
>       dev = util.format_1g(tmpdir)

test_basic.py:45: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
util.py:91: in format_1g
    run_bch('format', dev, check=True)
util.py:70: in run_bch
    return run(*cmds, **kwargs)
util.py:60: in run
    encoding='utf-8', check=check)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

input = None, capture_output = False, timeout = None, check = True
popenargs = ([PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_list_inodes0/dev-1g')],)
kwargs = {'encoding': 'utf-8', 'stderr': -1, 'stdout': -1}, process = <subprocess.Popen object at 0xfe9787f0>, stdout = ''
stderr = 'io_setup() error: Cannot allocate memory\n', retcode = 1

    def run(*popenargs,
            input=None, capture_output=False, timeout=None, check=False, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
    
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
    
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
    
        If timeout is given, and the process takes too long, a TimeoutExpired
        exception will be raised.
    
        There is an optional argument "input", allowing you to
        pass bytes or a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
    
        By default, all communication is in bytes, and therefore any "input" should
        be bytes, and the stdout and stderr will be bytes. If in text mode, any
        "input" should be a string, and stdout and stderr will be strings decoded
        according to locale encoding, or by "encoding" if set. Text mode is
        triggered by setting any of text, encoding, errors or universal_newlines.
    
        The other arguments are the same as for the Popen constructor.
        """
        if input is not None:
            if 'stdin' in kwargs:
                raise ValueError('stdin and input arguments may not both be used.')
            kwargs['stdin'] = PIPE
    
        if capture_output:
            if ('stdout' in kwargs) or ('stderr' in kwargs):
                raise ValueError('stdout and stderr arguments may not be used '
                                 'with capture_output.')
            kwargs['stdout'] = PIPE
            kwargs['stderr'] = PIPE
    
        with Popen(*popenargs, **kwargs) as process:
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired:
                process.kill()
                stdout, stderr = process.communicate()
                raise TimeoutExpired(process.args, timeout, output=stdout,
                                     stderr=stderr)
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
                raise CalledProcessError(retcode, process.args,
>                                        output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command '[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_list_inodes0/dev-1g')]' returned non-zero exit status 1.

/usr/lib/python3.7/subprocess.py:487: CalledProcessError
------------------------------------------------------------ Captured stdout call ------------------------------------------------------------
Running '[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_list_inodes0/dev-1g')]'
______________________________________________________________ test_list_dirent ______________________________________________________________

tmpdir = local('/tmp/pytest-of-root/pytest-0/test_list_dirent0')

    def test_list_dirent(tmpdir):
>       dev = util.format_1g(tmpdir)

test_basic.py:54: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
util.py:91: in format_1g
    run_bch('format', dev, check=True)
util.py:70: in run_bch
    return run(*cmds, **kwargs)
util.py:60: in run
    encoding='utf-8', check=check)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

input = None, capture_output = False, timeout = None, check = True
popenargs = ([PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_list_dirent0/dev-1g')],)
kwargs = {'encoding': 'utf-8', 'stderr': -1, 'stdout': -1}, process = <subprocess.Popen object at 0xfe8c2570>, stdout = ''
stderr = 'io_setup() error: Cannot allocate memory\n', retcode = 1

    def run(*popenargs,
            input=None, capture_output=False, timeout=None, check=False, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
    
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
    
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
    
        If timeout is given, and the process takes too long, a TimeoutExpired
        exception will be raised.
    
        There is an optional argument "input", allowing you to
        pass bytes or a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
    
        By default, all communication is in bytes, and therefore any "input" should
        be bytes, and the stdout and stderr will be bytes. If in text mode, any
        "input" should be a string, and stdout and stderr will be strings decoded
        according to locale encoding, or by "encoding" if set. Text mode is
        triggered by setting any of text, encoding, errors or universal_newlines.
    
        The other arguments are the same as for the Popen constructor.
        """
        if input is not None:
            if 'stdin' in kwargs:
                raise ValueError('stdin and input arguments may not both be used.')
            kwargs['stdin'] = PIPE
    
        if capture_output:
            if ('stdout' in kwargs) or ('stderr' in kwargs):
                raise ValueError('stdout and stderr arguments may not be used '
                                 'with capture_output.')
            kwargs['stdout'] = PIPE
            kwargs['stderr'] = PIPE
    
        with Popen(*popenargs, **kwargs) as process:
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired:
                process.kill()
                stdout, stderr = process.communicate()
                raise TimeoutExpired(process.args, timeout, output=stdout,
                                     stderr=stderr)
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
                raise CalledProcessError(retcode, process.args,
>                                        output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command '[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_list_dirent0/dev-1g')]' returned non-zero exit status 1.

/usr/lib/python3.7/subprocess.py:487: CalledProcessError
------------------------------------------------------------ Captured stdout call ------------------------------------------------------------
Running '[PosixPath('../bcachefs'), 'format', PosixPath('/tmp/pytest-of-root/pytest-0/test_list_dirent0/dev-1g')]'
=============================================== 6 failed, 6 passed, 16 skipped in 7.50 seconds ===============================================
make: *** [Makefile:88: check] Error 1

warning during make, about on every file:

# make
cc -std=gnu89 -O2 -g -MMD -Wall -Wno-pointer-sign -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-357-g6c42566"'  -Wno-unused-but-set-variable -Wno-stringop-overflow  -Wno-missing-braces  -Wno-shift-overflow  -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/arm-linux-gnueabihf   -c -o bcachefs.o bcachefs.c
cc -std=gnu89 -O2 -g -MMD -Wall -Wno-pointer-sign -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-357-g6c42566"'  -Wno-unused-but-set-variable -Wno-stringop-overflow  -Wno-missing-braces  -Wno-shift-overflow  -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/arm-linux-gnueabihf   -c -o cmd_assemble.o cmd_assemble.c
In file included from libbcachefs/bcachefs_format.h:77,
                 from libbcachefs/bcachefs_ioctl.h:7,
                 from cmd_assemble.c:10:
include/linux/slab.h: In function 'kmalloc':
include/linux/kernel.h:108:17: warning: comparison of distinct pointer types lacks a cast
  (void) (&_min1 == &_min2);  \
                 ^~
include/linux/slab.h:24:22: note: in expansion of macro 'min'
   size_t alignment = min(rounddown_pow_of_two(size), (size_t)PAGE_SIZE);
                      ^~~
cc -std=gnu89 -O2 -g -MMD -Wall -Wno-pointer-sign -fno-strict-aliasing -fno-delete-null-pointer-checks -I. -Iinclude -Iraid -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LGPL_SOURCE -DRCU_MEMBARRIER -DZSTD_STATIC_LINKING_ONLY -DFUSE_USE_VERSION=32 -DNO_BCACHEFS_CHARDEV -DNO_BCACHEFS_FS -DNO_BCACHEFS_SYSFS -DVERSION_STRING='"v0.1-357-g6c42566"'  -Wno-unused-but-set-variable -Wno-stringop-overflow  -Wno-missing-braces  -Wno-shift-overflow  -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/arm-linux-gnueabihf   -c -o linux/six.o linux/six.c
In file included from include/linux/bitops.h:5,
                 from include/linux/log2.h:12,
                 from linux/six.c:4:
include/linux/slab.h: In function 'kmalloc':
include/linux/kernel.h:108:17: warning: comparison of distinct pointer types lacks a cast
  (void) (&_min1 == &_min2);  \
                 ^~
include/linux/slab.h:24:22: note: in expansion of macro 'min'
   size_t alignment = min(rounddown_pow_of_two(size), (size_t)PAGE_SIZE);
                      ^~~
linux/six.c: In function '__six_lock_type_slowpath':
linux/six.c:142:23: warning: 'old.<U2058>.v' may be used uninitialized in this function [-Wmaybe-uninitialized]
  union six_lock_state old, new;

used dockerfile:

ARG IMG=debian:buster
FROM $IMG as deb

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update; apt-get install -y pkg-config libaio-dev libblkid-dev libkeyutils-dev \
        liblz4-dev libscrypt-dev libsodium-dev liburcu-dev libzstd-dev \
        uuid-dev zlib1g-dev valgrind libudev-dev git build-essential \
        python3 python3-docutils \
        python3-pytest devscripts debhelper
WORKDIR /root
RUN git clone https://github.com/koverstreet/bcachefs-tools.git
WORKDIR bcachefs-tools
#RUN make

images build:
docker buildx build --platform=linux/arm/v7 --progress plain -f Dockerfile -t toolb32 --load .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.