Title: Class 16: Storage
Date: 2014-03-27
Category: Classes
Tags: operating systems, kernel, kernel programming, storage, delay lines
Author: David Evans

   <div class="todo">
<center>
[Exam 2](http://goo.gl/41PmXp) is due at **11:59pm tonight**.  
[PS4](|filename|../../pages/ps/ps4/ps4.md) is due **Sunday, 6 April**.</b> 
</center>
   </div>

<center>
<iframe src="http://www.slideshare.net/slideshow/embed_code/32949359" width="476" height="400" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</center>

# Storage Systems

<center>
<iframe width="640" height="360" src="//www.youtube-nocookie.com/embed/_I6Kmw3KpUY?list=PLvpsxlEF9cP3sM_Zz1jiQVE64ekJzycjX" frameborder="0" allowfullscreen></iframe>
</center>

## Delay Lines

> _I do not imagine that many of the Turing lecturers who will follow me
will be people who were acquainted with Alan Turing... Although a
mathematician, Turing took quite an interest in the engineering side of
computer design… Turing’s contribution to this discussion was to
advocate the use of gin, which he said contained alcohol and water in
just the right proportions..._ 
> Sir Maurice Wilkes (1913-2010), [_Computers Then and Now_](|filename|./a1967-wilkes.pdf) (1967 Turing
Award Lecture)

Why does it matter what you put in the delay line?
<div class="gap">

</div>

<center>
<iframe width="640" height="360" src="//www.youtube-nocookie.com/embed/SO4i3rKkLIE?list=PLvpsxlEF9cP3sM_Zz1jiQVE64ekJzycjX" frameborder="0" allowfullscreen></iframe>
</center>

Kingston KVR16N11/4 4GB 2Rx8 512M x 64-Bit PC3-12800 [newegg](http://www.newegg.com/Product/Product.aspx?Item=N82E16820239263)
[Datasheet](http://www.kingston.com/datasheets/KVR16N11_4.pdf)

J. Alex Halderman, Seth D. Schoen, Nadia Heninger, William Clarkson, William Paul, Joseph A. Calandrino (UVa BSCS 2004), Ariel J. Feldman, Jacob Appelbaum, and Edward W. Felten.  [_Lest We Remember: Cold Boot Attacks on Encryption Keys_](https://citp.princeton.edu/research/memory/).  USENIX Security 2008.

<center>
<iframe width="640" height="360" src="//www.youtube-nocookie.com/embed/C676kv-NMIc?list=PLvpsxlEF9cP3sM_Zz1jiQVE64ekJzycjX" frameborder="0" allowfullscreen></iframe>
</center>

# Storage Abstractions

<center>
<iframe width="640" height="360" src="//www.youtube-nocookie.com/embed/OFQxuZMZsJU?list=PLvpsxlEF9cP3sM_Zz1jiQVE64ekJzycjX" frameborder="0" allowfullscreen></iframe>
</center>

# Unix File System

An **inode** represents a file.  It includes:

- size (in bytes)
- user ID, group ID, permissions
- link count
- diskmap

and many other properties (see [fs.h](https://github.com/torvalds/linux/blob/master/include/linux/fs.h)).

`stat` (Unix command) provides information about an inode.  

```bash
> stat -x class16.pptx
```

Why doesn't the inode include the filename?
<div class="gap">
</div>

What commands would make the value of Links become 2?  Can it ever be 0?
<div class="gap">
</div>

### Unix System 5 File System

Diskmap is 13 entries: 0-9 are direct pointers to disk blocks (each disk
block is 1K bytes); 10 is a pointer to an indirect block (each entry
points to a block); 11 is a pointer to a double indirect block (each
entry points to an indirect block); 12 is a pointer to a triple indirect
block (each entry points to a double indirect block).

What is the largest file that can be store using this system?
<div class="gap">

</div>

How would you test if your file system uses a similar structure?
<div class="gap">

</div>


`df -i` gives information about the device inodes:
```bash
> df -i
Filesystem    512-blocks      Used Available Capacity  iused    ifree %iused  Mounted on
/dev/disk0s2   975425848 503107888 471805960    52% 62952484 58975745   52%   /
devfs                369       369         0   100%      641        0  100%   /dev
map -hosts             0         0         0   100%        0        0  100%   /net
map auto_home          0         0         0   100%        0        0  100%   /home
```

Could I run out of inodes before I run out of storage space?
<div class="gap">

</div>

To explore your drive's inodes: `tree --inodes`


<div id="disqus_thread"></div>

<script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'rust-class'; // required: replace example with your forum shortname
	var disqus_url = 'http://www.rust-class.org/class-16-storage.html';

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
