mirror of
https://github.com/systemd/systemd.git
synced 2025-01-27 18:04:05 +03:00
udevd: serialize events for with the same major/minor
On Wed, Oct 7, 2009 at 21:46, Alan Jenkins <sourcejedi.lkml@googlemail.com> wrote: > Udev would have avoided the race prior to > > 82c785e "udevd: remove check for dev_t, DEVPATH_OLD takes care of that" > > (the "check" removed here used to serialize events based on the device > major:minor number). On Wed, Oct 7, 2009 at 22:31, Michael Guntsche <mike@it-loops.com> wrote: > add /module/8250_pnp (module) > remove /devices/platform/serial8250/tty/ttyS0 (tty) > add /devices/pnp0/00:05/tty/ttyS0 (tty)
This commit is contained in:
parent
a05cd7ea3e
commit
19711e1933
31
udev/udevd.c
31
udev/udevd.c
@ -118,6 +118,8 @@ struct event {
|
|||||||
const char *devpath;
|
const char *devpath;
|
||||||
size_t devpath_len;
|
size_t devpath_len;
|
||||||
const char *devpath_old;
|
const char *devpath_old;
|
||||||
|
dev_t devnum;
|
||||||
|
bool is_block;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct event *node_to_event(struct udev_list_node *node)
|
static struct event *node_to_event(struct udev_list_node *node)
|
||||||
@ -410,6 +412,8 @@ static void event_queue_insert(struct udev_device *dev)
|
|||||||
event->devpath = udev_device_get_devpath(dev);
|
event->devpath = udev_device_get_devpath(dev);
|
||||||
event->devpath_len = strlen(event->devpath);
|
event->devpath_len = strlen(event->devpath);
|
||||||
event->devpath_old = udev_device_get_devpath_old(dev);
|
event->devpath_old = udev_device_get_devpath_old(dev);
|
||||||
|
event->devnum = udev_device_get_devnum(dev);
|
||||||
|
event->is_block = (strcmp("block", udev_device_get_subsystem(dev)) == 0);
|
||||||
|
|
||||||
udev_queue_export_device_queued(udev_queue_export, dev);
|
udev_queue_export_device_queued(udev_queue_export, dev);
|
||||||
info(event->udev, "seq %llu queued, '%s' '%s'\n", udev_device_get_seqnum(dev),
|
info(event->udev, "seq %llu queued, '%s' '%s'\n", udev_device_get_seqnum(dev),
|
||||||
@ -473,7 +477,7 @@ static int mem_size_mb(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* lookup event for identical, parent, child device */
|
/* lookup event for identical, parent, child device */
|
||||||
static int devpath_busy(struct event *event)
|
static bool is_devpath_busy(struct event *event)
|
||||||
{
|
{
|
||||||
struct udev_list_node *loop;
|
struct udev_list_node *loop;
|
||||||
size_t common;
|
size_t common;
|
||||||
@ -488,18 +492,21 @@ static int devpath_busy(struct event *event)
|
|||||||
|
|
||||||
/* event we checked earlier still exists, no need to check again */
|
/* event we checked earlier still exists, no need to check again */
|
||||||
if (loop_event->seqnum == event->delaying_seqnum)
|
if (loop_event->seqnum == event->delaying_seqnum)
|
||||||
return 2;
|
return true;
|
||||||
|
|
||||||
/* found ourself, no later event can block us */
|
/* found ourself, no later event can block us */
|
||||||
if (loop_event->seqnum >= event->seqnum)
|
if (loop_event->seqnum >= event->seqnum)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* check major/minor */
|
||||||
|
if (major(event->devnum) != 0 && event->devnum == loop_event->devnum && event->is_block == loop_event->is_block)
|
||||||
|
return true;
|
||||||
|
|
||||||
/* check our old name */
|
/* check our old name */
|
||||||
if (event->devpath_old != NULL)
|
if (event->devpath_old != NULL && strcmp(loop_event->devpath, event->devpath_old) == 0) {
|
||||||
if (strcmp(loop_event->devpath, event->devpath_old) == 0) {
|
event->delaying_seqnum = loop_event->seqnum;
|
||||||
event->delaying_seqnum = loop_event->seqnum;
|
return true;
|
||||||
return 3;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* compare devpath */
|
/* compare devpath */
|
||||||
common = MIN(loop_event->devpath_len, event->devpath_len);
|
common = MIN(loop_event->devpath_len, event->devpath_len);
|
||||||
@ -511,26 +518,26 @@ static int devpath_busy(struct event *event)
|
|||||||
/* identical device event found */
|
/* identical device event found */
|
||||||
if (loop_event->devpath_len == event->devpath_len) {
|
if (loop_event->devpath_len == event->devpath_len) {
|
||||||
event->delaying_seqnum = loop_event->seqnum;
|
event->delaying_seqnum = loop_event->seqnum;
|
||||||
return 4;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parent device event found */
|
/* parent device event found */
|
||||||
if (event->devpath[common] == '/') {
|
if (event->devpath[common] == '/') {
|
||||||
event->delaying_seqnum = loop_event->seqnum;
|
event->delaying_seqnum = loop_event->seqnum;
|
||||||
return 5;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* child device event found */
|
/* child device event found */
|
||||||
if (loop_event->devpath[common] == '/') {
|
if (loop_event->devpath[common] == '/') {
|
||||||
event->delaying_seqnum = loop_event->seqnum;
|
event->delaying_seqnum = loop_event->seqnum;
|
||||||
return 6;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no matching device */
|
/* no matching device */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void events_start(struct udev *udev)
|
static void events_start(struct udev *udev)
|
||||||
@ -544,7 +551,7 @@ static void events_start(struct udev *udev)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* do not start event if parent or child event is still running */
|
/* do not start event if parent or child event is still running */
|
||||||
if (devpath_busy(event) != 0) {
|
if (is_devpath_busy(event)) {
|
||||||
dbg(udev, "delay seq %llu (%s)\n", event->seqnum, event->devpath);
|
dbg(udev, "delay seq %llu (%s)\n", event->seqnum, event->devpath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user