patch to fix disk usage numbers on FreeBSD

Doug Porter dsp at dsp.name
Fri Dec 8 16:38:58 UTC 2006


The current version of MogileFS doubles all the disk space numbers on
FreeBSD due to FreeBSD's df working differently than GNU coreutils df.
If the -P option follows -k with FreeBSD df the blocksize will be
512 bytes.  The following patch remedies this problem and seems to
produce the correct results on both FreeBSD and Linux.



Index: server/mogstored
===================================================================
--- server/mogstored	(revision 518)
+++ server/mogstored	(working copy)
@@ -259,7 +259,7 @@
         my ($osdevnum) = stat("$path/$devnum");
         $devnum_to_device{$devnum} = $osdevnum_to_device{$osdevnum};
 
-        my $rval = `df -k -l -P $path/$devnum`;
+        my $rval = `df -P -l -k $path/$devnum`;
         foreach my $l (split /\r?\n/, $rval) {
             next unless $l =~ /^(.+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(.+)\s+(.+)$/;
             my ($dev, $total, $used, $avail, $useper, $disk) = ($1, $2, $3, $4, $5, $6);



-- 
Doug Porter <dsp at dsp.name>


More information about the mogilefs mailing list