]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
reread-partition-table: trigger change events when we failed to lock device
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 6 Nov 2025 15:35:34 +0000 (00:35 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 7 Nov 2025 07:35:44 +0000 (16:35 +0900)
Before aa47d8ade18cc4a079fef5a1aaa37d763507104e, when we failed to lock
the device node, we simply trigger change events for the device and its
partitions. But the commit killed the fallback logic. Let's restore that.

Fixes #39544.

src/shared/reread-partition-table.c

index 3cf54b9f688d3c913e3d94b1a1162122710f8f34..9f9fa7d94cebee75daa8fe12d4ab0399eaf3d8c9 100644 (file)
@@ -259,8 +259,16 @@ static int reread_partition_table_full(sd_device *dev, int fd, RereadPartitionTa
                 if (lock_fd < 0)
                         return log_device_debug_errno(dev, lock_fd, "Failed top open lock fd for block device '%s': %m", p);
 
-                if (flock(lock_fd, LOCK_EX|LOCK_NB) < 0)
-                        return log_device_debug_errno(dev, errno, "Failed to take BSD lock on block device '%s': %m", p);
+                if (flock(lock_fd, LOCK_EX|LOCK_NB) < 0) {
+                        r = log_device_debug_errno(dev, errno, "Failed to take BSD lock on block device '%s': %m", p);
+
+                        if (r == -EBUSY && FLAGS_SET(flags, REREADPT_FORCE_UEVENT)) {
+                                log_device_debug(dev, "Giving up rereading partition table of '%s'. Triggering change events for the device and its partitions.", p);
+                                (void) trigger_partitions(dev, /* blkrrpart_success= */ false);
+                        }
+
+                        return r;
+                }
         }
 
         r = blockdev_partscan_enabled(dev);