Goals for Today Learning Objective: Learn about directory - - PowerPoint PPT Presentation

▶
goals for today
SMART_READER_LITE
LIVE PREVIEW

Goals for Today Learning Objective: Learn about directory - - PowerPoint PPT Presentation

Goals for Today Learning Objective: Learn about directory structures Run through some disk performance exercises Announcements, etc: C4: I removed 2 papers from your reading list No longer need to read Multics Security Eval


slide-1
SLIDE 1

CS 423: Operating Systems Design 1

Goals for Today

Reminder: Please put away devices at the start of class

  • Learning Objective:
  • Learn about directory structures
  • Run through some disk performance exercises
  • Announcements, etc:
  • C4: I removed 2 papers from your reading list
  • No longer need to read Multics Security Eval or SELinux
  • MP3 is out! Due April 18th.
slide-2
SLIDE 2

CS 423: Operating Systems Design

Professor Adam Bates Spring 2018

CS 423
 Operating System Design: Directory Structures & Disk Performance

slide-3
SLIDE 3

CS 423: Operating Systems Design

NTFS

3

■ Master File Table ■ Flexible 1KB storage for metadata and data ■ Extents ■ Block pointers cover runs of blocks ■ Similar approach in linux (ext4) ■ File create can provide hint as to size of file ■ Journalling for reliability

slide-4
SLIDE 4

CS 423: Operating Systems Design 4

NTFS

  • Std. Info.

File Name Data (resident) (free)

MFT Record (small fjle) Master File Table

slide-5
SLIDE 5

CS 423: Operating Systems Design 5

NTFS

MFT MFT Record

Start Length Start Length

  • Std. Info.

File Name (free) Data (nonresident) Data Extent Data Extent

slide-6
SLIDE 6

CS 423: Operating Systems Design 6

NTFS Indirect Block

MFT MFT Record (part 2)

  • Std. Info.

(free) Data (nonresident) MFT Record (part 1)

  • Std. Info.

Attr.list Data (nonresident) File Name

Data Extent Data Extent Data Extent Data Extent Data Extent

slide-7
SLIDE 7

CS 423: Operating Systems Design 7

NTFS

MFT Record (normal file) MFT

  • Std. Info.

Data (nonresident)

MFT Record (small file)

  • Std. Info.

Data (resident)

MFT Record (big/fragmented file)

  • Std. Info.

Attr.list Data (nonresident) Data (nonresident) Data (nonresident) Data (nonresident)

MFT MFT Record (huge/badly-fragmented file)

  • Std. Info.

Attr.list (nonresident) Data (nonresident) Data (nonresident) Data (nonresident) Data (nonresident) Extent with part of attribute list Extent with part of attribute list Data (nonresident)

slide-8
SLIDE 8

CS 423: Operating Systems Design

Named Data

8

fjle name

  • fgset

directory fjle number

  • fgset

storage block index structure

slide-9
SLIDE 9

CS 423: Operating Systems Design

Directory Structures

9

■ maps symbolic names into logical file

names

■ search ■ create file ■ list directory ■ backup, archival, file migration

■ Directories are also files!

music 320 work 219 foo.txt 871

slide-10
SLIDE 10

CS 423: Operating Systems Design

Directory Internals

10

■ Directories are also files! Special files

■ Denoted by “File Type” in inode ■ Hold access paths to the files in the file system

■ They have data blocks (inodes) on disk ■ Enables support for very large directories ■ The partition superblock points to the

inode of the root directory.

slide-11
SLIDE 11

CS 423: Operating Systems Design

Single-level Directory

11

slide-12
SLIDE 12

CS 423: Operating Systems Design 12

Tree-Structured Directories

slide-13
SLIDE 13

CS 423: Operating Systems Design

Directory Layout

13

■ Represent directory as a list of files ■ Linear search to find filename ■ Suitable for small directories

File 830 /home/tom

End of File Name File Number Next

. 830 .. 158 music 320 work 219

Free Space

foo.txt 871

Free Space

slide-14
SLIDE 14

CS 423: Operating Systems Design 14

What can we do to improve efficient in large directories?

slide-15
SLIDE 15

CS 423: Operating Systems Design

B Trees

15

■ Logarithmic search to find filename ■ Suitable for large directories

Search for Hash (foo.txt) = 0x30

Before Child Pointer

240 510 730 980 Root

Hash Entry Pointer

15 30 44 58 Leaf . 830 .. 158 30 foo.txt 871 music 320 ... ... work 219 code 3 bin 014 ... ... test 324 Leaf

Hash Number Name File Number Before Child Pointer

58 121 180 240 Child 780 841 930 980 Child

slide-16
SLIDE 16

CS 423: Operating Systems Design

B Trees

16

■ Logarithmic search to find filename ■ Suitable for large directories

Directory Entries B+Tree Nodes

... work 219 ... music 320 ... Child Root Leaf Leaf ... Child

Name File Number

File Containing Directory

slide-17
SLIDE 17

CS 423: Operating Systems Design

Recursive Filename Lookup

17

music 320 work 219 foo.txt 871 File 830

  • /home/tom

mike 682 ada 818 tom 830 File 158

  • /home

File 871

  • /home/tom/foo.txt

bin 737 usr 924 home 158 File 2

  • /

The quick brown fox jumped

  • ver the

lazy dog.

slide-18
SLIDE 18

CS 423: Operating Systems Design

Tree-Structured Directories

18

■ arbitrary depth of directories ■ leaf nodes are files ■ interior nodes are directories ■ path name lists nodes to traverse to find

node

■ use absolute paths from root ■ use relative paths from current working

directory pointer

slide-19
SLIDE 19

CS 423: Operating Systems Design 19

Tree-Structured Directories

■ We usually think of directories as trees…

slide-20
SLIDE 20

CS 423: Operating Systems Design

Acyclic Graph Structured Dir.’s

20

■ But in practice they’re actually acyclic graphs!

slide-21
SLIDE 21

CS 423: Operating Systems Design

Symbolic Links

21

■ Symbolic links are different than regular links (often

called hard links). Created with ln -s

■ Can be thought of as a directory entry that points to

the name of another file.

■ Does not change link count for file

■

When original deleted, symbolic link remains

■ They exist because:

■

Hard links don’t work across file systems

■

Hard links only work for regular files, not directories

Hard link Symbolic Link Contents of file Contents of file direct direct direct symlink

slide-22
SLIDE 22

CS 423: Operating Systems Design

Changing Gears

22

Some notes on disk performance…

slide-23
SLIDE 23

CS 423: Operating Systems Design

Typical Modern Spec’s

23

■ Disk rotation speed: 5,000-15,000 RPM ■ Number of sectors per track: 500-2000 ■ Number of tracks: 100,000-200,000 ■ Average seek latency: 2ms ■ Block size: 0.5K-4K ■ Multiple zones (layout is different for inner and

  • uter tracks)

■ Multiple bays (stacked drives)

slide-24
SLIDE 24

CS 423: Operating Systems Design

Estimated Sustained Average Transfer Rate

24

■ Suppose that a disk drive spins at 7200 RPM

(revolutions per minute), has a sector size of 512 bytes, and holds 160 sectors per track.

■ What is sustained average transfer rate of this drive in

megabytes per second?

A: Track. B: Sector. C: Sector of Track. D: File

slide-25
SLIDE 25

CS 423: Operating Systems Design

Estimated Sustained Average Transfer Rate

25

■ Suppose that a disk drive spins at 7200 RPM

(revolutions per minute), has a sector size of 512 bytes, and holds 160 sectors per track.

■ What is sustained average transfer rate of this drive in

megabytes per second? Disk spins 120 times per second (7200 RPM/60) Each spin transfers a track of 80 KB (160 sectors x0.5K) Sustained average transfer rate is 120x80 = 9.6MB/s.

slide-26
SLIDE 26

CS 423: Operating Systems Design

Average Performance of Random Access

26

■ Suppose that a disk drive spins at 7200 RPM

(revolutions per minute), has a sector size of 512 bytes, and holds 160 sectors per track.

■ Average seek time for the drive is 8 milliseconds ■ Estimate # of random sector I/Os per second that can

be done and the effective average transfer rate for random-access of a sector?

Disk spins 120 times per second Average rotational cost is time to travel half track: 1/120 * 50%=4.167ms Transfer time is 8ms to seek + 4.167 ms rotational latency + 0.052 ms (reading one sector takes 0.0005MB/ 9.6MB). = 12.219 ms # of random sector access/second = 1/0.012219=81.8 Effective transferring rate: 0.5 KB * 81.8= 0.0409 MB/s.

slide-27
SLIDE 27

CS 423: Operating Systems Design

Flash Memory

27

■ Electronically Erasable Programmable Read Only Memory

(EEPROM)

■ Example specifications (NAND Flash):

■ Page size: 2KB (approx.) ■ Block size: 64 pages (128KB) ■ Device size: 16K blocks

■ Random READ: 25µs, Sequential READ: 25ns ■ WRITE performance

■ PROGRAM PAGE: 220µs, BLOCK ERASE: 1.5ms

■ Endurance: 100,000 PROGRAM/ERASE cycles