CS 134: Operating Systems File System Design Choices 1 / 23 - - PowerPoint PPT Presentation

cs 134 operating systems
SMART_READER_LITE
LIVE PREVIEW

CS 134: Operating Systems File System Design Choices 1 / 23 - - PowerPoint PPT Presentation

CS34 2012-12-06 CS 134: Operating Systems File System Design Choices CS 134: Operating Systems File System Design Choices 1 / 23 Overview CS34 Overview 2012-12-06 Allocation Overall Organization Overview What to Store Metadata


slide-1
SLIDE 1

CS 134: Operating Systems

File System Design Choices

1 / 23

CS 134: Operating Systems

File System Design Choices

2012-12-06

CS34

slide-2
SLIDE 2

Overview

Allocation Overall Organization What to Store Metadata Directories

2 / 23

Overview

Allocation Overall Organization What to Store Metadata Directories

2012-12-06

CS34 Overview

slide-3
SLIDE 3

Allocation

File Sizes

3 / 23

File Sizes

2012-12-06

CS34 Allocation File Sizes

These are file-size distributions on several machines. Note similarities and differences. Also note it’s a log-log plot!

slide-4
SLIDE 4

Allocation

Heuristics for Improving Contiguousness

Contiguous allocation is good:

◮ Dramatically improves sequential access ◮ Helps random access (why?)

What steps can we take to assist in allocating files contiguously?

4 / 23

Heuristics for Improving Contiguousness

Contiguous allocation is good:

◮ Dramatically improves sequential access ◮ Helps random access (why?)

What steps can we take to assist in allocating files contiguously?

2012-12-06

CS34 Allocation Heuristics for Improving Contiguousness

slide-5
SLIDE 5

Allocation

Region-Based Approaches

Divide disk into regions (sometimes called cylinder groups), each with own free list

◮ Unless a file is very large, try to keep all of it in same region ◮ Try to put all the files in a directory in same region ◮ Put different directories in different regions

Class Exercise

What assumptions are we making here? What kinds of locality are we expecting?

5 / 23

Region-Based Approaches

Divide disk into regions (sometimes called cylinder groups), each with own free list

◮ Unless a file is very large, try to keep all of it in same region ◮ Try to put all the files in a directory in same region ◮ Put different directories in different regions

Class Exercise

What assumptions are we making here? What kinds of locality are we expecting?

2012-12-06

CS34 Allocation Region-Based Approaches

slide-6
SLIDE 6

Overall Organization

Layers in Action—Low-Level Filesystem

At low level, files don’t have names/directories, just numbers (e.g., inode number) We need mapping from human-friendly names to these numbers

6 / 23

Layers in Action—Low-Level Filesystem

At low level, files don’t have names/directories, just numbers (e.g., inode number) We need mapping from human-friendly names to these numbers

2012-12-06

CS34 Overall Organization Layers in Action—Low-Level Filesystem

slide-7
SLIDE 7

Overall Organization

Layers in Action—High-level Filesystem

Build on lower-level layer

◮ Provide mapping from filenames/directories to inode numbers

In Unix,

◮ Directories are files ◮ Directories only map filename → inode number ◮ All other metadata is included in file’s inode

Class Exercise

If we store data (permissions, ownerships, etc.) in inode, doesn’t this violate the two-layer scheme?

7 / 23

Layers in Action—High-level Filesystem

Build on lower-level layer

◮ Provide mapping from filenames/directories to inode numbers

In Unix,

◮ Directories are files ◮ Directories only map filename → inode number ◮ All other metadata is included in file’s inode

Class Exercise

If we store data (permissions, ownerships, etc.) in inode, doesn’t this violate the two-layer scheme?

2012-12-06

CS34 Overall Organization Layers in Action—High-level Filesystem

slide-8
SLIDE 8

Overall Organization

Race Conditions—Class Exercises

Suppose we create a file, and write “Hello World” to it

◮ Which on-disk structures will be modified? ◮ In what order should we modify those structures—and why?

8 / 23

Race Conditions—Class Exercises

Suppose we create a file, and write “Hello World” to it

◮ Which on-disk structures will be modified? ◮ In what order should we modify those structures—and why?

2012-12-06

CS34 Overall Organization Race Conditions—Class Exercises

slide-9
SLIDE 9

What to Store Metadata

Metadata—What to Store About Files. . .

What information should operating system store about files?

9 / 23

Metadata—What to Store About Files. . .

What information should operating system store about files?

2012-12-06

CS34 What to Store Metadata Metadata—What to Store About Files. . .

slide-10
SLIDE 10

What to Store Metadata

Creator—Who Made the File?

We might want to store

◮ The user ◮ Their role ◮ The program

(Windows & MacOS 9 track creator; Unix conflates ownership with creator)

10 / 23

Creator—Who Made the File?

We might want to store

◮ The user ◮ Their role ◮ The program

(Windows & MacOS 9 track creator; Unix conflates ownership with creator)

2012-12-06

CS34 What to Store Metadata Creator—Who Made the File?

slide-11
SLIDE 11

What to Store Metadata

Ownership—Who the File Belongs To

Unix stores two ownership attributes:

◮ User ◮ Group

where groups are system-wide groups of users. A different operating system might do things differently. . .

11 / 23

Ownership—Who the File Belongs To

Unix stores two ownership attributes:

◮ User ◮ Group

where groups are system-wide groups of users. A different operating system might do things differently. . .

2012-12-06

CS34 What to Store Metadata Ownership—Who the File Belongs To

slide-12
SLIDE 12

What to Store Metadata

Access Rights

A user might be allowed one or more of the following access rights to a file:

◮ Existence check ◮ Execute ◮ Read ◮ Append ◮ General update (write) ◮ Change access rights ◮ Delete ◮ Change ownership ◮ Anything else?

12 / 23

Access Rights

A user might be allowed one or more of the following access rights to a file:

◮ Existence check ◮ Execute ◮ Read ◮ Append ◮ General update (write) ◮ Change access rights ◮ Delete ◮ Change ownership ◮ Anything else?

2012-12-06

CS34 What to Store Metadata Access Rights

Windows NT provides “Take ownership.” Why do they do that?

slide-13
SLIDE 13

What to Store Metadata

Access—Who Can Access the File

Vanilla Unix provides access based on

◮ User ◮ Group ◮ Other

where owner can set protection for each individually Other options include:

◮ List of users allowed (“Access Control List”—ACL) ◮ List of groups ◮ List of programs ◮ List of roles ◮ Sensitivity labels

13 / 23

Access—Who Can Access the File

Vanilla Unix provides access based on

◮ User ◮ Group ◮ Other

where owner can set protection for each individually Other options include:

◮ List of users allowed (“Access Control List”—ACL) ◮ List of groups ◮ List of programs ◮ List of roles ◮ Sensitivity labels

2012-12-06

CS34 What to Store Metadata Access—Who Can Access the File

slide-14
SLIDE 14

What to Store Metadata

Watchdogs

Let files/directories declare a program as their guardian

◮ Maximum flexibility ◮ Slower performance

14 / 23

Watchdogs

Let files/directories declare a program as their guardian

◮ Maximum flexibility ◮ Slower performance

2012-12-06

CS34 What to Store Metadata Watchdogs

slide-15
SLIDE 15

What to Store Metadata

Access Information

When the file was

◮ Created ◮ Data modified ◮ Metadata modified ◮ Data read ◮ Metadata read ◮ Anything else?

and by whom We might want to have just information for most recent access, or we might want to keep a log of all accesses, perhaps with rollback information

15 / 23

Access Information

When the file was

◮ Created ◮ Data modified ◮ Metadata modified ◮ Data read ◮ Metadata read ◮ Anything else?

and by whom We might want to have just information for most recent access, or we might want to keep a log of all accesses, perhaps with rollback information

2012-12-06

CS34 What to Store Metadata Access Information

slide-16
SLIDE 16

What to Store Metadata

File Types

What kind of file it is:

◮ Executable ◮ Internal format (object file, TIFF image, Rich Text, . . . ) ◮ Logical records (fixed or variable size) ◮ File type for OS

◮ Lockable ◮ Has ACL or watchdog

◮ File organization

◮ Sequential ◮ Indexed ◮ Random 16 / 23

File Types

What kind of file it is:

◮ Executable ◮ Internal format (object file, TIFF image, Rich Text, . . . ) ◮ Logical records (fixed or variable size) ◮ File type for OS ◮ Lockable ◮ Has ACL or watchdog ◮ File organization ◮ Sequential ◮ Indexed ◮ Random

2012-12-06

CS34 What to Store Metadata File Types

See next slide for discussion of the Unix philosophy.

slide-17
SLIDE 17

What to Store Metadata

File Types (cont.)

Often file name and contents can supplement file types provided by OS, but

◮ Not always elegant ◮ Not always efficient

Class Exercise

Unix only provides simple (byte stream + seek) file organizations. Why? Is this choice good or bad?

17 / 23

File Types (cont.)

Often file name and contents can supplement file types provided by OS, but

◮ Not always elegant ◮ Not always efficient

Class Exercise

Unix only provides simple (byte stream + seek) file organizations. Why? Is this choice good or bad?

2012-12-06

CS34 What to Store Metadata File Types (cont.)

In the past, operating systems provided many different file types, and many different file organizations. But,

  • Inflexible
  • Complicated the operating system

Unix stores minimal file-type information. This follows the “worse is better” philosophy. It also has the serendipitous effect of allowing unexpected usages (e.g., grep through binaries or even a raw disk,

  • r dd on a plain file).
slide-18
SLIDE 18

What to Store Metadata

  • Other. . .

Various other information

◮ Version ◮ Dependencies ◮ Expected size ◮ Number of links ◮ Provenance

  • Alternatively. . .

◮ cvs/svn/darcs/git (or similar) can provide version control ◮ make can manage dependencies ◮ . . . ?

18 / 23

  • Other. . .

Various other information

◮ Version ◮ Dependencies ◮ Expected size ◮ Number of links ◮ Provenance

  • Alternatively. . .

◮ cvs/svn/darcs/git (or similar) can provide version control ◮ make can manage dependencies ◮ . . . ?

2012-12-06

CS34 What to Store Metadata

  • Other. . .
slide-19
SLIDE 19

What to Store Directories

Directories

Why have ’em?

19 / 23

Directories

Why have ’em?

2012-12-06

CS34 What to Store Directories Directories

  • Convenience for users:

– Names allow user control, rather than machine control, of file identifiers – Logical grouping of files

  • More efficient
  • Many-to-one mapping (one file, many names)
slide-20
SLIDE 20

What to Store Directories

Directories—Single Level

20 / 23

Directories—Single Level

2012-12-06

CS34 What to Store Directories Directories—Single Level

  • Non-hierarchical
  • Simple
  • Inflexible:

– Naming problems – Grouping problems

  • Inefficient search
slide-21
SLIDE 21

What to Store Directories

Directories—Tree Structured

21 / 23

Directories—Tree Structured

2012-12-06

CS34 What to Store Directories Directories—Tree Structured

slide-22
SLIDE 22

What to Store Directories

Directories—DAG Structured Class Exercise

What are the advantages and disadvantages of this approach?

22 / 23

Directories—DAG Structured Class Exercise

What are the advantages and disadvantages of this approach?

2012-12-06

CS34 What to Store Directories Directories—DAG Structured

Advantages:

  • Lets user set up convenient paths to things
  • Eases sharing
  • Why not?

Disadvantages:

  • What does “..” mean?
  • Users can manage to confuse themselves

Does Unix allow this? Did original Unix?

slide-23
SLIDE 23

What to Store Directories

Directories—Graph Structured Class Exercise

What are the advantages and disadvantages here?

23 / 23

Directories—Graph Structured Class Exercise

What are the advantages and disadvantages here?

2012-12-06

CS34 What to Store Directories Directories—Graph Structured

Advantages:

  • Complete generality and flexibility

Disadvantages:

  • Users can confuse themselves
  • .. becomes almost meaningless
  • Possiblity of disconnected subgraphs (if reference counting is used)
  • r accidental wiping out of complete subtrees (if proper garbage

collection)