Skip to contentSkip to conversation

common: switch _get_available_space accounting to units of 512 bytes

PATCH In review Anthony Iliopoulos 3 participants 3 messages Mar 28, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common: switch _get_available_space accounting to units of 512 bytes

xfs/220 relies on detecting free space changes after truncation of single filesystem blocks, and this fails when the fs block size is 512b.

By default df is counting 1024b block units and as such is not reporting any change in the number of available blocks after freeing just a 512b block.

Switch the df reporting block size from units of 1024b blocks to 512b blocks to accommodate accounting for smaller granularity fs block sizes.

---
 common/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/rc +2 -2
index 90749343f3c4..a32bbe3c0b5f 100644
@@ -4209,8 +4209,8 @@ _get_available_space()
 		exit 1
 	fi
 	local avail_kb;
-	avail_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $5 }'`
-	echo $((avail_kb * 1024))
+	avail_kb=`$DF_PROG --block-size=512 $1 | tail -n1 | awk '{ print $5 }'`
+	echo $((avail_kb * 512))
 }
 
 # get the total space in bytes
Signature · 1 line
2.35.3
#1 lore raw
Quoted 20 lines · Anthony Iliopoulos

xfs/220 relies on detecting free space changes after truncation of single filesystem blocks, and this fails when the fs block size is 512b.

By default df is counting 1024b block units and as such is not reporting any change in the number of available blocks after freeing just a 512b block.

Switch the df reporting block size from units of 1024b blocks to 512b blocks to accommodate accounting for smaller granularity fs block sizes.

---
 common/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/rc +0 -0
index 90749343f3c4..a32bbe3c0b5f 100644

common/rc _get_available_space() · line 4213

Quoted 7 lines
common/rc +2 -2
@@ -4209,8 +4209,8 @@ _get_available_space()
 		exit 1
 	fi
 	local avail_kb;
-	avail_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $5 }'`
-	echo $((avail_kb * 1024))
+	avail_kb=`$DF_PROG --block-size=512 $1 | tail -n1 | awk '{ print $5 }'`
+	echo $((avail_kb * 512))

Why not have df report the free space in bytes?

$DF_PROG -B 1 $1 | tail -n 1 | awk '{print $5}'

--D

Quoted 6 lines
common/rc +0 -0
 }
 
 # get the total space in bytes
Signature · 1 line
2.35.3
#2 lore raw
Quoted 31 lines · Darrick J. Wong
Quoted 20 lines · Anthony Iliopoulos

xfs/220 relies on detecting free space changes after truncation of single filesystem blocks, and this fails when the fs block size is 512b.

By default df is counting 1024b block units and as such is not reporting any change in the number of available blocks after freeing just a 512b block.

Switch the df reporting block size from units of 1024b blocks to 512b blocks to accommodate accounting for smaller granularity fs block sizes.

---
 common/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/rc +0 -0
index 90749343f3c4..a32bbe3c0b5f 100644

common/rc _get_available_space() · line 4213

Quoted 7 lines
common/rc +2 -2
@@ -4209,8 +4209,8 @@ _get_available_space()
 		exit 1
 	fi
 	local avail_kb;
-	avail_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $5 }'`
-	echo $((avail_kb * 1024))
+	avail_kb=`$DF_PROG --block-size=512 $1 | tail -n1 | awk '{ print $5 }'`
+	echo $((avail_kb * 512))

Why not have df report the free space in bytes?

Quoted 1 line

$DF_PROG -B 1 $1 | tail -n 1 | awk '{print $5}'

Agree, if we finally hope to get "bytes", and we can get it at beginning, why take a long way?

If you'd like to send a V2 to do that, you can do the same change on _get_total_space() too.

Thanks,
Zorro

Quoted 10 lines

--D

Quoted 6 lines
common/rc +0 -0
 }
 
 # get the total space in bytes
Signature · 1 line
2.35.3