Merge ~ddstreet/ubuntu/+source/systemd:lp1838329-ucd-g into ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-groovy

Proposed by Dan Streetman on 2020-07-07
Status: Merged
Merge reported by: Balint Reczey
Merged at revision: 6ff7e1127305c033e87e7b93f69b7ba49755fccf
Proposed branch: ~ddstreet/ubuntu/+source/systemd:lp1838329-ucd-g
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-groovy
Diff against target: 330 lines (+278/-0)
8 files modified
debian/changelog (+15/-0)
debian/patches/lp1838329/0001-blockdev-propagate-one-more-unexpected-error.patch (+23/-0)
debian/patches/lp1838329/0003-dissect-use-log_debug_errno-where-appropriate.patch (+33/-0)
debian/patches/lp1838329/0004-blockdev-add-helper-for-locking-whole-block-device.patch (+60/-0)
debian/patches/lp1838329/0005-makefs-lock-device-while-we-operate.patch (+57/-0)
debian/patches/lp1838329/0006-makefs-normalize-logging-a-bit.patch (+39/-0)
debian/patches/lp1838329/0007-cryptsetup-generator-use-systemd-makefs-for-implemen.patch (+45/-0)
debian/patches/series (+6/-0)
Reviewer Review Type Date Requested Status
Balint Reczey 2020-07-07 Approve on 2020-07-12
Review via email: mp+386957@code.launchpad.net
To post a comment you must log in.
Balint Reczey (rbalint) wrote :

Thanks for collecting the patches.
I'll give a try to 246-rc1 early next week and if that does not have blocking regressions I'll upload that instead, but more likely these patches will land in next upload without the rest of rc1.

review: Approve

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 87d0508..5dd7192 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,18 @@
6+systemd (245.6-2ubuntu2) UNRELEASED; urgency=medium
7+
8+ * Lock swap blockdevice while calling mkswap
9+ (LP: #1838329)
10+ Files:
11+ - d/p/lp1838329/0001-blockdev-propagate-one-more-unexpected-error.patch
12+ - d/p/lp1838329/0003-dissect-use-log_debug_errno-where-appropriate.patch
13+ - d/p/lp1838329/0004-blockdev-add-helper-for-locking-whole-block-device.patch
14+ - d/p/lp1838329/0005-makefs-lock-device-while-we-operate.patch
15+ - d/p/lp1838329/0006-makefs-normalize-logging-a-bit.patch
16+ - d/p/lp1838329/0007-cryptsetup-generator-use-systemd-makefs-for-implemen.patch
17+ https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=249e18ebbadce66b7e33066060f4628ff7a3a10b
18+
19+ -- Dan Streetman <ddstreet@canonical.com> Mon, 06 Jul 2020 18:04:00 -0400
20+
21 systemd (245.6-2ubuntu1) groovy; urgency=medium
22
23 * Merge to Ubuntu from Debian unstable
24diff --git a/debian/patches/lp1838329/0001-blockdev-propagate-one-more-unexpected-error.patch b/debian/patches/lp1838329/0001-blockdev-propagate-one-more-unexpected-error.patch
25new file mode 100644
26index 0000000..ba3e8b8
27--- /dev/null
28+++ b/debian/patches/lp1838329/0001-blockdev-propagate-one-more-unexpected-error.patch
29@@ -0,0 +1,23 @@
30+From 6cba41ab0dbe5eb817f37bd43caff4754d801d3b Mon Sep 17 00:00:00 2001
31+From: Lennart Poettering <lennart@poettering.net>
32+Date: Mon, 18 May 2020 18:29:57 +0200
33+Subject: [PATCH 1/7] blockdev: propagate one more unexpected error
34+Bug: https://github.com/systemd/systemd/issues/10179
35+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1838329
36+Origin: upstream, https://github.com/systemd/systemd/pull/15836
37+
38+---
39+ src/basic/blockdev-util.c | 2 ++
40+ 1 file changed, 2 insertions(+)
41+
42+--- a/src/basic/blockdev-util.c
43++++ b/src/basic/blockdev-util.c
44+@@ -78,6 +78,8 @@ int get_block_device(const char *path, d
45+ *ret = st.st_dev;
46+ return 1;
47+ }
48++ if (errno != ENOENT)
49++ return -errno;
50+
51+ r = btrfs_get_block_device_fd(fd, ret);
52+ if (r > 0)
53diff --git a/debian/patches/lp1838329/0003-dissect-use-log_debug_errno-where-appropriate.patch b/debian/patches/lp1838329/0003-dissect-use-log_debug_errno-where-appropriate.patch
54new file mode 100644
55index 0000000..37686a4
56--- /dev/null
57+++ b/debian/patches/lp1838329/0003-dissect-use-log_debug_errno-where-appropriate.patch
58@@ -0,0 +1,33 @@
59+From 58dfbfbdd6138de49c6f59a763c4cfc7acb8c9a9 Mon Sep 17 00:00:00 2001
60+From: Lennart Poettering <lennart@poettering.net>
61+Date: Mon, 18 May 2020 18:30:49 +0200
62+Subject: [PATCH 3/7] dissect: use log_debug_errno() where appropriate
63+Bug: https://github.com/systemd/systemd/issues/10179
64+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1838329
65+Origin: upstream, https://github.com/systemd/systemd/pull/15836
66+
67+---
68+ src/shared/dissect-image.c | 7 +++----
69+ 1 file changed, 3 insertions(+), 4 deletions(-)
70+
71+diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
72+index 23ad6b06cf..8decac94b2 100644
73+--- a/src/shared/dissect-image.c
74++++ b/src/shared/dissect-image.c
75+@@ -75,10 +75,9 @@ int probe_filesystem(const char *node, char **ret_fstype) {
76+ log_debug("No type detected on partition %s", node);
77+ goto not_found;
78+ }
79+- if (r == -2) {
80+- log_debug("Results ambiguous for partition %s", node);
81+- return -EUCLEAN;
82+- }
83++ if (r == -2)
84++ return log_debug_errno(SYNTHETIC_ERRNO(EUCLEAN),
85++ "Results ambiguous for partition %s", node);
86+ if (r != 0)
87+ return errno_or_else(EIO);
88+
89+--
90+2.25.1
91+
92diff --git a/debian/patches/lp1838329/0004-blockdev-add-helper-for-locking-whole-block-device.patch b/debian/patches/lp1838329/0004-blockdev-add-helper-for-locking-whole-block-device.patch
93new file mode 100644
94index 0000000..59aa74e
95--- /dev/null
96+++ b/debian/patches/lp1838329/0004-blockdev-add-helper-for-locking-whole-block-device.patch
97@@ -0,0 +1,60 @@
98+From ac83e5aeca7ca4eff3de6ef6d9a55b71b6eb10b1 Mon Sep 17 00:00:00 2001
99+From: Lennart Poettering <lennart@poettering.net>
100+Date: Mon, 18 May 2020 18:31:04 +0200
101+Subject: [PATCH 4/7] blockdev: add helper for locking whole block device
102+Bug: https://github.com/systemd/systemd/issues/10179
103+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1838329
104+Origin: upstream, https://github.com/systemd/systemd/pull/15836
105+
106+---
107+ src/basic/blockdev-util.c | 27 +++++++++++++++++++++++++++
108+ src/basic/blockdev-util.h | 2 ++
109+ 2 files changed, 29 insertions(+)
110+
111+--- a/src/basic/blockdev-util.c
112++++ b/src/basic/blockdev-util.c
113+@@ -1,5 +1,6 @@
114+ /* SPDX-License-Identifier: LGPL-2.1+ */
115+
116++#include <sys/file.h>
117+ #include <unistd.h>
118+
119+ #include "alloc-util.h"
120+@@ -189,3 +190,29 @@ int get_block_device_harder(const char *
121+
122+ return 1;
123+ }
124++
125++int lock_whole_block_device(dev_t devt, int operation) {
126++ _cleanup_free_ char *whole_node = NULL;
127++ _cleanup_close_ int lock_fd = -1;
128++ dev_t whole_devt;
129++ int r;
130++
131++ /* Let's get a BSD file lock on the whole block device, as per: https://systemd.io/BLOCK_DEVICE_LOCKING */
132++
133++ r = block_get_whole_disk(devt, &whole_devt);
134++ if (r < 0)
135++ return r;
136++
137++ r = device_path_make_major_minor(S_IFBLK, whole_devt, &whole_node);
138++ if (r < 0)
139++ return r;
140++
141++ lock_fd = open(whole_node, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
142++ if (lock_fd < 0)
143++ return -errno;
144++
145++ if (flock(lock_fd, operation) < 0)
146++ return -errno;
147++
148++ return TAKE_FD(lock_fd);
149++}
150+--- a/src/basic/blockdev-util.h
151++++ b/src/basic/blockdev-util.h
152+@@ -18,3 +18,5 @@ int block_get_originating(dev_t d, dev_t
153+ int get_block_device(const char *path, dev_t *dev);
154+
155+ int get_block_device_harder(const char *path, dev_t *dev);
156++
157++int lock_whole_block_device(dev_t devt, int operation);
158diff --git a/debian/patches/lp1838329/0005-makefs-lock-device-while-we-operate.patch b/debian/patches/lp1838329/0005-makefs-lock-device-while-we-operate.patch
159new file mode 100644
160index 0000000..5bffde5
161--- /dev/null
162+++ b/debian/patches/lp1838329/0005-makefs-lock-device-while-we-operate.patch
163@@ -0,0 +1,57 @@
164+From 0181ad85b37d37785787b4eb8aa8c72d2e4c76b4 Mon Sep 17 00:00:00 2001
165+From: Lennart Poettering <lennart@poettering.net>
166+Date: Mon, 18 May 2020 18:31:45 +0200
167+Subject: [PATCH 5/7] makefs: lock device while we operate
168+Bug: https://github.com/systemd/systemd/issues/10179
169+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1838329
170+Origin: upstream, https://github.com/systemd/systemd/pull/15836
171+
172+Let's implement our own specs, i.e.
173+
174+https://systemd.io/BLOCK_DEVICE_LOCKING/
175+
176+This should address issues like this: #13162
177+---
178+ src/partition/makefs.c | 11 ++++++++++-
179+ 1 file changed, 10 insertions(+), 1 deletion(-)
180+
181+diff --git a/src/partition/makefs.c b/src/partition/makefs.c
182+index df08a5fea6..128aa41044 100644
183+--- a/src/partition/makefs.c
184++++ b/src/partition/makefs.c
185+@@ -7,7 +7,9 @@
186+ #include <unistd.h>
187+
188+ #include "alloc-util.h"
189++#include "blockdev-util.h"
190+ #include "dissect-image.h"
191++#include "fd-util.h"
192+ #include "main-func.h"
193+ #include "process-util.h"
194+ #include "signal-util.h"
195+@@ -42,6 +44,7 @@ static int makefs(const char *type, const char *device) {
196+
197+ static int run(int argc, char *argv[]) {
198+ _cleanup_free_ char *device = NULL, *type = NULL, *detected = NULL;
199++ _cleanup_close_ int lock_fd = -1;
200+ struct stat st;
201+ int r;
202+
203+@@ -63,7 +66,13 @@ static int run(int argc, char *argv[]) {
204+ if (stat(device, &st) < 0)
205+ return log_error_errno(errno, "Failed to stat \"%s\": %m", device);
206+
207+- if (!S_ISBLK(st.st_mode))
208++ if (S_ISBLK(st.st_mode)) {
209++ /* Lock the device so that udev doesn't interfere with our work */
210++
211++ lock_fd = lock_whole_block_device(st.st_rdev, LOCK_EX);
212++ if (lock_fd < 0)
213++ return log_error_errno(lock_fd, "Failed to lock whole block device of \"%s\": %m", device);
214++ } else
215+ log_info("%s is not a block device.", device);
216+
217+ r = probe_filesystem(device, &detected);
218+--
219+2.25.1
220+
221diff --git a/debian/patches/lp1838329/0006-makefs-normalize-logging-a-bit.patch b/debian/patches/lp1838329/0006-makefs-normalize-logging-a-bit.patch
222new file mode 100644
223index 0000000..bdb8bcc
224--- /dev/null
225+++ b/debian/patches/lp1838329/0006-makefs-normalize-logging-a-bit.patch
226@@ -0,0 +1,39 @@
227+From a5a8fe2e8dbb9bc1981064d273b626d4aa187152 Mon Sep 17 00:00:00 2001
228+From: Lennart Poettering <lennart@poettering.net>
229+Date: Mon, 18 May 2020 18:32:17 +0200
230+Subject: [PATCH 6/7] makefs: normalize logging a bit
231+Bug: https://github.com/systemd/systemd/issues/10179
232+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1838329
233+Origin: upstream, https://github.com/systemd/systemd/pull/15836
234+
235+---
236+ src/partition/makefs.c | 11 ++++-------
237+ 1 file changed, 4 insertions(+), 7 deletions(-)
238+
239+diff --git a/src/partition/makefs.c b/src/partition/makefs.c
240+index 128aa41044..97f50c9033 100644
241+--- a/src/partition/makefs.c
242++++ b/src/partition/makefs.c
243+@@ -76,15 +76,12 @@ static int run(int argc, char *argv[]) {
244+ log_info("%s is not a block device.", device);
245+
246+ r = probe_filesystem(device, &detected);
247++ if (r == -EUCLEAN)
248++ return log_error_errno(r, "Ambiguous results of probing for file system on \"%s\", refusing to proceed.", device);
249+ if (r < 0)
250+- return log_warning_errno(r,
251+- r == -EUCLEAN ?
252+- "Cannot reliably determine probe \"%s\", refusing to proceed." :
253+- "Failed to probe \"%s\": %m",
254+- device);
255+-
256++ return log_error_errno(r, "Failed to probe \"%s\": %m", device);
257+ if (detected) {
258+- log_info("%s is not empty (type %s), exiting", device, detected);
259++ log_info("'%s' is not empty (contains file system of type %s), exiting.", device, detected);
260+ return 0;
261+ }
262+
263+--
264+2.25.1
265+
266diff --git a/debian/patches/lp1838329/0007-cryptsetup-generator-use-systemd-makefs-for-implemen.patch b/debian/patches/lp1838329/0007-cryptsetup-generator-use-systemd-makefs-for-implemen.patch
267new file mode 100644
268index 0000000..6707978
269--- /dev/null
270+++ b/debian/patches/lp1838329/0007-cryptsetup-generator-use-systemd-makefs-for-implemen.patch
271@@ -0,0 +1,45 @@
272+From db2c56b0dd28f271dd3fe53691b21484f72586e4 Mon Sep 17 00:00:00 2001
273+From: Lennart Poettering <lennart@poettering.net>
274+Date: Mon, 18 May 2020 18:37:02 +0200
275+Subject: [PATCH 7/7] cryptsetup-generator: use systemd-makefs for
276+ implementation of "swap" and "tmp" options
277+Bug: https://github.com/systemd/systemd/issues/10179
278+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1838329
279+Origin: upstream, https://github.com/systemd/systemd/pull/15836
280+
281+This way we can take benefit of the correct block device locking we just
282+added.
283+
284+I was thinking whether to instead pull in a regular
285+systemd-makefs@.service instance, but I couldn't come up with a reason
286+to, and thus opted for just doing the minimal patch and just replacing
287+the simply mkfs calls.
288+
289+Fixes: #10179
290+Replaces: #13162
291+---
292+ src/cryptsetup/cryptsetup-generator.c | 4 ++--
293+ 1 file changed, 2 insertions(+), 2 deletions(-)
294+
295+diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
296+index 20c752d88d..5724f88d0a 100644
297+--- a/src/cryptsetup/cryptsetup-generator.c
298++++ b/src/cryptsetup/cryptsetup-generator.c
299+@@ -367,12 +367,12 @@ static int create_disk(
300+
301+ if (tmp)
302+ fprintf(f,
303+- "ExecStartPost=/sbin/mke2fs '/dev/mapper/%s'\n",
304++ "ExecStartPost=" ROOTLIBEXECDIR "/systemd-makefs ext2 '/dev/mapper/%s'\n",
305+ name_escaped);
306+
307+ if (swap)
308+ fprintf(f,
309+- "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
310++ "ExecStartPost=" ROOTLIBEXECDIR "/systemd-makefs swap '/dev/mapper/%s'\n",
311+ name_escaped);
312+
313+ if (keydev)
314+--
315+2.25.1
316+
317diff --git a/debian/patches/series b/debian/patches/series
318index 1f6c3d2..c071be5 100644
319--- a/debian/patches/series
320+++ b/debian/patches/series
321@@ -78,3 +78,9 @@ lp1875708/journald-rework-pid-change-handling.patch
322 lp1875708/test-Add-a-test-case-for-15654.patch
323 lp1875708/man-document-the-new-_LINE_BREAK-type.patch
324 lp1861941-dont-generate-disk-byuuid-for-bcache-uuid.patch
325+lp1838329/0001-blockdev-propagate-one-more-unexpected-error.patch
326+lp1838329/0003-dissect-use-log_debug_errno-where-appropriate.patch
327+lp1838329/0004-blockdev-add-helper-for-locking-whole-block-device.patch
328+lp1838329/0005-makefs-lock-device-while-we-operate.patch
329+lp1838329/0006-makefs-normalize-logging-a-bit.patch
330+lp1838329/0007-cryptsetup-generator-use-systemd-makefs-for-implemen.patch

Subscribers

People subscribed via source and target branches