File Systems, Pt. 2 Flashcards

1
Q

Steps to Opening a File

A
  • Search the directory to find the FCB
  • May need to bring multiple directory blocks from disk if they’re not already cached
  • Create an entry in the per-process open-file table (PFT)
  • Check whether the system-wide open-file table has an entry for this file
  • If it does, increment its reference count and make the entry in the PFT point to this entry
  • If it doesn’t, create a new entry, set reference count to 1, make entry in PFT point to this entry
  • Return a pointer (file descriptor) to the entry in the PFT
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Steps to Creating a File

A
  • Allocate a new FCB
  • For faster file creation, FCBs are usually preallocated and a free one is found
  • Read relevant directory blocks in memory
  • Update blocks to reflect the new file and write back to disk
  • Allocate free blocks for the data of the file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Common Allocation Methods

A
  • Contiguous
  • Linked
  • Indexed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Contiguous Allocation

A
  • Each file occupies a set of contiguous blocks
  • Needs only start address and length
  • Compaction is possible, but expensive
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Pros and Cons of Contiguous Allocation

A
Pros:
-Simple
-Efficient sequential and random access (minimal disk head seeks)
Cons:
-External fragmentation
-Files may not be able to grow
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Linked Allocation

A
  • A file is a linked list of blocks
  • Blocks could be anywhere
  • Each block has a pointer to the next block
  • Need start block and end block to append file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Pros and Cons of Linked Allocation

A

Pros:
-Simple: Need only start and end addresses
-Doesn’t waste space except for pointers
-Supports dynamically growing files
Cons:
-Expensive random access (need to follow pointers from the start)
-Reliability: if one block is corrupted, the entire chain is broken

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

Indexed Allocation

A

Bring all pointers together in an index block

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

Pros and Cons of Indexed Allocation

A
Pros:
-Supports random access
-Supports dynamic growing of files
-No external fragmentation
Cons:
-Overhead of index blocks
-File of one or a few data blocks still needs an index block
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Choosing Size of Index Blocks

A
  • Small size may not fit some files
  • Large size may waste space
  • Use linked index blocks or multilevel indices
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Linked Index Blocks

A
  • Last word in index block points to another index block

- May need to traverse the index linked list (long access time)

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

Multilevel Index

A
  • First-level index block points to a set of second-level index blocks which refer to data blocks
  • Shorter access time but more space overhead
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Combined Index Blocks

A
  • Used by Unix
  • Each file has an index block (inode) which contains:
  • Pointers that point to data blocks directly for small files
  • Pointers to index blocks that may point to another level of index blocks or to data blocks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do we know where free blocks are?

A
  • Bit Map (one bit for each block, 0 = occupied, 1 = free)
  • Linked List
  • Grouping (addresses of n free blocks are stored in the first block, the last block of that group contains the next n free blocks, etc)
  • Counting (keep address of first free block and count the contiguous free blocks)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Crashes can leave file system in…

A

…an inconsistent state

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

File systems should have ____ mechanisms

A

Recovery

17
Q

Simple Consistency Checking

A
  • Set a bit on the disk before metadata is updated
  • Reset it after the update is complete
  • Upon reboot: if the bit is set, invoke consistency checking
18
Q

Log Structured File Systems

A
  • Log structured (journaling) file systems
  • Each metadata update to FS is a “transaction” which is sequentially written to the log
  • Transactions in the log are asynchronously written to the file system structures
  • When the structures are modified on the disk, the transaction is removed from the log
  • If file system crashes, transactions in log are redone
19
Q

Network File System (NFS)

A
  • Enables accessing files on remote machines
  • Supports different machines, OS, and networks
  • Mounts remote directory over local FS directory (subject to access rights)
  • Once mounted, remote directory is accessed transparently (looks like local directory, but all operations are sent over the network)