Compare commits
No commits in common. "5d8497e897353606b7b81a71d022aedaa9a08271" and "55cdfea10b2deebb80cfcd79a035c3e04be369c0" have entirely different histories.
5d8497e897
...
55cdfea10b
@ -1,128 +0,0 @@
|
|||||||
From 2cfea71ab753fc65f1d97b0af327e6e9e3fa204b Mon Sep 17 00:00:00 2001
|
|
||||||
From: Ryan Harper <ryan.harper@canonical.com>
|
|
||||||
Date: Wed, 19 Aug 2020 18:51:27 +0800
|
|
||||||
Subject: [PATCH] bcache-tools: Export CACHED_UUID and CACHED_LABEL
|
|
||||||
|
|
||||||
https://github.com/koverstreet/bcache-tools/pull/1
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
Signed-off-by: Shaoxiong Li <dahefanteng@gmail.com>
|
|
||||||
Signed-off-by: Coly Li <colyli@suse.de>
|
|
||||||
---
|
|
||||||
69-bcache.rules | 7 +++----
|
|
||||||
Makefile | 2 +-
|
|
||||||
bcache-export-cached | 31 +++++++++++++++++++++++++++++++
|
|
||||||
initcpio/install | 1 +
|
|
||||||
initramfs/hook | 1 +
|
|
||||||
5 files changed, 37 insertions(+), 5 deletions(-)
|
|
||||||
create mode 100644 bcache-export-cached
|
|
||||||
|
|
||||||
diff --git a/69-bcache.rules b/69-bcache.rules
|
|
||||||
index 9cc7f0d..fd25f5b 100644
|
|
||||||
--- 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 $tempnode"
|
|
||||||
+ENV{CACHED_UUID}=="?*", SYMLINK+="bcache/by-uuid/$env{CACHED_UUID}"
|
|
||||||
+ENV{CACHED_LABEL}=="?*", SYMLINK+="bcache/by-label/$env{CACHED_LABEL}"
|
|
||||||
|
|
||||||
LABEL="bcache_end"
|
|
||||||
|
|
||||||
diff --git a/Makefile b/Makefile
|
|
||||||
index 8b87a67..90db951 100644
|
|
||||||
--- a/Makefile
|
|
||||||
+++ b/Makefile
|
|
||||||
@@ -9,7 +9,7 @@ all: make-bcache probe-bcache bcache-super-show bcache-register bcache
|
|
||||||
|
|
||||||
install: make-bcache probe-bcache bcache-super-show
|
|
||||||
$(INSTALL) -m0755 make-bcache bcache-super-show bcache $(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
|
|
||||||
diff --git a/bcache-export-cached b/bcache-export-cached
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..b345922
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/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
|
|
||||||
+ 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 --git a/initcpio/install b/initcpio/install
|
|
||||||
index 72d4231..c1a86fe 100755
|
|
||||||
--- a/initcpio/install
|
|
||||||
+++ b/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
|
|
||||||
diff --git a/initramfs/hook b/initramfs/hook
|
|
||||||
index a6baa24..485491d 100755
|
|
||||||
--- a/initramfs/hook
|
|
||||||
+++ b/initramfs/hook
|
|
||||||
@@ -22,6 +22,7 @@ elif [ -e /lib/udev/rules.d/69-bcache.rules ]; then
|
|
||||||
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
|
|
||||||
--
|
|
||||||
2.33.0
|
|
||||||
|
|
||||||
@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
Name: bcache-tools
|
Name: bcache-tools
|
||||||
Version: 1.1
|
Version: 1.1
|
||||||
Release: 4
|
Release: 1
|
||||||
Summary: userspace tools for bcache
|
Summary: userspace tools for bcache
|
||||||
License: GPL-2.0
|
License: GPL-2.0
|
||||||
URL: http://bcache.evilpiepirate.org/
|
URL: http://bcache.evilpiepirate.org/
|
||||||
Source0: https://git.kernel.org/pub/scm/linux/kernel/git/colyli/bcache-tools.git/snapshot/%{name}-%{version}.tar.gz
|
Source0: https://git.kernel.org/pub/scm/linux/kernel/git/colyli/bcache-tools.git/snapshot/%{name}-%{version}.tar.gz
|
||||||
Patch0: 0001-bcache-tools-Export-CACHED_UUID-and-CACHED_LABEL.patch
|
|
||||||
|
|
||||||
BuildRequires: gcc, tar, pkgconfig
|
BuildRequires: gcc, tar, pkgconfig
|
||||||
BuildRequires: pkgconfig(blkid), pkgconfig(uuid)
|
BuildRequires: pkgconfig(blkid), pkgconfig(uuid)
|
||||||
@ -22,8 +21,6 @@ bcache-tools contains the userspace tools required for bcache.
|
|||||||
%autosetup -p1
|
%autosetup -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
CFLAGS="$CFLAGS -fstack-protector-strong -fPIE -pie -fPIC -D_FORTIFY_SOURCE=2"
|
|
||||||
export CFLAGS
|
|
||||||
%make_build all
|
%make_build all
|
||||||
|
|
||||||
%install
|
%install
|
||||||
@ -41,7 +38,6 @@ mkdir -p %{buildroot}/%{_mandir}/man8
|
|||||||
/lib/udev/rules.d/69-bcache.rules
|
/lib/udev/rules.d/69-bcache.rules
|
||||||
/lib/udev/probe-bcache
|
/lib/udev/probe-bcache
|
||||||
/lib/udev/bcache-register
|
/lib/udev/bcache-register
|
||||||
/lib/udev/bcache-export-cached
|
|
||||||
/lib/dracut/modules.d/90bcache/module-setup.sh
|
/lib/dracut/modules.d/90bcache/module-setup.sh
|
||||||
/usr/lib/initcpio/install/bcache
|
/usr/lib/initcpio/install/bcache
|
||||||
/usr/share/initramfs-tools/hooks/bcache
|
/usr/share/initramfs-tools/hooks/bcache
|
||||||
@ -49,15 +45,5 @@ mkdir -p %{buildroot}/%{_mandir}/man8
|
|||||||
%license COPYING
|
%license COPYING
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Mon Nov 4 2024 liequan che <cheliequan@inspur.com> - 1.1-4
|
* Wed Jan 6 2020 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 1.1-1
|
||||||
- add bcache-export-cached to export CACHED_UUID and CACHED_LABEL,so that 69-bcache.rules
|
|
||||||
udev rules can correctly create uuid and label links for bcache devices
|
|
||||||
|
|
||||||
* Tue Mar 7 2023 Weifeng Su <suweifeng1@huawei.com> - 1.1-3
|
|
||||||
- add safe compilation options PIE/pie/PIC/FS
|
|
||||||
|
|
||||||
* Mon Sep 6 2021 caodongxia <caodongxia@huawei.com> - 1.1-2
|
|
||||||
- add safe compilation options fstack-protector-strong
|
|
||||||
|
|
||||||
* Mon Jan 6 2020 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 1.1-1
|
|
||||||
- init bcache-tools v1.1
|
- init bcache-tools v1.1
|
||||||
|
|||||||
@ -1,4 +0,0 @@
|
|||||||
version_control: git
|
|
||||||
src_repo: https://git.kernel.org/pub/scm/linux/kernel/git/colyli/bcache-tools.git
|
|
||||||
tag_prefix: "bcache-tools-"
|
|
||||||
seperator: "."
|
|
||||||
Loading…
x
Reference in New Issue
Block a user