|
|
4295f9 |
From 458a6cd748ee5555b6957888b69d475ac3f619c6 Mon Sep 17 00:00:00 2001
|
|
|
4295f9 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
4295f9 |
Date: Wed, 1 Sep 2021 09:29:42 +0900
|
|
|
4295f9 |
Subject: [PATCH] udev-node: drop redundant trial of devlink creation
|
|
|
4295f9 |
|
|
|
4295f9 |
Previously, the devlink was created based on the priority saved in udev
|
|
|
4295f9 |
database. So, we needed to reevaluate devlinks after database is saved.
|
|
|
4295f9 |
|
|
|
4295f9 |
But now the priority is stored in the symlink under /run/udev/links, and
|
|
|
4295f9 |
the loop of devlink creation is controlled with the timestamp of the
|
|
|
4295f9 |
directory. So, the double evaluation is not necessary anymore.
|
|
|
4295f9 |
|
|
|
4295f9 |
(cherry picked from commit 7920d0a135fb6a08aa0bfc31e9d0a3f589fe7a1f)
|
|
|
4295f9 |
|
|
|
4295f9 |
Related: #1977994
|
|
|
4295f9 |
---
|
|
|
4295f9 |
src/udev/udev-event.c | 5 +----
|
|
|
4295f9 |
src/udev/udev-node.c | 12 ++++--------
|
|
|
4295f9 |
2 files changed, 5 insertions(+), 12 deletions(-)
|
|
|
4295f9 |
|
|
|
4295f9 |
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
|
|
|
4295f9 |
index 8b9f8aecfe..c77f55c67e 100644
|
|
|
4295f9 |
--- a/src/udev/udev-event.c
|
|
|
4295f9 |
+++ b/src/udev/udev-event.c
|
|
|
4295f9 |
@@ -1060,10 +1060,7 @@ int udev_event_execute_rules(
|
|
|
4295f9 |
|
|
|
4295f9 |
device_set_is_initialized(dev);
|
|
|
4295f9 |
|
|
|
4295f9 |
- /* Yes, we run update_devnode() twice, because in the first invocation, that is before update of udev database,
|
|
|
4295f9 |
- * it could happen that two contenders are replacing each other's symlink. Hence we run it again to make sure
|
|
|
4295f9 |
- * symlinks point to devices that claim them with the highest priority. */
|
|
|
4295f9 |
- return update_devnode(event);
|
|
|
4295f9 |
+ return 0;
|
|
|
4295f9 |
}
|
|
|
4295f9 |
|
|
|
4295f9 |
void udev_event_execute_run(UdevEvent *event, usec_t timeout_usec, int timeout_signal) {
|
|
|
4295f9 |
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
|
|
|
4295f9 |
index 675e6ce313..bb551d86b0 100644
|
|
|
4295f9 |
--- a/src/udev/udev-node.c
|
|
|
4295f9 |
+++ b/src/udev/udev-node.c
|
|
|
4295f9 |
@@ -416,7 +416,7 @@ static int link_update(sd_device *dev, const char *slink_in, bool add) {
|
|
|
4295f9 |
_cleanup_free_ char *slink = NULL, *dirname = NULL;
|
|
|
4295f9 |
const char *slink_name;
|
|
|
4295f9 |
char name_enc[NAME_MAX+1];
|
|
|
4295f9 |
- int i, r, retries;
|
|
|
4295f9 |
+ int r;
|
|
|
4295f9 |
|
|
|
4295f9 |
assert(dev);
|
|
|
4295f9 |
assert(slink_in);
|
|
|
4295f9 |
@@ -443,11 +443,7 @@ static int link_update(sd_device *dev, const char *slink_in, bool add) {
|
|
|
4295f9 |
if (r < 0)
|
|
|
4295f9 |
return r;
|
|
|
4295f9 |
|
|
|
4295f9 |
- /* If the database entry is not written yet we will just do one iteration and possibly wrong symlink
|
|
|
4295f9 |
- * will be fixed in the second invocation. */
|
|
|
4295f9 |
- retries = sd_device_get_is_initialized(dev) > 0 ? LINK_UPDATE_MAX_RETRIES : 1;
|
|
|
4295f9 |
-
|
|
|
4295f9 |
- for (i = 0; i < retries; i++) {
|
|
|
4295f9 |
+ for (unsigned i = 0; i < LINK_UPDATE_MAX_RETRIES; i++) {
|
|
|
4295f9 |
_cleanup_free_ char *target = NULL;
|
|
|
4295f9 |
struct stat st1 = {}, st2 = {};
|
|
|
4295f9 |
|
|
|
4295f9 |
@@ -472,7 +468,7 @@ static int link_update(sd_device *dev, const char *slink_in, bool add) {
|
|
|
4295f9 |
log_device_debug_errno(dev, errno, "Failed to remove '%s', ignoring: %m", slink);
|
|
|
4295f9 |
|
|
|
4295f9 |
(void) rmdir_parents(slink, "/dev");
|
|
|
4295f9 |
- break;
|
|
|
4295f9 |
+ return 0;
|
|
|
4295f9 |
}
|
|
|
4295f9 |
|
|
|
4295f9 |
r = node_symlink(dev, target, slink);
|
|
|
4295f9 |
@@ -487,7 +483,7 @@ static int link_update(sd_device *dev, const char *slink_in, bool add) {
|
|
|
4295f9 |
return 0;
|
|
|
4295f9 |
}
|
|
|
4295f9 |
|
|
|
4295f9 |
- return i < LINK_UPDATE_MAX_RETRIES ? 0 : -ELOOP;
|
|
|
4295f9 |
+ return -ELOOP;
|
|
|
4295f9 |
}
|
|
|
4295f9 |
|
|
|
4295f9 |
static int device_get_devpath_by_devnum(sd_device *dev, char **ret) {
|