With the regression fix tested, I've gone ahead and fixed the core problem on my system, switching the backing device to 4k. Documented below and worked for me, but PLEASE don't take it at face value, since part of it is literally destroying the bcache header area of the backing disk.
# WARNING! Loss of data, life, liberty, etc. Do not blindly copy/paste!
# You need to unmount and make sure the bcache device is not being used,
# and specifically wait for the cache state to go from dirty to clean
# if using writeback.
DEV_BACKING=/dev/sdx1 # /dev/md0 for me
DEV_CACHE=/dev/sdy1 # /dev/sdb1 for me
DEV_BCACHE=bcache0
OFFSET="$(bcache-super-show ${DEV_BACKING?} | awk '$1=="dev.data.first_sector" {print $2}')"
CSET_UUID="$(bcache-super-show ${DEV_CACHE?} | awk '$1=="cset.uuid" {print $2}')"
file -s ${DEV_CACHE?}
file -s ${DEV_BACKING?}
dd if=${DEV_BACKING?} bs=512 skip=${OFFSET?} count=8 | file -
# Remove and wipe cache device
echo ${CSET_UUID?} >/sys/block/${DEV_BCACHE?}/bcache/detach
cat /sys/block/${DEV_BCACHE?}/bcache/state
echo 1 >/sys/fs/bcache/${CSET_UUID?}/stop
while [ -e /sys/fs/bcache/${CSET_UUID?}/stop ]; do sleep 1; done
wipefs -a ${DEV_CACHE?}
# Stop bcache0, wipe and recreate bcache portion of backing device
echo 1 >/sys/block/${DEV_BCACHE?}/bcache/stop
while [ -e /sys/block/${DEV_BCACHE?}/bcache/stop ]; do sleep 1; done
# Removes bcache magic bytes from beginning and (hopefully) leaves all data from
# ${OFFSET?} onward (the actual data). But don't trust me here.
wipefs -a ${DEV_BACKING?}
dd if=/dev/zero of=${DEV_BACKING?} bs=512 count=${OFFSET?}
make-bcache --block 4k --bucket 2M --data-offset ${OFFSET?} -B ${DEV_BACKING?}
while [ ! -e /sys/block/${DEV_BCACHE?}/bcache/attach ]; do sleep 1; done
file -s /dev/${DEV_BCACHE?}
With the regression fix tested, I've gone ahead and fixed the core problem on my system, switching the backing device to 4k. Documented below and worked for me, but PLEASE don't take it at face value, since part of it is literally destroying the bcache header area of the backing disk.
# WARNING! Loss of data, life, liberty, etc. Do not blindly copy/paste!
# You need to unmount and make sure the bcache device is not being used,
# and specifically wait for the cache state to go from dirty to clean
# if using writeback.
DEV_BACKING= /dev/sdx1 # /dev/md0 for me "$(bcache- super-show ${DEV_BACKING?} | awk '$1=="dev. data.first_ sector" {print $2}')" "$(bcache- super-show ${DEV_CACHE?} | awk '$1=="cset.uuid" {print $2}')"
DEV_CACHE=/dev/sdy1 # /dev/sdb1 for me
DEV_BCACHE=bcache0
OFFSET=
CSET_UUID=
file -s ${DEV_CACHE?}
file -s ${DEV_BACKING?}
dd if=${DEV_BACKING?} bs=512 skip=${OFFSET?} count=8 | file -
# Remove and wipe cache device ${DEV_BCACHE? }/bcache/ detach ${DEV_BCACHE? }/bcache/ state bcache/ ${CSET_ UUID?}/ stop bcache/ ${CSET_ UUID?}/ stop ]; do sleep 1; done
echo ${CSET_UUID?} >/sys/block/
cat /sys/block/
echo 1 >/sys/fs/
while [ -e /sys/fs/
wipefs -a ${DEV_CACHE?}
# Stop bcache0, wipe and recreate bcache portion of backing device ${DEV_BCACHE? }/bcache/ stop ${DEV_BCACHE? }/bcache/ stop ]; do sleep 1; done ${DEV_BCACHE? }/bcache/ attach ]; do sleep 1; done
echo 1 >/sys/block/
while [ -e /sys/block/
# Removes bcache magic bytes from beginning and (hopefully) leaves all data from
# ${OFFSET?} onward (the actual data). But don't trust me here.
wipefs -a ${DEV_BACKING?}
dd if=/dev/zero of=${DEV_BACKING?} bs=512 count=${OFFSET?}
make-bcache --block 4k --bucket 2M --data-offset ${OFFSET?} -B ${DEV_BACKING?}
while [ ! -e /sys/block/
file -s /dev/${DEV_BCACHE?}
# Safe to remount and use bcache device now
# Recreate and attach cache "$(bcache- super-show ${DEV_CACHE?} | awk '$1=="cset.uuid" {print $2}')" ${DEV_BCACHE? }/bcache/ attach ${DEV_BCACHE? }/bcache/ cache_mode ${DEV_BCACHE? }/bcache/ state
make-bcache --block 4k --bucket 2M -C ${DEV_CACHE?}
CSET_UUID=
echo ${CSET_UUID?} >/sys/block/
echo writeback >/sys/block/
cat /sys/block/