Skip to contentSkip to conversation

generic/619: a better way to get tot_avail_size

PATCH Superseded Sun Ke 2 participants 2 messages Apr 15, 2021 – Apr 18, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sun Ke

author
#0 lore raw

PATCH 1/1 generic/619: a better way to get tot_avail_size

When FSTYP is tmpfs, $DF_PROG --block-size=1 $SCRATCH_DEV is not suitted.

---
 tests/generic/619 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/619 +1 -1
index 3c43fe746917..76d6b2c470b9 100755
@@ -89,7 +89,7 @@ calc_thread_cnt()
 	IFS=',' read -ra fratio <<< $file_ratio
 	file_ratio_cnt=${#fratio[@]}
 
-	tot_avail_size=$($DF_PROG --block-size=1 $SCRATCH_DEV | awk 'FNR == 2 { print $5 }')
+	tot_avail_size=$(echo $($DF_PROG | grep -w $SCRATCH_DEV | awk '{print $5}')*1024 | $BC_PROG)
 	avail_size=$(echo $tot_avail_size*$disk_saturation | $BC_PROG)
 	thread_cnt=$(echo "$file_ratio_cnt*($avail_size/$file_ratio_unit)" | $BC_PROG)
 
Signature · 1 line
2.25.4
#1 lore raw
Quoted 12 lines · Sun Ke

When FSTYP is tmpfs, $DF_PROG --block-size=1 $SCRATCH_DEV is not suitted.

---
 tests/generic/619 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/619 +0 -0
index 3c43fe746917..76d6b2c470b9 100755

tests/generic/619 calc_thread_cnt() · line 92

Quoted 4 lines
tests/generic/619 +0 -1
@@ -89,7 +89,7 @@ calc_thread_cnt()
 	IFS=',' read -ra fratio <<< $file_ratio
 	file_ratio_cnt=${#fratio[@]}
 
-	tot_avail_size=$($DF_PROG --block-size=1 $SCRATCH_DEV | awk 'FNR == 2 { print $5 }')

Does s/$SCRATCH_DEV/$SCRATCH_MNT/ work for you? And please replace 'awk' with $AWK_PROG while we're at it.

Thanks,
Eryu

Quoted 6 lines
tests/generic/619 +1 -0
+	tot_avail_size=$(echo $($DF_PROG | grep -w $SCRATCH_DEV | awk '{print $5}')*1024 | $BC_PROG)
 	avail_size=$(echo $tot_avail_size*$disk_saturation | $BC_PROG)
 	thread_cnt=$(echo "$file_ratio_cnt*($avail_size/$file_ratio_unit)" | $BC_PROG)
 
Signature · 1 line
2.25.4