21. Intro to File Systems Flashcards

1
Q

What are the 5 components of the UNIX file interface?

A
  1. open(“foo”): “I’d like to use the file named foo”
  2. close(“foo”): “I’m finished with foo”
  3. read(2): “I’d like to perform a read from file handle 2 at the current position”
  4. write(2): “I’d like to perform a write from file handle 2 at the current position”
  5. lseek(2, 100): “Please move my saved position for file handle 2 to position 100”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a hierarchical file system allow users to do (or not do)?

A

Users don’t have to look at everything all at once. Hierarchical file systems allow users to store and examine related files together.

Ex:
letters/Mom/letter.txt
letters/Chuchu/woof.txt
letters/Suzanna/letter1.txt
letters/Suzanna/letter2.txt
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe how location plays a role in hierarchical file systems.

A

Locations for files require the ability to navigate up and down directories, so directories need to include pointers to other (deeper or higher) directories.

Location is also only meaningful if it is tied to the name of the file, so hierarchical file systems implement name spaces, whcih require that a file’s name map to a single unique location within the file system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why do file systems usually require that files be organized into an acyclic graph with a single root (aka tree)?

A

An acyclic graph means there is only one possible path from the root of the tree (top-level directory) to the file you’re looking for.

If there is a cycle in your graph, it is possible that you could have multiple (infinite) possible canonical names for your file, which violates the one-name-one-location rule of hierarchical file systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How many relative and canonical names exist for a given file in a tree-implemented hierarchical file system?

A

One canonical name (/you/used/to/love/well) and an infinite number of relative names (you/used/to/love/me/../well)
(love/me/../../love/me/../well)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the 5 file system design goals?

A
  1. Efficiently translate file names to file contents
  2. Allow files to move, grow, shrink, and otherwise change
  3. Optimize access to single files
  4. Optimize access to multiple files, particularly related files
  5. Survive failures and maintain a consistent view of file names and contents
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the two types of disk blocks?

A

Data blocks (contain file data)

Index nodes (aka inodes, contain non-file data)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What three decisions distinguish one file system from another?

A
  1. On-disk layout. (How does each file system decide where to put data and metadata blocks in order to optimize file access?)
  2. Data structures. (What data structures does each file system use to translate names and locate file data?)
  3. Crash recovery. (How does each file system prepare for and recover from crashes?)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the primary challenge of file systems? Why is it hard?

A

To maintain a large and complex data structure using disk blocks as storage

This is hard because making changes potentially requires updating many different structures

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Say a process wants to write data to the end of a file. What does the file system have to do?

A
  1. Find empty disk blocks to use and mark them as in use.
  2. Associate those blocks with the file that is being written to.
  3. Adjust the size of the file that is being written to
  4. Actually copy the data to the disk blocks being used
    * From the perspective of a process, all of these things need to happen synchronously
    * This creates a consistency and a performance problem
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a sector?

A

The smallest unit that the disk allows to be written, usually 256 bytes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a block?

A

The smallest unit that the file system actually writes, usually 4K bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an extent?

A

A set of contiguous blocks used to hold part of a file. Described by a start and end block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why would file systems not write chunks smaller than 4K?

A

Because contiguous writes are good for disk head scheduling and 4K is the page size which affects in-memory file caching

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why would file systems want to write file data in even larger chunks?

A

Because contiguous writes are good for disk head scheduling and many files are larger than 4K!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What happens on disk during file-system use?

A

File systems translate paths to file index nodes (or inodes).

They find data blocks associated with a given inode (file).

They allocate and free inodes and data blocks.