Do we want a periodic script for a zfs scrub?

Alexander Leidinger Alexander at Leidinger.net
Tue Jun 15 07:53:39 UTC 2010


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.

> Another situation that had come to mind is when & certainly being
> possible that the time on the system could drop to before the last scrub
> has taken place causing (using the above script for example) todayjul to
> be less than scrubjul and in that case would output a negative integer
> that would skew results until the system time has been restored to its
> correct & current date & time.

I think there are more places which are screwed up when the time is  
not correct, so I will not say "hey, yeah! let's add some code for  
this" now (I see no problem if there is no scrub until the date of the  
machine is fixed).

Bye,
Alexander.

-- 
Be sure to evaluate the bird-hand/bush ratio.

http://www.Leidinger.net    Alexander @ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org       netchild @ FreeBSD.org  : PGP ID = 72077137


More information about the freebsd-fs mailing list