[openwrt/openwrt] base-files: Make sure rootfs_data_max is considered

LEDE Commits lede-commits at lists.infradead.org
Thu Feb 17 07:17:01 PST 2022


dangole pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/397de500896f3c7c4e2468c21521502392af4574

commit 397de500896f3c7c4e2468c21521502392af4574
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Thu Feb 17 15:10:00 2022 +0000

    base-files: Make sure rootfs_data_max is considered
    
    For sysupgrade on NAND/UBI devices there is the U-Boot environment
    variable rootfs_data_max which can be used to limit the size of the
    rootfs_data volume created on sysupgrade.
    This stopped working reliable with recent kernels, probably due to a
    race condition when reading the number of free erase blocks from sysfs
    just after removing a volume.
    Change the script to just try creating rootfs_data with the desired
    size and retry with maximum size in case that fails. Hence calculating
    the available size in the script can be dropped which works around the
    problem.
    
    Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 package/base-files/files/lib/upgrade/nand.sh | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh
index 9b29266479..19be9dd730 100644
--- a/package/base-files/files/lib/upgrade/nand.sh
+++ b/package/base-files/files/lib/upgrade/nand.sh
@@ -193,18 +193,15 @@ nand_upgrade_prepare_ubi() {
 
 	# create rootfs_data for non-ubifs rootfs
 	if [ "$rootfs_type" != "ubifs" ]; then
-		local availeb=$(cat /sys/devices/virtual/ubi/$ubidev/avail_eraseblocks)
-		local ebsize=$(cat /sys/devices/virtual/ubi/$ubidev/eraseblock_size)
-		local avail_size=$((availeb * ebsize))
 		local rootfs_data_size_param="-m"
-		if [ -n "$rootfs_data_max" ] &&
-		   [ "$rootfs_data_max" != "0" ] &&
-		   [ "$rootfs_data_max" -le "$avail_size" ]; then
+		if [ -n "$rootfs_data_max" ]; then
 			rootfs_data_size_param="-s $rootfs_data_max"
 		fi
 		if ! ubimkvol /dev/$ubidev -N rootfs_data $rootfs_data_size_param; then
-			echo "cannot initialize rootfs_data volume"
-			return 1
+			if ! ubimkvol /dev/$ubidev -N rootfs_data -m; then
+				echo "cannot initialize rootfs_data volume"
+				return 1
+			fi
 		fi
 	fi
 	sync



More information about the lede-commits mailing list