]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
reread-partition-table: take exclusive lock when requested
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 31 Oct 2025 14:03:14 +0000 (23:03 +0900)
committerLennart Poettering <lennart@poettering.net>
Fri, 31 Oct 2025 16:12:44 +0000 (17:12 +0100)
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

index 78f07598275a166402c40fb63625282a89add53a..44eca43a68d2ecd599ceb6651dedfa4d425c0e1b 100644 (file)
@@ -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);
         }