Do we want a periodic script for a zfs scrub?

Stefan Esser se at FreeBSD.org
Tue Jun 15 08:42:22 UTC 2010


Am 15.06.2010 09:53, schrieb Alexander Leidinger:
> Quoting jhell <jhell at dataix.net> (from Sat, 12 Jun 2010 08:17:18 -0400):
> 
>> On 06/11/2010 04:42, Alexander Leidinger wrote:
>> : #!/bin/sh
>> :
>> : lastscrub=$(zpool history exports |grep scrub |tail -1 |cut -f1 -d.)
>> : todayjul=$(date -j -f "%Y-%m-%d" "+%j" $(date "+%Y-%m-%d"))
>> : scrubjul=$(date -j -f "%Y-%m-%d" "+%j" $lastscrub)
>> :
>> : echo $lastscrub Last Scrub From zpool history
>> : echo $todayjul Today converted to julian
>> : echo $scrubjul Last scrub converted to julian
>> :
>> : expired=$(($todayjul-$scrubjul))
>>>
>>> Apart from the fact that we can do this with one $(( ))... what happens
>>> if/when time_t is extended to 64 bits on 32 bit platforms? Can we get
>>> into trouble with the shell-arithmetic or not? It depends upon the
>>> bit-size of the shell integers, and the signedness of them. Jilles (our
>>> shell maintainer) suggested also to use the seconds since epoch and I
>>> asked him the same question. I'm waiting for an answer from him.
>>>
>>
>> I do not think this would be a problem for the script as the script is
>> relying on date for the conversion except for the subtraction that is
>> taking place.
>>
>> If there was a problem then I would believe it would have to be
>> corrected in date(1) & possibly sh(1), I could be wrong though.
> 
> The question is if the integer arithmetic in shell is supposed/allowed
> to handle 64bit unsigned integers on 32bit machines or not.

I extended expr and test (standalone binaries and /bin/sh builtins) to
handle 64 bit on i386 a looong time ago (and I also added overflow
checks to all calculations). But then it was decided, that POSIX demands
32 bit range on 32 bit machines, so support for 64 bit range was made
conditional on a switch (expr -e if memory serves me right ...). So yes,
64 bit range is available on all platforms.

Best regards, STefan


More information about the freebsd-fs mailing list