[PATCH v2] common: switch _get_{available,total}_space accounting to units of single bytes

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



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 _get_available_space df reporting block size from units of
1024b blocks directly to single bytes in order to make free space
accounting fine-grained and independent of any fs block size
assumptions.

Do the same for _get_available_space, since there is no reason for
having an additional conversion step.

Signed-off-by: Anthony Iliopoulos <ailiop@xxxxxxxx>
---
 common/rc | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

v2: incorporate changes from reviews by djwong and zlang
* change reporting directly to bytes and avoid conversion step
  altogether
* do the same for _get_available_space

diff --git a/common/rc b/common/rc
index 90749343f3c4..9e4475c0f429 100644
--- a/common/rc
+++ b/common/rc
@@ -4208,9 +4208,7 @@ _get_available_space()
 		echo "Usage: _get_available_space <mnt>"
 		exit 1
 	fi
-	local avail_kb;
-	avail_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $5 }'`
-	echo $((avail_kb * 1024))
+	$DF_PROG -B 1 $1 | tail -n1 | awk '{ print $5 }'
 }
 
 # get the total space in bytes
@@ -4221,9 +4219,7 @@ _get_total_space()
 		echo "Usage: _get_total_space <mnt>"
 		exit 1
 	fi
-	local total_kb;
-	total_kb=`$DF_PROG $1 | tail -n1 | awk '{ print $3 }'`
-	echo $(($total_kb * 1024))
+	$DF_PROG -B 1 $1 | tail -n1 | awk '{ print $3 }'
 }
 
 # return device size in kb
-- 
2.35.3




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux