diff -Nru bcache-tools-1.0.8/debian/changelog bcache-tools-1.0.8/debian/changelog --- bcache-tools-1.0.8/debian/changelog 2018-03-27 18:21:51.000000000 +0000 +++ bcache-tools-1.0.8/debian/changelog 2020-07-23 00:33:50.000000000 +0000 @@ -1,3 +1,10 @@ +bcache-tools (1.0.8-3ubuntu0.1) focal; urgency=medium + + [ Ryan Harper ] + * Add helper script to read bcache devs superblock (LP: #1861941) + + -- Rafael David Tinoco Thu, 23 Jul 2020 00:33:50 +0000 + bcache-tools (1.0.8-3) unstable; urgency=medium * d/bcache-tools.preinst: fail on unexpected error (Closes: #866250). diff -Nru bcache-tools-1.0.8/debian/control bcache-tools-1.0.8/debian/control --- bcache-tools-1.0.8/debian/control 2018-03-27 18:20:54.000000000 +0000 +++ bcache-tools-1.0.8/debian/control 2020-07-23 00:33:50.000000000 +0000 @@ -1,5 +1,6 @@ Source: bcache-tools -Maintainer: David Mohr +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: David Mohr Uploaders: Robie Basak Section: utils Priority: optional @@ -11,7 +12,7 @@ Package: bcache-tools Architecture: linux-any -Depends: ${misc:Depends}, ${shlibs:Depends} +Depends: ${misc:Depends}, ${shlibs:Depends}, gawk Recommends: initramfs-tools | linux-initramfs-tool Description: bcache userspace tools Bcache allows the use of SSDs to cache other block devices. diff -Nru bcache-tools-1.0.8/debian/patches/0003-Add-bcache-export-cached-helper.patch bcache-tools-1.0.8/debian/patches/0003-Add-bcache-export-cached-helper.patch --- bcache-tools-1.0.8/debian/patches/0003-Add-bcache-export-cached-helper.patch 1970-01-01 00:00:00.000000000 +0000 +++ bcache-tools-1.0.8/debian/patches/0003-Add-bcache-export-cached-helper.patch 2020-07-23 00:33:50.000000000 +0000 @@ -0,0 +1,104 @@ +Description: Add bcache-export-cached helper to export CACHED_UUID and + CACHED_LABEL always + +Linux kernel bcache driver does not always emit a uevent[1] for when a backing +device is bound to a bcacheN device. When this happens, the udev rule for +creating /dev/bcache/by-uuid or /dev/bcache/by-label symlinks does not fire and +removes any persistent symlink to a specific backing device since the bcache +minor numbers (bcache0, 1, 2) are not guaranteed across reboots. + +This script reads the superblock of the bcache device slaves, ensuring the +slave is a backing device via sb.version check, extracts the dev.uuid and +dev.label values and exports them to udev for triggering the symlink rules in +the existing rules file. + +1. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1729145 + +Author: Ryan Harper +Bug: https://bugs.debian.org/890446 +Bug-Ubuntu: https://launchpad.net/bugs/1861941 +Forwarded: https://github.com/koverstreet/bcache-tools/pull/6/ +Reviewed-By: Rafael David Tinoco +Last-Update: 2020-07-22 + +--- bcache-tools-1.0.8.orig/69-bcache.rules ++++ bcache-tools-1.0.8/69-bcache.rules +@@ -23,10 +23,9 @@ RUN+="bcache-register $tempnode" + LABEL="bcache_backing_end" + + # Cached devices: symlink +-DRIVER=="bcache", ENV{CACHED_UUID}=="?*", \ +- SYMLINK+="bcache/by-uuid/$env{CACHED_UUID}" +-DRIVER=="bcache", ENV{CACHED_LABEL}=="?*", \ +- SYMLINK+="bcache/by-label/$env{CACHED_LABEL}" ++IMPORT{program}="bcache-export-cached $tempnode" ++ENV{CACHED_UUID}=="?*", SYMLINK+="bcache/by-uuid/$env{CACHED_UUID}" ++ENV{CACHED_LABEL}=="?*", SYMLINK+="bcache/by-label/$env{CACHED_LABEL}" + + LABEL="bcache_end" + +--- bcache-tools-1.0.8.orig/Makefile ++++ bcache-tools-1.0.8/Makefile +@@ -9,7 +9,7 @@ all: make-bcache probe-bcache bcache-sup + + install: make-bcache probe-bcache bcache-super-show + $(INSTALL) -m0755 make-bcache bcache-super-show $(DESTDIR)${PREFIX}/sbin/ +- $(INSTALL) -m0755 probe-bcache bcache-register $(DESTDIR)$(UDEVLIBDIR)/ ++ $(INSTALL) -m0755 probe-bcache bcache-register bcache-export-cached $(DESTDIR)$(UDEVLIBDIR)/ + $(INSTALL) -m0644 69-bcache.rules $(DESTDIR)$(UDEVLIBDIR)/rules.d/ + $(INSTALL) -m0644 -- *.8 $(DESTDIR)${PREFIX}/share/man/man8/ + $(INSTALL) -D -m0755 initramfs/hook $(DESTDIR)/usr/share/initramfs-tools/hooks/bcache +--- /dev/null ++++ bcache-tools-1.0.8/bcache-export-cached +@@ -0,0 +1,31 @@ ++#!/bin/sh ++# ++# This program reads the bcache superblock on bcacheX slaves to extract the ++# dev.uuid and dev.label which refer to a specific backing device. ++# ++# It integrates with udev 'import' by writing CACHED_UUID=X and optionally ++# CACHED_LABEL=X for the backing device of the provided bcache device. ++# Ignore caching devices by skipping unless sb.version=1 ++# ++# There is 1 and only 1 backing device (slaves/*) for a bcache device. ++ ++TEMPNODE=${1} # /dev/bcacheN ++DEVNAME=${TEMPNODE##*/} # /dev/bcacheN -> bcacheN ++ ++for slave in "/sys/class/block/$DEVNAME/slaves"/*; do ++ [ -d "$slave" ] || continue ++ /usr/sbin/bcache-super-show "/dev/${slave##*/}" | ++ awk '$1 == "sb.version" { sbver=$2; } ++ $1 == "dev.uuid" { uuid=$2; } ++ $1 == "dev.label" && $2 != "(empty)" { label=$2; } ++ END { ++ if (sbver == 1 && uuid) { ++ print("CACHED_UUID=" uuid) ++ if (label) print("CACHED_LABEL=" label) ++ exit(0) ++ } ++ exit(1); ++ }' ++ # awk exits 0 if it found a backing device. ++ [ $? -eq 0 ] && exit 0 ++done +--- bcache-tools-1.0.8.orig/initcpio/install ++++ bcache-tools-1.0.8/initcpio/install +@@ -1,6 +1,7 @@ + #!/bin/bash + build() { + add_module bcache ++ add_binary /usr/lib/udev/bcache-export-cached + add_binary /usr/lib/udev/bcache-register + add_binary /usr/lib/udev/probe-bcache + add_file /usr/lib/udev/rules.d/69-bcache.rules +--- bcache-tools-1.0.8.orig/initramfs/hook ++++ bcache-tools-1.0.8/initramfs/hook +@@ -22,6 +22,7 @@ elif [ -e /lib/udev/rules.d/69-bcache.ru + cp -pt "${DESTDIR}/lib/udev/rules.d" /lib/udev/rules.d/69-bcache.rules + fi + ++copy_exec /lib/udev/bcache-export-cached + copy_exec /lib/udev/bcache-register + copy_exec /lib/udev/probe-bcache + manual_add_modules bcache diff -Nru bcache-tools-1.0.8/debian/patches/series bcache-tools-1.0.8/debian/patches/series --- bcache-tools-1.0.8/debian/patches/series 2018-03-27 16:44:16.000000000 +0000 +++ bcache-tools-1.0.8/debian/patches/series 2020-07-23 00:33:50.000000000 +0000 @@ -1,2 +1,3 @@ 0001-Clean-should-remove-bcache-register.patch 0002-Don-t-inline-crc64-for-gcc-5-compatibility.patch +0003-Add-bcache-export-cached-helper.patch