Merge ~rafaeldtinoco/ubuntu/+source/bcache-tools:lp1861941-bionic into ubuntu/+source/bcache-tools:ubuntu/bionic-devel

Proposed by Rafael David Tinoco
Status: Merged
Approved by: Rafael David Tinoco
Approved revision: 04bb61a2b38d946689c444da74af6dffe2f72141
Merged at revision: bceab9b6db33158d3204616beb28e434a150c557
Proposed branch: ~rafaeldtinoco/ubuntu/+source/bcache-tools:lp1861941-bionic
Merge into: ubuntu/+source/bcache-tools:ubuntu/bionic-devel
Diff against target: 154 lines (+115/-2)
4 files modified
debian/changelog (+7/-0)
debian/control (+3/-2)
debian/patches/0003-Add-bcache-export-cached-helper.patch (+104/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Core Reviewers Pending
Canonical Server Pending
Review via email: mp+388774@code.launchpad.net

Commit message

SUMMARY:

BUG: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1861941
TESTCASE: https://paste.ubuntu.com/p/37KGy2Smnp/
PPA: https://launchpad.net/~rafaeldtinoco/+archive/ubuntu/lp1861941

BCACHE-TOOLS:

GROOVY: https://tinyurl.com/yxonp5hz (merged)
FOCAL: https://tinyurl.com/y3tbd3un (committed + verified)
BIONIC: THIS ONE

SYSTEMD-UDEV:

GROOVY: https://tinyurl.com/y4w22s57 (merged patch rewording, will wait next upload)
FOCAL: https://tinyurl.com/y2uqbyll (merged patch, will ask for an upload - SRU)
BIONIC: BEING WORKED

KERNEL:

Decided that won't be changed as the udev bcache changes won't cause any harm. Will ask for the patch to be dropped from groovy's kernel since there isn't any need to keep it.

To post a comment you must log in.
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

Subscribed @paelzer directly as he was the one to review merges for Groovy and Focal. Bionic time has arrived =).

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

I've got to be honest here.. bionic is affected ** in theory ** .. but I could *not* reproduce the same issue in Bionic using 18.04 kernel or the HWE one.

(k)rafaeldtinoco@bcachebionic:~/scripts$ dpkg-query -f '${Package}###${Version}\n' -W 'bcache-tools'
bcache-tools###1.0.8-2ubuntu0.1~ppa1

I could, though, make sure that the reproducer works and there are no regressions:

(k)rafaeldtinoco@bcachebionic:~/scripts$ sudo ./test-bcache.sh
/mnt is a mountpoint
/dev/bcache0: 2 bytes were erased at offset 0x00000438 (ext4): 53 ef
writing 1 to /sys/class/block/bcache0/bcache/stop
writing 1 to /sys/fs/bcache/d959d8c4-d6ba-4798-b145-f3f2b8137d88/stop
/dev/vdc: 16 bytes were erased at offset 0x00001018 (bcache): c6 85 73 f6 4e 1a 45 ca 82 65 f5 7f 48 ba 6d 81

...

mounting bcache0 to /mnt
total 0
drwxr-xr-x 2 root root 60 Aug 5 21:30 .
drwxr-xr-x 3 root root 60 Aug 5 21:30 ..
lrwxrwxrwx 1 root root 13 Aug 5 21:30 70f53747-cc4b-427d-8300-f6ae3ff5c41e -> ../../bcache0
Everything OK

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

So, after this change getting accepted for Groovy and Focal, I really would like not to rely in kernel patches for bcache CACHED uuid events. This method (being SRUed here) is the most correct and effective way, and proved to be racy-less when other devices trigger udevs).

Please share your thoughts.

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

I have updated the case with SRU notes and added a specific note for [Test Case] saying that the issue is not reproducible in Bionic but it would be better for all supported versions to have the same "bcached" environment feed: the wrapper reading superblock of the bcache devices.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

LGTM - changes are as discussed and match.
I have tried to force it as well but couldn't - I thought my setup is bad but I've read it was the same for you.

Never the less for an issue like this (racy by nature) I too agree that I'd prefer to have the fix in Bionic despite not being able to perfectly reproduce it there.

What I wondered - can we show that the new code works correctly on Bionic by modifying the script that is placed to do something else - then show the issues (this confirms it is executed as expected). Then restore the correct content of the script and trigger things again - show the resulting by-uuid links.

+1 - doing the modified test I suggested is up to you

review: Approve
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

I tried some changes to mock the issue... but they made the thing so artificial that I think its better just to leave as it is. I'm confident that wrapper script is a better approach for symlink creation - than the actual - with or without the bug.

Thanks for reviewing this for me @paelzer.

LOGs:

$ debdiff ./*.dsc 2>&1 | grep -v gpg| diffstat
 changelog | 7 ++
 control | 5 +-
 patches/0003-Add-bcache-export-cached-helper.patch | 104 ++++++++++++++++++++++++++++++++++++++++++
 patches/series | 1
 4 files changed, 115 insertions(+), 2 deletions(-)

(c)rafaeldtinoco@bionic:~/.../sources/ubuntu/bcache-tools$ git ubuntu tag --upload

(c)rafaeldtinoco@bionic:~/.../sources/ubuntu/bcache-tools$ git describe --tags
upload/1.0.8-2ubuntu0.1

(c)rafaeldtinoco@bionic:~/.../sources/ubuntu/bcache-tools$ git push pkg upload/1.0.8-2ubuntu0.1
Counting objects: 16, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (16/16), 3.51 KiB | 1.17 MiB/s, done.
Total 16 (delta 11), reused 0 (delta 0)
remote: Checking connectivity: 16, done.
To ssh://git.launchpad.net/ubuntu/+source/bcache-tools
 * [new tag] upload/1.0.8-2ubuntu0.1 -> upload/1.0.8-2ubuntu0.1

(c)rafaeldtinoco@bionic:~/work/sources/ubuntu$ dput ubuntu bcache-tools_1.0.8-2ubuntu0.1_source.changes
Checking signature on .changes
gpg: /home/rafaeldtinoco/work/sources/ubuntu/bcache-tools_1.0.8-2ubuntu0.1_source.changes: Valid signature from A93E0E0AD83C0D0F
Checking signature on .dsc
gpg: /home/rafaeldtinoco/work/sources/ubuntu/bcache-tools_1.0.8-2ubuntu0.1.dsc: Valid signature from A93E0E0AD83C0D0F
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading bcache-tools_1.0.8-2ubuntu0.1.dsc: done.
  Uploading bcache-tools_1.0.8-2ubuntu0.1.debian.tar.xz: done.
  Uploading bcache-tools_1.0.8-2ubuntu0.1_source.buildinfo: done.
  Uploading bcache-tools_1.0.8-2ubuntu0.1_source.changes: done.
Successfully uploaded packages.

Revision history for this message
Ryan Harper (raharper) wrote :

> saying that the issue is not reproducible in Bionic

ISTR that Bionic rootfs with GA kernel or even -updates kernel
was not easily reproduced. However, I did observe issues with -hwe
and edge kernels over bionic rootfs.

The difficulty in producing on bionic/ga originally lead me to look
at the kernel for a potential regression; we've been running without
this change on bionic for quite sometime without issues. With focal
and bionic running focal kernel (-hwe) that's where it will show up.

FWIW, I'm +1 on getting the user-space tools in bionic since they provide
the rules and can handle a newer kernel which the issue may be more easily
reproduced.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 77cb821..cf755d7 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+bcache-tools (1.0.8-2ubuntu0.18.04.1) bionic; urgency=medium
7+
8+ [ Ryan Harper ]
9+ * Add helper script to read bcache devs superblock (LP: #1861941)
10+
11+ -- Rafael David Tinoco <rafaeldtinoco@ubuntu.com> Wed, 05 Aug 2020 17:44:05 -0300
12+
13 bcache-tools (1.0.8-2build1) artful; urgency=medium
14
15 * No-change rebuild to pick up -fPIE compiler default in static
16diff --git a/debian/control b/debian/control
17index 4a138f6..4f60931 100644
18--- a/debian/control
19+++ b/debian/control
20@@ -1,5 +1,6 @@
21 Source: bcache-tools
22-Maintainer: David Mohr <david@mcbf.net>
23+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
24+XSBC-Original-Maintainer: David Mohr <david@mcbf.net>
25 Uploaders: Robie Basak <robie@justgohome.co.uk>
26 Section: utils
27 Priority: optional
28@@ -11,7 +12,7 @@ Homepage: http://bcache.evilpiepirate.org/
29
30 Package: bcache-tools
31 Architecture: linux-any
32-Depends: ${shlibs:Depends}, ${misc:Depends}
33+Depends: ${shlibs:Depends}, ${misc:Depends}, gawk
34 Recommends: initramfs-tools | linux-initramfs-tool
35 Description: bcache userspace tools
36 Bcache allows the use of SSDs to cache other block devices.
37diff --git a/debian/patches/0003-Add-bcache-export-cached-helper.patch b/debian/patches/0003-Add-bcache-export-cached-helper.patch
38new file mode 100644
39index 0000000..f24424b
40--- /dev/null
41+++ b/debian/patches/0003-Add-bcache-export-cached-helper.patch
42@@ -0,0 +1,104 @@
43+Description: Add bcache-export-cached helper to export CACHED_UUID and
44+ CACHED_LABEL always
45+
46+Linux kernel bcache driver does not always emit a uevent[1] for when a backing
47+device is bound to a bcacheN device. When this happens, the udev rule for
48+creating /dev/bcache/by-uuid or /dev/bcache/by-label symlinks does not fire and
49+removes any persistent symlink to a specific backing device since the bcache
50+minor numbers (bcache0, 1, 2) are not guaranteed across reboots.
51+
52+This script reads the superblock of the bcache device slaves, ensuring the
53+slave is a backing device via sb.version check, extracts the dev.uuid and
54+dev.label values and exports them to udev for triggering the symlink rules in
55+the existing rules file.
56+
57+1. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1729145
58+
59+Author: Ryan Harper <ryan.harper@canonical.com>
60+Bug: https://bugs.debian.org/890446
61+Bug-Ubuntu: https://launchpad.net/bugs/1861941
62+Forwarded: https://github.com/koverstreet/bcache-tools/pull/6/
63+Reviewed-By: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>
64+Last-Update: 2020-07-22
65+
66+--- a/69-bcache.rules
67++++ b/69-bcache.rules
68+@@ -23,10 +23,9 @@
69+ LABEL="bcache_backing_end"
70+
71+ # Cached devices: symlink
72+-DRIVER=="bcache", ENV{CACHED_UUID}=="?*", \
73+- SYMLINK+="bcache/by-uuid/$env{CACHED_UUID}"
74+-DRIVER=="bcache", ENV{CACHED_LABEL}=="?*", \
75+- SYMLINK+="bcache/by-label/$env{CACHED_LABEL}"
76++IMPORT{program}="bcache-export-cached $tempnode"
77++ENV{CACHED_UUID}=="?*", SYMLINK+="bcache/by-uuid/$env{CACHED_UUID}"
78++ENV{CACHED_LABEL}=="?*", SYMLINK+="bcache/by-label/$env{CACHED_LABEL}"
79+
80+ LABEL="bcache_end"
81+
82+--- a/Makefile
83++++ b/Makefile
84+@@ -9,7 +9,7 @@
85+
86+ install: make-bcache probe-bcache bcache-super-show
87+ $(INSTALL) -m0755 make-bcache bcache-super-show $(DESTDIR)${PREFIX}/sbin/
88+- $(INSTALL) -m0755 probe-bcache bcache-register $(DESTDIR)$(UDEVLIBDIR)/
89++ $(INSTALL) -m0755 probe-bcache bcache-register bcache-export-cached $(DESTDIR)$(UDEVLIBDIR)/
90+ $(INSTALL) -m0644 69-bcache.rules $(DESTDIR)$(UDEVLIBDIR)/rules.d/
91+ $(INSTALL) -m0644 -- *.8 $(DESTDIR)${PREFIX}/share/man/man8/
92+ $(INSTALL) -D -m0755 initramfs/hook $(DESTDIR)/usr/share/initramfs-tools/hooks/bcache
93+--- /dev/null
94++++ b/bcache-export-cached
95+@@ -0,0 +1,31 @@
96++#!/bin/sh
97++#
98++# This program reads the bcache superblock on bcacheX slaves to extract the
99++# dev.uuid and dev.label which refer to a specific backing device.
100++#
101++# It integrates with udev 'import' by writing CACHED_UUID=X and optionally
102++# CACHED_LABEL=X for the backing device of the provided bcache device.
103++# Ignore caching devices by skipping unless sb.version=1
104++#
105++# There is 1 and only 1 backing device (slaves/*) for a bcache device.
106++
107++TEMPNODE=${1} # /dev/bcacheN
108++DEVNAME=${TEMPNODE##*/} # /dev/bcacheN -> bcacheN
109++
110++for slave in "/sys/class/block/$DEVNAME/slaves"/*; do
111++ [ -d "$slave" ] || continue
112++ /usr/sbin/bcache-super-show "/dev/${slave##*/}" |
113++ gawk '$1 == "sb.version" { sbver=$2; }
114++ $1 == "dev.uuid" { uuid=$2; }
115++ $1 == "dev.label" && $2 != "(empty)" { label=$2; }
116++ END {
117++ if (sbver == 1 && uuid) {
118++ print("CACHED_UUID=" uuid)
119++ if (label) print("CACHED_LABEL=" label)
120++ exit(0)
121++ }
122++ exit(1);
123++ }'
124++ # gawk exits 0 if it found a backing device.
125++ [ $? -eq 0 ] && exit 0
126++done
127+--- a/initcpio/install
128++++ b/initcpio/install
129+@@ -1,6 +1,7 @@
130+ #!/bin/bash
131+ build() {
132+ add_module bcache
133++ add_binary /usr/lib/udev/bcache-export-cached
134+ add_binary /usr/lib/udev/bcache-register
135+ add_binary /usr/lib/udev/probe-bcache
136+ add_file /usr/lib/udev/rules.d/69-bcache.rules
137+--- a/initramfs/hook
138++++ b/initramfs/hook
139+@@ -22,6 +22,7 @@
140+ cp -pt "${DESTDIR}/lib/udev/rules.d" /lib/udev/rules.d/69-bcache.rules
141+ fi
142+
143++copy_exec /lib/udev/bcache-export-cached
144+ copy_exec /lib/udev/bcache-register
145+ copy_exec /lib/udev/probe-bcache
146+ manual_add_modules bcache
147diff --git a/debian/patches/series b/debian/patches/series
148index d487cf6..30402a4 100644
149--- a/debian/patches/series
150+++ b/debian/patches/series
151@@ -1,2 +1,3 @@
152 0001-Clean-should-remove-bcache-register.patch
153 0002-Don-t-inline-crc64-for-gcc-5-compatability.patch
154+0003-Add-bcache-export-cached-helper.patch

Subscribers

People subscribed via source and target branches