]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: run link_update() with increased retry count in second invocation
authorMichal Sekletar <msekleta@redhat.com>
Thu, 4 Mar 2021 16:35:22 +0000 (17:35 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 6 Mar 2021 06:33:05 +0000 (15:33 +0900)
In PR #17431 we have introduced retry loop in link_update() in order to
maximize the chance that we end up with correct target when there are
multiple contenders for given symlink.

Number of iterations in retry loop is either 1 or
LINK_UPDATE_MAX_RETRIES, depending on the value of 'initialized' db
flag. When device appears for the first time we need to set the
flag before calling link_update() via update_devnode() for the second
time to make sure we run the second invocation with higher retry loop
counter.

src/udev/udev-event.c

index d5d89d6802f75b10911aa897e63b3b1c034cd07f..12597194a91d7e2f64a385d5985da16c99371639 100644 (file)
@@ -1043,6 +1043,8 @@ int udev_event_execute_rules(UdevEvent *event,
         if (r < 0)
                 return log_device_debug_errno(dev, r, "Failed to update database under /run/udev/data/: %m");
 
+        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. */
@@ -1050,8 +1052,6 @@ int udev_event_execute_rules(UdevEvent *event,
         if (r < 0)
                 return r;
 
-        device_set_is_initialized(dev);
-
         return 0;
 }