SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2014-05-20 11:17:58 +00:00 committed by Git OBS Bridge
parent 944087ad76
commit 5e6dc476b5
8 changed files with 328 additions and 6 deletions

View File

@ -0,0 +1,83 @@
From 3ebdb81ef088afd3b4c72b516beb5610f8c93a0d Mon Sep 17 00:00:00 2001
From: Kay Sievers <kay@vrfy.org>
Date: Sun, 13 Apr 2014 19:54:27 -0700
Subject: [PATCH] udev: serialize/synchronize block device event handling with
file locks
---
src/udev/udevd.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git src/udev/udevd.c src/udev/udevd.c
index f9ee368..aecd208 100644
--- src/udev/udevd.c
+++ src/udev/udevd.c
@@ -31,6 +31,7 @@
#include <time.h>
#include <getopt.h>
#include <dirent.h>
+#include <sys/file.h>
#include <sys/time.h>
#include <sys/prctl.h>
#include <sys/socket.h>
@@ -265,6 +266,7 @@ static void worker_new(struct event *event)
for (;;) {
struct udev_event *udev_event;
struct worker_message msg;
+ int fd_lock = -1;
int err;
log_debug("seq %llu running", udev_device_get_seqnum(dev));
@@ -280,6 +282,30 @@ static void worker_new(struct event *event)
if (exec_delay > 0)
udev_event->exec_delay = exec_delay;
+ /*
+ * Take a "read lock" on the device node; this establishes
+ * a concept of device "ownership" to serialize device
+ * access. External processes holding a "write lock" will
+ * cause udev to skip the event handling; in the case udev
+ * acquired the lock, the external process will block until
+ * udev has finished its event handling.
+ */
+ if (streq_ptr("block", udev_device_get_subsystem(dev))) {
+ struct udev_device *d = dev;
+
+ if (streq_ptr("partition", udev_device_get_devtype(d)))
+ d = udev_device_get_parent(d);
+
+ if (d) {
+ fd_lock = open(udev_device_get_devnode(d), O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
+ if (fd_lock >= 0 && flock(fd_lock, LOCK_SH|LOCK_NB) < 0) {
+ log_debug("Unable to flock(%s), skipping event handling: %m", udev_device_get_devnode(d));
+ err = -EWOULDBLOCK;
+ goto skip;
+ }
+ }
+ }
+
/* apply rules, create node, symlinks */
err = udev_event_execute_rules(udev_event, rules, &sigmask_orig);
@@ -292,13 +318,16 @@ static void worker_new(struct event *event)
udev_device_update_db(dev);
}
+ if (fd_lock >= 0)
+ close(fd_lock);
+
/* send processed event back to libudev listeners */
udev_monitor_send_device(worker_monitor, NULL, dev);
+skip:
/* send udevd the result of the event execution */
memzero(&msg, sizeof(struct worker_message));
- if (err != 0)
- msg.exitcode = err;
+ msg.exitcode = err;
msg.pid = getpid();
send(worker_watch[WRITE_END], &msg, sizeof(struct worker_message), 0);
--
1.7.9.2

View File

@ -0,0 +1,140 @@
From 1ea972174baba40dbc80c51cbfc4edc49764b59b Mon Sep 17 00:00:00 2001
From: Kay Sievers <kay@vrfy.org>
Date: Wed, 14 May 2014 00:34:49 +0200
Subject: [PATCH] udev: do not skip the execution of RUN when renaming a
network device fails
---
src/test/test-udev.c | 5 ++---
src/udev/udev-event.c | 11 +++++------
src/udev/udev.h | 2 +-
src/udev/udevadm-test.c | 13 +++++--------
src/udev/udevd.c | 5 ++---
5 files changed, 15 insertions(+), 21 deletions(-)
diff --git src/test/test-udev.c src/test/test-udev.c
index b064744..b057cc8 100644
--- src/test/test-udev.c
+++ src/test/test-udev.c
@@ -155,9 +155,8 @@ int main(int argc, char *argv[]) {
}
}
- err = udev_event_execute_rules(event, rules, &sigmask_orig);
- if (err == 0)
- udev_event_execute_run(event, NULL);
+ udev_event_execute_rules(event, rules, &sigmask_orig);
+ udev_event_execute_run(event, NULL);
out:
if (event != NULL && event->fd_signal >= 0)
close(event->fd_signal);
diff --git src/udev/udev-event.c src/udev/udev-event.c
index 2cab42b..5213a4a 100644
--- src/udev/udev-event.c
+++ src/udev/udev-event.c
@@ -776,13 +776,12 @@ static int rename_netif(struct udev_event *event)
return r;
}
-int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigmask)
+void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigmask)
{
struct udev_device *dev = event->dev;
- int err = 0;
if (udev_device_get_subsystem(dev) == NULL)
- return -1;
+ return;
if (streq(udev_device_get_action(dev), "remove")) {
udev_device_read_db(dev, NULL);
@@ -816,9 +815,10 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
event->name != NULL && !streq(event->name, udev_device_get_sysname(dev))) {
char syspath[UTIL_PATH_SIZE];
char *pos;
+ int r;
- err = rename_netif(event);
- if (err == 0) {
+ r = rename_netif(event);
+ if (r >= 0) {
log_debug("renamed netif to '%s'", event->name);
/* remember old name */
@@ -881,7 +881,6 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
udev_device_unref(event->dev_db);
event->dev_db = NULL;
}
- return err;
}
void udev_event_execute_run(struct udev_event *event, const sigset_t *sigmask)
diff --git src/udev/udev.h src/udev/udev.h
index 936adfb..62538bc 100644
--- src/udev/udev.h
+++ src/udev/udev.h
@@ -84,7 +84,7 @@ int udev_event_apply_subsys_kernel(struct udev_event *event, const char *string,
int udev_event_spawn(struct udev_event *event,
const char *cmd, char **envp, const sigset_t *sigmask,
char *result, size_t ressize);
-int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigset);
+void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigset);
void udev_event_execute_run(struct udev_event *event, const sigset_t *sigset);
int udev_build_argv(struct udev *udev, char *cmd, int *argc, char *argv[]);
diff --git src/udev/udevadm-test.c src/udev/udevadm-test.c
index 6cd311b..6a2f548 100644
--- src/udev/udevadm-test.c
+++ src/udev/udevadm-test.c
@@ -43,7 +43,6 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
_cleanup_udev_device_unref_ struct udev_device *dev = NULL;
_cleanup_udev_event_unref_ struct udev_event *event = NULL;
sigset_t mask, sigmask_orig;
- int err;
int rc = 0, c;
static const struct option options[] = {
@@ -139,18 +138,16 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
goto out;
}
- err = udev_event_execute_rules(event, rules, &sigmask_orig);
+ udev_event_execute_rules(event, rules, &sigmask_orig);
udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev))
printf("%s=%s\n", udev_list_entry_get_name(entry), udev_list_entry_get_value(entry));
- if (err == 0) {
- udev_list_entry_foreach(entry, udev_list_get_entry(&event->run_list)) {
- char program[UTIL_PATH_SIZE];
+ udev_list_entry_foreach(entry, udev_list_get_entry(&event->run_list)) {
+ char program[UTIL_PATH_SIZE];
- udev_event_apply_format(event, udev_list_entry_get_name(entry), program, sizeof(program));
- printf("run: '%s'\n", program);
- }
+ udev_event_apply_format(event, udev_list_entry_get_name(entry), program, sizeof(program));
+ printf("run: '%s'\n", program);
}
out:
if (event != NULL && event->fd_signal >= 0)
diff --git src/udev/udevd.c src/udev/udevd.c
index aecd208..bc0696c 100644
--- src/udev/udevd.c
+++ src/udev/udevd.c
@@ -307,10 +307,9 @@ static void worker_new(struct event *event)
}
/* apply rules, create node, symlinks */
- err = udev_event_execute_rules(udev_event, rules, &sigmask_orig);
+ udev_event_execute_rules(udev_event, rules, &sigmask_orig);
- if (err == 0)
- udev_event_execute_run(udev_event, &sigmask_orig);
+ udev_event_execute_run(udev_event, &sigmask_orig);
/* apply/restore inotify watch */
if (err == 0 && udev_event->inotify_watch) {
--
1.7.9.2

View File

@ -0,0 +1,37 @@
From bf9bead187802a52a1f376a03caee762d663e945 Mon Sep 17 00:00:00 2001
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Date: Fri, 16 May 2014 23:46:48 +0200
Subject: [PATCH] udev: avoid use of uninitialized err
After 1ea972174baba40dbc80c51cbfc4edc49764b59b err is no longer
set unless we hit a special case. Initialize it to 0 and remove
a check that will never fail.
---
src/udev/udevd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git src/udev/udevd.c src/udev/udevd.c
index bc0696c..1c9488e 100644
--- src/udev/udevd.c
+++ src/udev/udevd.c
@@ -267,7 +267,7 @@ static void worker_new(struct event *event)
struct udev_event *udev_event;
struct worker_message msg;
int fd_lock = -1;
- int err;
+ int err = 0;
log_debug("seq %llu running", udev_device_get_seqnum(dev));
udev_event = udev_event_new(dev);
@@ -312,7 +312,7 @@ static void worker_new(struct event *event)
udev_event_execute_run(udev_event, &sigmask_orig);
/* apply/restore inotify watch */
- if (err == 0 && udev_event->inotify_watch) {
+ if (udev_event->inotify_watch) {
udev_watch_begin(udev, dev);
udev_device_update_db(dev);
}
--
1.7.9.2

View File

@ -1,7 +1,29 @@
-------------------------------------------------------------------
Tue May 20 11:03:54 UTC 2014 - werner@suse.de
- Add upstream patches to allow processes to serialize block device
events, also do execute the RUN tag if rename of a network device
fails:
1016-udev-serialize-synchronize-block-device-event-handli.patch
1017-udev-do-not-skip-the-execution-of-RUN-when-renaming-.patch
1018-udev-avoid-use-of-uninitialized-err.patch
- Rename 0002-udev-warn-when-name_to_handle_at-is-not-implemented.patch
to 1016-udev-warn-when-name_to_handle_at-is-not-implemented.patch
-------------------------------------------------------------------
Mon May 19 13:21:18 UTC 2014 - werner@suse.de
- Add upstream patches mainly for better lid handling
0001-logind-ignore-lid-switch-if-more-than-1-display-is-c.patch
0002-logind-fix-printf-format.patch
0003-logind-ignore-lid-switch-events-for-30s-after-each-s.patch
0004-logind-Do-not-fail-display-count-if-a-device-has-no-.patch
0005-logind-move-lid-switch-handling-from-logind-main-to-.patch
0006-man-clarify-that-the-ExecReload-command-should-be-sy.patch
0007-man-readahead-fix-cmdline-switch-inconsistency-betwe.patch
0008-man-update-journald-rate-limit-defaults.patch
0009-nspawn-properly-format-container_uuid-in-UUID-format.patch
0010-logind-allow-suspending-if-there-are-no-displays.patch
-------------------------------------------------------------------
Fri May 16 12:00:12 UTC 2014 - werner@suse.de

View File

@ -410,8 +410,6 @@ Patch208: parse-crypttab-for-noauto-option.patch
# PATCH-FIX-UPSTREAM added at 2014/05/12
Patch209: 0001-errno-make-sure-to-handle-the-3-errnos-that-are-alia.patch
# PATCH-FIX-UPSTREAM added at 2014/05/12
Patch210: 0002-udev-warn-when-name_to_handle_at-is-not-implemented.patch
# PATCH-FIX-UPSTREAM added at 2014/05/12
Patch211: 0003-analyze-fix-plot-with-bad-y-size.patch
# PATCH-FIX-UPSTREAM added at 2014/05/12
Patch212: 0004-job-add-waiting-jobs-to-run-queue-in-unit_coldplug.patch
@ -496,6 +494,14 @@ Patch1013: 1013-no-runtime-PM-for-IBM-consoles.patch
Patch1014: 1014-udev-update-net_id-comments.patch
# PATCH-FIX-USTREAM 1015-udev-persistent-naming-we-cannot-use-virtio-numbers-.patch
Patch1015: 1015-udev-persistent-naming-we-cannot-use-virtio-numbers-.patch
# PATCH-FIX-UPSTREAM added at 2014/05/12
Patch1016: 1016-udev-warn-when-name_to_handle_at-is-not-implemented.patch
# PATCH-FIX-UPSTREAM added at 2014/05/20
Patch1017: 1017-udev-serialize-synchronize-block-device-event-handli.patch
# PATCH-FIX-UPSTREAM added at 2014/05/20
Patch1018: 1018-udev-do-not-skip-the-execution-of-RUN-when-renaming-.patch
# PATCH-FIX-UPSTREAM added at 2014/05/20
Patch1019: 1019-udev-avoid-use-of-uninitialized-err.patch
%description
Systemd is a system and service manager, compatible with SysV and LSB
@ -853,7 +859,6 @@ cp %{SOURCE7} m4/
%patch207 -p0
%patch208 -p1
%patch209 -p0
%patch210 -p0
%patch211 -p0
%patch212 -p0
%patch213 -p0
@ -896,6 +901,10 @@ cp %{SOURCE7} m4/
%patch1013 -p1
%patch1014 -p1
%patch1015 -p1
%patch1016 -p0
%patch1017 -p0
%patch1018 -p0
%patch1019 -p0
# ensure generate files are removed
rm -f units/emergency.service

View File

@ -1,7 +1,29 @@
-------------------------------------------------------------------
Tue May 20 11:03:54 UTC 2014 - werner@suse.de
- Add upstream patches to allow processes to serialize block device
events, also do execute the RUN tag if rename of a network device
fails:
1016-udev-serialize-synchronize-block-device-event-handli.patch
1017-udev-do-not-skip-the-execution-of-RUN-when-renaming-.patch
1018-udev-avoid-use-of-uninitialized-err.patch
- Rename 0002-udev-warn-when-name_to_handle_at-is-not-implemented.patch
to 1016-udev-warn-when-name_to_handle_at-is-not-implemented.patch
-------------------------------------------------------------------
Mon May 19 13:21:18 UTC 2014 - werner@suse.de
- Add upstream patches mainly for better lid handling
0001-logind-ignore-lid-switch-if-more-than-1-display-is-c.patch
0002-logind-fix-printf-format.patch
0003-logind-ignore-lid-switch-events-for-30s-after-each-s.patch
0004-logind-Do-not-fail-display-count-if-a-device-has-no-.patch
0005-logind-move-lid-switch-handling-from-logind-main-to-.patch
0006-man-clarify-that-the-ExecReload-command-should-be-sy.patch
0007-man-readahead-fix-cmdline-switch-inconsistency-betwe.patch
0008-man-update-journald-rate-limit-defaults.patch
0009-nspawn-properly-format-container_uuid-in-UUID-format.patch
0010-logind-allow-suspending-if-there-are-no-displays.patch
-------------------------------------------------------------------
Fri May 16 12:00:12 UTC 2014 - werner@suse.de

View File

@ -405,8 +405,6 @@ Patch208: parse-crypttab-for-noauto-option.patch
# PATCH-FIX-UPSTREAM added at 2014/05/12
Patch209: 0001-errno-make-sure-to-handle-the-3-errnos-that-are-alia.patch
# PATCH-FIX-UPSTREAM added at 2014/05/12
Patch210: 0002-udev-warn-when-name_to_handle_at-is-not-implemented.patch
# PATCH-FIX-UPSTREAM added at 2014/05/12
Patch211: 0003-analyze-fix-plot-with-bad-y-size.patch
# PATCH-FIX-UPSTREAM added at 2014/05/12
Patch212: 0004-job-add-waiting-jobs-to-run-queue-in-unit_coldplug.patch
@ -491,6 +489,14 @@ Patch1013: 1013-no-runtime-PM-for-IBM-consoles.patch
Patch1014: 1014-udev-update-net_id-comments.patch
# PATCH-FIX-USTREAM 1015-udev-persistent-naming-we-cannot-use-virtio-numbers-.patch
Patch1015: 1015-udev-persistent-naming-we-cannot-use-virtio-numbers-.patch
# PATCH-FIX-UPSTREAM added at 2014/05/12
Patch1016: 1016-udev-warn-when-name_to_handle_at-is-not-implemented.patch
# PATCH-FIX-UPSTREAM added at 2014/05/20
Patch1017: 1017-udev-serialize-synchronize-block-device-event-handli.patch
# PATCH-FIX-UPSTREAM added at 2014/05/20
Patch1018: 1018-udev-do-not-skip-the-execution-of-RUN-when-renaming-.patch
# PATCH-FIX-UPSTREAM added at 2014/05/20
Patch1019: 1019-udev-avoid-use-of-uninitialized-err.patch
%description
Systemd is a system and service manager, compatible with SysV and LSB
@ -848,7 +854,6 @@ cp %{SOURCE7} m4/
%patch207 -p0
%patch208 -p1
%patch209 -p0
%patch210 -p0
%patch211 -p0
%patch212 -p0
%patch213 -p0
@ -891,6 +896,10 @@ cp %{SOURCE7} m4/
%patch1013 -p1
%patch1014 -p1
%patch1015 -p1
%patch1016 -p0
%patch1017 -p0
%patch1018 -p0
%patch1019 -p0
# ensure generate files are removed
rm -f units/emergency.service