From 9011b1cfc03bf85c7e1d66a1e489ee3c71fa90a9 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 31 Oct 2025 23:03:14 +0900 Subject: [PATCH] reread-partition-table: take exclusive lock when requested Before aa47d8ade18cc4a079fef5a1aaa37d763507104e, we took an exclusive lock for the whole block device, but with the commit, a shared lock is taken. That causes, during we requesting the kernel to reread partition table, udev workers can process the block device or its partitions. Let's make udev workers not process block devices during rereading partition table again. Follow-up for aa47d8ade18cc4a079fef5a1aaa37d763507104e. --- src/shared/reread-partition-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/reread-partition-table.c b/src/shared/reread-partition-table.c index 78f0759827..44eca43a68 100644 --- a/src/shared/reread-partition-table.c +++ b/src/shared/reread-partition-table.c @@ -259,7 +259,7 @@ static int reread_partition_table_full(sd_device *dev, int fd, RereadPartitionTa if (lock_fd < 0) return log_device_debug_errno(dev, r, "Failed top open lock fd for block device '%s': %m", p); - if (flock(lock_fd, LOCK_SH|LOCK_NB) < 0) + 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); }