25.03.2015 Views

Implementation of the file system layer in HelenOS

Implementation of the file system layer in HelenOS

Implementation of the file system layer in HelenOS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Implementation</strong><br />

<strong>of</strong> <strong>the</strong> <strong>file</strong> <strong>system</strong> <strong>layer</strong> <strong>in</strong><br />

<strong>HelenOS</strong><br />

XXXII. Conference EurOpen.CZ<br />

Jakub Jermar<br />

May 21, 2008


<strong>HelenOS</strong> basic facts<br />

<br />

<br />

<br />

<br />

http://www.helenos.eu<br />

Experimental general purpose operat<strong>in</strong>g <strong>system</strong><br />

Microkernel and userspace libraries and services<br />

Incomplete, under development<br />

<br />

Lack <strong>of</strong> <strong>file</strong> <strong>system</strong> support<br />

<br />

Major barrier prevent<strong>in</strong>g adoption


Project history<br />

9<br />

8<br />

7<br />

6<br />

5<br />

4<br />

Developers<br />

Architectures<br />

Theses <strong>in</strong> Progress<br />

F<strong>in</strong>ished Theses<br />

3<br />

2<br />

1<br />

0<br />

2001 2002 2003 2004 2005 2006 2007 2008


File <strong>system</strong>s vs. Monolithic kernels<br />

<br />

<br />

Well understood topic<br />

<br />

Several well­known implementations<br />

Everyth<strong>in</strong>g runs <strong>in</strong> one address space<br />

<br />

<br />

<br />

VFS polymorphism via structures with function po<strong>in</strong>ters<br />

Function calls<br />

Execution <strong>in</strong> kernel


Big picture: monolithic kernels<br />

Standard<br />

library<br />

Kernel<br />

Client application<br />

VFS<br />

TMPFS<br />

FAT<br />

DRIVERS<br />

RAMDISK<br />

IDE<br />

Client application<br />

Client application


File <strong>system</strong>s vs. Microkernels<br />

<br />

<br />

Well understood topic?<br />

Problems:<br />

<br />

<br />

What does <strong>the</strong> big picture (should) look like<br />

<br />

<br />

<br />

No common address space<br />

Break<strong>in</strong>g functionality <strong>in</strong>to separate entities<br />

Execution <strong>in</strong> userspace<br />

How do <strong>the</strong> separate entities communicate?<br />

<br />

<br />

<br />

IPC messages<br />

Memory shar<strong>in</strong>g<br />

Data copy<strong>in</strong>g


Big picture: <strong>HelenOS</strong><br />

Standard<br />

library<br />

VFS<br />

TMPFS<br />

FAT<br />

libfs<br />

library<br />

Client application<br />

RAMDISK<br />

Client application<br />

Client application<br />

DEVMAP<br />

IDE


Standard library<br />

Client application<br />

Standard<br />

library<br />

Client application<br />

Client application<br />

<br />

<br />

<br />

Applications use a ”subset”<br />

<strong>of</strong> POSIX calls<br />

The library translates some<br />

<strong>of</strong> <strong>the</strong>se calls to VFS calls<br />

<br />

<br />

Directly<br />

Wraps around o<strong>the</strong>rs<br />

Relative to absolute paths


VFS frontend<br />

Standard<br />

library<br />

VFS<br />

<br />

<br />

<br />

<br />

<br />

<br />

VFS nodes<br />

Open <strong>file</strong>s per client<br />

Path canonization<br />

Reference count<strong>in</strong>g<br />

Synchronization<br />

Multiplexes requests


VFS backend<br />

<br />

Registry <strong>of</strong> <strong>in</strong>dividual FS<br />

<br />

Pathname Lookup Buffer<br />

<br />

VFS shares PLB read­write<br />

VFS<br />

TMPFS<br />

FAT<br />

<br />

<br />

FS share PLB read­only<br />

VFS output protocol<br />

<br />

All output VFS methods<br />

<br />

All FS must understand it<br />

<br />

VFS polymorphism


Individual FS servers<br />

<br />

Implement <strong>the</strong> output VFS<br />

protocol<br />

<br />

File <strong>system</strong>'s logic<br />

VFS<br />

TMPFS<br />

<br />

Cache some data/metadata<br />

<strong>in</strong> memory<br />

FAT<br />

<br />

Understand VFS triplets<br />

<br />

(fs_handle, dev_handle,<br />

<strong>in</strong>dex)


libfs library<br />

<br />

FS registration code<br />

<br />

libfs_lookup<br />

TMPFS<br />

FAT<br />

libfs<br />

library<br />

<br />

<br />

Template for<br />

VFS_LOOKUP<br />

libfs_ops_t<br />

<br />

Virtual methods needed by<br />

libfs_lookup


Block device drivers<br />

FAT<br />

RAMDISK<br />

<br />

<br />

<br />

All block devices required<br />

to implement <strong>the</strong> same<br />

protocol<br />

FS doesn't care what block<br />

device it is mounted on<br />

FS learns about <strong>the</strong> device<br />

and its driver via DEVMAP


DEVMAP<br />

FAT<br />

RAMDISK<br />

<br />

<br />

Registry <strong>of</strong> block device<br />

drivers and block device<br />

<strong>in</strong>stances<br />

Maps device handles to<br />

connections<br />

DEVMAP<br />

IDE


File <strong>system</strong> synchronization<br />

<br />

Mostly <strong>in</strong> VFS<br />

<br />

<br />

<br />

VFS nodes have contents RW lock<br />

Namespace RW lock<br />

No lock<strong>in</strong>g for table <strong>of</strong> open <strong>file</strong>s<br />

<br />

<br />

Per­fibril data a.k.a. TLS<br />

Less synchronization <strong>in</strong> <strong>in</strong>dividual FS servers


Means <strong>of</strong> communication<br />

<br />

<br />

<br />

Short IPC messages (method + up to 5 arguments)<br />

<br />

Both requests and answers<br />

Memory shar<strong>in</strong>g and data copy<strong>in</strong>g <strong>in</strong>tegrated <strong>in</strong> IPC<br />

<br />

<br />

Parties negotiate over IPC; kernel carries out <strong>the</strong> action<br />

Combo messages<br />

Short and combo messages can be forwarded<br />

<br />

<br />

Memory shared/data copied only between <strong>the</strong> endpo<strong>in</strong>ts<br />

Sender masquerad<strong>in</strong>g


Communication example: open()<br />

Standard<br />

library<br />

2. VFS_OPEN 4. VFS_LOOKUP<br />

VFS<br />

TMPFS<br />

libfs<br />

library<br />

PLB<br />

Client application<br />

3. IPC_M_DATA_WRITE<br />

1. open(”/my<strong>file</strong>”, ...)<br />

5. libfs_lookup()<br />

...<br />

/my<strong>file</strong><br />

...


VFS + Standard library<br />

<br />

<br />

Fairly complete, but still evolv<strong>in</strong>g<br />

<br />

<br />

<br />

mount(), open(), read(), write(), lseek(), close(), mkdir(),<br />

unl<strong>in</strong>k(), rename()<br />

opendir(), readdir(), rew<strong>in</strong>ddir(), closedir()<br />

getcwd(), chdir()<br />

Miss<strong>in</strong>g<br />

<br />

stat(), unmount(), ...<br />

<br />

mmap()


TMPFS<br />

<br />

<br />

<br />

<br />

<br />

<br />

Both metadata and data live <strong>in</strong> virtual memory<br />

No on­disk format<br />

No block­device needed<br />

Contents lost on reset<br />

<strong>Implementation</strong> complete<br />

Test<strong>in</strong>g purposes


FAT<br />

<br />

<br />

<br />

<br />

FAT16<br />

Work <strong>in</strong> progress<br />

Not that easy as it might seem<br />

<br />

<br />

Simple on­disk layout<br />

Non­existence <strong>of</strong> stable and unique node <strong>in</strong>dices<br />

Evolution <strong>of</strong> translation <strong>layer</strong> that provides stable<br />

unique <strong>in</strong>dices


Perspective<br />

<br />

<br />

<br />

<br />

<br />

<br />

F<strong>in</strong>ish<strong>in</strong>g FAT<br />

<br />

<br />

Needed for load<strong>in</strong>g programs from disk<br />

Needed for non­root mounts<br />

Evolv<strong>in</strong>g block device drivers<br />

Block cache<br />

More FS implementations<br />

Improv<strong>in</strong>g IPC mechanism for copy<strong>in</strong>g data<br />

Swapp<strong>in</strong>g to/from <strong>file</strong> <strong>system</strong>


http://www.helenos.eu<br />

Jakub Jermar

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!