]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Fix resolution of nested DM devices for cgroups
authorBenjamin Berg <bberg@redhat.com>
Thu, 5 Mar 2020 10:35:45 +0000 (11:35 +0100)
committerChris Down <chris@chrisdown.name>
Fri, 6 Mar 2020 16:11:44 +0000 (16:11 +0000)
When using the cgroups IO controller, the device that is controlled
should always be the toplevel block device. This did not get resolved
correctly for an LVM volume inside a LUKS device, because the code would
only resolve one level of indirection.

Fix this by recursively looking up the originating block device for DM
devices.

Resolves: #15008

src/core/cgroup.c

index 89fa97cb603bd972154045672e689071c9db5a96..ddd3f408174482f97c17d56261c204f5ada7883e 100644 (file)
@@ -678,8 +678,8 @@ static int lookup_block_device(const char *p, dev_t *ret) {
                         return log_warning_errno(r, "Failed to determine block device backing btrfs file system '%s': %m", p);
         }
 
-        /* If this is a LUKS device, try to get the originating block device */
-        (void) block_get_originating(*ret, ret);
+        /* If this is a LUKS/DM device, recursively try to get the originating block device */
+        while (block_get_originating(*ret, ret) > 0);
 
         /* If this is a partition, try to get the originating block device */
         (void) block_get_whole_disk(*ret, ret);