Browse Source

Plan 9 from Bell Labs 2008-04-24

David du Colombier 16 years ago
parent
commit
61ffdb7b17

+ 7 - 1
dist/replica/_plan9.db

@@ -5852,7 +5852,7 @@ sys/games - 20000000775 sys sys 1117225532 0
 sys/games/lib - 20000000775 sys sys 1165337608 0
 sys/games/lib - 20000000775 sys sys 1165337608 0
 sys/games/lib/4scores - 10000000666 sys sys 1118680448 0
 sys/games/lib/4scores - 10000000666 sys sys 1118680448 0
 sys/games/lib/5scores - 10000000666 sys sys 1118680453 0
 sys/games/lib/5scores - 10000000666 sys sys 1118680453 0
-sys/games/lib/fortunes - 664 sys sys 1207370998 268981
+sys/games/lib/fortunes - 664 sys sys 1208978371 269327
 sys/games/lib/mahjongg - 20000000775 sys sys 1095792278 0
 sys/games/lib/mahjongg - 20000000775 sys sys 1095792278 0
 sys/games/lib/mahjongg/backgrounds - 20000000775 sys sys 1095792293 0
 sys/games/lib/mahjongg/backgrounds - 20000000775 sys sys 1095792293 0
 sys/games/lib/mahjongg/backgrounds/default.bit - 664 sys sys 1095792293 346803
 sys/games/lib/mahjongg/backgrounds/default.bit - 664 sys sys 1095792293 346803
@@ -14441,6 +14441,12 @@ sys/src/cmd/venti/srv/xml.h - 664 sys sys 1142736357 450
 sys/src/cmd/venti/srv/zblock.c - 664 sys sys 1178160305 1659
 sys/src/cmd/venti/srv/zblock.c - 664 sys sys 1178160305 1659
 sys/src/cmd/venti/srv/zeropart.c - 664 sys sys 1178160305 707
 sys/src/cmd/venti/srv/zeropart.c - 664 sys sys 1178160305 707
 sys/src/cmd/venti/sync.c - 664 sys sys 1177189440 726
 sys/src/cmd/venti/sync.c - 664 sys sys 1177189440 726
+sys/src/cmd/venti/words - 20000000775 sys sys 1208985205 0
+sys/src/cmd/venti/words/backup.example - 775 sys sys 1045503662 521
+sys/src/cmd/venti/words/dumpvacroots - 775 sys sys 1163468045 571
+sys/src/cmd/venti/words/notes - 664 sys sys 1068500911 4032
+sys/src/cmd/venti/words/venti.conf - 664 sys sys 1019867537 397
+sys/src/cmd/venti/words/wrtape - 775 sys sys 1019678881 555
 sys/src/cmd/venti/write.c - 664 sys sys 1177189440 1106
 sys/src/cmd/venti/write.c - 664 sys sys 1177189440 1106
 sys/src/cmd/vi - 20000000775 sys sys 1039727599 0
 sys/src/cmd/vi - 20000000775 sys sys 1039727599 0
 sys/src/cmd/vi/bpt.c - 664 sys sys 944961341 2216
 sys/src/cmd/vi/bpt.c - 664 sys sys 944961341 2216

+ 7 - 1
dist/replica/plan9.db

@@ -5852,7 +5852,7 @@ sys/games - 20000000775 sys sys 1117225532 0
 sys/games/lib - 20000000775 sys sys 1165337608 0
 sys/games/lib - 20000000775 sys sys 1165337608 0
 sys/games/lib/4scores - 10000000666 sys sys 1118680448 0
 sys/games/lib/4scores - 10000000666 sys sys 1118680448 0
 sys/games/lib/5scores - 10000000666 sys sys 1118680453 0
 sys/games/lib/5scores - 10000000666 sys sys 1118680453 0
-sys/games/lib/fortunes - 664 sys sys 1207370998 268981
+sys/games/lib/fortunes - 664 sys sys 1208978371 269327
 sys/games/lib/mahjongg - 20000000775 sys sys 1095792278 0
 sys/games/lib/mahjongg - 20000000775 sys sys 1095792278 0
 sys/games/lib/mahjongg/backgrounds - 20000000775 sys sys 1095792293 0
 sys/games/lib/mahjongg/backgrounds - 20000000775 sys sys 1095792293 0
 sys/games/lib/mahjongg/backgrounds/default.bit - 664 sys sys 1095792293 346803
 sys/games/lib/mahjongg/backgrounds/default.bit - 664 sys sys 1095792293 346803
@@ -14441,6 +14441,12 @@ sys/src/cmd/venti/srv/xml.h - 664 sys sys 1142736357 450
 sys/src/cmd/venti/srv/zblock.c - 664 sys sys 1178160305 1659
 sys/src/cmd/venti/srv/zblock.c - 664 sys sys 1178160305 1659
 sys/src/cmd/venti/srv/zeropart.c - 664 sys sys 1178160305 707
 sys/src/cmd/venti/srv/zeropart.c - 664 sys sys 1178160305 707
 sys/src/cmd/venti/sync.c - 664 sys sys 1177189440 726
 sys/src/cmd/venti/sync.c - 664 sys sys 1177189440 726
+sys/src/cmd/venti/words - 20000000775 sys sys 1208985205 0
+sys/src/cmd/venti/words/backup.example - 775 sys sys 1045503662 521
+sys/src/cmd/venti/words/dumpvacroots - 775 sys sys 1163468045 571
+sys/src/cmd/venti/words/notes - 664 sys sys 1068500911 4032
+sys/src/cmd/venti/words/venti.conf - 664 sys sys 1019867537 397
+sys/src/cmd/venti/words/wrtape - 775 sys sys 1019678881 555
 sys/src/cmd/venti/write.c - 664 sys sys 1177189440 1106
 sys/src/cmd/venti/write.c - 664 sys sys 1177189440 1106
 sys/src/cmd/vi - 20000000775 sys sys 1039727599 0
 sys/src/cmd/vi - 20000000775 sys sys 1039727599 0
 sys/src/cmd/vi/bpt.c - 664 sys sys 944961341 2216
 sys/src/cmd/vi/bpt.c - 664 sys sys 944961341 2216

+ 7 - 0
dist/replica/plan9.log

@@ -19031,3 +19031,10 @@
 1208662204 0 c 386/bin/cdfs - 775 sys sys 1208662151 173247
 1208662204 0 c 386/bin/cdfs - 775 sys sys 1208662151 173247
 1208725204 0 c sys/man/2/auth - 664 sys sys 1208725235 7535
 1208725204 0 c sys/man/2/auth - 664 sys sys 1208725235 7535
 1208881804 0 c sys/src/mkfile.proto - 664 sys sys 1208881081 266
 1208881804 0 c sys/src/mkfile.proto - 664 sys sys 1208881081 266
+1208979003 0 c sys/games/lib/fortunes - 664 sys sys 1208978371 269327
+1208986205 0 a sys/src/cmd/venti/words - 20000000775 sys sys 1208985205 0
+1208986205 1 a sys/src/cmd/venti/words/backup.example - 775 sys sys 1045503662 521
+1208986205 2 a sys/src/cmd/venti/words/dumpvacroots - 775 sys sys 1163468045 571
+1208986205 3 a sys/src/cmd/venti/words/notes - 664 sys sys 1068500911 4032
+1208986205 4 a sys/src/cmd/venti/words/venti.conf - 664 sys sys 1019867537 397
+1208986205 5 a sys/src/cmd/venti/words/wrtape - 775 sys sys 1019678881 555

+ 3 - 0
sys/games/lib/fortunes

@@ -192,6 +192,7 @@ As goatherd learns his trade by goat, so writer learns his trade by wrote.
 As of Tuesday, C will be flushed in favor of COBOL. Please update all programs.
 As of Tuesday, C will be flushed in favor of COBOL. Please update all programs.
 Assassination is the extreme form of censorship.
 Assassination is the extreme form of censorship.
 At the feast of souls failure is always the guest of honor.
 At the feast of souls failure is always the guest of honor.
+Atomic compare and exchange.  These sequences are not actually atomic [⋯].  However, they are very close to atomic, [⋯] LinuxThreads has been using these sequences for many years.
 Attend winter sheep meetings. Learning never ends!
 Attend winter sheep meetings. Learning never ends!
 Auribus teneo lupum.
 Auribus teneo lupum.
 Automating a mess yields an automated mess. -Michael Hammer
 Automating a mess yields an automated mess. -Michael Hammer
@@ -4219,3 +4220,5 @@ Perfection is achieved, not when there is nothing more to add, but when there is
   bucket = Buckets + pe; /* bucket = &(Buckets[pe]); */
   bucket = Buckets + pe; /* bucket = &(Buckets[pe]); */
 Those who can do, those who can't write and those who can't write make ezines. - Sape
 Those who can do, those who can't write and those who can't write make ezines. - Sape
 Command (m for help): 
 Command (m for help): 
+`the dreaded Wordstar, the Wordprocessor that Time joined the Foreign Legion to Forget.' - Verity Stob
+Please contact nicfae@realtek.com.tw for singing NDA form.

+ 26 - 0
sys/src/cmd/venti/words/backup.example

@@ -0,0 +1,26 @@
+#!/bin/rc
+
+rfork e
+cd /usr/rsc
+. bkup.info
+fn x {
+	echo x $*
+	y=$1
+	if(~ $#$y 0){
+		$y=0
+	}
+	echo venti/wrarena -o $2 $3 $$y
+	end=`{venti/wrarena -o $2 $3 $$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=0+substr($5, 2)-blockSize; printf("x %s %d %s\n", arena, start, $3); }
+' |rc
+

+ 19 - 0
sys/src/cmd/venti/words/dumpvacroots

@@ -0,0 +1,19 @@
+#!/bin/rc
+# dumpvacroots - dumps all the vac scores ever stored to the venti server
+# if nothing else, this illustrates that you have to control access
+# to the physical disks storing the archive!
+
+ventihttp=`{echo $venti | sed 's/^[a-z]+!([0-9\.]+)![a-z0-9]+$/\1/
+		s/^[a-z]+!([0-9\.]+)/\1/; s/$/:80/'
+}
+
+hget http://$ventihttp/index | 
+	awk '
+ /^index=/ { blockSize=0+substr($3, 11) }
+ /^arena=/ { arena=substr($1, 7) }
+ /^	arena=/ {
+		start = (0+substr($5, 2))-blockSize
+		printf("venti/printarena -o %.0f %s\n", start, $3 "")
+}' |
+	rc |
+	sed -n 's/^(.*) 1$/vac:\1/p'

+ 149 - 0
sys/src/cmd/venti/words/notes

@@ -0,0 +1,149 @@
+all data is big-endian on disk.
+
+arena layout:
+
+ArenaPart (first at offset PartBlank = 256kB in the disk file)
+	magic[4] 0xA9E4A5E7
+	version[4] 3
+	blockSize[4]
+	arenaBase[4] offset of first ArenaHead structure in the disk file
+
+the ArenaMap starts at the first block at offset >= PartBlank+512 bytes.
+it is a sequence of text lines
+/*
+ * amap: n '\n' amapelem * n
+ * n: u32int
+ * amapelem: name '\t' astart '\t' asize '\n'
+ * astart, asize: u64int
+ */
+
+the astart and astop are byte offsets in the disk file.
+they are the offsets to the ArenaHead and the end of the Arena block.
+
+ArenaHead 
+[base points here in the C code]
+size bytes
+	Clumps
+	ClumpInfo blocks
+Arena
+
+Arena
+	magic[4] 0xF2A14EAD
+	version[4] 4
+	name[64]
+	clumps[4]
+	cclumps[4]
+	ctime[4]
+	wtime[4]
+	used[8]
+	uncsize[8]
+	sealed[1]
+	optional score[20]
+
+once sealed, the sha1 hash of every block from the
+ArenaHead to the Arena is checksummed, as though
+the final score in Arena were the zeroScore.  strangely,
+the tail of the Arena block (the last one) is not included in the checksum
+(i.e., the unused data after the score).
+
+clumpMax = blocksize/ClumpInfoSize = blocksize/25
+dirsize = ((clumps/clumpMax)+1) * blocksize
+want used+dirsize <= size
+want cclumps <= clumps
+want uncsize+clumps*ClumpSize+blocksize < used
+want ctime <= wtime
+
+clump info is stored packed into blocks in order.
+clump info moves forward through a block but the
+blocks themselves move backwards.  so if cm=clumpMax
+and there are two blocks worth of clumpinfo, the blocks
+look like;
+
+	[cm..2*cm-1] [0..cm-1] [Arena]
+
+with the blocks pushed right up against the Arena trailer.
+
+ArenaHead
+	magic[4] 0xD15C4EAD
+	version[4] = Arena.version
+	name[64]
+	blockSize[4]
+	size[8]
+
+Clump
+	magic[4] 0xD15CB10C (0 for an unused clump)
+	type[1]
+	size[2]
+	uncsize[2]
+	score[20]
+	encoding[1] raw=1, compress=2
+	creator[4]
+	time[4]
+
+ClumpInfo
+	type[1]
+	size[2]
+	uncsize[2]
+	score[20]
+
+the arenas are mapped into a single address space corresponding
+to the index that brings them together.  if each arena has 100M bytes
+excluding the headers and there are 4 arenas, then there's 400M of
+index address space between them.  index address space starts at 1M
+instead of 0, so the index addresses assigned to the first arena are
+1M up to 101M, then 101M to 201M, etc.
+
+of course, the assignment of addresses has nothing to do with the index,
+but that's what they're called.
+
+
+the index is split into index sections, which are put on different disks
+to get parallelism of disk heads.  each index section holds some number
+of hash buckets, each in its own disk block.  collectively the index sections
+hold ix->buckets between them. 
+
+the top 32-bits of the score is used to assign scores to buckets.
+div = ceil(2³² / ix->buckets) is the amount of 32-bit score space per bucket.
+
+to look up a block, take the top 32 bits of score and divide by div
+to get the bucket number.  then look through the index section headers
+to figure out which index section has that bucket.
+
+then load that block from the index section.  it's an IBucket.
+
+the IBucket has ib.n IEntry structures in it, sorted by score and then by type.
+do the lookup and get an IEntry.  the ia.addr will be a logical address
+that you then use to get the 
+
+ISect
+	magic[4] 0xD15C5EC7
+	version[4]
+	name[64]
+	index[64]
+	blockSize[4]
+	blockBase[4]	address in partition where bucket blocks start
+	blocks[4]
+	start[4]
+	stop[4]	stop - start <= blocks, but not necessarily ==
+
+IEntry
+	score[20]
+	wtime[4]
+	train[2]
+	ia.addr[8]		index address (see note above)
+	ia.size[2]		size of uncompressed block data
+	ia.type[1]
+	ia.blocks[1]	number of blocks of clump on disk
+
+IBucket
+	n[2]
+	next[4]	not sure; either 0 or inside [start,stop) for the ISect
+	data[n*IEntrySize]
+
+final piece: all the disk partitions start with PartBlank=256kB of unused disk
+(presumably to avoid problems with boot sectors and layout tables
+and the like).
+
+actually the last 8k of the 256k (that is, at offset 248kB) can hold
+a venti config file to help during bootstrap of the venti file server.
+

+ 20 - 0
sys/src/cmd/venti/words/venti.conf

@@ -0,0 +1,20 @@
+# a sample venti configuration file
+#
+# formated with
+#	venti/fmtarenas arena. /tmp/disks/arenas
+# 	venti/fmtisect isect0 /tmp/disks/isect0
+# 	venti/fmtisect isect1 /tmp/disks/isect1
+#	venti/fmtindex venti.conf
+#
+# server is started with
+#	venti/venti
+
+# the name of the index
+index main
+
+# the index sections
+isect /tmp/disks/isect0
+isect /tmp/disks/isect1
+
+# the arenas
+arenas /tmp/disks/arenas

+ 21 - 0
sys/src/cmd/venti/words/wrtape

@@ -0,0 +1,21 @@
+#!/bin/rc
+
+tape=$1
+
+start=`{echo $tape'*32+1' | hoc}
+end=`{echo  $start'+31' | hoc}
+
+echo rewind | scuzz /dev/sd03
+
+arenas=`{hget http://iolaire/index | grep '^arena' | sed  -n $start,$end^p | sed 's/^.*=//' | sed 's/ .*//'}
+for(i in $arenas) {
+	dev=`{hget http://iolaire/index | grep ''''$i'''' | sed 's/.* on //' | sed 's/ .*//'}
+	echo `{date} $tape $i
+	echo `{date} $tape $i >> /sys/log/ventibackup
+	echo $dev
+	echo write '''|venti/rdarena $dev $i''' | scuzz -m 8192 /dev/sd03
+	echo filemark | scuzz -m 6144 /dev/sd03
+}
+
+echo rewind | scuzz /dev/sd03
+