ðŸ Archived View for kamalatta.ddnss.de ⺠cwfs-eng.txt captured on 2021-12-05 at 23:47:19.
View Raw
More Information
â¬
ïž Previous capture (2021-11-30)
â¡ïž Next capture (2024-07-08)
-=-=-=-=-=-=-
cwfs ã®ç 究 Study of cwfs
ç®æ¬¡ table of contents
⢠1.0.0 cwfs ãšã¯ 1.0.0 What is cwfs
⢠2.0.0 cwfs console 2.0.0 cwfs console
⢠2.1.0 æŠèŠ 2.1.0 Overview
⢠2.2.0 fsworm ã®ããã¯ã¢ãã 2.2.0 backup of fsworm
⢠3.0.0 fsworm ã®æ§é 3.0.0 Structure of fsworm
⢠3.1.0 Block 3.1.0 Block
⢠3.2.0 dump stack 3.2.0 dump stack
⢠3.3.0 Super Block 3.3.0 Super Block
⢠3.4.0 Directory Entry Block 3.4.0 Directory Entry Block
⢠3.5.0 Indirect Block 3.5.0 Indirect Block
⢠3.6.0 File Block 3.6.0 File Block
⢠3.7.0 Fsworm Root 3.7.0 Fsworm Root
⢠3.8.0 ãã³ãã®é åº 3.8.0 Dump order
⢠3.9.0 qid 3.9.0 qid
⢠4.0.0 fscache ã®æ§é 4.0.0 Structure of fscache
⢠4.1.0 Config Block 4.1.0 Config Block
⢠4.2.0 Tcache Block 4.2.0 Tcache Block
⢠4.3.0 Mapping 4.3.0 Mapping
⢠4.3.1 bucket 4.3.1 bucket
⢠4.3.2 cache entry 4.3.2 cache entry
⢠4.3.3 age 4.3.3 age
⢠4.3.4 state 4.3.4 state
⢠4.4.0 free block and dirty block 4.4.0 free block and dirty block
⢠4.5.0 msize 㚠csize 4.5.0 msize and csize
⢠4.6.0 Map from Worm to Cache 4.6.0 Map from Worm to Cache
⢠4.7.0 msize ã®æ±ºå®ã¢ã«ãŽãªãºã 4.7.0 msize determination algorithm
⢠4.8.0 Fscache Root 4.8.0 Fscache Root
⢠5.0.0 Recovery 5.0.0 Recovery
⢠5.1.0 埩å
(recovery) 5.1.0 recovery
⢠5.2.0 埩å
(recovery)ã«ã€ããŠåå³ 5.2.0 Review on recovery
⢠5.3.0 Recovery ã«ãã£ãŠå€±ããããã® 5.3.0 What is lost by Recovery
⢠6.0.0 Other Configurations 6.0.0 Other Configurations
⢠6.1.0 pseudo-RAID1 6.1.0 pseudo-RAID 1
⢠6.2.0 fake WORM 6.2.0 fake WORM
⢠6.2.1 fake WORM ã®äœæ 6.2.1 Creating fake WORM
⢠6.3.0 Tvirgo 6.3.0 Tvirgo
⢠7.0.0 Misc. 7.0.0 Misc.
⢠7.1.0 What did I do that day? 7.1.0 What did I do that day?
⢠7.2.0 atime 7.2.0 atime
⢠7.2.1 Plan9 7.2.1 Plan 9
⢠7.2.2 Linux 7.2.2 Linux
⢠7.2.3 OSX 7.2.3 OSX
⢠8.0.0 cwstudy 8.0.0 cwstudy
⢠8.1.0 usage 8.1.0 usage
⢠9.0.0 æç® References
2012/10/20 2012/10/20
2013/03/14 æŽæ° 2013/03/14 renewal
2013/03/28 æŽæ° Updated on March 20, 2013
2013/04/02 æŽæ° Updated 2013/04/02
2013/04/10 æŽæ° Updated 2013/04/10
2013/04/24 æŽæ° 2013/04/24 Update
2012幎ã®å€äŒã¿ã¯ã9front ã® cwfs ãè©ŠããŠããã For the summer vacation in 2012, I
was trying 9front's cwfs. cwfs 㯠fscache ãš fsworm ã§æ§æãããŠããããfsworm
ã®æ¹ãã調ã¹ãããšãšããã cwfs consists of fscache and fsworm, but we decided to
look it up from fsworm. fsworm ã®æ¹ã«é¢å¿ãããçç±ã¯ããã¡ã€ã«ã®å±¥æŽçã®æ
å ±ã¯ fsworm ã«çœ®ããããŸã
fscache ãã¯ã©ãã·ã¥ããæã®ãªã«ããªãŒã fsworm ã«åºã¥ããŠè¡ãããããã§ããã The reason why you are
more interested in fsworm is that information such as file history is
placed in fsworm and recovery when fscache crashes is done based on
fsworm.
ãã¡ããããããªãããã€ã¹ããããŠã¯æ»ãè¿ããã Of course, any device eventually will die.
fsworm ã«å¯ŸããŠãããã¯ã¢ãããå¿
èŠã§ããã Backup is necessary for fsworm. cwfs èªäœã
RAID ã«çœ®ãããšãèãããããããåã«ã¯å€§ãããããã It may be possible to put cwfs itself in
RAID, but it's too overkill for me. ããäžã€ HDD ãè¿œå ããŠãããã« fsworm
ã®ã³ããŒãæã¡ããã Add another HDD and want to have a copy of fsworm there.
ããã§ã¯ãã©ã®ããã«ã³ããŒããã°ãçæéã§ãããã®ã? ãã®åé¡ã解æãããã£ãã®ã§ããã So, how can we copy it
in a short time? I wanted to elucidate this problem.
9front ä»å±ã® cwfs 㯠cwfs64x ã§ããã The cwfs attached to 9front is cwfs64x.
ããã§ãããã§ã¯ cwfs64x ã«åºã¥ããŠè§£èª¬ããã Therefore, we will explain it based on
cwfs64x.
=======
泚æ: ãã®èšäºã¯ä»ã®ãšããçè
ã®ã¡ã¢ã«éããªãã Note: This article is just my memo so far.
ãã¡ããã誀ããå«ãã§ããããç¥ããªãã Of course, it may contain errors.
誀ããçºèŠãããç¥ãããŠããã ããã°å¹žãã§ããã I would be pleased if you let me know if you
find an error.
=======
cwfs ãšã¯ What is cwfs
ãã®ç¯ã¯æªå®æã§ããã This section is incomplete. æãªæã«æžãäºãšããã I will write it in
my spare time.
泚æ: ããªãã®ãã©ãŠã¶ã¯ SVG ããµããŒãããŠããŸããã Note: Your browser does not support
SVG.ææ°ã®ãã©ãŠã¶ãã䜿ããã ããã Please use the latest browser.
å³1. layer Figure 1. layer
Sean Quinlan (Ph.D) Sean Quinlan (Ph.D)
Ken Thompson (Ken's fs) Ken Thompson (Ken's fs)
Plan9 2nd edition (1995) Plan 9 2nd edition (1995)
Geoff Collyer (2007/03/27 mail) Geoff Collyer (2007/03/27 mail)
9front (2011) 9front (2011)
éå»ã®å±¥æŽ Past History
WORM (write once read many) WORM (write once read many)
æ¶ããªã(æ¶ããªã) It will not disappear (can not be erased)
dump dump
Mac/OSX ã® time machine ãšã®æ¯èŒ Comparison with Mac / OSX time machine
pdumpfs pdumpfs
以åã¯ãµãŒãã®ããã«1å°ãå²ãåœãŠãŠããã Previously we had one assigned for the server.
memory: ãã¡ã€ã«ãµãŒãå°çšæ©ã®äžã®ã¡ã¢ãªãŒ memory: Memory in the dedicated file server
disk: disk cache disk: disk cache
WORM: å
ãã£ã¹ã¯ WORM: Optical disc
çŸåšã¯ Plan9 ã®åºã§åããŠãŒã¶ãŒããã°ã©ã cwfs Currently it runs under Plan 9 user
program cwfs
ãŠãŒã¶ããã°ã©ã ã§ããäºã®å©ç¹: ä»çµã¿ã調ã¹ãããã Advantages of being a user program: It is
easy to check the mechanism.
memory: cwfs daemon äžã®ã¡ã¢ãªãŒ memory: memory in cwfs daemon
disk: ãã¡ã€ã«ãµãŒãã® fscache ããŒãã£ã·ã§ã³ disk: fscache partition of file server
WORM: ãã¡ã€ã«ãµãŒãã® fsworm ããŒãã£ã·ã§ã³ WORM: File server fsworm partition
cwfs (or cwfs32) cwfs (or cwfs32)
cwfs64 cwfs64
cwfs64x cwfs64x
cwfs console cwfs console
æŠèŠ Overview
cwfs ã«é¢ããåã®ããŒãã£ã·ã§ã³ã®ãµã€ãºã¯æ¬¡ã®éãã§ããã The size of my partition on cwfs is as
follows.
term% ls -l /dev/sdC0/fs* term% ls - l / dev / sdC 0 / fs *
--rw-r----- S 0 arisawa arisawa 22848146432 Sep 13 09:50
/dev/sdC0/fscache - rw - r ---- - S 0 arisawa arisawa 22848146432 Sep
13 09: 50 / dev / sdC 0 / fscache
--rw-r----- S 0 arisawa arisawa 114240734208 Sep 13 09:50
/dev/sdC0/fsworm - rw - r ----- S 0 arisawa arisawa 114240734208 Sep
13 09: 50 / dev / sdC 0 / fsworm
term% term%
cwfs ã³ã³ãœãŒã«ã¯ã³ãã³ã The cwfs console uses commands
con -C /srv/cwfs.cmd con -C /srv/cwfs.cmd
ã§äœ¿ããããã«ãªãã You will be able to use with.
=======
泚æ: ãŠã£ã³ããæ°ãã«1ã€äœã£ãŠ Note: Create one new window
cat /srv/cwfs.cmd cat /srv/cwfs.cmd
ãå®è¡ããŠãããŠãä»ã®ãŠã£ã³ããŠãã Run it from another window
echo statw>> /srv/cwfs.cmd echo statw>> /srv/cwfs.cmd
ãå®è¡ããŠãããã May be executed. é
åžçã¯ãã®æ¹æ³ãæ³å®ããŠãããšæãããã Distribution seems to
assume this method.
=======
cwfs ã³ã³ãœãŒã«ã§ statw ãå®è¡ãããšãfsworm ã®å©çšçµ±èšãåºåãããã Running statw on the cwfs
console will output usage statistics for fsworm.次ã«ãã®åºåäŸã瀺ãã Next, an
example of the output is shown.
> statw> statw
cwstats main cwstats main
filesys main filesys main
maddr = 3 maddr = 3
msize = 10313 msize = 10313
caddr = 1035 caddr = 1035
csize = 1392255 csize = 1392255
sbaddr = 1755217 sbaddr = 1755217
craddr = 1755389 1755389 craddr = 1755389 1755389
roaddr = 1755392 1755392 roaddr = 1755392 1755392
fsize = 1755394 1755394 0+25% fsize = 1755394 1755394 0 + 25%
slast = 1754642 slast = 1754642
snext = 1755393 snext = 1755393
wmax = 1755392 0+25% wmax = 1755392 0 + 25%
wsize = 6972701 1+ 0% wsize = 6972701 1 + 0%
8600 none 8600 none
230005 dirty 230005 dirty
0 dump 0 dump
1153555 read 1153555 read
95 write 95 write
0 dump1 0 dump1
cache 17% full cache 17% full
>>
å³2. cwfs ã³ã³ãœãŒã«ã§ã® statw ã®åºåäŸã Figure 2. Example of statw output from
the cwfs console.
ããã³ãã â> â ã¯ããªãã£ã·ã£ã«ãªé
åžçã§ã¯åºãªãã The prompt">" is not issued in the
official distribution version.
çè
ã«ããä¿®æ£çã§åºãããã«ããŠããã I am trying to go out with a modified version by
the author.
maddr ãã wsize ãŸã§ã®ãçå·ã®å³ã®æ°å(1åç®ãš2åç®)ã¯ããµã€ãºãè¡šããŠããã The numbers on the
right of the equal sign ( maddr to wsize) (the first and second
columns) represent the size. 1åç®ã®æ°åã®æ
å ±ã¯ãfscache ã® Tcache block (block
address 2) ããåŸãããã The information of the number in the first column
is obtained from Tcache block (block address 2) of Tcache. 2åç®ã¯ fsworm
ããåŸããã 泚1 ã The second column is obtained from fsworm Note 1. ãããã®åäœã¯
msize ãé€ãã° block ã§ããã These units are block except for msize. msize
ã ã㯠bucket æ°ã§ããã Only msize is a bucket number.
泚1: ãã®éšåã¯æ£ãããªãã Note 1: This part is incorrect. 2åç®ã fscache ããåŸãããŠããã
The second row is also obtained from fscache. fsworm ã®æåŸã® super block
ã® cache ã fscache ã®äžã«å«ãŸããããã衚瀺ããŠããã The cache of the last super block
of fsworm is included in fscache and this is displayed. fsize
ãé€ããŠã2åç®ã®æ
å ±ã¯ãæåŸã® super block ããåŸãããæ
å ±ãšäžèŽããŠããã fsize for fsize, the
information in the second column matches the information obtained from
the last super block. fsize 㯠statw ã³ãã³ããå®è¡ããæç¹ã§ã®å€ã§ããããã㯠fscache ã®
Tcache block ããåŸããã fsize ãšäžèŽããŠããã fsize is the value at the time of
executing the statw command, which is consistent with fsize obtained
from the Tcache block of Tcache. (2013/04/24) (2013/04/24)
fsworm ã«ã¯ãfsworm ã®ããŒãã£ã·ã§ã³ãµã€ãºã«é¢ããæ
å ±ã¯å«ãŸããªãäºã«æ³šç®ãããã Notice that fsworm
does not include information on fsworm's partition size. fsworm
ãæºæ¯ã«ãªã£ãæã«ããã£ãšå€§ããªããŒãã£ã·ã§ã³ã«çœ®ãæããããå¯èœæ§ãããã®ã§ããã®å Žåã«ã¯ãåã«æºæ¯ã«ãªã£ãããŒãã£ã·ã§ã³ã®å
容ãæ°ããããŒãã£ã·ã§ã³ã«ã³ããŒããã°ããããã«èšèšãããŠããã®ã§ãããã
It may be replaced by a larger partition when fsworm is full, so in
that case it would be designed to just copy the contents of the full
partition to the new partition.
fscache ã fsworm ã block ãåäœãšããŠç®¡çãããŠãã 泚2 ã Both fscache and fsworm
are managed in block units. cwfs64x ã®å Žåã«ã¯ 1 block 㯠16KB ã§ããã In the
case of cwfs64x, 1 block is 16 KB. 以äžãblock ãã¢ãã¬ã¹ã§è¡šãããšãšããã
Hereinafter, block is represented by an address. ba[0] ã¯æåã® block ã
ba[1] ã¯ç¬¬2 block ãæå³ããã ba[0] means the first block, and ba[1] means
the second block.
wsize ã® 6972701 㯠/dev/sdC0/fsworm ã®å€§ããã block æ°ã§è¡šããŠããã wsize 6972701
/dev/sdC0/fsworm the size of /dev/sdC0/fsworm the number of blocks.
6972701*16*1024 == 114240733184 6972701 * 16 * 1024 == 114240733184
ããã¯å®éã® /dev/sdC0/fsworm ã®å€§ãã 114240734208 ããã 1024 ã ãå°ãªãããblock
ãåäœãšããŠäœ¿çšãããŠããçºã«ã䜿çšã§ããªãé åãçºçããã®ã§ããã This is 1024 less than the actual
size of /dev/sdC0/fsworm, but since it is being used as a unit, an
unusable area has occurred.
fsworm ã«ã¯ãã©ãŒãããã®æŠå¿µãååšããªãäºã«æ³šæãã¹ãã§ããã It should be noted that there is
no concept of format in fsworm. ãªããªã Write Once
ã ããããã©ãŒããããããããŒã¿ãæžã蟌ããªã! 泚3 Because it is Write Once, after formatting
it can not write data! 3
fsworm ã«ã¯å
é block ããé ã«æžã蟌ãŸããã It is written to fsworm in order from
the top block. snext (next super block) ã¯ã次ã«æžã蟌ãŸãã block ã瀺ããŠããã snext
(next super block) indicates the next block to be written. dump
ãè¡ããšãæåã« super block ãšåŒã°ãã block ãæžã蟌ãŸããããã«ç¶ããŠããŒã¿ã®æ¬äœãæžã蟌ãŸããã When you
dump, a block called super block is written first, followed by the
body of the data. Super block ã¯ãdump æ¯ã®å¢çãšããŠãfsworm
ã«ãããŠã¯åºæ¬çãªåœ¹å²ãæãããŠããã Super block serves as a boundary for every dump
and plays a fundamental role in fsworm.
sbaddr (super block address) ã¯ãæåŸã«æžã蟌ãã super block ã®ã¢ãã¬ã¹ã§ããã sbaddr
(super block address) is the address of the super block written last.
ãŸãã slast ã¯ããã®1ã€åã® super block ã®ã¢ãã¬ã¹ã§ããã Also, slast is the address of
the preceding super block.
泚2: cwfs ã管çãã block ã¯ããã©ã€ãã管çããèªã¿æžãåäœãšããŠã®ãããã¯ãšã¯å¥ã®ãã®ã§ããã Note 2: The
block managed by cwfs is different from the block as the unit of
reading / writing managed by the driver.
泚3:æè¿ã§ã¯æ¬æ¥ã®æå³ã§ã® WORM ã䜿ãäºã¯ãªãã§ãããã Note 3: WORM in its original meaning
will not be used recently. ããã¯ã¢ããã¡ãã£ã¢ãšããŠã®å
ãã£ã¹ã¯ã®ååšæ矩ã¯ç¡ããªã£ãŠãããããŒããã£ã¹ã¯ã§
WORM ã代çšããæ¹ãäœã³ã¹ãã§ããã€äœ¿ãåæãè¯ãã The significance of the existence of an
optical disk as a backup medium has disappeared, substituting WORM for
a hard task is low cost and easy to use. 以äžã®è§£èª¬ãããŒããã£ã¹ã¯ã®äœ¿çšãåæãšããŠããã The
following explanation also assumes the use of a hard disk.
fsworm ã®ããã¯ã¢ãã Backup of fsworm
2013/03/06 æ¹èš Revised 2013/03/06
fsworm ã¯(ãã®ä»çµã¿äž)éåžžã«å
ç¢ã§ã¯ããããããã§ãããŒããŠã§ã¢ã¯ã©ãã·ã¥ã«ããããŒã¿æ¶å€±ã®ãªã¹ã¯ãè² ã£ãŠããã Although
fsworm is very robust (in its mechanism), it still has the risk of
data loss due to hardware crashes. ããã¯ã¢ãããè¡ãã«ã¯ãfsworm ã®ã³ããŒ(äŸãã°
fsworm-bak)ãæãŠã°ããã To do the backup you have a copy of fsworm (eg
fsworm-bak).
dump æ¯ã«ãfsworm ã®äžã«æ°ãã«çæããã block
ã ããã³ããŒããŠè¡ãã°ãããšèããããç¥ããªããã話ã¯ãããªã«ç°¡åã§ã¯ãªãã For each dump, you might think
that you can copy only the newly created block in fsworm, but the
story is not that easy. ãªããªããæžã蟌ãŸããŠããªã block ãæåŸã« dump ããã super block
ã®äžã«ååšããããã§ããã This is because unwritten blocks exist under the last
dumped super block. çè
ã®èŠ³å¯ã§ã¯ãããã«ã¯2çš®é¡ããã In my observation there are two
kinds of them.
(a) reserved block 泚1 (a) reserved blockNote 1
(b) free block (b) free block
ã§ããã.
(a)ã¯ãfscache ã®äžã§äœ¿çšãããŠãããããŸã dump ãå®äºããŠããªã fsworm ã® block ã§ããã (a) is a
block of fsworm that is used in fscache, but has not yet completed
dump.
(b)ã¯ãä»åŸ fscache ã䜿çšå¯èœãª fsworm ã® block ã§ããã (b) is a block of fsworm
that fscache can use in the future.
泚1: âreserved blockâ ã¯çè
ãåæã«äœ¿ã£ãŠããçšèªã§ããã Note 1:"reserved block" is a
term that I am using arbitrarily. ãã®çšèªã¯æç®ã«ã¯ååšããªãã This term does not
exist in the literature.
fsworm ã®æ§é Structure of fsworm
Block Block
fscache ã fsworm ã block ãåäœãšããŠç®¡çãããŠããã Both fscache and fsworm are
managed in units of block. cwfs64x ã®å Žåã«ã¯ 1 block 㯠16KB ã§ããã In the
case of cwfs64x, 1 block is 16 KB. 以äžãblock ãã¢ãã¬ã¹ã§è¡šãããšãšããã
Hereinafter, block is represented by an address. ba[0] ã¯æåã® block ã
ba[1] ã¯ç¬¬2ãããã¯ãæå³ããã ba[0] means the first block and ba[1] means the
second block. å
±ã«ãå
é ã® 2 block ã¯ç¹æ®ã§ããã Together, the first two blocks
are special. block ã®ã¢ãã¬ã¹ã¯ 8 B ã®ããŒã¿ã§æå®ãããã The address of block is
specified by 8 B data. ããã°ã©ã ã®äžã§ã¯ããŒã¿åã Off ã§ç€ºãããŠããã In the program, the
data type is indicated by Off.
fscache ã®å Žåã«ã¯ã ba[0] ã«ã¯ config æ
å ±ã眮ãããŠããã In the case of fscache,
ba[0] contains config information. ba[1] ã¯äœ¿ãããŠããªãããã§ããã ba[1] seems
not to be used.
fsworm ã®å Žåã«ãå
é ã® 2 block ã䜿çšãããŠããæ°é
ã¯ãªãã In the case of fsworm, there is
no indication that the first 2 blocks are used.
ã©ã® block ã Tag ãæã£ãŠããã Each block has Tag. ãã£ãšããå
šãŠã® block
ããã©ãŒããããããŠããã®ã§ã¯ãªã 泚1 ã However, not all the blocks are formatted.
Tag ã®å€§ããã¯ãcwfs64x ã®å Žåã«ã¯ 12B ã§ãããblock ã®æ«å°Ÿã«çœ®ãããã The size of Tag is 12
B in the case of cwfs 64 x, and it is placed at the end of the block.
ãã®æ§é ã¯æ¬¡ã®ãããªãã®ã§ããã Its structure is as follows.
struct Tag struct Tag
{ {
short pad; /* make tag end at a long boundary */ short pad; / * make
tag end at a long boundary * /
short tag; short tag;
Off path; Off path;
};};
pad ã®å€ã¯ 0 ã§ããã The value of pad is 0. tag ã block ã®çš®é¡ãè¡šããŠããã tag
indicates the type of block. path ã®å€ã«é¢ããèãæ¹ã¯ tag æ¯ã«ç°ãªãã path way of
thinking about the value of path is different for each tag.
16KB ãã Tag ã® 12B ãé€ãé åãããŒã¿é å(以äžãData ã§è¡šã)ã§ãããblock ã®çš®é¡æ¯ã®æ§é ãæã£ãŠããã The
area excluding Tag 12B is a data area (hereinafter referred to as
Data) from 16 KB and has a structure for each type of block. çºãããš To
summarize
block = Data + Tag block = Data + Tag
ã§ããã.
泚1:æè¿ã® HD ã¯å®¹éã倧ããã Note 1: Recent HD has large capacity. ãããå
šãŠã® block
ããã©ãŒããããããšèšå€§ãªæéãèŠããã Formatting all the blocks takes a huge amount of
time. ããã«èšãã°ãWORM ããã€ã¹ã¯ãã©ãŒãããããã°æžã蟌ããªããªã! In addition, the WORM device
can not write if formatted!
dump stack dump stack
2013/02/28 2013/02/28
dump ãç¹°ãè¿ããšãfsworm ã«ã¯ããã³ãããããŒã¿ãç©ã¿éããããã When dump is repeated, dumped
data is stacked on fsworm. ããŒã¿ã¯æ±ºããŠäžæžããããããšã¯ãªãã Data will never be
overwritten.ãã®æ§åãå³3(å·Š)ã«ç€ºãã The situation is shown in Fig. 3 (left).
泚æ: ããªãã®ãã©ãŠã¶ã¯ SVG ããµããŒãããŠããŸããã Note: Your browser does not support
SVG.ææ°ã®ãã©ãŠã¶ãã䜿ããã ããã Please use the latest browser.
å³3. dump Figure 3. dump
以äžãblock address n ã® block ã ba[n] ã§è¡šãã Hereinafter, the block of
block address n is represented by ba[n]. ba[0] ãš ba[1] ã¯äœ¿ãããŠããªãã ba[0]
and ba[1] are not used. cwfs ãå®è¡ããããšãæåã« 3 ã€ã® block When cwfs is
executed, first three blocks
ba[2]: super block ba [2]: super block
ba[3]: cfs root block ba [3]: cfs root block
ba[4]: dump root block ba [4]: ââdump root block
ãäœãããã Is made. ãã®äžã«ã¯ fscache ã®äžã«å«ãŸãããã¡ã€ã«ã®æ
å ±ã¯å«ãŸããŠããªãã It does not
contain information on files included in fscache.
泚æ: âcfs root blockâ ãšã âdump root blockâ
ãšãã®èšèã¯æ£åŒãªããã¥ã¡ã³ããããã°ã©ã ã³ãŒãã®äžã«ã¯çŸããªãã Note: The words"cfs root block" or
"dump root block" do not appear in formal documents or program code.
âcfs root addressâ ãš âdump root addressâ ã¯çŸããã"Cfs root address" and
"dump root address" appear.
dump æ¯ã« block ãç©ã¿äžããããã Blocks are stacked for each dump. 1åã® dump
ã§ç©ã¿äžãããã block ãåã« dump ãšåŒã¶äºã«ããã We call the block that is stacked
with one dump simply as dump. 1ã€ã® dump ã®äžã«ã¯å¿
ã3ã€ã® block, âsuper blockâ,
âcfs root blockâ, âdump root blockâ ãå«ãŸããã One dump always includes
three blocks,"super block","cfs root block","dump root block".
å³3(å³)ã«ã¯ãdump ã®å
éšæ§é ã瀺ãããŠããã Figure 3 (right) shows the internal
structure of dump.
super block ãš cfs root block ã®éã® block ã«ã¯ãfscache ã®å
容ã(ååã® dump
ããæŽæ°ãããå·®åã ã)ä¿åãããã In the block between super block and cfs root
block, the content of fscache is saved (only the difference updated
from the previous dump).
cfs root block ãš dump root block ã®éã® block ã«ã¯ãdump ããã幎ææ¥ã®æ
å ±ãå«ãŸããã The
block between the cfs root block and the dump root block contains
information on the dumped date. å¿
èŠãª block æ°ã¯ dump ã®åæ°ã«äŸåããã The
required number of blocks depends on the number of dumps.
Super Block Super Block
fsworm ã®æ§é ãæããäžã§ããã£ãšãåºæ¬çãªã®ã¯ super block ã§ããã The most basic thing to
capture the structure of fsworm is super block. super block ã® tag ã¯
Tsuper (=1) ã§ããã The tag of super block is Tsuper (= 1). cwfs
ã®ã³ãŒããèªããšãsuper block ã® Tag ã®äžã® path ã¯ã QPSUPER (=2) ãšãªã£ãŠããã When we
read the code of cwfs, the path the Tag of super block is QPSUPER (=
2).
super block ã¯ãfscache ããã³ãããæã« 1 ã€äœãããã One super block is created
when you dump fscache. ãŸã super block ã fsworm ã«æžã蟌ãŸããç¶ããŠããŒã¿ã®æ¬äœã block
åäœã«æžã蟌ãŸãã(å³3å³)ã First, super block is written to fsworm, then the body
of the data is written block by block (right in Figure 3).
super block ã®æ§é 㯠The structure of super block
struct Superb struct Superb
{ {
Fbuf fbuf; Fbuf fbuf;
Super1; Super 1;
};};
ãæã€ã have.
Fbuf 㯠free block ã®ã¢ãã¬ã¹ã®é
åãå
éšã«ä¿æããŠããã Fbuf has an array of addresses
of free blocks inside. free block ã«é¢ãã解説ã¯åŸåãã«ããã I will postpone
commentary on free block.
Super1 ãéèŠã§ããã Super1 is important.
struct Super1 struct Super 1
{ {
Off fstart; Off fstart;
Off fsize; Off fsize;
Off tfree; Off tfree;
Off qidgen; /* generator for unique ids */ Off qidgen; / * generator
for unique ids * /
/* / *
- Stuff for WWC device * Stuff for WWC device
- / * /
Off cwraddr; /* cfs root addr */ Off cwraddr; / * cfs root addr * /
Off roraddr; /* dump root addr */ Off roraddr; / * dump root addr * /
Off last; /* last super block addr */ Off last; / * last super block
addr * /
Off next; /* next super block addr */ Off next; / * next super block
addr * /
};};
å³4. Super1 ã®æ§é Figure 4. Structure of Super1
ããã§åããããã«ãåã
ã® super block ã¯ã次㮠super block ã®ã¢ãã¬ã¹( next)ãä¿æããŠããã As can
be seen, each super block has the address ( next) of the next super
block.ãããŠæåã® super block 㯠ba[2] ããå§ãŸãã And the first super block
starts with ba[2]. åŸã£ãŠ ba[2] ããé ã« super block
ã蟿ãã°ã次ã«ãã³ããããã¢ãã¬ãºãåããããšã«ãªãã Therefore, if you follow the super block
from ba[2] order, you will know the address to be dumped next.
次ã«ããã®åºåçµæäŸã瀺ãã Next, an example of the output result is shown.
(ãã®ããŒã«ã¯åŸã«çŽ¹ä»ãã) (This tool will be introduced later)
super blocks: super blocks:
2 2
5 Five
69908 69908
85793 85793
104695 104695
222009 222009
......
1751346 1751346
1754278 1754278
1754381 1754381
1754569 1754569
1754642 1754642
1755217 1755217
1755393 1755393
æåŸã® 1755393 ã¯ã次ã«äœãããäºå®ã® super block ã¢ãã¬ã¹ã§ããã The last 1755393 is the
super block address to be made next. ba[1755217] ã®äžã® Super1
ã®å
容ã¯(äŸãã°)次ã®ãããªãã®ã§ããã The contents of Super1 ba[1755217] are (for
example) as follows.
super1 fstart: 2 super1 fstart: 2
super1 fsize: 1755394 super1 fsize: 1755394
super1 tfree: 92 super1 tfree: 92
super1 qidgen: 6d76e super1 qidgen: 6d76e
super1 cwraddr: 1755389 super1 cwraddr: 1755389
super1 roraddr: 1755392 super1 roraddr: 1755392
super1 last: 1754642 super1 last: 1754642
super1 next: 1755393 super1 next: 1755393
ãããã®æ
å ±ã®äžéšã¯ cwfs ã®ã³ã³ãœãŒã«ãããåŸãããã Some of these information is also
obtained from the cwfs console.
sbaddr 1755217: çŸåšã® super block (æåŸã«æžã蟌ãŸãã super block) sbaddr 1755217
: current super block (last written super block)
snext 1755393:次ã®ãã³ãäºå®ã®ã¢ãã¬ã¹(ã€ãŸãã次ã«äœãããäºå®ã® super block ã¢ãã¬ã¹) snext
1755393: The next dump schedule address (that is, the super block
address to be created next)
slast 1754642: sbaddr ããäžã€æåã® super block ã¢ãã¬ã¹ slast 1754642: super
block address one before the sbaddr
Directory Entry Block Directory Entry Block
2013/03/02 æŽæ° Updated 2013/03/02
次ã«åºæ¬çãªã®ã¯ directory entry block ã§ããã Next is the directory entry block.
ãã® block ã® Tag.tag 㯠Tdir ã§ããã Tag.tag of this block is Tdir. ãŸãã
Tag.path ã¯ã芪ãã£ã¬ã¯ããªã® qid ã«äžèŽããã Also, Tag.path matches the Tag.path of
the parent directory.
directory entry block ã«ã¯æ¬¡ã® directory entry ( Dentry) ã1å以äž(cwfs64x
ã®å Žåãæ倧62å)å«ãŸããŠããã The directory entry block contains one or more of
the following directory entries (Dentry) (up to 62 in the case of
cwfs64x).
struct Dentry struct Dentry
{ {
char name[NAMELEN]; char name [NAMELEN];
Userid uid; Userid uid;
Userid gid; Userid gid;
ushort mode; ushort mode;
#define DALLOC 0x8000 #define DALLOC 0x8000
#define DDIR 0x4000 #define DDIR 0x4000
#define DAPND 0x2000 #define DAPND 0x2000
#define DLOCK 0x1000 #define DLOCK 0x1000
#define DTMP 0x0800 #define DTMP 0x0800
#define DREAD 0x4 #define DREAD 0x4
#define DWRITE 0x2 #define DWRITE 0x2
#define DEXEC 0x1 #define DEXEC 0x1
Userid muid; Userid muid;
Qid9p1 qid; Qid 9 p 1 qid;
Off size; Off size;
Off dblock[NDBLOCK]; Off dblock [NDBLOCK];
Off iblocks[NIBLOCK]; Off iblocks [NIBLOCK];
long atime; long atime;
long mtime; long mtime;
};};
å³5. Directory entry Figure 5. Directory entry
ããã«ã¯ãã¡ã€ã«ããã£ã¬ã¯ããªã®åå( name)ãå«ãŸããŠããã®ã§ã Dentry ã®ãµã€ãºã¯èš±å®¹ããååã®é·ã( NAMELEN-1
)ã«äŸåããã Since the names of files and directories are included here,
the size of NAMELEN-1 depends on the allowable name length ( NAMELEN-1
).
dump root block 㯠directory entry block ã® 1 ã€ã§ããã The dump root block
is one of directory entry blocks. çè
ã®å®¶åºã§ã®ã·ã¹ãã ã®å Žåã«ã¯æ¬¡ã®ããã« dump ããæ¥ä»ãèŠããã
In the case of my system at home, you can see the dumped date as
follows.
term% ls /n/dump term% ls / n / dump
/n/dump/2012/0801 / n / dump / 2012/0801
/n/dump/2012/0802 / n / dump / 2012/0802
/n/dump/2012/0804 / n / dump / 2012/0804
/n/dump/2012/0813 / n / dump / 2012/0813
........
/n/dump/2013/0121 / n / dump / 2013/0121
/n/dump/2013/0127 / n / dump / 2013/0127
/n/dump/2013/0128 / n / dump / 2013/0128
/n/dump/2013/0205 / n / dump / 2013/0205
........
æåã®è¡ã¯åã㊠dump ãè¡ã£ãæã«(2012幎8æ1æ¥)çæãããŠããã The first line is generated
for the first time on dump (August 1, 2012).
ls -l /n/dump/2012/0801 ls - l / n / dump / 2012/0801
ãå®è¡ãããšæ¬¡ã®ããã«ããã®æ¥ã®ãã¡ã€ã«ã«ã¢ã¯ã»ã¹ã§ããã You can access the files on this day as
follows.
maia% ls -l /n/dump/2012/0801 maia% ls - l / n / dump / 2012/0801
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 /n/dump/2012/0801/386
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 / n / dump / 2012/0801/386
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 /n/dump/2012/0801/68000
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 / n / dump / 2012/0801/68000
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 /n/dump/2012/0801/68020
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 / n / dump / 2012/0801/68020
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 /n/dump/2012/0801/acme
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 / n / dump / 2012/0801 / acme
d-rwxrwxr-x M 495 adm adm 0 Jul 31 2012 /n/dump/2012/0801/adm
d-rwxrwxr-x M 495 adm adm 0 Jul 31 2012 / n / dump / 2012/0801 / adm
........
d-rwxrwxr-x M 495 sys sys 0 Jan 18 2012 /n/dump/2012/0801/mnt
d-rwxrwxr-x M 495 sys sys 0 Jan 18 2012 / n / dump / 2012/0801 / mnt
d-rwxrwxr-x M 495 sys sys 0 Jan 18 2012 /n/dump/2012/0801/n
d-rwxrwxr-x M 495 sys sys 0 Jan 18 2012 / n / dump / 2012/0801 / n
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 /n/dump/2012/0801/power
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 / n / dump / 2012/0801 / power
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 /n/dump/2012/0801/power64
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 / n / dump / 2012/0801 /
power64
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 /n/dump/2012/0801/rc
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 / n / dump / 2012/0801 / rc
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 /n/dump/2012/0801/sparc
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 / n / dump / 2012/0801 / sparc
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 /n/dump/2012/0801/sparc64
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 / n / dump / 2012/0801 / sparc
64
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 /n/dump/2012/0801/sys
d-rwxrwxr-x M 495 sys sys 0 Jul 31 2012 / n / dump / 2012/0801 / sys
dr-xr-xr-x M 495 sys sys 0 Jan 18 2012 /n/dump/2012/0801/tmp
dr-xr-xr-x M 495 sys sys 0 Jan 18 2012 / n / dump / 2012/0801 / tmp
d-rwxrwxr-x M 495 sys sys 0 Aug 1 2012 /n/dump/2012/0801/usr
d-rwxrwxr-x M 495 sys sys 0 Aug 1 2012 / n / dump / 2012/0801 / usr
maia% maia%
å³6. ls /n/dump Figure 6. ls / n / dump
dump ãã幎ææ¥æ
å ± ( YYYY/MMDD) 㯠dump root address ãš cfs root address
ã®éã«ããã The dumped date information ( YYYY/MMDD) is between dump root
address and cfs root address. (å³3) (Figure 3)
ãã®ã±ãŒã¹ã§ã¯æ¬¡ã®å³7ã«ç€ºãããã« block ãç¹ãã£ãŠããã In this case, blocks are connected as
shown in the next figure 7.
泚æ: ããªãã®ãã©ãŠã¶ã¯ SVG ããµããŒãããŠããŸããã Note: Your browser does not support
SVG.ææ°ã®ãã©ãŠã¶ãã䜿ããã ããã Please use the latest browser.
å³7. directory entry block ã®ç¹ãã Figure 7. Connection of directory entry
block
é·æ¹åœ¢ã1ã€ã®ãããã¯ãè¡šããŠããã A rectangle represents one block. ãã®å³ã§ã¯ã©ãã
directory entry block ã§ããã In this figure, none is a directory entry
block. dump ã®åæ°ããŸã å°ãªãã®ã§ã2013幎ã®ææ¥ã®æ
å ±ã¯1åã® directory entry block
ã§éã«åã£ãŠãããããã®ãã¡ã«è€æ°ã® block ãèŠæ±ãããããã«ãªãã ããã Since the number of dumps is
still small, the date information of 2013 can be made in time with one
directory entry block, but multiple blocks will be required within the
time.
Plan9 ã§ã¯å³5ã® Dentry æ§é äœãèŠãã°åããããã«ãdirectory ã®ååãšãmode ãªã©ã®æ
å ±ãåã block
ã«åå±
ããŠããã In Plan 9, as you can see from the Dentry structure in Figure
5, the name of directory and the information such as mode live in the
same block. ä»æ¹ UNIX ã§ã¯ mode ãªã©ã®æ
å ±ã¯ãinode ã«çœ®ãããååã®äžèŠ§ãšã¯å¥ã® block
ã«ãªã£ãŠãã(å³8)ã On UNIX, on the other hand, information such as mode is
placed in the inode and is a block different from the list of names
(Fig. 8). ãã®éãã®èµ·æºã¯ UNIX ã§ã¯ hard link ã®ãµããŒãã®ããã«ãlink counter ãååãšã¯å¥ã®
block (å
·äœçã«ã¯ inode) ã«æããªããŠã¯ãªããªãããã ãšæããã The origin of this difference
seems to be that in UNIX, in order to support hard link, it is
necessary to have the link counter in another block (specifically,
inode) different from the name.
泚æ: ããªãã®ãã©ãŠã¶ã¯ SVG ããµããŒãããŠããŸããã Note: Your browser does not support
SVG.ææ°ã®ãã©ãŠã¶ãã䜿ããã ããã Please use the latest browser.
å³8. unix inode ã®æŠå¿µå³ã§ contents ãšæžããã®ã¯ãfile ã®äžèº«ã§ãã£ãããä»ã® directory
ã§ãã£ããããã Figure 8. In the conceptual diagram of unix inode, we write
contents as contents of file or other directory.
Dentry ã® Qid9p1 æ§é äœã¯ Qid9p1's Qid9p1 structure
struct Qid9p1 struct Qid 9 p 1
{ {
Off path; /* was long */ Off path; / * was long * /
ulong version; /* should be Off */ ulong version; / * should be Off *
/
};};
ã§ãããããã® path ã¯ã mode ããã£ã¬ã¯ããªã®å Žå(ã€ãŸã mode&DDIR!= 0 ã®å Žå)ã«ã¯å
é ãããã« 1
ãç«ãŠãããŠããã However, this path is set to 1 in the first bit when mode is
a directory (that is, when mode&DDIR!= 0).
(ãã®ããã«èšèšããçç±ã«é¢ããŠã¯åã¯ä»ã®ãšãã解ããªãã) æ£åŒãª qidãããªãã¡ãã³ãã³ã (I'm not sure about
the reason why I designed this way.) The official qid, ie the command
ls -ql ls - ql
ã§è¡šç€ºããã qid ã¯ããã® qid.path ã®å
é ããããèœãšãããã®ãããªãã¡ qid.path&~DDIR ã§ããã The
qid displayed is the one with the first bit of this qid.path, that is,
qid.path&~DDIR.
cwfs64x ã®å Žåã1ã€ã® Dentry 㯠260 B ã§ããã In the case of cwfs 64 x, one
Dentry is 260 B. åŸã£ãŠã1ã€ã® block ã«ã¯æ倧 62 åã® Dentry ãä¿æã§ããã Therefore,
one block can hold up to 62 Dentry.
name ã«ã¯ããã¡ã€ã«åããã£ã¬ã¯ããªåãå
¥ãã name contains the file name and directory
name. NAMELEN 㯠cwfs64x ã®å Žåã«ã¯ 144 ã§ããã NAMELEN is 144 in the case of
cwfs NAMELEN x. ååã¯'\0' ã§çµããã®ã§ãååã®æ倧é·ã¯ 143 æåã§ããã Since the name ends
with'\0', the maximum length of the name is 143 characters.
ååã®ä»ã«ããã£ã¬ã¯ããªããã¡ã€ã«ã«ãšã£ãŠåºæ¬çãªæ
å ±ããã®äžã«å«ãŸããŠããã In addition to the name, basic
information for directories and files is included in this.
Dentry ããã¡ã€ã«ãè¡šããŠããå Žå( mode&DDIR == 0)ããã¡ã€ã«ã³ã³ãã³ãã®çœ®ãããŠãã block 㯠direct
block ( dblock[NDBLOCK]) ãš indirect block ( iblocks[NIBLOCK])
ãåºã«èŸ¿ãäºãã§ããã Dentry mode&DDIR == 0 represents a file ( mode&DDIR == 0),
the block dblock[NDBLOCK] the file contents can be traced based on
direct block ( dblock[NDBLOCK]) and indirect block ( iblocks[NIBLOCK]
). ãã¡ã€ã«ã³ã³ãã³ããå«ã block 㯠Tfile ã§ã¿ã°ä»ããããŠããã The block containing the
file contents is tagged with Tfile.
Dentry ããã£ã¬ã¯ããªã®å Žå( mode&DDIR!= 0
)ã«ã¯ããã®ãã£ã¬ã¯ããªã³ã³ãã³ã(äžã«å«ãŸããŠãããã¡ã€ã«ããã£ã¬ã¯ããªã®æ
å ±)ã®çœ®ãããŠãã block
ã¯ããã¡ã€ã«ã®å Žåãšåæ§ã«ãdirect block ( dblock[NDBLOCK]) ãš indirect block (
iblocks[NIBLOCK]) ãåºã«èŸ¿ãäºãã§ããã Dentry mode&DDIR!= 0 is a directory (
mode&DDIR!= 0), the mode&DDIR!= 0 in which the directory contents (the
information of the files and directories contained therein) is placed
is set to direct block ( dblock[NDBLOCK]) and indirect block (
iblocks[NIBLOCK]). ãã£ã¬ã¯ããªã³ã³ãã³ããå«ã block 㯠Tdir ã§ã¿ã°ä»ããããŠããã The block
containing the directory contents is tagged with Tdir.
cwfs64x ã®å Žåã«ã¯ NDBLOCK ã®å€ã¯ 6ã NIBLOCK ã®å€ã¯ 4 ã§ããã In the case of NDBLOCK
the value of NDBLOCK is 6 and the value of NIBLOCK is 4.
6 åã® direct block ã«ã¯ãããŒã¿ãçŽæ¥æžãããã Data is directly written to 6 direct
blocks. 1ã€ã® direct block ã«ã¯ 16*1024 - 12 B ã®ããŒã¿ãæžã蟌ããã®ã§ã6 åã® direct
block ã«ã¯åèš 6*(16*1024 - 12) B ã®ããŒã¿ãæžã蟌ããã Because 16 * 1024 - 12 B
data can be written in one direct block, 6 direct blocks can be
written with a total of 6 * (16 * 1024 - 12) B data. ãã£ã¬ã¯ããªã®å Žåã«ã¯
372(=62*6)åãŸã§ã® Dentry ãæ±ããäºãšãªãã In the case of a directory, up to 372
(= 62 * 6) Dentry can be handled.
Indirect Block Indirect Block
directory entry block ã® Dentry æ§é äœã«å«ãŸãã iblocks[0] ã«ãã£ãŠç€ºããã block ã«ã¯ã
For the block indicated by iblocks[0] included in the iblocks[0]
structure of the directory entry block,
(16*1024 - 12)/8 = 2046 (16 * 1024 - 12) / 8 = 2046
åã® block ã¢ãã¬ã¹ãå«ãŸããã Block addresses. ããã® 8 㯠1 åã® block ã¢ãã¬ã¹ã®å€§ããã§ããã
Here, 8 is the size of one block address.) ãããã® block ã¢ãã¬ã¹ã¯ãããŒã¿ã®å Žæ(ã€ãŸã
direct block)ã瀺ããŠããã) These block addresses indicate the location of
the data (ie direct block). åŸã£ãŠ Therefore
2046 * (16*1024 - 12) = 33497112 B 2046 * (16 * 1024 - 12) = 33497112
B
ã®ããŒã¿ãæžã蟌ããã Can be written. ãã®ãã㪠block æ
å ±ã 1次㮠indirect block
ãšèšãããšãšãããã Let's say that such block information is the primary
indirect block.
iblocks[1] ã«ã¯ã2次㮠indirect block ãæžãããã iblocks[1], a secondary
indirect block is written. ã€ãŸãããã® block ã«ã¯ block
ã¢ãã¬ã¹ãæžãããŠããã®ã§ãããããããã®ã¢ãã¬ã¹ã¯(ããŒã¿ã®å Žæã§ã¯ãªã) 1次㮠indirect block ã¢ãã¬ã¹ã§ããã In
other words, the block addresses are written in this block, but these
addresses are the primary indirect block addresses (not the data
location). åŸã£ãŠ Therefore
2046 * 2046 * (16*1024 - 12) = 68535091152 B 2046 * 2046 * (16 * 1024
- 12) = 68535091152 B
ã®ããŒã¿ãæžã蟌ããã Can be written.
åæ§ã«ã iblocks[2] ã«ã¯ Likewise, iblocks[2] has
2046 * 2046 * 2046 * (16*1024 - 12) = 140222796496992 B 2046 * 2046 *
2046 * (16 * 1024 - 12) = 140222796496992 B
ãã㊠iblocks[3] ã«ã¯ And iblocks[3] has
2046 * 2046 * 2046 *2046 * (16*1024 - 12) = 286895841632845632 B 2046
- 2046 * 2046 * 2046 * (16 * 1024 - 12) = 286895841632845632 B
ãšãªãã.
indirect block ã®ã¿ã°ã¯ The tag of indirect block
iblocks[0] Tind1 iblocks [0] Tind 1
iblocks[1] Tind2 iblocks [1] Tind 2
iblocks[2] Tind3 iblocks [2] Tind 3
iblocks[3] Tind4 iblocks [3] Tind 4
ãšãªã£ãŠããã. ãŸãããããã® Tag.path ã¯ã©ãã芪ãã£ã¬ã¯ããªã® qid ã«äžèŽããã Also, any of these
Tag.paths matches the qid of the parent directory.
File Block File Block
ãã¡ã€ã«ã®å
容ãå«ã block 㯠Tfile ã®ã¿ã°ãä»ããããŠããã The block containing the
contents of the file is tagged with Tfile. ãã® block ã® Tag.path
ã¯ããã®ãã¡ã€ã«ãå±ãããã£ã¬ã¯ããªã® qid ã«äžèŽããã Tag.path of this block matches the qid
of the directory to which this file belongs.
1ã€ã® file block ã«ã¯ãæ倧 One file block has a maximum
16*1024 - 12 B 16 * 1024 - 12 B
ã®ãã¡ã€ã«ããŒã¿ãä¿åã§ããã File data can be saved.
ãã¡ã€ã«ã®å
容㯠block åäœã§ç®¡çãããŠããã The contents of the file are managed in
block unit. ãã¡ã€ã«ã®å
容ãæŽæ°ãããæã«ã¯å
šãŠã® block ãæžãæããããã®ã ããã? çè
ã®å®éšã«ãããšåŠã§ããã
Will all blocks be rewritten when the contents of the file is updated?
According to my experiment, it is not.
1ãããã¯ããã倧ããªãã¡ã€ã«ã®æ«å°Ÿã«ããŒã¿ãè¿œå ãããšãæåŸã® block ã ããæŽæ°ãããã If you add data to
the end of a file larger than one block, only the last block is
updated. ä»ã® block ã¯ããã®ãŸãŸå©çšãããã Other blocks are used as they are.
ãã£ãšãããã®å®éšã¯ However, this experiment
(a) ãã¡ã€ã«ã« append å±æ§ãæå®ããŠãã (a) The append attribute is specified in
the file
(b) ãã¡ã€ã«ã®æ«å°Ÿã« seek ããŠæžã蟌ãã§ããã®ããããã®æ¡ä»¶ã®äžã§å®éšããŠããã (b) writing at the end
of the file by seeking at the end of the experiment under either
condition.
16KB ãè¶
ãã倧ããªãã¡ã€ã«ãããã¹ããšãã£ã¿ã§éããŠãæ«å°Ÿã«ããŒã¿ãè¿œå ããå Žåã«ã¯ãå®å
šã«æžãæãããããšæãã If I open
a large file larger than 16 KB with a text editor and add data to the
end, I think that it can be completely rewritten. (å®éšã¯ããŠããªããã©...) (I
have not done an experiment though...)
æžãæãããã block ã ããæ°ãã«çæããã cwfs ã®ç¹æ§ã¯ãç¹ã«ãµãŒãã§éèŠã§ããã Characteristics of
cwfs in which only rewritten blocks are newly generated is
particularly important in servers. çè
ã®ãµãŒãã§ã¯ãŠã§ãã®ãµãŒãã®ãã°ãã¡ã€ã«ã¯ 1.7GB ã«ãäžãã
On my server, the log file of web server is 1.7 GB.
1757143424 Oct 18 17:13 http 1757143424 Oct 18 17: 13 http
ãã®å€§ããã®ãã¡ã€ã«ã®ã³ããŒãæ¯æ¥äœãç¶ããããã«ã¯è¡ããªãã§ããã 泚1 ã It will not go on to keep
copying files of this size every day1.
泚1: Mac/OSX ã® TimeMachine ã Linux ã® pdumpfs
ã§ã¯ããã¡ã€ã«ãæŽæ°ãããŠããã°ããã®ã³ããŒãæ°ãã«äœãããŠããã Note 1: On Mac / OSX's Time Machine
or Linux pdumpfs, if the file has been updated, a new copy of it will
be made. ããŒããªã³ã¯ã ã㧠TimeMachine ã®æ©èœãå®çŸããããšããã°ãã³ããŒã¯äžå¯é¿ãªä»æ§ã«ãªãã¯ãã§ããã If we
try to realize the function of TimeMachine with only hard links, copy
will be inevitable specification.
ãµãŒãã§ã¯ãæ¥ã
æŽæ°ããã倧ããªãã°ãã¡ã€ã«ãæ±ã蟌ãã®ã§ããµãŒããŒçšéã«ã¯å
šãåããªãã¯ãã§ããã Since the server
carries a large log file which is updated day by day, it should not be
suitable for server use at all. ããŒã¿ããŒã¹ãã¡ã€ã«ã®å Žåã«ã¯ãcwfs ãšèšãã©ãæ¥ã
ã® dump
ããå€ããªããŠã¯ãªããªãã ããã In the case of database files, even cwfs should be
removed from daily dump. ãã©ã³ã¶ã¯ã·ã§ã³ã®ãã°ãæ¡ãæ¹ãå®å
šã§ããã It is safer to log
transactions.
Fsworm Root Fsworm Root
2013/03/09 2013/03/09
fsworm ã®å
šãŠã®æ
å ±ã¯ dump stack ã®ãããã«ãã dump root block ãã蟿ãäºãã§ããã All
information on fsworm can be traced from the dump root block at the
top of the dump stack. ãã®ã¢ãã¬ã¹ã¯ cwfs console ã® roaddr ããç¥ãããšãã§ããã You
can find out this address from roaddr of cwfs console.
å³6ããã³å³7ã¯ããããã蟿ã£ãŠèŠãããã¹ã®æåã®éšåã§ããã Figures 6 and 7 are the first part of
the path seen from here.
å®ã¯ roaddr 㯠fscache ã管çããŠãã root block ã§ããããfsworm ã® dump root block
ãšäžèŽããŠããã Actually roaddr is a root block managed by fscache, but it
matches dump root block of fsworm.
ãã³ãã®é åº Dump order
ãã³ãã¯çŸåšã® fscache ã«åºã¥ããŠè¡ãããã The dump is done based on the current
fscache.ãããŠããŸãæåã« super block ã fsworm ã«æžã蟌ãŸããã First, super block is
written to fsworm. ããã«ç¶ããŠããã£ã¬ã¯ããªããªãŒã®æ«ç«¯ã®æ
å ±ããé ã«æžã蟌ãŸããã Following this,
the information at the end of the directory tree is written in order.
åŸã£ãŠãfsworm ã®äžã«ãäŸãã° Thus, in fsworm, for example
/2012/0925/.... / 2012/0925 /....
ãäœæãããå Žåã«ã¯ãäžçªæåŸã« /ããã®åã« 2012 ãããã«ãã®åã« 0925 ã... Is created, the last /
before 2012, before 0925 before that...
qid qid
ãŠãŒã¶ãã㯠ls command ã« q option ãæ·»ããŠãã¡ã€ã«ããã£ã¬ã¯ããªã® qid ãèŠãããšãã§ããã From the
user, you can see the qid of the file or directory by adding q option
to ls command. äŸãã° For example
maia% ls -ql maia% ls - ql
(000000000009baa2 6 00) --rw-rw-r-- M 326 web web 33597 Mar 8 15:01
bucket.png (000000000009 baa2 6 00) - rw - rw - r - M 326 web web
33597 Mar 8 15: 01 bucket.png
(000000000009baa3 3 00) --rw-rw-r-- M 326 web web 13693 Mar 8 15:02
bucket.svg (000000000009 baa 3 300) - rw - rw - r - M 326 web web
13693 Mar 8 15: 02 bucket.svg
(0000000000089b8c 2 00) --rw-rw-r-- M 326 arisawa web 782 Sep 28 10:11
console.txt (0000000000089b8c 2 00) - rw - rw - r - M 326 arisawa web
782 Sep 28 10: 11 console.txt
(0000000000089b8d 2 00) --rw-rw-r-- M 326 arisawa web 2401 Oct 15
21:21 cwfs.svg (0000000000089b8d 2 00) - rw - rw - r - M 326 arisawa
web 2401 Oct 15 21:21 cwfs.svg
......
maia% maia%
ã®ããã«è¡šç€ºãããã As shown in FIG. å
é ã® () ã®äžã® 16 é²æ°è¡šç€ºã®éšåã qid ã§ããããã®æ¬¡ã®æ°åã qid
version ã§ããã The part of hexadecimal notation in the head () is qid,
and the next digit is qid version.
ããã¥ã¢ã«ã«ãããš qid ã¯file system ã®äžã§ãŠããŒã¯ã§ãããšèšãã According to the manual qid
is unique within the file system.
ãŠããŒã¯ã§ãããªãã°ãqid ã管çãããªããŠã¯ãªããªãã If it is unique, the qid must be
managed. super block ã®äžã® qidgen ãããã®ããã«ãããšæãã(å³4)ã It seems that
qidgen in super block is there for that (Figure 4).
å®éšãããŠèŠãã°åããã qid ã¯ãã¡ã€ã«åã®å€æŽã«ãã£ãŠã¯å€ãããªãã You can tell by experimenting
but qid does not change by changing file name. å
容ãå€ãããš version ãå€ããã
Version changes when content changes.
ããã§ããããããšãã£ã¿ãäœãå Žåã«ã¯ãä¿åæã«ä»ã®äœãã«ãã£ãŠå€æŽãåãããåŠããç¥ãããã«äœ¿ããã®ã§ããããtime stamp
ã®æ¹ãæ軜ãªã®ã§åã¯ãããŸã§ã« qid ãå©çšããäºã¯ç¡ãã So, when creating an editor, you can
use it to know whether or not you have changed by something else at
the time of saving, but time stamp is easier, so I used qid so far
There is nothing. (ãªã unix ã® qid ã¯ãéããã®ããã) (The qid of unix seems to
be different)
fsworm ã fscache ã®äžãé€ããšãqid ãšãã® version 㯠directory entry
ã®äžã«å«ãŸã(å³5)ããã® contents ã«é¢ãã block ãåã qid ãšãªã£ãŠããããšãåããã Except in
fsworm and fscache, qid and its version are included in the directory
entry (Figure 5), and you can see that the block concerning the
contents is the same qid. ã€ãŸã block ã®æå±ã確èªããããã«äœ¿ãããŠãããšæãããã That is,
it seems to be used to confirm the affiliation of block.
fscache ã®æ§é Structure of fscache
ba[0] config ba [0] config
ba[1] - ba [1] -
ba[2] Tcache ba [2] Tcache
ba[maddr] map ba [maddr] map
......
ba[caddr] cache ba [caddr] cache
......
Config Block Config Block
2013/03/05 2013/03/05
cwfs64x ãèŠãéããçè
ã® config block ( ba[0])
ã«ã¯ãããã¹ã圢åŒã§æ¬¡ã®ãããªããŒã¿ãå
é ããæžã蟌ãŸããŠããã As far as cwfs64x is concerned, the
following data was written in the text format from the beginning in my
config block ( ba[0]). (ãã®å
容㯠cwfs console ã® printconf ã³ãã³ãã§ãèŠãã)
(This content can also be seen with the printconf command of cwfs
console)
service cwfs service cwfs
filsys main c(/dev/sdC0/fscache)(/dev/sdC0/fsworm) filsys main c (/
dev / sdC 0 / fscache) (/ dev / sdC 0 / fsworm)
filsys dump o filsys dump o
filsys other (/dev/sdC0/other) filsys other (/ dev / sdC 0 / other)
noauth noauth
newcache newcache
blocksize 16384 blocksize 16384
daddrbits 64 daddrbits 64
indirblks 4 indirblks 4
dirblks 6 dirblks 6
namelen 144 namelen 144
=======
noauth ã¯ãèªèšŒãããªã㧠cwfs ãžã®ã¢ã¯ã»ã¹ãèš±ãäºãæå³ããŠããã noauth means allowing access
to cwfs without authentication. noauth
ã¯å®å
šãªç°å¢ã§ã®å®éšã¬ãã«ã§ããèš±ãããªãç¹æ®ãªèšå®ã§ããäºã«æ³šæãã¹ãã§ããã noauth should be noted that
noauth is a special setting only allowed at the experimental level in
a secure environment.
倧åŠã§äœ¿ã£ãŠããã®ã¯ãä»å¹Žã®2æã®çã§ããããã㯠noauth ã«ã¯ãªã£ãŠããªãã What I use at university is
the February version of this year, which is not noauth. (2013/04/10)
(2013/04/10)
=======
ããã«ããã® block ã¯æ¬¡ã®ããã« tag ä»ããããŠããã In addition, this block is tagged as
follows.
pad: 0000 pad: 0000
tag: 10 (Tconfig) tag: 10 (Tconfig)
path: 0 path: 0
ãœãŒã¹ã³ãŒãã«ã¯ã次ã®æ§é åããŒã¿ãããã The source code has the following structured
data.
struct Conf struct Conf
{ {
ulong nmach; /* processors */ ulong nmach; / * processors * /
ulong nuid; /* distinct uids */ ulong nuid; / * distinct uids * /
ulong nserve; /* server processes */ ulong nserve; / * server
processes * /
ulong nfile; /* number of fid -- system wide */ ulong nfile; / *
number of fid - system wide * /
ulong nwpath; /* number of active paths, derived from nfile */ ulong
nwpath; / * number of active paths, derived from nfile * /
ulong gidspace; /* space for gid names -- derived from nuid */ ulong
gidspace; / * space for gid names - derived from nuid * /
ulong nlgmsg; /* number of large message buffers */ ulong nlgmsg; / *
number of large message buffers * /
ulong nsmmsg; /* number of small message buffers */ ulong nsmmsg; / *
number of small message buffers * /
Off recovcw; /* recover addresses */ Off recovcw; / * recover
addresses * /
Off recovro; Off recovro;
Off firstsb; Off firstsb;
Off recovsb; Off recovsb;
ulong configfirst; /* configure before starting normal operation */
ulong configfirst; / * configure before starting normal operation * /
char *confdev; char * confdev;
char *devmap; /* name of config->file device mapping file */ char *
devmap; / * name of config-> file device mapping file * /
uchar nodump; /* no periodic dumps */ uchar nodump; / * no periodic
dumps * /
uchar dumpreread; /* read and compare in dump copy */ uchar
dumpreread; / * read and compare in dump copy * /
uchar newcache; uchar newcache;
};};
ãã®äžã®ããŒã¿ã¯ãåæåéçšã®äžã§ãcwfs ã®çš®é¡æ¯ã«(ãœãŒã¹ã³ãŒãã®äžã§)äžããããŠããã Data in this is given
(in the source code) for each type of cwfs during the initialization
process.
Tcache Block Tcache Block
Tcache block 㯠cwfs ã«é¢ããåºæ¬æ
å ±ã管çããŠããã Tcache block manages basic
information about cwfs. ãã®å
容㯠cwfs ã³ã³ãœãŒã«ã§èŠãããšãã§ããã You can see this in
the cwfs console.
struct Cache struct Cache
{ {
Off maddr; /* cache map addr */ Off maddr; / * cache map addr * /
Off msize; /* cache map size in buckets */ Off msize; / * cache map
size in buckets * /
Off caddr; /* cache addr */ Off caddr; / * cache addr * /
Off csize; /* cache size */ Off csize; / * cache size * /
Off fsize; /* current size of worm */ Off fsize; / * current size of
worm * /
Off wsize; /* max size of the worm */ Off wsize; / * max size of the
worm * /
Off wmax; /* highwater write */ Off wmax; / * highwater write * /
Off sbaddr; /* super block addr */ Off sbaddr; / * super block addr *
/
Off cwraddr; /* cw root addr */ Off cwraddr; / * cw root addr * /
Off roraddr; /* dump root addr */ Off roraddr; / * dump root addr * /
Timet toytime; /* somewhere convienent */ Timet toytime; / * somewhere
convienent * /
Timet time; Timet time;
};};
fscache ã®åãããã¯ã¯ã¡ã¢ãªãŒã«ãã£ãã·ã¥ãããŠããã Each block of fscache is cached in
memory. 10ç§æ¯ã«ã¡ã¢ãªãŒã®ãã£ãã·ã¥ã¯ã(æŽæ°ãããã°) fscache ã«æžã蟌ãŸããã Every ten seconds
the cache of memory is written to fscache (if there is an update).
Mapping Mapping
2013/03/08 æŽæ° Updated 2013/03/08
fsworm ã®å block ã¯ãå³9ã® cache area ã® cache block ã« mapping ãããã Each
block of fsworm is mapped to the cache block of the cache area of
ââFIG.
fscache ã® cache block ã®ã¢ãã¬ã¹ã cba ãšãããš cba 㯠Let cba be the cache block
address of cba, cba
caddr <= cba < caddr + csize caddr <= cba <caddr + csize
ã®ç¯å²ã«ããã. fsworm ã® 0 ãã wsize ã® block ã fscache ã®ãã®é åã« map ãããã A block
of fsworm 0 to wsize is mapped to this area of ââfscache.
cache block ã®ç·æ°ã¯(cwfs ã³ã³ãœãŒã«ã§ã¯) csize ã§è¡šç€ºãããŠããã The total number of
cache blocks is indicated by csize (in the cwfs console). caddr
ããå§ãŸããæ®ãã®å
šãŠã® block ã cache block ã§ã¯ãªãäºã«æ³šæããã caddr all remaining caddr
starting with caddr are not cache blocks.
çè
ã®ã·ã¹ãã ã®äŸã§ã¯ fsworm ã® block æ°ã¯ 6972701 ã§ããã®ã«å¯ŸããŠãfscache ã® cache block
æ°ã¯ 1392255 ã§ããã In the example of my system, the number of blocks of
fsworm is 6972701, whereas the number of cache blocks of fscache is
1392255. åŸã£ãŠ 1/5 çšåºŠã®ãã£ãã·ã¥èœåãæã£ãŠããã Therefore, it has about 1/5 cache
capacity. ãŸããfscache ã«ã¯ 1394540 åã® block
ãæ¡ããããå®éã«äœ¿ãããŠããã®ã¯ã1035+1392255(=1393290) ã«éããªãã Also, 13604540 blocks
can be taken in fscache, but only 1035 + 1392255 (= 1393290) are
actually used. æªäœ¿çšé å㯠0.1% çšåºŠã§ããã The unused area is about 0.1%.
åçŽã«èãããšè¡š1ã«ç€ºããã㪠mapping ãæãæµ®ãã¹ãããç¥ããªãã Just thinking about it might
think of mapping as shown in Table 1.
泚æ: ããªãã®ãã©ãŠã¶ã¯ SVG ããµããŒãããŠããŸããã Note: Your browser does not support
SVG.ææ°ã®ãã©ãŠã¶ãã䜿ããã ããã Please use the latest browser.
è¡š1. a simple but problematic mapping from fsworm to cache Table 1. a
simple but problematic mapping from fsworm to cache
ããã«ãcache ãšæžããã®ã¯ fscache ã® cache area ã§ããã Here, cache is written in
fscache's cache area.瀺ãããŠãã address 㯠caddr ããæ°ããŠããã The address shown
is counted from caddr.
ãããããã® mapping ã¯åé¡ãåãã§ããã However, this mapping suffers from problems.
ãã fsworm block ã cache ãããŠãããšãåã cache block ã« map ãããä»ã® fsworm block
ã cache ã«å
¥ã蟌ããªãå Žåãããã If an fsworm block is cached, there may be cases
where other fsworm blocks that are mapped to the same cache block can
not enter cache.
ãã㧠cwfs ã§ã¯ãéã« bucket ãããŸããŠãmapping ã«æè»æ§ãæãããŠããã So cwfs keeps bucket
in between, giving flexibility to mapping.ãã®æ§åãè¡š2ã«ç€ºãã The situation is
shown in Table 2.
泚æ: ããªãã®ãã©ãŠã¶ã¯ SVG ããµããŒãããŠããŸããã Note: Your browser does not support
SVG.ææ°ã®ãã©ãŠã¶ãã䜿ããã ããã Please use the latest browser.
è¡š2. real mapping implementation of cwfs. Table 2. real mapping
implementation of cwfs.
説æã容æã«ããããã« fsworm ã® block address ã wa ãšãã caddr ããæ°ãã cache ã®
address ã ca ãšããã For ease of explanation, block address of fsworm is
set to wa and cache address counted from caddr to ca wa%msize ãåäžã® wa
㯠ca%msize ã® ca ã®ã©ããã« map ããããšèããã®ã§ããã wa%msize that wa%msize with the
same wa%msize is ca%msize to ca of ca%msize. å®éã® mapping ã®ç¶æ
㯠fscache
ã® map block ã«ãã bucket ã«ãã£ãŠç®¡çãããŠããã The state of actual mapping is
managed by bucket in map block of fscache.
bucket bucket
fscache ã® maddr ãã caddr ãŸã§ã® block 㯠map block ã§ããã® tag 㯠Tbuck ã§ããã A
block from caddr to caddr in maddr is a map block, and its tag is
Tbuck. map block 㯠bucket ã®éãŸãã§ãbucket ã«ã¯ cache ã®ç¶æ
ãšã察å¿ãã fsworm ã®
block address ãå«ãŸããŠããã The map block is a collection of buckets, and
the bucket contains the state of cache and the block address of the
corresponding fsworm.
å bucket ã¯æ¬¡ã®æ§é ãæã£ãŠããã Each bucket has the following structure.
struct Bucket struct Bucket
{ {
long agegen; /* generator for ages in this bkt */ long agegen; / *
generator for ages in this bkt * /
Centry entry[CEPERBK]; Centry entry [CEPERBK];
};};
å map block ã¯æ倧 BKPERBLK (=10) åã® bucket ãä¿æã§ããã Each map block can
hold up to BKPERBLK (= 10) BKPERBLK.
泚æ: ããªãã®ãã©ãŠã¶ã¯ SVG ããµããŒãããŠããŸããã Note: Your browser does not support
SVG.ææ°ã®ãã©ãŠã¶ãã䜿ããã ããã Please use the latest browser.
å³9. fscache ã®æ§é (cwfs64x) Figure 9. Structure of fscache (cwfs64x)
fscache ã«å«ãŸãã bucket ã®ç·æ°ã¯ msize ã§äžããããŠããã The total number of msize
included in msize is given by msize. 以äžãbucket ã« block address
ã®å°ããæ¹ããé ã« 0 ãã msize - 1 ãŸã§ã®çªå·ãä»ããããã bucket address ãšèšãã In the
following, bucket is numbered from 0 to msize - 1 in ascending order
of block address, and it is called bucket address.
cache entry cache entry
å bucket 㯠CEPERBK (=135) åã® Cache Entry ãæã£ãŠããã Each bucket has
CEPERBK (= 135) Cache Entries. å Cache Entry ã¯ãçŸåšã®ãããã®ç¶æ
ãè¡šããŠããã Each
Cache Entry represents the state of the current map.
struct Centry struct Centry
{ {
ushort age; ushort age;
short state; short state;
Off waddr; /* worm addr */ Off waddr; / * worm addr * /
};};
fsworm ã® block address ba ããã察å¿ãã fscache ã® block address cba
ãèŠã€ããã«ã¯ããŸã In order to find the block address cba of the corresponding
fscache from the block address ba cba, first
bn = ba % msize bn = ba% msize
ãèšç®ããã.ãã㊠bucket[bn] ã®äžã® 135åã® cache entry ã® waddr ã調ã¹ãã Then check
the waddr of 135 cache entries in bucket[bn]. ããããfsworm ã® block
address ba ã® block ã cache ãããŠããã°ããã®äžã« ba ãšäžèŽãããã®ãååšããã¯ãã§ããã If the
block of block address ba of fsworm is cached, there should be some
matching ba it. ãã® cache entry ã entry[ce] ãšãããšã Letting this cache
entry be entry[ce]
cba = msize*ce+bn+caddr cba = msize * ce + bn + caddr
ã§æ±ããäºãã§ããã Can be obtained with. 詳ããã¯ãMap from Worm to Cacheãã§è§£èª¬ããã
Details are explained in"Map from Worm to Cache".
éã«ãçŸåš cache ãããŠãã fscache ã® block address cba ãã fsworm ã® block
address ba ãæ±ããã«ã¯ããŸã Conversely, to obtain the block address ba of cba
from the block address cba fscache currently being cached, first
bn = (cba - caddr) % msize # bucket addr bn = (cba - caddr)% msize #
bucket addr
ce = (cba - caddr) / msize # entry addr ce = (cba - caddr) / msize #
entry addr
ãèšç®ããã° bucket address bn ãæ±ãŸãã®ã§ããã®äžã® cache entry ce ã® waddr ãèŠãã°ããã
The bucket address bn can be found by looking up the waddr of the
cache entry ce in it.
fscache ã® cache area ã® block 㯠cache entry ã«ãã£ãŠãç¶æ
ããä¿æããŠããããšã«ãªãã The
cache area block of fscache has"state" by cache entry. 以äžãcache block
ã®ç¶æ
ã¯â¯â¯ã§ãããšããcache block ã«å¯Ÿå¿ãã worm address ã¯â¯â¯ã§ãããšãèšãäºã«ããã In the
following, let's say that the state of the cache block is â¯â¯ or the
worm address corresponding to the cache block is â¯â¯.
age age
age ã¯ãcache block ã®å€ããè¡šããŠããã age represents the age of the cache
block. å°ããå€ãå€ãã Small values ââare old. ã ããæŠå¿µçã«ã¯ age ãšèšãããã birth day
ã«è¿ãã So it is conceptually close to birth day rather than age. æ°ãã«
cache ããå¿
èŠãçºçããå Žåã«ã¯ã( Cnone ãååšããªãå Žåã«ã¯) age ã®å°ãã cache ãåªå
çã«æšãŠãããã
When it becomes necessary to cache newly, the small cache of age is
preferentially discarded (when Cnone does not exist).ãã㊠bucket ã®
agegen ã®å€ãæ°ãã«å²ãåœãŠã age ã®å€ãšãªãã And the value of agegen of bucket
becomes the value of age be newly allocated. cache ã«ããŒã¿ãå²ãåœãŠãããã°
agegen ã 1 ã€å¢å ããã If data is allocated to cache, agegen increases by
1. age ã®æå€§å€ MAXAGE=10000 ãååšããã The maximum value MAXAGE=10000 age
exists.ãããè¶
ããæã«ã¯ã age ã®åå²åœãå¿
èŠã«ãªãã¯ãã§ãããã詳现ã¯ã³ãŒããããèªãã§ããªãã®ã§ããããªãã When it
exceeds it, reallocation of age is necessary, but details are not
understood because I have not read the code well.
state state
cache ã® state ãšã¯ã察å¿ãã Centry ã®ç¶æ
ã§ã次ã®å€ãæã€ã The cache state is the state
of the corresponding Centry and has the following values.
Cnone = 0 Cnone = 0
Cdirty = 1 Cdirty = 1
Cdump = 2 Cdump = 2
Cread = 3 Cread = 3
Cwrite = 4 Cwrite = 4
Cdump1 = 5 Cdump 1 = 5
cache ãããŠããªã cache block ã®ç¶æ
㯠Cnone ã«ãªã£ãŠããã The state of an Cnone
cache block is Cnone to Cnone. åã®èŠ³å¯ã§ã¯ããã®å Žåã® waddr
ã¯ãŽãã§ããæå³ãæã£ãŠããªãããã«æããã In my observation, waddr in this case seems to
be garbage and has no meaning.
worm ããããŒã¿ãèªã¿åã£ã cache ã®å Žåã«ã¯ã waddr ã¯å
ã® worm ã® addressãã®ãã®ã§ããã In the
case of cache which reads data from worm, waddr is the address itself
of the original worm. cache ã®ç¶æ
㯠Cread ã«ãªã£ãŠããã The state of cache is
Cread. ãã®å Žåã«ã¯ cache block ã®å
容ã¯å¯Ÿå¿ãã fsworm ã® block ãšåãã§ããã In this case
the contents of the cache block are the same as the corresponding
block of fsworm. (ãã£ãã·ã¥ã§ããããåœç¶ã®äº) (Naturally because it is a cache)
æ¢åã® directory ã file ãå€æŽãåãããšããã® cache ã® Cread ã®ã¿ã°ã Cwrite ã«å€åããã When
an existing directory or file is changed, the Cread tag of that cache
changes to Cwrite.ãã㊠waddr ã¯å€æŽãåããªãã And waddr is not changed. ãã¡ãã
dump æã«äžæžãããããã«ã¯è¡ããªãã®ã ããããã®æã«ã¯æ°ãã worm address ã«ä¿åãããåæã« cache entry
ã®äžã® waddr ãæŽæ°ãããã¯ãã§ããã Of course it will not go overwrite on dump, so
at that time it will be saved in the new worm address and waddr in the
cache entry should be updated at the same time. ç°åžžãªã dump ããããšç¶æ
ã¯
Cread ã«ãªãã§ãããã If abnormally dumped, the state will be Cread.
æ°ãã« directory ã file ãäœæããå Žåã«ã¯ããã® cache block ã«å¯Ÿå¿ãã wba ã«ã¯ worm ã®æªäœ¿çšã®
address ãå²ãåœãŠãããã When creating a new directory or file, wba
corresponding to that cache block is assigned an unused address of
worm. ç¶æ
㯠Cdirty ã«ãªãã The state is Cdirty. dump ãå®äºãããš Cread
ã«ãªã£ãŠããã¯ãã§ããã When dump is completed it should be Cread.
ç¶æ
Cnone ãš Cread ã® cache ã¯ã waddr ã«å€æŽãåæ ãããå¿
èŠã¯ç¡ãã The cache of the
state Cnone and Cread does not need to reflect the change in waddr.
åŸã£ãŠããã® Centry ã«å¯Ÿå¿ãã fscache ã® block ã¯(å¿
èŠã«å¿ããŠ)æšãŠãŠãæ§ããªãããšãæå³ããŠããã
Therefore, it means that the block of fscache corresponding to this
Centry may be discarded (if necessary).
ãšãã㧠cwfs ã³ã³ãœãŒã«ã® statw ã³ãã³ããå®è¡ããæã® By the way, when you run the cwfs
console statw command
8600 none 8600 none
230005 dirty 230005 dirty
0 dump 0 dump
1153555 read 1153555 read
95 write 95 write
0 dump1 0 dump1
ã§ã¯ Centry ãçŽæ¥èª¿ã¹ãŠã state ã®å€ã®ååž(åæ°)ã衚瀺ããŠããã We examine Centry directly
and display the distribution (number) of values ââof state.
free block and dirty block free block and dirty block
2013/03/11 2013/03/11
2013/03/14 æ¹èš 2013/03/14 revision
2013/03/29 èšæ£ 2013/03/29 Correction
2013/04/10 è¿œå 2013/04/10 added
次ã®ããã«åé¡ããã®ãè¯ãã It is better to classify as follows.
(a) unwritten block (a) unwritten block
(b) dirty block (b) dirty block
(c) free block (c) free block
(a) ã® unwritten block ãšã¯ dumped area ã®äžã«ååšãããæªæžã蟌ã¿ã® blockã The
unwritten block in (a) is an unwritten block existing in the dumped
area.
(b) ã® dirty block ãšã¯ fscache ã®äžã§ Cdirty ãšãããŠãã blockã The dirty block
in (b) is a block which is called Cdirty in fscache. cwfs ã¯ãæ°ãã« file ã
directory ãäœæããæã«ãcache ã« worm ã® address ã察å¿ä»ããcache ã® block ã®ç¶æ
ã
Cdirty ãšããã When cwfs creates a new file or directory, it associates
worm's address with cache, and Cdirty cache's state to Cdirty. ãã® worm
address ã¯æªäœ¿çšã¢ãã¬ã¹ã§ãããunwritten block ã䜿ãããªããããã䜿ãã This worm address is
an unused address, and if unwritten block is available, use it.
dump çŽåŸã«ã¯ Immediately after dump
(a) â (b) (a) â (b)
ã§ããã.
(c) ã® free block ãšã¯ dirty block ã®ãã¡ãfscache ã« free block ãšããŠç»é²ãããŠãã
blockã (c) free block is a block that is registered as a free block in
fscache among dirty blocks. ããã㯠file tree ã« link ãããŠããªãã They are not
linked to the file tree. link ãããŠãã dirty block 㯠dump ã®å¯Ÿè±¡ãšãªãããlink
ããå€ãã block 㯠dump ãããªãã Linked dirty blocks are subject to dump, but
blocks deviated from link are not dumped. cwfs ã¯ãããããŽããšããŠæšãŠãã®ã§ã¯ãªããæ°ãã«
dirty block ãäœãæã«å©çšããã
cwfs 㯠free block ã® list ãæã£ãŠãããfree block list 㯠supper block
ã®äžãšãfscache ã® Tfree 㧠tag ä»ãããã block ã«ååšãããsupper block ããã³ Tfree
block ã«ã¯ 2037 åã® block address æ
å ±ãä¿æã§ããã
åŸã£ãŠ
(b) â (c)
ã§ããã.
fscache ã® Cwrite ã®ç¶æ
ã® block ã¯ãå®éã« dump ãããæã«åã㊠dump å
ã® address
ã確å®ããããããã® address ã¯æåŸã® dump ã®äžã«ç©ã¿äžãããããä»æ¹ Cdirty ã®ç¶æ
ã® block ã«ã¯ãåãããã
fsworm ã® address ãšé¢ä¿ä»ããããã
ãããã free block ãªã©çºçãããªãããã«å·§ããããªãã®ã? ããããèããããçµæ§é£ãããã§ãããfile ã
directory ã®åé€ãåé¡ã§ãããdump ãæ¯æ¥æ5æã«è¡ããããšããããæŒéã®äœæ¥ã§ããã€ãã® directory ã file
ãæ°ãã«äœã£ããšããããããã C1,C2,...,Cn ãšãããfscache å
ã®ãããã® block ã¯ã©ãã Cdirty
ã®ç¶æ
ã«çœ®ãããfsworm ã® address
ãšé¢ä¿ä»ããããããããã®å
ã®ããã€ãã¯ãã®æ¥ã®å
ã«åé€ãããããšãããã ãããåé€ããããã®ã D1,D2,...,Dm ãšããã
C1,C2,...,Cn ãã D1,D2,...,Dm ãå·®ãåŒããéšåã dump ãããã®ã§ããããdump ã§çæããã
fsworm ã® address ãé£ç¶ããŠããäºã¯æåŸ
ããããããç©Žããæã€äºãšãªããããã㯠free block
ãšããŠå°æ¥ã®å©çšã®ããã«äºçŽãããã¯ãã§ããã
ãã¡ãããåé€ãã file ã directory ã¯çŽã¡ã«èŠª directory ã® entry ããåé€ããããããã®
contents ã®ç¶æ
㯠Cdirty ã®ãŸãŸã«ãªã£ãŠããã
Cdirty åé¡ã¯åã«ã¯ãŸã åãããªãäºãå€ããåã® fscache ã¯å€§éã® Cdirty block
ãæ±ããŠãããã©ãããããã®ç¶æ
ã¯ç°åžžããããåå ã¯äœã? èããããã®ã¯ cwfs console ã® clri ã³ãã³ãã§å€§ããª
directory ãåé€ããããšã«ãcheck free ã³ãã³ããè¡ããªãã£ãäºãrm
ã³ãã³ãã«ãã£ãŠãã¡ã€ã«ãåé€ããå Žåã«ã¯ãäžèŠã«ãªã£ã block 㯠free block list ã«å
¥ã£ãŠè¡ãããclri
ã®å Žåã«ã¯å
¥ããªããããããããã¯å©çšãããªã block ãšããŠæšãŠããããããã
super block ã«ã¯ free block list ãæã¡ã2037 åã® free block ãç»é²ã§ããããããè¶
ãã
free block ã® address ã¯ã Tfree ã§ã¿ã°ä»ãããã fscache ã® block ã«èšé²ãããŠããã Tfree
block 㯠super block ãšåæ§ã« free block list ãæã£ãŠãããfree block list
ã®æ§é äœã¯äž¡è
ãšãåãã§ããã
super block ã Tfree block ã«å«ãŸãã free block ã free[n] ( n=0,1,...)
ãšããããœãŒã¹ããã°ã©ã ãè¿œã£ãŠè¡ããšã free[0] ã¯ç¹æ®ã§ããããšãåããããã㯠Tfree block ãžã® pointer
ãªã®ã§ããããã£ãšæ£ç¢ºã«èšãã°ã free[0] ã«å¯Ÿå¿ãã fscache ã® address ã Tfree block
ã«ãªã£ãŠããã¯ãã§ããã(å³10)
泚æ: ããªãã®ãã©ãŠã¶ã¯ SVG ããµããŒãããŠããŸããã Note: Your browser does not support
SVG.ææ°ã®ãã©ãŠã¶ãã䜿ããã ããã Please use the latest browser.
å³10. freelist chaine
msize ãš csize
msize åã® bucket ã®äžã«ã¯ msize*CEPERBK åã® cache entry ãååšãããçè
ã®ã±ãŒã¹ã§ã¯ã
msize ã 10313 ãªã®ã§ããã®èšç®çµæ㯠1392255 ãšãªãããã®æ°å㯠csize ã«äžèŽããã ã€ãŸãã In other
words,
csize = msize*CEPERBK
ã®é¢ä¿ãæç«ããã1ã€ã® Cache Entry 㯠1ã€ã® cache block ã管çããŠããã®ã§ããã
msize åã® bucket ãåçŽããã«ã¯ã
(msize+BKPERBLK-1)/BKPERBLK
åã® block ãå¿
èŠã§ãããå²ãç®ã®åœ¢ãè€éãªã®ã¯ãåãäžããŠããããã§ãããçè
ã®ã±ãŒã¹ã§ã¯ã msize ã 10313
ãªã®ã§ããã®èšç®çµæ㯠1032 ãšãªããããã« maddr ã® 3 ãå ããŠã caddr ã® 1035 ãšäžèŽããã ã€ãŸãã In
other words,
caddr = (msize+BKPERBLK-1)/BKPERBLK + maddr
ã®é¢ä¿ãæç«ããã
Map from Worm to Cache
bn ã bucket addressã ce ãããã® bucket ã®äžã® cache entry ã®ã¢ãã¬ã¹ãšããã bn ãš ce
ã¯æ¬¡ã®ç¯å²ã«ããã
0 <= bn < msize
0 <= ce < CEPERBK
bn ãš ce ãåºã«ãcache block address ã察å¿ãããªããŠã¯ãªããªãã
2ã€ã®èªç¶ãªèãæ¹ãããã
(a) bn*CEPERBK+ce+caddr
(b) msize*ce+bn+caddr
ãã¡ããä»ã®ãã£ãšè€éãªãããã³ã°ã¯èããããããããããæ¡çšããçç±ã¯ååšããªãã
ãããŠãå®éã«ã¯åŸè
ã®æ¹åŒ(b)ãæ¡çšãããŠããã
å è
ã¯æ¡çšããããããªããªãããã¡ã€ã«ã¯ fsworm ã®é£ç¶ãã block ãå ããåŸåããããåŸã£ãŠ (a)
ãæ¡çšãããªãã°ãæ°ãã«äœæããã倧ããªãã¡ã€ã«ã®ãã£ã·ã¥æ
å ±ã¯1ã€ã® bucket ãå æããããšã«ãªãããããšãã® bucket
ã管çãã cache block ã«ã¯ã(fsworm ã« dump ããªãéã)æ°ãã«ãã£ãã·ã¥ã§ããªããªãã
ããã«åŸè
ã®å Žåã«ã¯ãfsworm ã®é£ç¶ãã block ããã£ãã·ã¥ããå Žåã«ãfscache ã§ãé£ç¶ãã block
ã«ãªãå¯èœæ§ãé«ããšããã«ããã(ããŒããã£ã¹ã¯ã® seek time ãç¯çŽã§ããã)
msize ã®æ±ºå®ã¢ã«ãŽãªãºã
msize ã¯ã©ã®ãããªèšç®ã§æ±ºå®ãããã?
map block ãš cache block ã®åèšæ°ã m ãšãããšã
map block ã n åã«ããå Žåã®å¯èœãª mn (= csize) ã®å€ã¯ã
(n-1)*BKPERBLK*CEPERBK < m - n <= n*BKPERBLK*CEPERBK
ãæºããå¿
èŠãããã ã€ãŸãã In other words,
1.0*m/(1 + BKPERBLK*CEPERBK) <= n < 1.0*(m + BKPERBLK*CEPERBK)/(1 +
BKPERBLK*CEPERBK)
ãå
±ã«æºããå¿
èŠããããããã®ãã㪠n ã¯
n = (m + BKPERBLK*CEPERBK)/(1 + BKPERBLK*CEPERBK)
ã§åŸãããã ããªãã¡ã That is,
m - n = ((m - 1)*BKPERBLK*CEPERBK)/(1 + BKPERBLK*CEPERBK)
ãã®ããã«èšç®ããã mn 㯠CEPERBK ã®åæ°ã§ããä¿èšŒãç¡ããåŸã£ãŠæ¬¡ã®è£æ£ãå ããå¿
èŠãããã
msize = (mn)/CEPERBK
csize = msize*CEPERBK
caddr = (msize + BKPERBLK - 1)/BKPERBLK + maddr
ã§èšç®ãããäºã«ãªããã
çè
ã® fscache ã¯
1394540 block
確ä¿ã§ããã®ã§ã
m = 1394540 - 3 = 1394537
ã§ããã. ãã®èšç®æ¹åŒã«ããã°
msize = 10322
caddr = 1036
csize = 1393470
ãšãªãã caddr + csize 㯠1394506 ã§ããããã㯠fscache ã® block æ° 1394540
ãããå°ããã®ã§ãããã§è¯ãã¯ããªã®ã§ããããå®éã® cwfs ã®å€ã¯éããå®éã«ã¯ããã® msize ãããã«èª¿æŽã
msize = maxprime(msize - 5) # Ken's value
csize = msize*CEPERBK
caddr = (msize + BKPERBLK - 1)/BKPERBLK + maddr
ãšããŠãã( cw.c)ãããã« maxprime(n) ã¯ã n ãè¶
ããªãæ倧ã®çŽ æ°ã§ããããã®èª¿æŽãäœæ
å¿
èŠãªã®ã?
çè
ã«ã¯äžæã§ããã(fsworm ãš fscache ãšã®é¢ä¿ã§ã¯ããã®èª¿æŽã¯äžèŠãªã¯ãã§ããã)
Fscache Root
2013/03/09
fsworm ã root ãæã€ããã«ãfscache ã root ãæã£ãŠããã(æããªããã° directory tree
ã蟿ããªã)
fscache 㮠root block 㮠address 㯠fsworm 㮠dump stack top 㮠dump root
block ã® address ãåºã«ããŠãéåžžã® mapping rule ã«åŸã£ãŠæ±ºå®ãããŠããã
Recovery
埩å
(recovery)
2013/02/28 æŽæ°
cwfs ã«ç°åžžãããããåå ã¯ããããããããäž»ãªã±ãŒã¹ã¯æ¬¡ã®2ã€ã§ãããã
(a) æžã蟌ã¿äžã®åé»
(b) ããŒããŠã§ã¢ã¯ã©ãã·ã¥ãããã¯ããã«ãæ§ã
ãªã±ãŒã¹ã§çŽ°ååãããããããã§ã¯ fsworm
ãå¥å
šã§ãã(ãããã¯åããããªããšã§ããããfsworm ã®ããã¯ã¢ãããååšããŠãã)ããšãä»®å®ããããã®å Žåã«ã¯ãfsworm
ã«åºã¥ããŠåŸ©å
ããããšã«ãªãã
以äžã®ä»®å®ã眮ã:
/dev/sdC0/fscache
/dev/sdC0/fsworm
ãååšãã
⢠fsworm ã¯å¥å
šã§ããã
⢠fscache ã®å
é block ã«ã¯æ£ãã config æ
å ±ãå«ãŸããŠããã
ãã®å
ã§ã¯ãcwfs ã®ã¹ã¿ãŒãã§(9front ã§ã¯)
bootargs is (tcp, il, local!device)[local!/dev/sdC0/fscache]
ã®ã¡ãã»ãŒãžãã§ãã®ã§
local!/dev/sdC0/fscache -c
ã input ãããã®åŸ config: ã® prompt ã«å¯ŸããŠ
recover main
end
ã§å¿ããã°ããã(埩å
ã¯éåžžã«æ©ãã(1~2ç§?)
fscache ã®å
é ãããã¯ã¯ãcwfs
ã®æŽ»åäžã«ã¯æžã蟌ã¿å¯Ÿè±¡ããå€ãããŠããã®ã§ãããŒããã£ã¹ã¯ãç©ççæå·ãåããŠããªãéããããŒã¿ã®ãã¹ã¯é«ã
ãæåŸã® dump
以éã«éããããšèšããã
fscache ã®åŸ©å
ã«å¿
èŠãªå
šãŠã®æ
å ±ã fsworm ã® block address ç¯å² 0 ãã snext
ãŸã§ã®äžã«å«ãŸããŠããã埩å
ã«éããŠãfsworm ã®å
šãŠã調ã¹ãå¿
èŠã¯ç¡ããæåŸã«ãã³ãããèšé²ãã蟿ãäºãã§ããããã®äœæ¥ã¯ cwfs
ãèªåçã«è¡ãã¯ãã§ããããåèã®ããã«ãfsworm ã®æ§é ãããå°ã詳ãã解説ããã
Plan9(ãããã¯9front)ã§ã¯ãéå»ã®ãã¡ã€ã«ã®ç¶æ
ã¯
9fs dump
ãå®è¡ããŠ
/n/dump
以äžã«èŠããããããã«èŠããå
šãŠã®æ
å ±ã次ã®ãã³ãã¢ãã¬ã¹ snext ã®1ã€åã® block ã¢ãã¬ã¹ ( = roaddr =
snext - 1) ããç°¡åã«èŸ¿ã£ãŠè¡ãããšãã§ããã
åŸã«çŽ¹ä»ããããã°ã©ã cwstudy ã¯ãblock ã¢ãã¬ã¹ãæå®ããŠããã®å
容ã衚瀺ããã次㯠cwstudy ã®å®è¡äŸã§ããã
cpu% cwstudy 1755392
/dev/sdC0/fsworm
tag pad: 0000
tag tag: 11 (Tdir)
tag path: 1
name: /
uid: -1
gid: -1
mode: 0140555
muid: 0
qid path: 80000001
qid ver.: 0
size: 0
dblock: 1755391 0 0 0 0 0
iblock: 0 0 0 0
atime: 1343737574 // Tue Jul 31 21:26:14 JST 2012
mtime: 1343737574 // Tue Jul 31 21:26:14 JST 2012
æåã«åŸãããåå㯠â / â ã§ãããäœææ¥ã¯ãfsworm ãäœããã 2012幎7æ31æ¥ãšãªã£ãŠããã dblock[0] ã®
1755391 ã¯ã" /" ã®äžã® directory entry block ã®ã¢ãã¬ã¹ã§ããã
cpu% cwstudy 1755391
/dev/sdC0/fsworm
tag pad: 0000
tag tag: 11 (Tdir)
tag path: 1
name: 2012
uid: -1
gid: -1
mode: 0140555
muid: 0
qid path: 80000001
qid ver.: 27
size: 0
dblock: 1755390 0 0 0 0 0
iblock: 0 0 0 0
atime: 1348729247 // Thu Sep 27 16:00:47 JST 2012
mtime: 1343797238 // Wed Aug 1 14:00:38 JST 2012
block ã¢ãã¬ã¹ 1755391 ã«å«ãŸãããã£ã¬ã¯ããªã®åå㯠2012 ã§ããã1ã€ããçŸããŠããªãã®ã¯ãfsworm ã®éçšéå§ã
2012 ã ããã§ããã
block ã¢ãã¬ã¹ 1755390 ã«ã¯å€æ°ã® directory entry ãå«ãŸããŠããã
term% cwstudy 1755390
[äžç¥]
name: 0925
uid: -1
gid: -1
mode: 0140555
muid: 0
qid path: 80000001
qid ver.: 27
size: 0
dblock: 1755212 0 0 0 0 0
iblock: 0 0 0 0
atime: 1348584237 // Tue Sep 25 23:43:57 JST 2012
mtime: 1348584237 // Tue Sep 25 23:43:57 JST 2012
name: 0927
uid: -1
gid: -1
mode: 0140555
muid: 0
qid path: 80000001
qid ver.: 27
size: 0
dblock: 1755388 0 0 0 0 0
iblock: 0 0 0 0
atime: 1348729247 // Thu Sep 27 16:00:47 JST 2012
mtime: 1348729247 // Thu Sep 27 16:00:47 JST 2012
ãããã®ååã¯ããã³ãããææ¥ãè¡šããŠããããŸãããããã¯
ls /n/dump/2012
ã§è¡šç€ºãããååãšäžèŽããã
ããã«é²ãã§ã 2012 ã®äžã«ãã 0927 ã® directory entry ãåæ§ã«èŠã€ããäºãã§ããããããã®ååã¯
ls /n/dump/2012/0927
ã§è¡šç€ºãããååãšäžèŽãããããã«ã¯ adm ã sys ã usr ãªã©ã®ååãèŠããã ããã
0925 ã® dblock[0] 㯠1755212 ã§ããããã® block ã¢ãã¬ã¹ã¯ 9æ25æ¥ã«ãã³ããã block
ã®äžã«å«ãŸããŠããã(ãã®æ¥ã«ã¯ 1754642 ãã 1755216 ãŸã§ãæ¶è²»ããã)
9æ27æ¥ã®ãã³ãã§ã¯ããã®æ¥ã®ãã¡ã€ã«ãå
šãŠæ°ãã«ã³ããŒããã®ã§ã¯ãªããå€æŽãããŠããªãã³ã³ãã³ãã«é¢ããŠã¯ãå€ãã³ã³ãã³ãããã®ãŸãŸäœ¿ããããã§ã¯
0925 ã«é¢ããŠã¯ã9æ25æ¥ã®ã³ã³ãã³ãããã®ãŸãŸäœ¿ãããŠããã
fsworm ã§ã¯ block åäœã®å·®åæ³ã䜿ãããŠããã®ã§ããã(ãã®ä»¶ã«é¢ããŠã¯åŸã«ãŸãåå³ãã)
埩å
(recovery)ã«ã€ããŠåå³
fsworm ãå¥å
šã§ããã°ãsuper block ã snext ãŸã§èŸ¿ãã°ã snext ãåºã«åŸ©å
ã§ãããã§ã¯ç¢ºå®ã« snext
ãŸã§èŸ¿ããã®ã?
fsworm ãæ¬åœã® WORM ãããã¯æ°åã®ããŒããã£ã¹ã¯ã§ããã°åé¡ã¯ãªãã§ãããã snext ã®å
ã«ã Tag
ãããããŒã¿ã¯ç¡ãã®ã§ããããééãäœå°ã¯ç¡ããããã䜿ãå€ãã®ããŒããã£ã¹ã¯ã§ããã°ã©ãã ãã?
Tag ãé Œãã« super block ã蟿ãéã«ããŽãã Tag ãšåéããããããããªããsuper block ã® Tag æ§é äœã¯
struct Tag
{ {
short pad; /* make tag end at a long boundary */
short tag;
Off path;
};
ã§ããã pad 㯠0ã tag 㯠1ã path 㯠2 ã§ããããŽãã®äžã§ããã® 12Bãå®å
šã«äžèŽãã確ç㯠2 -96 㧠泚1
ãååã«å°ãããšèãããããããªããäœãããfscache
ãã¯ã©ãã·ã¥ãã確çèªäœã極ããŠå°ãããŠããµãŒãã®ã©ã€ãã¿ã€ã (5幎çšåºŠã?)ã®äžã«ããããç¡ããã ã
ã ããããããã確çã®èšç®ã¯ãã©ã³ãã ãªããŒã¿ãæžã蟌ãŸããŠããäºãåæã«ããŠããããã®äœ¿ãå€ãã®ããŒããã£ã¹ã¯ã® fscache
ããŒãã£ã·ã§ã³ãã以åã« fscache ããŒãã£ã·ã§ã³ãšããŠå©çšãããŠãããã®ãããã®ãŸãŸäœ¿ã£ããã©ãã ãã? 誀èªããã確çã¯
fsworm ã®äžã§ã® super block ã®å²åãŸã§ã«äžããã®ã§ãç¡èŠã§ããªããããããªããåŸã£ãŠãfscache
ã®ããŒãã£ã·ã§ã³ãäœãå Žåã«æ³šæããæ¹ãè¯ãã ããã(ããŒãã£ã·ã§ã³ã®å
é ã¢ãã¬ã¹ãå°ãããããšã...)
fscache ã® Tcache block ã®äžã«ã¯ fsworm ã®æåŸã® super block
ãšã®æŽåæ§ã確èªã§ããæ
å ±ãå«ãŸããŠãããåŸã£ãŠéåžžã® recovery ã«ãããŠã¯ãã®ãããªå¿é
ã¯ãããªãã¯ãã§ããã
泚1: å®éã«ã¯ã tag ãš path ã ãã§èŸ¿ã£ãŠããã®ã§ã確ç㯠2 -80 ã§ããããã®ç¢ºçãå°ããããããã«ã¯ãä»ã« slast
ã®æ
å ±ã䜿ãæãããããããããŸã§ã®äŸ¡å€ããããã¯æªããã
Recovery ã«ãã£ãŠå€±ããããã®
2013/03/28
free block ã§å€±ããããã®ãããã free block ãšã¯æ¢ã« dump ãããé åã«ååšããããŸã æžã蟌ãŸããŠããªã
block ã§ãããcwfs ã¯ãããã« data
ãæžã蟌ãæ©äŒãããã°æžã蟌ãããšãããèšæ¶ã¹ããŒã¹ãæå¹ã«äœ¿ãããšããŠããã®ã§ãããfree block ã®ãã¡ 2037 åã¯
superblock ã管çããŠããããã®æ
å ±ã¯ fsworm ã«ããã®ã§å€±ãããªããããã 2037 åãè¶
ããéšåã® free
block list 㯠fscache ã® Tfree block ã«ååšããŠãããTfree block 㯠fsworm
ã«ã³ããŒãããªããããã㯠Recovery ã§å€±ãããã
Other Configurations
2013/04/02
pseudo-RAID1
çµå±çŸåšã® cwfs configuration
filsys main c(/dev/sdC0/fscache)(/dev/sdC0/fsworm)
ã®äžã§ã¯ fsworm ã® backup ãåãã®ã¯è³é£ã®æã§ãããšè«ŠããŠãä»ã® configuration
filsys main c(/dev/sdC0/fscache){(/dev/sdC0/fsworm)(/dev/sdD0/fsworm)}
ãæ¡çšããããšãšããã
ãã㯠pseudo-RAID1 ã® configuration ã§ãããããã€ã¹ãŸãããšã§ã¯ãªããfsworm partition ã ãã
RAID1 颚ã«åŠçããŠãããã
/dev/sdC0/fsworm ãš /dev/sdD0/fsworm ã¯ãµã€ãºãç°ãªã£ãŠãæ§ããªãããã®å Žåã«ã¯å°ããæ¹ã«åãããããã
æžã蟌ã¿ã®é åºã¯ã(ãã®å Žåã«ã¯) D0 â C0 ã§ãããèªã¿åã㯠C0 ã§è¡ãããã
ãã£ã¹ã¯ç·šæã®å€æŽã«ããã£ãŠã¯ãæºåãå¿
èŠã§ããã
⢠ã³ããŒãåããªããŠã¯ãªããªããpartition ãŸãããšã¯æéãããããããã®ã§ãæåŸã® super block
ãŸã§ã®ã³ããŒã«å¶éããå¿
èŠãããã
â¢ããã§ããŸã æéãæãããããããç¥ããªãã®ã§ããã®éã® auto dump ãæ¢ããå¿
èŠãããããã®ããã«ã¯ãcwfs
ã«ããããããŠãªããšãããªãã
ãã£ãšããRAID ã¯åã家åºã§äœ¿ãã«ã¯å€§ãããªã®ã§ããã...
家ã§äœ¿ã£ãŠããéãé 調ã«åããŠããã倧åŠã®ãµãŒããŒãããã§ããããšã«ããã
fake WORM
Cinap ã«ãããš fake WORM ã®äžã«ã¯ written block ã® bit map ãããããã§ããããã®å ŽåãHDD ã
WORM ã®ä»£ããã«äœ¿ãã®ã ãããçŸåšã®å©çšç¶æ
ã瀺ã bit map ãæã€äºã¯å¯èœãªã®ã§ããããã®å Žåã® configuration ã¯
filsys main c(/dev/sdC0/fscache)f(/dev/sdC0/fsworm)
ãšãªãã.
ããã䜿ãã°ãæ®æ®µã¯ 1 åã® disk ã䜿ããæ°ã®åããæã« backup disk
ãè¿œå ããŠããã¯ã¢ãããåãåã®ãããªæ°ãŸãããªäººéã«é©ããåŠçãå¯èœã§ããããšæããã
fake WORM ã®äœæ
å ã® WORM ã¯éåžžã® WORM ãªã®ã§ãfake WORM ãäœãå Žåã«ã¯ãdevice
ã®ã³ããŒãšããèš³ã«ã¯è¡ããªãã¯ããŠãããæ°ãã«æ§æããäºãšããå®å
šã®ããã«ãPXE ã§ç«ã¡äžãã端æ«ã§äœæ¥ããããšãšãããlocal
disk ã«ã¯ããããã cached fake WORM ãæ§æãã plan9 partition ãæºåããŠããã
/dev/sdC0/fscache
/dev/sdC0/fsworm
ãã®äžã§
cwfs64x -c -f /dev/sdC0/fscache
ãå®è¡ãã 泚1 ã
泚1: cwfs ã®ã³ãã³ãã®äœ¿ãæ¹ã¯ãBell-labs ç(Geoff ã®ãªãªãžãã«ç)ãš 9front çã§ã¯ç°ãªããããã§ã¯
9front çã«åºã¥ãã9front çã§ã¯ãkfs ã fossil ãªã©ãä»ã®ãã¡ã€ã«ã·ã¹ãã ãš -f
ãªãã·ã§ã³ã®äœ¿ãæ¹ã®çµ±äžãèšã£ãŠããã
9front çã§ã¯ -c option 㧠config mode ã«å
¥ãã config ã® prompt ã«å¯ŸããŠæ¬¡ã®ããŒã¿ã
input ããã
service cwfs
filsys main c(/dev/sdC0/fscache)f(/dev/sdC0/fsworm)
filsys dump o
filsys other (/dev/sdC0/other)
ream other
ream main
end
以äžã¯äžåéãã§ããã
次㫠cwfs console ãžã®ã³ãã³ããš shell ã¬ãã«ã®ã³ãã³ããçºçãããããã§ã¯ cwfs console ãžã®ã³ãã³ãã
fscons> ã§è¡šãã
以äžã®æäœã¯æ°ãã window ã®äžã§è¡ãã®ãç¡é£ã§ããã
fscons> users default
fscons> newuser arisawa
fscons> allow
term% mount -c /srv/cwfs /n/cwfs
term% mkdir /n/cwfs/adm
term% cp /adm/users /n/cwfs/adm
fscons> users
泚æ: newuser arisawa ã¯ãçè
ã®ã·ã¹ãã ã® system owner 㯠glenda ã§ã¯ãªã arisawa
ã ããå¿
èŠã«ãªã£ãã®ã§ããã glenda ã®ãŸãŸã§ããã°äžèŠã§ããã
ãã®ããšã¯ãçè
ã® cpdir ã䜿ãã®ãæ©ãã
cpdir -mvug /root /n/cwfs adm 386 acme cfg cron lib mail rc sys
/root ã®äžã«ãã fd ã mnt ã n ã tmp ã usr ã¯åå¥ã«ç¢ºèªããæ¹ãç¡é£ã§ããã
ç¹ã«ã /root/n/ ã®äžã«ã¯ cwfs ãèŠããŠããã¯ãã§ããã
Tvirgo
fakeworm ã®å Žåã«ã¯ cwfs console ã® statw ã§è¡šç€ºããã wsize ããã Tvirgo block
ãå§ãŸãã Tvirgo block 㯠fsworm ã® block 0 ãã wsize 㟠ã§ã®äœ¿çšç¶æ³ã bitmap
ã§è¡šããŠãããæžã蟌ãŸãã block ã«ã¯ bit 1 ãç«ãŠããããŸã æžã蟌ãŸããŠããªã block ã® bit 㯠0
ã§ãããfsworm ã®å
é 2 block ã¯æžã蟌ãŸããŠããªãã®ã§ãbitmap ã®æåã® 2 bit 㯠0 ã§ããã
fakeworm 㯠fsworm ã®æ«å°Ÿã« bitmap ãå
¥ã蟌ãã®ã§ããã®åã wsize ã¯å°ãããªãã
Misc.
What did I do that day?
2013/03/18
ããã®æ¥ã¯äœãããŠããã®ã ãã?ããšåãèããå Žåã«ã¯ããã¡ã€ã«ã®ä¿®æ£ãªã©ã®è©±ã§ããã飲ã¿ã«è¡ã£ããšãã®è©±ã§ã¯ãªãã
ãã®æ¥ã«å€æŽããããã¡ã€ã«ãå
šãŠåæããã«ã¯ãUNIX ã§ã¯ find
ã³ãã³ãã䜿ããšæããèšå€§ãªãã¡ã€ã«ã®äžãããå€æŽããããã¡ã€ã«ãæ¢ãåºãäœæ¥ã¯(ãã¡ã€ã«ã®éã«ãããã)å€ãã®æéãèŠãæ°ç§ã§ã¯çµãããªããã¡ãªã¿ã«åã®
MacBook ã§ã¯åã® $HOME ã®æ¢çŽ¢ã ãã§ã30ç§çšèŠããŠããã(çµæ§ããããã®ãã¡ã€ã«ãæã£ãŠããããããã)
bash$ touch a.txt
bash$ time find $HOME -newer a.txt -print
find: /Users/arisawa/.emacs.d/auto-save-list: Permission denied
/Users/arisawa/Library/Application
Support/Google/Chrome/Default/Cookies
......
......
find:
/Users/arisawa/src/rminnich-vx32-17a064eed9c2/src/9vx/osx/9vx.app:
Permission denied
real 0m28.372s
user 0m0.783s
sys 0m18.783s
bash$
ããã§çŽ¹ä»ããã®ã¯åã®äœã£ã lr ã³ãã³ãã§ãããfind ã® -newer
ãªãã·ã§ã³ã«çžåœãããªãã·ã§ã³ãååšãããããã䜿ã£ãŠæšæ¥ã«å€æŽããããã¡ã€ã«ããµãŒããŒã®å
šãŠã®ãã¡ã€ã«ã®äžããèŠã€ããã«ã¯æ¬¡ã®ããã«ããã
term% cpu -h ar
ar% 9fs dump
mounting as arisawa
mounting as arisawa
ar% ls /n/dump/2013|tail -2
/n/dump/2013/0317
/n/dump/2013/0318
ar% mtime /n/dump/2013/0317
1363498134 /n/dump/2013/0317
ar% time lr -lt 1363498134 /n/dump/2013/0318
......
......
--rw-rw-rw- web arisawa 5819730 2013/03/18 12:54:03
/n/dump/2013/0318/usr/cpa/www/log/dict
d-rwxrwxrwx arisawa arisawa 0 2013/03/17 21:51:56
/n/dump/2013/0318/usr/cpa/www/users
......
......
0.01u 0.18s 1.91r lr -lt 1363498134 /n/dump/2013/0318
ar%
ãã®æ¥ã«ã¯33åã®ãã¡ã€ã«ã®å€æŽããã£ããå€ã㯠log ãã¡ã€ã«ã§ãããå€æŽããããã¡ã€ã«ã®äžã«ã¯ web ã® cgi
ã«æ ããã®ããããã·ã¹ãã ã®å
šãŠã®ãã¡ã€ã«ãæ¢ããŠããã®ã ã2ç§åŒ±ã§æ¢çŽ¢ãå®äºããŠãããåã¯èšå€§ãªãã¡ã€ã«ããµãŒããŒäžã«æã£ãŠããã«ãä¿ãããã§
ãã!
ãªããããªã«é«éã«å€æŽã調ã¹ãããã®ã?
æ¢çŽ¢ã« atime ãå©çšãããŠããããã§ããã atime ãšã¯ access time
ã®æå³ã§ãããããã¥ã¢ã«ãèŠãŠããã以äžã«è©³ãã説æã¯ãªãã(Plan9 ã®ããã¥ã¢ã«ã«ã¯ read time ãšæžããŠããããwrite
ã«å¯ŸããŠã atime ãæŽæ°ããã)
=======
泚: lr ã¯
http://plan9.aichi-u.ac.jp/netlib/cmd/lr/
ã«çœ®ãããŠããã
=======
atime
2013/06/06
å®éã®åäœãèŠãŠãããšãPlan9 ãš UNIX(MacOSX ã Linux) ã§æ¯ãèããç°ãªãã
Plan9 ã®å Žåã«ã¯ããã¡ã€ã«ãµãŒãããã¡ã€ã«ãæ¢ãåºãããã«èŸ¿ã£ãã«ãŒãã«ååšããå
šãŠã®ãã£ã¬ã¯ããªã® atime
ãæŽæ°ãããŠãããèšå€§ãª directory tree ã®äžã§ãæå®ãããæ¥ã«å®éã«ãã¡ã€ã«ãµãŒãã蟿ã£ãéã¯æ¥µã極ãå
ãã§ãããåŸã£ãŠ
atime ãèŠãŠããã°ãå¿
èŠãªæ¢çŽ¢ã®ã«ãŒãã倧å¹
ã«æžããäºãå¯èœã§ããã
UNIX ã§ã¯éãããã¡ã€ã«ãµãŒãããã¡ã€ã«ãæ¢ãåºãããã«èŸ¿ã£ãã«ãŒãã«ååšãããã£ã¬ã¯ããªã® atime
ã¯æŽæ°ãããŠããªããå€æŽãå®éã«çºçãããã£ã¬ã¯ããªããã¡ã€ã«ã® atime ã ããæŽæ°ãããŠãããåŸã£ãŠã atime
ãé Œãã«ãæŽæ°ãå¹ççã«æ¢ãåºãäºã¯ã§ããªãã
以äžã«ãPlan9 ãš UNIX ã® atime ã®éããå
·äœäŸã§ç€ºãã
Plan9
# Plan9
term% date; touch $home/doc/x;ls -dlu /usr $home/doc
Wed Jun 5 07:58:17 JST 2013
d-rwxrwxr-x M 20 sys sys 0 Jun 5 07:58 /usr
d-rwxrwxr-x M 20 arisawa arisawa 0 Jun 5 07:58 /usr/arisawa/doc
term% term%
Linux
# UNIX (Linux)
hebe$ date; touch $HOME/doc/x; ls -dlu /home $HOME/doc
Wed Jun 5 07:56:41 JST 2013
drwxr-xr-x 3 root root 4096 Jun 4 09:49 /home
drwxr-xr-x 9 arisawa arisawa 4096 Jun 5 07:46 /home/arisawa/doc
hebe$
OSX
# UNIX (OSX)
-bash$ date; touch $HOME/doc/x; ls -dlu /Users $HOME/doc
Wed Jun 5 08:08:27 JST 2013
drwxr-xr-x 6 root admin 204 May 31 07:51 /Users
drwxr-xr-x 3 arisawa staff 102 Jun 5 08:03 /Users/arisawa/doc
-bash$
cwstudy
ãã®ç¯ã¯æªå®æã§ããã This section is incomplete.
usage
cwstudy block_address
cwstudy -C block_address
cwstudy path
cwstudy super
æç®
[1] Sean Quinlan âA Cached WORM File Systemâ
Softw., Pract. Exper., vol. 21 (1991), pp. 1289-1299
http://plan9.bell-labs.com/who/seanq/cw.pdf
[2] Ken Thompson, Geoff Collyer âThe 64-bit Standalone Plan 9 File
Serverâ
http://plan9.bell-labs.com/sys/doc/fs/fs.pdf
1006