28.07.2013 Views

Performance Analysis and Optimization of the Hurricane File System ...

Performance Analysis and Optimization of the Hurricane File System ...

Performance Analysis and Optimization of the Hurricane File System ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

CHAPTER 3. HFS ARCHITECTURE 21<br />

global<br />

block cache<br />

lock<br />

0<br />

1<br />

2<br />

3<br />

4<br />

5<br />

6<br />

7<br />

free list<br />

dirty list<br />

¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦<br />

¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦<br />

¦¦¦<br />

¦¦¦ ¦¦¦<br />

¦¦¦ ¦¦¦<br />

¦¦¦ ¦¦¦<br />

waiting list<br />

free list<br />

¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦<br />

¦¦ ¦¦ ¦¦ ¦¦ ¦¦<br />

¦¦¦<br />

¦¦¦ ¦¦<br />

¦¦ ¦¦¦<br />

¦¦ ¦¦¦<br />

hash list<br />

0 1 2 3<br />

Waiting I/O<br />

Figure 3.5: Block cache.<br />

memory, similar to <strong>the</strong> memory layout <strong>of</strong> an array in <strong>the</strong> C language 1 , <strong>and</strong> point to <strong>the</strong> head <strong>of</strong> each list. All<br />

lists are doubly-linked <strong>and</strong> circular. Each cache entry in <strong>the</strong> hash list is protected with a simple reader-writer<br />

lock 2 implemented using three data structures.<br />

¦¦ ¦¦ ¦¦ ¦¦<br />

¦¦ ¦¦ ¦¦ ¦¦ ¦¦<br />

¦¦<br />

¦¦ ¦¦<br />

¦¦ ¦¦<br />

¦¦ ¦¦<br />

block<br />

cache<br />

entry<br />

¦¦ ¦¦ ¦¦ ¦¦<br />

¦¦ ¦¦ ¦¦ ¦¦ ¦¦<br />

¦¦<br />

1. A counter indicating <strong>the</strong> number <strong>of</strong> reads in progress. The counter is protected by ei<strong>the</strong>r <strong>the</strong> global<br />

lock (block cache) or <strong>the</strong> corresponding hash list lock (ORS cache).<br />

2. A busy bit flag indicating that an exclusive write is in progress.<br />

3. A global wait queue (one for <strong>the</strong> block cache, <strong>and</strong> one for <strong>the</strong> ORS cache) for waiting readers <strong>and</strong><br />

writers.<br />

The first cache is <strong>the</strong> ORS cache, which contains entries <strong>of</strong> 128 bytes in size. It is hashed by file token<br />

<strong>and</strong> is mainly used to hold file attributes such as <strong>the</strong> meta-data information that is obtained from a typical<br />

Unix stat() function call. For certain types <strong>of</strong> files such as extent-based files, it is used to hold <strong>the</strong> index <strong>of</strong><br />

extent blocks. It can also be used to hold a shortened version <strong>of</strong> <strong>the</strong> directory block index. The structure <strong>of</strong><br />

<strong>the</strong> ORS cache system implementation is shown in Figure 3.4.<br />

The second cache is <strong>the</strong> block cache, which contains larger cache entries <strong>of</strong> 4096 bytes in size 3 . It is used<br />

to hold <strong>the</strong> file index <strong>of</strong> each disk, block index <strong>of</strong> each file, directory contents, etc. It is hashed by three<br />

values: (1) file token, (2) block number, <strong>and</strong> (3) type <strong>of</strong> meta-data block, such as block index, file index,<br />

1 Due to <strong>the</strong> allocation algorithm <strong>of</strong> hash <strong>and</strong> dirty list headers, <strong>the</strong>se data structures are arranged in memory in a form that<br />

is equivalent to a contiguously allocated array.<br />

2 This reader-writer lock is by no means <strong>the</strong> most efficient.<br />

3 In reality, <strong>the</strong> block cache entry contains a pointer to a 4096 byte memory region to hold <strong>the</strong> cache contents ra<strong>the</strong>r than<br />

having it embedded within <strong>the</strong> cache entry itself.

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

Saved successfully!

Ooh no, something went wrong!