]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-node: drop redundant trial of devlink creation 20603/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 1 Sep 2021 00:29:42 +0000 (09:29 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 2 Sep 2021 00:06:25 +0000 (09:06 +0900)
Previously, the devlink was created based on the priority saved in udev
database. So, we needed to reevaluate devlinks after database is saved.

But now the priority is stored in the symlink under /run/udev/links, and
the loop of devlink creation is controlled with the timestamp of the
directory. So, the double evaluation is not necessary anymore.

src/udev/udev-event.c
src/udev/udev-node.c

index 3f0e11d5099b2d7626a84731941a41e392aa7e4a..11531236ce341b8f09eb1d38bf31d69c0a229a79 100644 (file)
@@ -1058,10 +1058,7 @@ int udev_event_execute_rules(
 
         device_set_is_initialized(dev);
 
-        /* Yes, we run update_devnode() twice, because in the first invocation, that is before update of udev database,
-         * it could happen that two contenders are replacing each other's symlink. Hence we run it again to make sure
-         * symlinks point to devices that claim them with the highest priority. */
-        return update_devnode(event);
+        return 0;
 }
 
 void udev_event_execute_run(UdevEvent *event, usec_t timeout_usec, int timeout_signal) {
index 675e6ce3134de8736103ae831541e3de94af1a10..bb551d86b0b7e07258562da4860ccdcdc3079b8b 100644 (file)
@@ -416,7 +416,7 @@ static int link_update(sd_device *dev, const char *slink_in, bool add) {
         _cleanup_free_ char *slink = NULL, *dirname = NULL;
         const char *slink_name;
         char name_enc[NAME_MAX+1];
-        int i, r, retries;
+        int r;
 
         assert(dev);
         assert(slink_in);
@@ -443,11 +443,7 @@ static int link_update(sd_device *dev, const char *slink_in, bool add) {
         if (r < 0)
                 return r;
 
-        /* If the database entry is not written yet we will just do one iteration and possibly wrong symlink
-         * will be fixed in the second invocation. */
-        retries = sd_device_get_is_initialized(dev) > 0 ? LINK_UPDATE_MAX_RETRIES : 1;
-
-        for (i = 0; i < retries; i++) {
+        for (unsigned i = 0; i < LINK_UPDATE_MAX_RETRIES; i++) {
                 _cleanup_free_ char *target = NULL;
                 struct stat st1 = {}, st2 = {};
 
@@ -472,7 +468,7 @@ static int link_update(sd_device *dev, const char *slink_in, bool add) {
                                 log_device_debug_errno(dev, errno, "Failed to remove '%s', ignoring: %m", slink);
 
                         (void) rmdir_parents(slink, "/dev");
-                        break;
+                        return 0;
                 }
 
                 r = node_symlink(dev, target, slink);
@@ -487,7 +483,7 @@ static int link_update(sd_device *dev, const char *slink_in, bool add) {
                         return 0;
         }
 
-        return i < LINK_UPDATE_MAX_RETRIES ? 0 : -ELOOP;
+        return -ELOOP;
 }
 
 static int device_get_devpath_by_devnum(sd_device *dev, char **ret) {