From d8e38d4aaac23cb27cc7e0f410449c3a6034db4f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 7 Nov 2025 00:35:34 +0900 Subject: [PATCH] reread-partition-table: trigger change events when we failed to lock device 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/shared/reread-partition-table.c b/src/shared/reread-partition-table.c index 3cf54b9f68..9f9fa7d94c 100644 --- a/src/shared/reread-partition-table.c +++ b/src/shared/reread-partition-table.c @@ -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);