Understanding File Systems: Locality, Access Methods, and Protection, Slides of Computer Science

An overview of file systems, focusing on locality, access methods, and protection. Topics include estimating disk latencies, file organization, types, and basic operations. Access methods discussed include sequential, direct, record, and indexed access. Protection systems ensure file security by controlling access for users and programs.

Typology: Slides

2012/2013

Uploaded on 03/27/2013

agarkar
agarkar 🇮🇳

4.3

(26)

372 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE 410
Computer Systems
Lt
22
Di k & Fil S t
L
ec
t
ure
22
Di
s
k
s
&
Fil
e
S
ys
t
ems
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Understanding File Systems: Locality, Access Methods, and Protection and more Slides Computer Science in PDF only on Docsity!

CSE 410Computer Systems

L^

t^

Di k

& Fil

S^

t

Lecture 22 – Disks & File Systems

Hard drivesHard

drives

-^

The ugly guts of a hard disk.–^

Data is stored on double-sided magnetic disks called platters.

-^

Each platter is arranged like a record, with many concentric tracks.

-^

Tracks are further divided into individual sectors, which are the basic unit ofdata transferdata transfer.

-^

Each surface has a read/write head like the arm on a record player, but allthe heads are connected and move together.

-^

A 1TB Hitachi Deskstar has:–^

2 platters (4 surfaces)

-^

4 heads

-^

512 bytes/sectorL^

i^

l l^

t (^

d^

t^

ti^

ll )

Platters Tracks

-^

Logical layout (mapped automatically):•^

16 heads

-^

63 sectors/track

-^

16 383 cylinders (tracks)

Platter

Sectors

16,383 cylinders (tracks)

Track

3

Estimating disk latencies (seek time)Estimating

disk latencies (seek time)

-^

Manufacturers often report

average

seek times of 8-

p^

g

10 ms.– These times average the time to seek from any track to any

other trackother track.

-^

In practice, seek times are often much better.– For example, if the head is already on or near the desired

track, then seek time is much smaller. In other words, localityis important!

  • Actual average seek times are often just 2-3 ms.

5

Estimating Disk Latencies (rotational latency)Estimating

Disk Latencies (rotational latency)

-^

Once the head is in place, we need to wait until the right sectoris underneath the head.–

This may require as little as no time (reading consecutive sectors)or as much as a full rotation (just missed it).– On average, for random reads/writes, we can assume that the diskspins halfway.

-^

Rotational delay depends partly on how fast the disk plattersspin.Average rotational delay = 0 5 x rotations x rotational speedAverage rotational delay = 0.5 x rotations x rotational speed–

For example, a 5400 RPM disk has an average rotational delay of:

0 5

t ti

/ (

t ti

/^

i^

t )

5 55

0.5 rotations / (5400 rotations/minute) = 5.55 ms

6

Storage Latency:How Far Away is the Data?How Far Away is the Data?

Andromeda

Tape /OpticalRobot

10

9

2,000 Years

Disk

10

6

2 Years

Pluto

Memory

100

Olympia

1.5 hr

MemoryOn Board Cache^ On Chip Cache 102 100

This BuildingThis Room

10 min

2

Registers 1

My Head

1 min

© 2004 Jim Gray, Microsoft Corporation

8

File systemsFile

systems

-^

The concept of a file system is simple

p^

y^

p

  • the implementation of the abstraction for

secondary storage• abstraction = files

  • logical organization of files into directories

the directory hierarchy

  • the directory hierarchy
    • sharing of data between processes, people and

machines• access control, consistency, …

9

Basic operationsBasic

operations

NT

Unix

  • CreateFile(name, CREATE)• CreateFile(name, OPEN)
  • create(name)• open(name, mode)
  • ReadFile(handle, …)• WriteFile(handle, …)Fl

hFil B ff

(h^

dl^

)

  • read(fd, buf, len)• write(fd, buf, len)• sync(fd)
    • FlushFileBuffers(handle, …)• SetFilePointer(handle, …)• CloseHandle(handle

)

  • sync(fd)• seek(fd, pos)• close(fd)
    • CloseHandle(handle, …)• DeleteFile(name)• CopyFile(name)

close(fd)• unlink(name)• rename(old, new)

py

(^

)

  • MoveFile(name)

(^

,^

)

11

File access methodsFile

access methods

•^

Some file systems provide different access methods thatspecify ways the application will access dataspecify ways the application will access data– sequential access

  • read bytes one at a time, in order
    • direct access

direct access• random access given a block/byte #

  • record access
    • file is array of fixed- or variable-sized records

y

  • indexed access
    • FS contains an index to a particular field of each record in a file - apps can find a file based on value in that record• apps can find a file based on value in that record (similar to DB)

•^

Why do we care about distinguishing sequential fromdirect access?– what might the FS do differently in these cases?

12

Directory internalsDirectory

internals

•^

A directory is typically just a file that happens to containspecial metadata– directory = list of (name of file, file attributes)– attributes include such things as:

g

  • size, protection, location on disk, creation time, access time, … - the directory list is usually unordered (effectively

the directory list is usually unordered (effectivelyrandom)• when you type “ls”, the “ls” command sorts the

results for youresults for you

  • Key difference from ordinary files: system will not allow

user process to write a directory with ordinary I/O calls,even if the user created/owns it

Why?

even if the user created/owns it. Why?

14

Path name translationPath

name translation

-^

Let’s say you want to open “/one/two/three”^ fd =

open(“/one/two/three”, O_RDWR);

-^

What goes on inside the file system?– open directory “/” (well known, can always find)

h th

di

t^

f^

“^

”^

t l^

ti^

f “^

  • search the directory for “one”, get location of “one”– open directory “one”, search for “two”, get location of “two”– open directory “two”, search for “three”, get loc. of “three”– open file “three”– (of course, permissions are checked at each step) -^

FS spends lots of time walking down directory paths– this is why open is separate from read/write (session state)– OS will cache prefix lookups to enhance performance

  • /a/b, /a/bb, /a/bbb all share the “/a” prefix

15

The original Unix file systemThe

original Unix file system

-^

Dennis Ritchie and Ken Thompson, Bell Labs, 1969

p^

,^

-^

“UNIX rose from the ashes of a multi-organizationaleffort in the early 1960s to develop a dependableti^

h^

i^

ti^

t^

”^

M lti

timesharing operating system” -- Multics

-^

Designed for a “workgroup” sharing a single system

-^

Did its job exceedingly well

-^

Did its job exceedingly well– Although it has been stretched in many directions and made

ugly in the process

A^

d^

f l

t d

i^

i^

i^

t^

d^

ff

-^

A wonderful study in engineering tradeoffs

17

All Unix disks are divided into five partsAll

Unix disks are divided into five parts

-^

Boot block– can boot the system by loading from this block

-^

Superblock– specifies boundaries of next 3 areas, and contains

h^

d^

f f

li t

f i^

d^

d fil

bl^

k

head of freelists of inodes and file blocks

-^

i-node area– contains descriptors (i-nodes) for each file on the disk;

all i nodes are the same si e head of freelist is in theall i-nodes are the same size; head of freelist is in thesuperblock

-^

File contents area

fixed size blocks; head of freelist is in the superblock

  • fixed-size blocks; head of freelist is in the superblock -^

Swap area– holds processes that have been swapped out of

memorymemory

18

i-node formati node format•^

User number

-^

Group number

-^

Protection bitsTi

(fil

l^

t^

d fil

l^

t^

itt

i^

d^

l^

t^

itt^

•^

Times (file last read, file last written, inode last written)

-^

File code: specifies if the i-node represents a directory, anordinary user file, or a “special file” (typically an I/O device)

y^

p^

( yp

y^

•^

Size: length of file in bytes

-^

Block list: locates contents of file (in the file contents area)

thi

  • more on this soon! -^

Link count: number of directories referencing this i-node

20

The flat (i

-node) file system

The flat (i node) file system•^

Each file is known by a number, which is the number

y^

of the i-node– seriously – 1, 2, 3, etc.!– why is it called “flat”?

-^

Files are created empty, and grow when extendedthrough writesthrough writes

21