������: guru (������~~��业=���), ����: BIBLE
�� ��: ���共�停���Unix Internels������
����站: UNIX��� (2001��10��14��17:19:44 ������), 站���偶�
������: BlueOcean (Blue), ����: Unix
�� ��: [转��] ���共�停���Unix Internels������
����站: BBS 水木�华站 (Mon Apr 27 13:20:24 1998) WWW-POST
Chapter 8 File System Interface and Framework
����前�������(��习)��filesystem�泄氐�系统����. ��������mordern
Unix��VFS (vnode)�芄�, �即, kernel����file system�姆���. ��一��chapter
��要����file system��disk�系�layout.
s5fs��unix����(System V r4��前)����系统,��色�羌虻サ������锌�,���
��缺������14���值牡�������. 4.2BSD�����Fast File System, FFS,
�供�私��诺�performance�凸���. FFS�艿����幕�迎, ���被SVR4
�����. FFS�殖�为UFS (UNIX File System)
���诘�Unix kernel����同时支援�������系牡���系统. ����
���薪��之��. AT&T��file system switch, DEC��gnode/gfs, Sun
�������vnode/vfs���为����, ����赢��胜��,��为SVR4��
一����.
inode ��Unix���械墓���. Unix kernel����inode����为��缘����慕���.
一��inode���一������, ��录��kernel��取�玫�������要�玫�������,
�约��玫��������缘鹊�.���inode��原������为�����结构�拇蟛糠�
���萁���on-disk��inode����.Unix file system ��disk�系�image���玫���
��������(i-number)����示每一������. 目录只��一����为�乇�牡���,
��录i-number�偷���亩��斩���.����i-number,kernel���业玫�inode,
也���羌�录�������位�������缘牡胤�.一�����disk�系�inode为on-disk
inode,��kernel���������,使���械�inode为in-core inode.
vnode/vfs�母����前�原��in-core inode�������为 virtual class.
vnode�供一�����蠡慕���. kernel要�缘��������胁�����
透��vnode��������函式�����. 一��vnode ��始����,��
���懈�指��指��file system dependant part.���圆��艿��碌牡���
系统��式为��, kernel���芎��械���确�暮���. VFS�募芄�使��
Unix����支援���氐���系统, kernel����vnode�供����系统��
��展��一����准�慕���. ���潞诺�InfoMac���芸������
一篇����说VFS�����械���压��,��压��,���戏����墓���,
�������为���..
�冉��乇����Unix��实���投����点不太一��.
����说:
struct vnode {
public_data1,2,3,....
caddr_t v_data;
} vnode;
vnode.v_data = (caddr_t *)&vnode;
Understand?������去�����!��������图示����,��图知��.
vnode/vfs�懈��胤���原����unix��一��,�导��race condition.��������
���security hole��泉源.����file name lookup��一��.��前只��一��
filesystem��时��(��Bach����) Unix�谴�一��路����namei(),�涂����业�
inode. vnode�姆���要��一��路������,一��一����.��也使performance
���筒���. (unix filesystem瓶��之一��file name lookup,每��lookup����
����路����每一��目录��inode....4.4BSD��OSF/1�����������亩圆�.
(�约�����,太������)
����vnode/vfs, ����怨�������拇���, ���牡���系统���员������.
�冉���趣����NFS, specfs, fifofs, /proc fs.����顺����一��������.��������
������陆诓��到.
specfs�诟�什�����?��前s5fs��时��,��些�乇��inode����示实��牡���,
����������示�鼙�装��.���诩������堑�ffs���懈�/dev/tty1�牡���. ����
�崭��到��vnode/vfs�姆�式, kernel��去���械�ffs�暮�式,����些��式������
知��������tty driver.����姆�式�����一��specfs.只要kernel����
inode�歉�device file�幕�,�筒�去����vnode��open,���呛���specvp(),��
��vnode������.specvp�突���实���virtual function��指���到vnode去,
��玫���希��牟���.�����specfs���诘�目��. Chapter 16�懈���细������.
�����鄣���同device file major/minor device number��一��,也����指��
��同device������法.
fifofs��specfs一��.������ffs��某��vnode������fifo���玫�named pipe.
/proc file system���前�process�诩������械�状态,转��为file system�姆�式
�����取.������debugger���愿��目���process,�供���墓���,
也����debugger执�械�一���process. (前���到�诰傻�Unix��,���遣����械�)
Chapter 9 File System Implementations
������要����on disk file system layout, ��一些�����file system.
前��没���到vnode��kernel�����织,��������也����.
������s5fs.��实�还���约����冉峡�,��图说���戮投���.
�冉��乇����file system��未���free block. s5fs��free block
list������free block.���list���占�占���?�����,��为��
list��free block��,也���墙���没���玫牡目占�.free block list
�拇�小����剩�目占�����.���没�锌占���,也����要
free block list��; free block list原��占�玫目占��
���统�������free block��.
��实前��没说���. free block list�殖�������.��super block
����一小��,剩�碌牟欧���free data block��. super block��
free list�����司突��free data block�系�list����. ����
free block list占��data block�目占����data block����前�统�.
Berkeley Fast File System
s5fs���������, performance��一������.����说ls -l dir,�突���inode��dir
�牡��������乇���. (inode����file attribute.) s5fs��inode table����disk
�占����前��, ����牡胤���data block.�����朔训����seek time.
s5fs fragmentation������也没�写���煤芎�.��free block list�姆���只��
�诘���系统�战�����时��拥�����玫���������,�镁���fragmentation��������.
block size也������. block size�������效��,�����朔芽占�,��之����效��,
s5fs��一��super block也��危��, super block �������filesystem������.
s5fs����一��缺����14���值牡�������.
FFS�某��志��墙����些�����. How? s5fs��disk������一���糯�处��,
没�锌���实��构, FFS��频�时��������实,��实��构���墙�去,也����
������disk��head, track, cylinder������. hard disk�珊眉�片platter
(硬��片)���.cylinder���遣�同platter����同track����傻�圆����.
FFS��一��disk���珊眉���cylinder group. 一��cylinder group
�����诘�cylinder���.�虻サ�说,FFS���前�一��disk���杉���小
disk (cylinder group),每��cylinder group (disk)����鸥�s5fs
������. ��������������某��cylinder group�诘����������诩���
cylinder�摹�围��,����seek time.
���fragmentation����������使��bitmap�����. FFS使�贸���
��data block�越���fragmentation������影��.
���嵌��小�牡���(�痛蟮蛋���尾��,����一��block�牟���),���前�data block
�谐杉���小��,��藕眉���小������省�朔训��目占�.�����fragmented
block������一��要��一����������尾��,�����诖�block�诘����媳���
������,������说A����tail住��一block�牡�1/4, 3/4��, B���冉�小,
住��同一 block�牡�2/4��.��������要��A����block�频���一���碌�block
��,��A������一��block������.
为�吮�����为一����������某沙����虏���要�陌���, FFS����只��direct
block������fragmentation.也���堑�������一����小�筒���fragmentation block
��.
���思芄��系母谋�, allocation policy也����要. FFS��������硬��占�:
* 同一��目录�牡���(inode)������同一��cylinder group��. (localizing
policy)
* 每���碌�目录������parent位於�同��cylinder group��. (distributing
policy)
* ������data block���诤���inode��同��cylinder group��(localizing policy)
* ��������48kb,�约�����每����1MB,��要���艿�,���cylinder
group.���某�������爆一��cylinder.
* ����data block时����disk��interleave factor.(����?����一��没��
�霉�MS-DOS��floppy���俪�式:) 没��系, ������图��)
s5fs��super block���殖�������. FFS4每��cylinder group���屑�录
�约��目占�使��状��. �����disk��super block只��录�����缘�����,
��cylinder�拇�小位��, block�拇�小位�玫鹊�����.每��cylinder group
����一��super block�谋���. FFS����些���莘�散����, 使��没�械�一��
��头,�殴�,������片�����些����. (没�邪����械募�������同一����
�系���思.)
��使目前��SCSI硬�����head, cylinder, sector,�������供������只��
�����������硬��拇�小��同����, ����实����示FFS�姆�式���强��缘玫�
���玫�效��.
FFS���泻芏�chache�母慕����������效��,����要�约�����:)
Temporary File System
temporary file system�����要��时使�玫����某��峡�������效��.
��前�姆�式�前�一��ram��������ram disk.�������朔鸭�����. BSD��memory file
system (mfs)�姆�式, ��一��io server�����address space�����占����供
temporary file system���荽�占�,��������缺����context switch使
performance����. Sun�姆�式���, tmpfs�����vnode/vfs�����VM����,
�����virtual memory���供tmpfs�目占�. �����取�姆�����一���filesystem
没������,��������姆���. ����一���������定file system write back��时��,
����图�������械���系统������写��disk���到temp file system��目��. (����
Unix�玫���时���牡胤��芏�(��cc).����temporary file system�姆�展
�呛��屑�值��.
Chapter 9�����时���到��Buffer Cache.���������Bach���������氐�,����
目前��Unix�丫�����Buffer Cache,�牟����file system��virtual memory�姆�式,
��为��效�����眉�����.
Chapter 10 Distributed File Systems
���陆���..NFS/RFS/AFS/DFS.
NFS��实����虻サ�,��只�前�kernel��disk写�氐亩���(& reading),����
network packet�统�去����.��kernel�慕������遣���vnode/vfs��.
NFS performance bottleneck���NFS要��每�蔚�write()���芄�cache,一��要
����写��,�����员���一��一����询��,使��ls -l���������traffic.
��然�������蟹����慕�.
NFS version 3�1995�公��,������NFS v2�拇蟛糠莸�����. (security
����������RPC����. RPC���������供security�幕���,只������实����
�����到����dedicated NFS server. �冶冉�����趣����Auspex NS5000.
����一����IBM��, focus���荽�. Auspex NS5000�泻眉���CPU, 每��CPU
������一����,�殖�����,一�处����路�系�����,��一�处��硬��系
统��IO.������一��CPU���薷墓��SunOS,admin��,�����CPU����一����
��functional multiprocessing kenel (FMK)��系统,�舜思���message
passing��谈. FMK�暮么�����只�供��NFS server���要��function,
���供Unix������/����,使��系统省�虏��俑���.
RFS没什������...
AFS, Andrew File System��CMU��展��系统, ��������Transarc
Corporation.����展. ����AFS�荼��OSF DCE��Distributed File
System.����AFS/DFS������细�慕���.����太������,����冉����.
������AFS�冉喜���, DFS���撕芏����, ����也�冉隙�. DFS�冉���
����嵌苑�散式����系统cache�母慕�. DFS server������client
一��(read/write/status/lock..)token, ������(read/write/status
/lock..)�鹊鹊亩�������要��server synchronize,也����
update cache.也����说��client拥�懈����系�使��权(token,权��之��).
client拥��token直��kernel��������权��为止.kernel��时�沙���
��些token,��示����要���data,��要synchronize��.
token���法�浅��母���,��为��统�姆������械�时�都要synchronize.����
token���法���强��堑��蟛糠莸�时���诮圆������race condition,����
����要每��������synchronize.
��������也指��, DFS�浅��母���, ����实��������.
--
Buck barks in the darkness
--
Target Locked:Guru In Darkness.
��只��一只�������诺�狮�印�����
�� ��源:��UNIX��� www.tiaozhan.com/unixbbs/��[FROM: 202.114.36.175]
--
Only the Paranoid Survive!
Andrew S.Grove
[m[1;32m�� ��源:������未��站 bbs.pku.edu.cn��[FROM: 162.105.45.67][m