mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-02 22:42:30 +03:00
libdm: improve parallel create of control node
When two parallel commands would have tried to create our /dev/mapper/control node at the same time, one of them could actually fail even if the 2nd. command actually mknod() this control node correctly. So for EEXIST case add detection if the control node is ok. This may possibly help with some race case in early boot.
This commit is contained in:
parent
cf0dc9a13c
commit
7e14835a46
@ -312,8 +312,13 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
|
||||
old_umask = umask(DM_CONTROL_NODE_UMASK);
|
||||
if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR,
|
||||
MKDEV(major, minor)) < 0) {
|
||||
log_sys_error("mknod", control);
|
||||
ret = 0;
|
||||
if (errno != EEXIST) {
|
||||
log_sys_error("mknod", control);
|
||||
ret = 0;
|
||||
} else if (_control_exists(control, major, minor) != 1) {
|
||||
stack; /* Invalid control node created by parallel command ? */
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
umask(old_umask);
|
||||
(void) dm_prepare_selinux_context(NULL, 0);
|
||||
|
@ -311,8 +311,13 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
|
||||
old_umask = umask(DM_CONTROL_NODE_UMASK);
|
||||
if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR,
|
||||
MKDEV(major, minor)) < 0) {
|
||||
log_sys_error("mknod", control);
|
||||
ret = 0;
|
||||
if (errno != EEXIST) {
|
||||
log_sys_error("mknod", control);
|
||||
ret = 0;
|
||||
} else if (_control_exists(control, major, minor) != 1) {
|
||||
stack; /* Invalid control node created by parallel command ? */
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
umask(old_umask);
|
||||
(void) dm_prepare_selinux_context(NULL, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user