[systemd-commits] 5 commits - TODO src/core src/shared src/test
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Jan 27 16:02:46 PST 2015
TODO | 5 +++++
src/core/swap.c | 46 +++++++++++++++++++++++-----------------------
src/shared/list.h | 10 ++++++++++
src/test/test-list.c | 9 ++++++++-
4 files changed, 46 insertions(+), 24 deletions(-)
New commits:
commit 7dfb0404b3b6882d582a571f61a52b2f56961675
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 28 01:02:36 2015 +0100
update TODO
diff --git a/TODO b/TODO
index c99905f..7f5db20 100644
--- a/TODO
+++ b/TODO
@@ -31,6 +31,11 @@ External:
Features:
+* nspawn: emulate /dev/kmsg using CUSE and turn off the syslog syscall
+ with seccomp. That should provide us with a useful log buffer that
+ systemd can log to during early boot, and disconnect container logs
+ from the kernel's logs.
+
* networkd/udev: implement SR_IOV configuration in .link files:
http://lists.freedesktop.org/archives/systemd-devel/2015-January/027451.html
commit 37cf8fee46025d704660a9fc1d1349fe7d0b139d
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 28 00:38:38 2015 +0100
core: if two start jobs for the same swap device node are queued, only dispatch one of them at a time
If two start jobs for two seperate .swap device nodes are queued, which
then turns out to be referring to the same device node, refuse
dispatching more than one of them at the same time.
This should solve an issue when the same swap partition is found via GPT
auto-discovery and via /etc/fstab, where one uses a symlink path, and
the other the raw devce node. So far we might have ended up invoking
mkswap on the same node at the very same time with the two device node
names.
With this change only one mkswap should be executed at a time. THis
mkswap should have immediate effect on the other swap unit, due to the
state in /proc/swaps changing, and thus suppressing actual invocation of
the second mkswap.
http://lists.freedesktop.org/archives/systemd-devel/2015-January/027314.html
diff --git a/src/core/swap.c b/src/core/swap.c
index b97f102..1ef672f 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -473,6 +473,7 @@ static int swap_process_new_swap(Manager *m, const char *device, int prio, bool
static void swap_set_state(Swap *s, SwapState state) {
SwapState old_state;
+ Swap *other;
assert(s);
@@ -500,6 +501,15 @@ static void swap_set_state(Swap *s, SwapState state) {
swap_state_to_string(state));
unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], true);
+
+ /* If there other units for the same device node have a job
+ queued it might be worth checking again if it is runnable
+ now. This is necessary, since swap_start() refuses
+ operation with EAGAIN if there's already another job for
+ the same device node queued. */
+ LIST_FOREACH_OTHERS(same_devnode, other, s)
+ if (UNIT(other)->job)
+ job_add_to_run_queue(UNIT(other)->job);
}
static int swap_coldplug(Unit *u) {
@@ -796,7 +806,7 @@ fail:
}
static int swap_start(Unit *u) {
- Swap *s = SWAP(u);
+ Swap *s = SWAP(u), *other;
assert(s);
@@ -818,6 +828,13 @@ static int swap_start(Unit *u) {
if (detect_container(NULL) > 0)
return -EPERM;
+ /* If there's a job for another swap unit for the same node
+ * running, then let's not dispatch this one for now, and wait
+ * until that other job has finished. */
+ LIST_FOREACH_OTHERS(same_devnode, other, s)
+ if (UNIT(other)->job && UNIT(other)->job->state == JOB_RUNNING)
+ return -EAGAIN;
+
s->result = SWAP_SUCCESS;
swap_enter_activating(s);
return 0;
commit caac2704d57ef6d95f7053456479353bae3638de
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 28 00:37:11 2015 +0100
swap: simplify a few things by making use of new LIST_FOREACH_OTHERS macro
diff --git a/src/core/swap.c b/src/core/swap.c
index cc03b14..b97f102 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -1178,11 +1178,7 @@ static Unit *swap_following(Unit *u) {
if (s->from_fragment)
return NULL;
- LIST_FOREACH_AFTER(same_devnode, other, s)
- if (other->from_fragment)
- return UNIT(other);
-
- LIST_FOREACH_BEFORE(same_devnode, other, s)
+ LIST_FOREACH_OTHERS(same_devnode, other, s)
if (other->from_fragment)
return UNIT(other);
@@ -1224,13 +1220,7 @@ static int swap_following_set(Unit *u, Set **_set) {
if (!set)
return -ENOMEM;
- LIST_FOREACH_AFTER(same_devnode, other, s) {
- r = set_put(set, other);
- if (r < 0)
- goto fail;
- }
-
- LIST_FOREACH_BEFORE(same_devnode, other, s) {
+ LIST_FOREACH_OTHERS(same_devnode, other, s) {
r = set_put(set, other);
if (r < 0)
goto fail;
commit 7663df377016cf7b95001aec893006647175ae4a
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 28 00:34:58 2015 +0100
list: add macro for iterating through a list an item is in, skipping the item
diff --git a/src/shared/list.h b/src/shared/list.h
index f0458b5..7ed6318 100644
--- a/src/shared/list.h
+++ b/src/shared/list.h
@@ -138,6 +138,16 @@
#define LIST_FOREACH_AFTER(name,i,p) \
for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next)
+/* Iterate through all the members of the list p is included in, but skip over p */
+#define LIST_FOREACH_OTHERS(name,i,p) \
+ for (({ \
+ (i) = (p); \
+ while ((i) && (i)->name##_prev) \
+ (i) = (i)->name##_prev; \
+ }); \
+ (i); \
+ (i) = (i)->name##_next == (p) ? (p)->name##_next : (i)->name##_next)
+
/* Loop starting from p->next until p->prev.
p can be adjusted meanwhile. */
#define LIST_LOOP_BUT_ONE(name,i,head,p) \
diff --git a/src/test/test-list.c b/src/test/test-list.c
index e9d47f0..399ec8e 100644
--- a/src/test/test-list.c
+++ b/src/test/test-list.c
@@ -38,6 +38,13 @@ int main(int argc, const char *argv[]) {
LIST_PREPEND(item, head, &items[i]);
}
+ i = 0;
+ LIST_FOREACH_OTHERS(item, cursor, &items[2]) {
+ i++;
+ assert_se(cursor != &items[2]);
+ }
+ assert_se(i == ELEMENTSOF(items)-1);
+
assert_se(!LIST_JUST_US(item, head));
assert_se(items[0].item_next == NULL);
@@ -125,7 +132,7 @@ int main(int argc, const char *argv[]) {
assert_se(items[3].item_prev == &items[2]);
for (i = 0; i < ELEMENTSOF(items); i++)
- LIST_REMOVE(item, head, &items[i]);
+ LIST_REMOVE(item, head, &items[i]);
assert_se(head == NULL);
commit 976dec6e7b2d193533191be2969dd4eee95fc6bb
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 28 00:04:47 2015 +0100
swap: properly specify errno when logging
diff --git a/src/core/swap.c b/src/core/swap.c
index b2ebed4..cc03b14 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -637,7 +637,6 @@ static int swap_spawn(Swap *s, ExecCommand *c, pid_t *_pid) {
fail:
s->timer_event_source = sd_event_source_unref(s->timer_event_source);
-
return r;
}
@@ -699,9 +698,7 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) {
return;
fail:
- log_unit_warning(UNIT(s)->id,
- "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
-
+ log_unit_warning_errno(UNIT(s)->id, r, "%s failed to kill processes: %m", UNIT(s)->id);
swap_enter_dead(s, SWAP_FAILURE_RESOURCES);
}
@@ -764,9 +761,7 @@ static void swap_enter_activating(Swap *s) {
return;
fail:
- log_unit_warning(UNIT(s)->id,
- "%s failed to run 'swapon' task: %s",
- UNIT(s)->id, strerror(-r));
+ log_unit_warning_errno(UNIT(s)->id, r, "%s failed to run 'swapon' task: %m", UNIT(s)->id);
swap_enter_dead(s, SWAP_FAILURE_RESOURCES);
}
@@ -796,9 +791,7 @@ static void swap_enter_deactivating(Swap *s) {
return;
fail:
- log_unit_warning(UNIT(s)->id,
- "%s failed to run 'swapoff' task: %s",
- UNIT(s)->id, strerror(-r));
+ log_unit_warning_errno(UNIT(s)->id, r, "%s failed to run 'swapoff' task: %m", UNIT(s)->id);
swap_enter_active(s, SWAP_FAILURE_RESOURCES);
}
More information about the systemd-commits
mailing list