From: Ole-Hjalmar Kristensen <ole.hjalmar.kristensen@gmail.com>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] venti/mirrorarenas usage
Date: Sun, 27 Oct 2024 10:57:38 +0100 [thread overview]
Message-ID: <CAHqDL_-QEoyProd_3HZBT8FHmxhFehXiOHq7Fxsx-s0uysvfFw@mail.gmail.com> (raw)
In-Reply-To: <17A842AE-951B-43EC-AAAB-E7B64377462F@germteig.com>
[-- Attachment #1: Type: text/plain, Size: 4668 bytes --]
I just stumbled across this thread, so I will repost something I wrote in
2017 about mirroring of venti. I had the need to create the union of two
venti servers, so I wrote a client that copies individual venti blocks,
given the scores. This you can do without worrying about what is on the
target venti, since the deduplication takes care of any conflicts. So, in
case it might be useful for someone, here it comes:
Based on copy.c and readlist.c, I have cobbled together a venti client to
copy a list of venti blocks from one venti server to another. I am thinking
of using it to incrementally replicate the contents on one site site to
another. It could even be used for two-way replication, since the CAS and
deduplicating properties of venti ensures that you will never have write
conflicts at a block level.
I have tried it out by feeding it with the output from printarenas, and it
seems to work reasonably well. Does anyone have any good ideas about how to
incrementally extract the set of scores that has been added to a venti
server? You could extract the whole set of scores and do a diff with an old
set of course, but that's rather inefficient.
Ole-Hj.
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <venti.h>
#include <bio.h>
enum
{
// XXX What to do here?
VtMaxLumpSize = 65535,
};
char *srchost;
char *dsthost;
Biobuf b;
VtConn *zsrc;
VtConn *zdst;
uchar *buf;
void run(Biobuf*);
int nn;
void
usage(void)
{
fprint(2, "usage: copylist srchost dsthost list\n");
threadexitsall("usage");
}
int
parsescore(uchar *score, char *buf, int n)
{
int i, c;
memset(score, 0, VtScoreSize);
if(n != VtScoreSize*2){
werrstr("score wrong length %d", n);
return -1;
}
for(i=0; i<VtScoreSize*2; i++) {
if(buf[i] >= '0' && buf[i] <= '9')
c = buf[i] - '0';
else if(buf[i] >= 'a' && buf[i] <= 'f')
c = buf[i] - 'a' + 10;
else if(buf[i] >= 'A' && buf[i] <= 'F')
c = buf[i] - 'A' + 10;
else {
c = buf[i];
werrstr("bad score char %d '%c'", c, c);
return -1;
}
if((i & 1) == 0)
c <<= 4;
score[i>>1] |= c;
}
return 0;
}
void
threadmain(int argc, char *argv[])
{
int fd, i;
ARGBEGIN{
default:
usage();
break;
}ARGEND
if(argc < 2)
usage();
fmtinstall('V', vtscorefmt);
buf = vtmallocz(VtMaxLumpSize);
srchost = argv[0];
zsrc = vtdial(srchost);
if(zsrc == nil)
sysfatal("could not dial src server: %r");
if(vtconnect(zsrc) < 0)
sysfatal("vtconnect src: %r");
dsthost = argv[1];
zdst = vtdial(dsthost);
if(zdst == nil)
sysfatal("could not dial dst server: %r");
if(vtconnect(zdst) < 0)
sysfatal("vtconnect dst: %r");
if(argc == 2){
Binit(&b, 0, OREAD);
run(&b);
}else{
for(i=2; i<argc; i++){
if((fd = open(argv[i], OREAD)) < 0)
sysfatal("open %s: %r", argv[i]);
Binit(&b, fd, OREAD);
run(&b);
}
}
threadexitsall(nil);
}
void
run(Biobuf *b)
{
char *p, *f[10];
int nf;
uchar score[20];
int type, n;
while((p = Brdline(b, '\n')) != nil){
p[Blinelen(b)-1] = 0;
nf = tokenize(p, f, nelem(f));
if(nf != 2)
sysfatal("syntax error in work list");
if(parsescore(score, f[0], strlen(f[0])) < 0)
sysfatal("bad score %s in work list", f[0]);
type = atoi(f[1]);
n = vtread(zsrc, score, type, buf, VtMaxLumpSize);
if(n < 0)
sysfatal("could not read %s %s: %r", f[0], f[1]);
n = vtwrite(zdst, score, type, buf, n);
if(n < 0)
sysfatal("could not write %s %s: %r", f[0], f[1]);
if(++nn%1000 == 0)
print("%d...", nn);
}
}
On Fri, Aug 2, 2024 at 7:08 PM Marco Feichtinger <marco@germteig.com> wrote:
> Thank you very much guys, there are some helpful answers,
> even though this thread got a little messy. (didn't see that coming)
>
> Charles Forsyth, since you are using venti/mirrorarenas,
> if you don't mind, I would like to know what your venti.conf looks like.
>
> -marco
>
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tca0eb0fbb2404e31-Ma9856351c69b05b0716dccc0
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 9225 bytes --]
next prev parent reply other threads:[~2024-10-27 9:58 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 5:29 Marco Feichtinger
2024-07-30 6:18 ` [9fans] " kalona.ayeliski
2024-07-30 6:57 ` Cherokee [Re: [9fans] Re: venti/mirrorarenas usage)] quiekaizam via 9fans
2024-07-30 7:32 ` kalona.ayeliski
2024-07-30 16:19 ` [9fans] Re: venti/mirrorarenas usage hiro
2024-07-30 21:42 ` kalona.ayeliski
2024-07-30 22:59 ` ori
2024-07-31 0:09 ` kalona.ayeliski
2024-07-31 0:54 ` Kurt H Maier via 9fans
2024-07-31 1:01 ` kalona.ayeliski
2024-07-31 1:19 ` Dave Eckhardt
2024-07-31 1:33 ` kalona.ayeliski
2024-07-31 2:07 ` moody
2024-07-31 13:43 ` Charles Forsyth
2024-07-31 2:18 ` ori
2024-07-31 4:55 ` moody
2024-07-31 7:55 ` kalona.ayeliski
2024-07-31 3:45 ` Kurt H Maier via 9fans
2024-07-31 4:28 ` kalona.ayeliski
2024-07-31 7:53 ` sirjofri
2024-07-31 9:09 ` hiro
2024-07-31 9:39 ` sirjofri
2024-07-31 9:56 ` Steve Simon
2024-07-31 11:33 ` kalona.ayeliski
2024-07-31 14:17 ` Stanley Lieber
2024-07-31 18:32 ` Noam Preil
2024-07-31 18:43 ` Noam Preil
2024-08-01 0:25 ` kalona.ayeliski
2024-08-01 0:20 ` Noam Preil
2024-08-01 2:31 ` B. Atticus Grobe
2024-08-01 8:27 ` hiro
2024-08-01 9:12 ` plan6
2024-08-01 9:53 ` kalona.ayeliski
2024-08-01 10:49 ` kalona.ayeliski
2024-08-01 12:28 ` Noam Preil
2024-08-01 11:36 ` kalona.ayeliski
2024-08-01 17:00 ` Ori Bernstein
2024-08-02 17:07 ` [9fans] " Marco Feichtinger
2024-10-27 9:57 ` Ole-Hjalmar Kristensen [this message]
2024-10-29 14:42 ` wb.kloke
2024-08-01 0:36 ` [9fans] " Dave Eckhardt
2024-08-01 1:01 ` kalona.ayeliski
2024-08-01 0:21 ` Noam Preil
2024-08-01 2:23 ` Dave Eckhardt
2024-08-01 2:34 ` kalona.ayeliski
2024-08-01 2:46 ` Kurt H Maier via 9fans
2024-08-01 4:52 ` kalona.ayeliski
2024-08-01 5:16 ` kalona.ayeliski
2024-08-01 8:08 ` sirjofri
2024-08-01 8:27 ` hiro
2024-08-01 12:20 ` Noam Preil
2024-08-01 12:20 ` Noam Preil
2024-07-31 4:49 ` [9fans] " ori
2024-08-01 19:13 ` [9fans] " wb.kloke
2024-08-01 19:57 ` Steve Simon
2024-08-01 20:32 ` kalona.ayeliski
2024-08-03 20:58 ` [9fans] " noam
2024-08-03 18:10 ` kalona.ayeliski
2024-08-03 18:14 ` Kurt H Maier via 9fans
2024-08-03 22:27 ` noam
2024-08-03 18:27 ` kalona.ayeliski
2024-08-03 18:40 ` Kurt H Maier via 9fans
2024-08-03 19:06 ` kalona.ayeliski
2024-08-03 20:24 ` sirjofri
2024-08-03 21:14 ` kalona.ayeliski
2024-08-04 16:30 ` noam
2024-08-04 16:29 ` noam
2024-08-03 22:29 ` noam
2024-08-03 19:09 ` wb.kloke
2024-08-04 16:34 ` noam
2024-08-04 14:07 ` wb.kloke
2024-08-04 14:39 ` Noam Preil
2024-08-04 6:35 ` Marco Feichtinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAHqDL_-QEoyProd_3HZBT8FHmxhFehXiOHq7Fxsx-s0uysvfFw@mail.gmail.com \
--to=ole.hjalmar.kristensen@gmail.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).