592caf
From 1f3165bda13c8572c8c31d23c998835c4e2ad8f3 Mon Sep 17 00:00:00 2001
592caf
From: Michal Sekletar <msekleta@redhat.com>
592caf
Date: Thu, 4 Mar 2021 17:35:22 +0100
592caf
Subject: [PATCH] udev: run link_update() with increased retry count in second
592caf
 invocation
592caf
592caf
In PR #17431 we have introduced retry loop in link_update() in order to
592caf
maximize the chance that we end up with correct target when there are
592caf
multiple contenders for given symlink.
592caf
592caf
Number of iterations in retry loop is either 1 or
592caf
LINK_UPDATE_MAX_RETRIES, depending on the value of 'initialized' db
592caf
flag. When device appears for the first time we need to set the
592caf
flag before calling link_update() via update_devnode() for the second
592caf
time to make sure we run the second invocation with higher retry loop
592caf
counter.
592caf
592caf
(cherry picked from commit 996c83903da5bf8b371314b4207ff97afeef65a4)
592caf
592caf
Related: #1931947
592caf
---
592caf
 src/udev/udev-event.c | 3 +--
592caf
 1 file changed, 1 insertion(+), 2 deletions(-)
592caf
592caf
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
592caf
index 9004634f65..eaec05523b 100644
592caf
--- a/src/udev/udev-event.c
592caf
+++ b/src/udev/udev-event.c
592caf
@@ -934,14 +934,13 @@ void udev_event_execute_rules(struct udev_event *event,
592caf
                 /* (re)write database file */
592caf
                 udev_device_tag_index(dev, event->dev_db, true);
592caf
                 udev_device_update_db(dev);
592caf
+                udev_device_set_is_initialized(dev);
592caf
 
592caf
                 /* Yes, we run update_devnode() twice, because in the first invocation, that is before update of udev database,
592caf
                  * it could happen that two contenders are replacing each other's symlink. Hence we run it again to make sure
592caf
                  * symlinks point to devices that claim them with the highest priority. */
592caf
                 update_devnode(event);
592caf
 
592caf
-                udev_device_set_is_initialized(dev);
592caf
-
592caf
                 event->dev_db = udev_device_unref(event->dev_db);
592caf
         }
592caf
 }