add finding partitions retry loop 67/308067/2 accepted/tizen/unified/20240320.152019 accepted/tizen/unified/x/20240326.073621
authorMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 15 Mar 2024 12:21:41 +0000 (13:21 +0100)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 19 Mar 2024 01:54:50 +0000 (10:54 +0900)
Retry finding partitions if no rootfs has been found to let kernel to
probe slowly-initializing block devices.

Change-Id: I8eeb72d1e44c4e91609ea21d3185a616082ce913
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
data/initrd-file.list
scripts/init.sh

index 5f059fd8c493b5ae90036f8441f204ff468ebaa3..7728c970724b0c813413e8bde15ef305dc0680e1 100644 (file)
@@ -32,6 +32,7 @@ PROGS="
 /usr/bin/xargs
 /usr/bin/mkdir
 /usr/bin/mount
+/usr/bin/sleep
 /usr/bin/umount
 /usr/sbin/blkid
 /usr/sbin/pivot_root
index 0170748dfd01c3c603202a13fdc3c0e65499ca7b..db0e14b4e4766cb92bd05c6c5943632786d2e6b2 100755 (executable)
@@ -17,6 +17,7 @@ IN_INITRD=0
 IN_INITRAMFS=0
 NEED_RESIZEFS=1
 USERFS_ENCRYPTED=0
+FS_RETRY_COUNT=10
 
 BLKID_LINES=()
 
@@ -120,9 +121,7 @@ function find_partitions()
 
     IFS_BACKUP=$IFS
     IFS=$'\n'
-    if [ "x$BLKID_LINES" = "x" ]; then
-        BLKID_LINES=($(/sbin/blkid))
-    fi
+    BLKID_LINES=($(/sbin/blkid))
 
     SUPERFS=`get_blk_dev_path "PARTLABEL=\"super\""`
     if [ x$SUPERFS = "x" ]
@@ -206,6 +205,20 @@ function find_partitions()
     IFS=$IFS_BACKUP
 }
 
+function wait_find_partitions()
+{
+       for ((I=1;I<=$FS_RETRY_COUNT;I++))
+       do
+               find_partitions
+               if [ x$ROOTFS != "x" ]
+               then
+                       break
+               fi
+               echo "Waiting for rootfs block device, try $I of $FS_RETRY_COUNT..."
+               sleep .5
+       done
+}
+
 function check_flags()
 {
     if [ -e /etc/initrd-release ]
@@ -497,7 +510,7 @@ print_boot_info
 
 check_network
 setup_nbd
-find_partitions
+wait_find_partitions
 check_flags
 
 process_rootfs