179 lines · 3.7 KB · Text
RawDownload
.SHThe server processes.PPThe main file system algorithm is a setof identical processesnamed.CW srvthat honor the9P protocol.Each file system process waits ona message queue for an incoming request.The request contains a 9P message andthe address of a reply queue.A.CW srvprocess parses the message,performs pseudo-disk I/Oto the corresponding file system block device,formulates a response,and sends theresponse back to the reply queue..PPThe unit of storage is alogical block(not physical sector) of data on a device:.Ex.TA 0.5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i	enum	{		RBUFSIZE = 8*1024	}; 	typedef vlong Off;	typedef	struct	{		short	pad;		short	tag;		Off	path;	} Tag; 	enum	{		BUFSIZE = RBUFSIZE - sizeof(Tag)	}; 	typedef	struct	{		uchar	data[BUFSIZE];		Tag	tag;	} Block;.EeAll devices are idealized as a perfect diskof contiguously numbered blocks each of size.CW RBUFSIZE .Each block has a tag that identifies what typeof block it is and a unique id of the file or directorywhere this block resides.The remaining data in the block depends onwhat type of block it is..PPThe.CW srvprocess's main data structure is the directory entry.This is the equivalent of a UNIX i-node anddefines the set of block addresses that comprise a file or directory.Unlike the i-node,the directory entry also has the name of thefile or directory in it:.Ex	enum	{		NAMELEN = 56,		NDBLOCK = 6,		NIBLOCK = 4,	};.Ee.Ex	typedef	struct	{		char	name[NAMELEN];		short	uid;		short	gid;		ushort	mode;		short	wuid;		Qid	qid;		Off	size;		Off	dblock[NDBLOCK];		Off	iblocks[NIBLOCK];		long	atime;		long	mtime;	} Dentry;.EeEach directory entry holds the file or directoryname, protection mode, access times, user-id, group-id, and addressinginformation.The entry.CW wuidis the user-id of the last writer of the fileand.CW sizeis the size of the file in bytes.The addresses of the first 6blocks of the file are held in the.CW dblockarray.If the file is larger than that,an indirect block is allocated that holdsthe next.CW BUFSIZE/sizeof(Off)block addresses of the file.The indirect block address is held in.CW iblocks[0] .If the file is larger yet,then there is a double indirect block that pointsat indirect blocks.The double indirect address is held in.CW iblocks[1]and can point at another.CW (BUFSIZE/sizeof(Off))\u\s-2\&2\s+2\dblocks of data.This is extended through a quadruple indirect block at.CW iblocks[3]but the code is now parameterised to permit easily changing thenumber of direct blocks and the depth of indirect blocks,and also the maximum size of a file name component.The maximum addressable size of a file istherefore 7.93 petabytes at a block size of 8k,but 7.98 exabytes (just under $2 sup 63$ bytes) at a block size of 32k.File size is restricted to $2 sup 63 - 1$ bytes in any casebecause the length of a file is maintained in a(signed).I vlong .These numbers are based on.I fs64which has a block size of 8k and.CW sizeof(Off)is 8..PPThe declarations of the indirect and double indirect blocksare as follows..Ex	enum	{		INDPERBUF = BUFSIZE/sizeof(Off),	};.Ee.Ex	typedef	{		Off	dblock[INDPERBUF];		Tag	ibtag;	} Iblock;.Ee.Ex	typedef	{		Off	iblock[INDPERBUF];		Tag	dibtag;	} Diblock;.Ee.PPThe root of a file system is a single directory entryat a known block address.A directory is a file that consists of a list ofdirectory entries.To make access easier,a directory entry cannot cross blocks.In.I fs64there are 47 directory entries per block..PPThe device on which the blocks reside is implicitand ultimately comes from the 9P.CW attachmessage that specifies the name of thedevice containing the root.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t