diff -Nru bcache-tools-1.0.8/debian/changelog bcache-tools-1.0.8/debian/changelog --- bcache-tools-1.0.8/debian/changelog 2020-05-20 07:41:11.000000000 -0500 +++ bcache-tools-1.0.8/debian/changelog 2020-05-22 15:01:02.000000000 -0500 @@ -1,3 +1,13 @@ +bcache-tools (1.0.8-4ubuntu1) groovy; urgency=medium + + * Drop keep symlinks patch + * bcache-export-cached-uuid.patch: Add a udev import program to extract + the backing device dev.uuid/dev.label values and export this for + constructing the /dev/bcache/by-{uuid,label} symlink to the bcacheN + device. (LP: #1861941) + + -- Ryan Harper Fri, 22 May 2020 15:01:02 -0500 + bcache-tools (1.0.8-4) unstable; urgency=medium [ Debian Janitor ] diff -Nru bcache-tools-1.0.8/debian/patches/bcache-export-cached-uuid.patch bcache-tools-1.0.8/debian/patches/bcache-export-cached-uuid.patch --- bcache-tools-1.0.8/debian/patches/bcache-export-cached-uuid.patch 1969-12-31 18:00:00.000000000 -0600 +++ bcache-tools-1.0.8/debian/patches/bcache-export-cached-uuid.patch 2020-05-22 15:01:02.000000000 -0500 @@ -0,0 +1,72 @@ +Description: Add bcache-export-cached-uuid udev import for bcache symlinks + Add a shell program, bcache-export-cached-uuid used in 69-bcache.rules to + extract and import the backing device dev.uuid, for used with CACHED_UUID + and dev.label (if set) for CACHED_LABEL which enable udev symlinks to point + to the bcacheN device name. +Author: Ryan Harper +Bug-Ubuntu: LP: #1861941 +Forwarded: no +Last-Update: 2020-05-22 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/69-bcache.rules ++++ b/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-uuid $tempnode" ++ENV{CACHED_UUID}=="?*", SYMLINK+="bcache/by-uuid/$env{CACHED_UUID}" ++ENV{CACHED_LABEL}=="?*", SYMLINK+="bcache/by-label/$env{CACHED_LABEL}" + + LABEL="bcache_end" + +--- a/Makefile ++++ b/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-uuid $(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 ++++ b/bcache-export-cached-uuid +@@ -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 ++ 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 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 2020-05-20 07:41:11.000000000 -0500 +++ bcache-tools-1.0.8/debian/patches/series 2020-05-22 14:48:26.000000000 -0500 @@ -1,3 +1,3 @@ 0001-Clean-should-remove-bcache-register.patch 0002-Don-t-inline-crc64-for-gcc-5-compatibility.patch -udev-keep-symlinks.patch +bcache-export-cached-uuid.patch diff -Nru bcache-tools-1.0.8/debian/patches/udev-keep-symlinks.patch bcache-tools-1.0.8/debian/patches/udev-keep-symlinks.patch --- bcache-tools-1.0.8/debian/patches/udev-keep-symlinks.patch 2020-05-20 07:41:11.000000000 -0500 +++ bcache-tools-1.0.8/debian/patches/udev-keep-symlinks.patch 1969-12-31 18:00:00.000000000 -0600 @@ -1,50 +0,0 @@ -Description: Keep symlinks when udev changes /dev/bcacheN -Author: Balint Reczey -Origin: vendor -Bug-Ubuntu: https://launchpad.net/bugs/1861941 -Last-Update: 2020-05-19 - ---- a/69-bcache.rules -+++ b/69-bcache.rules -@@ -30,3 +30,9 @@ - - LABEL="bcache_end" - -+# keep symlinks when the block device is changed by a different driver -+DRIVER!="bcache", ENV{DEVNAME}=="/dev/bcache[0-9]*" ACTION=="change", ENV{DEVLINKS}=="?*",IMPORT{program}="bcache-keep-symlinks $env{DEVNAME}" -+ENV{BCACHE_CACHED_UUID}=="?*", \ -+ SYMLINK+="bcache/by-uuid/$env{BCACHE_CACHED_UUID}" -+ENV{BCACHE_CACHED_LABEL}=="?*", \ -+ SYMLINK+="bcache/by-label/$env{BCACHE_CACHED_LABEL}" ---- a/Makefile -+++ b/Makefile -@@ -9,7 +9,7 @@ - - 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-keep-symlinks $(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 -+++ b/bcache-keep-symlinks -@@ -0,0 +1,18 @@ -+#!/bin/sh -+ -+DEVNAME=$1 -+ -+for link in /dev/bcache/by-uuid/*; do -+ if [ -n "$DEVNAME" -a "$DEVNAME" = "$(readlink -f $link)" ]; then -+ echo "BCACHE_CACHED_UUID=$(basename $link)" -+ break -+ fi -+done -+ -+for link in /dev/bcache/by-label/*; do -+ if [ -n "$DEVNAME" -a "$DEVNAME" = "$(readlink -f $link)" ]; then -+ echo "BCACHE_CACHED_LABEL=$(basename $link)" -+ break -+ fi -+done -+