From: Yu Watanabe Date: Fri, 31 Oct 2025 14:03:14 +0000 (+0900) Subject: reread-partition-table: take exclusive lock when requested X-Git-Tag: v259-rc1~208 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9011b1cfc03bf85c7e1d66a1e489ee3c71fa90a9;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/reread-partition-table.c b/src/shared/reread-partition-table.c index 78f07598275..44eca43a68d 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); }