* [9fans] venti backup example vs. 2GB
@ 2006-09-25 21:11 Robert Raschke
2006-09-25 21:28 ` geoff
2006-09-26 0:49 ` Russ Cox
0 siblings, 2 replies; 7+ messages in thread
From: Robert Raschke @ 2006-09-25 21:11 UTC (permalink / raw)
To: 9fans
Hi,
I've been using a backup script modelled on the example in
/sys/src/cmd/venti/backup.example and the other day it "just" stopped
working. On debugging I found that I have now reached the beginning
of the fifth 500MB arena. The script uses awk to calculate the
starting byte offset and that fails with a floating point error (!)
when we go beyond the 2G mark.
I resorted to a fairly brutal use of bc(1) and that seems to work.
Here's what I use now (I flipped the 2nd and 3rd parameter to the x fn
to make printing from bc easier):
#!/bin/rc
rfork e
. bkup.info
fn x {
echo x $*
y=$1
if(~ $#$y 0){
$y=0
}
echo venti/wrarena -h venti_backup_server -o $3 $2 $$y
end=`{venti/wrarena -h venti_backup_server -o $3 $2 $$y | grep '^end offset ' | sed 's/^end offset //'}
if(~ $#end 1 && ! ~ $$y $end){
$y=$end
echo '#' `{date} >>bkup.info
whatis $y >>bkup.info
}
}
hget http://127.1:8000/index |
awk '
/^index=/ { blockSize=0+substr($3, 11); }
/^arena=/ { arena=substr($1, 7); }
/^ arena=/ {
start=substr($5, 2, index($5, ",")-2);
printf("\"x \"; \"%s \"; \"%s \"; s=%s-%s; print s;", arena, $3, start, blockSize);
}
' |bc -s |rc
Robby
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] venti backup example vs. 2GB
2006-09-25 21:11 [9fans] venti backup example vs. 2GB Robert Raschke
@ 2006-09-25 21:28 ` geoff
2006-09-25 21:53 ` geoff
2006-09-26 0:09 ` erik quanstrom
2006-09-26 0:49 ` Russ Cox
1 sibling, 2 replies; 7+ messages in thread
From: geoff @ 2006-09-25 21:28 UTC (permalink / raw)
To: 9fans
I think that the floating-point exception is from converting the
internal floating-point representation of start to an int for printing
with %d. Numbers above 2^31 won't fit in a signed int, thus the
exception. awk doesn't seem to have any form of vlong, nor %lld;
perhaps it should.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] venti backup example vs. 2GB
2006-09-25 21:28 ` geoff
@ 2006-09-25 21:53 ` geoff
2006-09-26 0:09 ` erik quanstrom
1 sibling, 0 replies; 7+ messages in thread
From: geoff @ 2006-09-25 21:53 UTC (permalink / raw)
To: 9fans
... or perhaps %g suffices.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] venti backup example vs. 2GB
2006-09-25 21:28 ` geoff
2006-09-25 21:53 ` geoff
@ 2006-09-26 0:09 ` erik quanstrom
2006-09-26 0:12 ` geoff
1 sibling, 1 reply; 7+ messages in thread
From: erik quanstrom @ 2006-09-26 0:09 UTC (permalink / raw)
To: 9fans
perhaps awk numbers should be 64 bits?
- erik
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] venti backup example vs. 2GB
2006-09-26 0:09 ` erik quanstrom
@ 2006-09-26 0:12 ` geoff
2006-09-26 0:18 ` erik quanstrom
0 siblings, 1 reply; 7+ messages in thread
From: geoff @ 2006-09-26 0:12 UTC (permalink / raw)
To: 9fans
They are 64 bits, just floating-point. Changing them to an integral
type would break lots of existing awk programs.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] venti backup example vs. 2GB
2006-09-26 0:12 ` geoff
@ 2006-09-26 0:18 ` erik quanstrom
0 siblings, 0 replies; 7+ messages in thread
From: erik quanstrom @ 2006-09-26 0:18 UTC (permalink / raw)
To: 9fans
i guess i didn't say what i ment. there are places where the Awkfloat
is treated as an integer and manipulated with a signed int or long.
i was suggesting replacing that with vlong.
- erik
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] venti backup example vs. 2GB
2006-09-25 21:11 [9fans] venti backup example vs. 2GB Robert Raschke
2006-09-25 21:28 ` geoff
@ 2006-09-26 0:49 ` Russ Cox
1 sibling, 0 replies; 7+ messages in thread
From: Russ Cox @ 2006-09-26 0:49 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
You can use %.0f to print the number from awk.
Russ
On 9/25/06, Robert Raschke <rrplan9@tombob.com> wrote:
> Hi,
>
> I've been using a backup script modelled on the example in
> /sys/src/cmd/venti/backup.example and the other day it "just" stopped
> working. On debugging I found that I have now reached the beginning
> of the fifth 500MB arena. The script uses awk to calculate the
> starting byte offset and that fails with a floating point error (!)
> when we go beyond the 2G mark.
>
> I resorted to a fairly brutal use of bc(1) and that seems to work.
> Here's what I use now (I flipped the 2nd and 3rd parameter to the x fn
> to make printing from bc easier):
>
> #!/bin/rc
>
> rfork e
> . bkup.info
> fn x {
> echo x $*
> y=$1
> if(~ $#$y 0){
> $y=0
> }
> echo venti/wrarena -h venti_backup_server -o $3 $2 $$y
> end=`{venti/wrarena -h venti_backup_server -o $3 $2 $$y | grep '^end offset ' | sed 's/^end offset //'}
> if(~ $#end 1 && ! ~ $$y $end){
> $y=$end
> echo '#' `{date} >>bkup.info
> whatis $y >>bkup.info
> }
> }
> hget http://127.1:8000/index |
> awk '
> /^index=/ { blockSize=0+substr($3, 11); }
> /^arena=/ { arena=substr($1, 7); }
> /^ arena=/ {
> start=substr($5, 2, index($5, ",")-2);
> printf("\"x \"; \"%s \"; \"%s \"; s=%s-%s; print s;", arena, $3, start, blockSize);
> }
> ' |bc -s |rc
>
>
> Robby
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-09-26 0:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-25 21:11 [9fans] venti backup example vs. 2GB Robert Raschke
2006-09-25 21:28 ` geoff
2006-09-25 21:53 ` geoff
2006-09-26 0:09 ` erik quanstrom
2006-09-26 0:12 ` geoff
2006-09-26 0:18 ` erik quanstrom
2006-09-26 0:49 ` Russ Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).