summaryrefslogtreecommitdiff
path: root/src/core/device.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-25 21:08:39 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-25 22:10:22 +0100
commit9670d583d381d4c2c7f4d80de63bee7ad54fef44 (patch)
tree64468a91c77e6ea65f684353e3af59d6b20313ac /src/core/device.c
parent0bee65f0622c4faa8ac8ae771cc0c8a936dfa284 (diff)
swap: always track the current real device node of all swap devices, even when not active
This way, we can avoid executing two /bin/swapon jobs to be dispatched for the same swap device if it is configured for two different paths. Previously we were just tracking the device nodes of active swap devices, which would not allow us to recognize the identity of two swap devices before they are active. https://bugs.freedesktop.org/show_bug.cgi?id=69835
Diffstat (limited to 'src/core/device.c')
-rw-r--r--src/core/device.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/core/device.c b/src/core/device.c
index 63d0302d3b..4ff7c37238 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -23,8 +23,6 @@
#include <sys/epoll.h>
#include <libudev.h>
-#include "unit.h"
-#include "device.h"
#include "strv.h"
#include "log.h"
#include "unit-name.h"
@@ -32,6 +30,9 @@
#include "def.h"
#include "path-util.h"
#include "udev-util.h"
+#include "unit.h"
+#include "swap.h"
+#include "device.h"
static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = {
[DEVICE_DEAD] = UNIT_INACTIVE,
@@ -502,11 +503,6 @@ static void device_shutdown(Manager *m) {
m->udev_monitor = NULL;
}
- if (m->udev) {
- udev_unref(m->udev);
- m->udev = NULL;
- }
-
hashmap_free(m->devices_by_sysfs);
m->devices_by_sysfs = NULL;
}
@@ -518,11 +514,7 @@ static int device_enumerate(Manager *m) {
assert(m);
- if (!m->udev) {
- m->udev = udev_new();
- if (!m->udev)
- return -ENOMEM;
-
+ if (!m->udev_monitor) {
m->udev_monitor = udev_monitor_new_from_netlink(m->udev, "udev");
if (!m->udev_monitor) {
r = -ENOMEM;
@@ -607,11 +599,20 @@ static int device_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
r = device_process_removed_device(m, dev);
if (r < 0)
log_error("Failed to process device remove event: %s", strerror(-r));
+
+ r = swap_process_removed_device(m, dev);
+ if (r < 0)
+ log_error("Failed to process swap device remove event: %s", strerror(-r));
+
} else {
r = device_process_new_device(m, dev);
if (r < 0)
log_error("Failed to process device new event: %s", strerror(-r));
+ r = swap_process_new_device(m, dev);
+ if (r < 0)
+ log_error("Failed to process swap device new event: %s", strerror(-r));
+
manager_dispatch_load_queue(m);
device_set_path_plugged(m, dev);