1 overview assignment 12: hints distributed file systems assignment 11: solution file systems

16
1 Overview Assignment 12: hints Distributed file systems Assignment 11: solution File systems

Upload: amice-chase

Post on 24-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

1

Overview Assignment 12: hints

Distributed file systems Assignment 11: solution

File systems

Page 2: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

2

A12 – Network File System (Sun)

Virtual file system layer

System call layer

Local operatingsystem

NFS client

Messageto server

Virtual file system layer

Local operatingsystem

NFS server

Messagefrom client

Page 3: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

3

A12 – NFS Mounting protocol:

The server exports certain directories to certain machines (IP authentication)

The clients mounts a given directory from a specified server.

Directory and file access: System calls are performed as remote procedure

calls. No open and close: stateless.

Security: IP based (export lists) UNIX permissions based on UID/GID

Page 4: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

4

A12 – Andrew File System (CMU)

Virtual file system layer

System call layer

Local operatingsystem

AFS client

Messageto server

Virtual file system layer

Local operatingsystem

AFS server

Messagefrom clientAFS

cache

Page 5: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

5

A12 – AFS Mounting

The server has no information about the clients. Cell list maintained. The client mounts the whole AFS tree (the whole AFS

world).

Directory and file access The file is cached locally and committed on close.

Security: Kerberos server Access list for files access

Page 6: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

6

Server B

A12 Ex1 – Moving a shared volume

Client

Server A

Page 7: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

7

A12 Ex2 – Simultaneous accesses

Client

• open• modify• close

Server

Client

• open• modify• close

Page 8: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

8

A12 Ex3 – Immutable Files Files can only be created and read.

What is simplified?What can be avoided?

Page 9: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

9

Overview Assignment 12: hints

Distributed file systems Assignment 11: solution

File systems

Page 10: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

10

A11 Ex1 – Max File Length datablocks

inode

direct 0

direct 1

direct 2

direct 3

direct 4

direct 5

direct 6

direct 7

direct …

direct 11single indirect

double indirect

triple indirect

Page 11: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

11

A11 Ex1 – Maximal File LengthGiven: block size = 2KB address = 4 bytes (assumption) table of contents = 15 entries (12 / 1 / 1 / 1)

number of entries in index table = 2048 / 4 = 512

GB256B382

)3512125121512112(KB2

Length

Length

Page 12: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

12

A11 Ex2 – File Access./a/b/c/f, File length is 1GB

Directory access 2 disk acc. (1 for the inode, 1 for table) 7 accesses until the file inode is knownPositioning at the end of the file (2K blocks): direct access: 24 KB single indirect access: 1 MB double indirect access: 512 MB must use triple indirect access 4 accesses (1i+3t)Read the block and rewrite it with the additional byte

2 accesses

Total: 13 disk accesses

Page 13: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

13

A11 Ex3 – I/O redirection / Pipes

$ command < file

After shell fork() in the child process: fd = open(file) close(stdin) dup2(stdin,fd) close(fd) exec(command)

Page 14: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

14

A11 Ex3 – I/O redirection / Pipes

0 stdin

1 stdout

2 stderr

3

4

… …

count 2, wr

user file descriptor file table

cnt 2 (/dev/tty1)

inode table

count 1 rd cnt 1 (file)

$ command < file

fd = open(file) close(stdin)dup2(stdin,fd)close(fd)exec(command)

count 1, rd

count 2, rd

cnt 1 (/dev/tty1)

Page 15: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

15

A11 Ex3 – I/O redirection / Pipes

$ command1 | command2

Shell

fork()pipe(fd[])fork()

close(stdout)dup2(stdout,fd[1])close(fd[1])exec(command1)

close(stdin)dup2(stdin,fd[0])close(fd[0])exec(command2)

Page 16: 1 Overview Assignment 12: hints  Distributed file systems Assignment 11: solution  File systems

16

A11 Ex4 – MountingBach Book:

Each file system type has a method tableTo access a file, indirect function call through

the table

need FS abstraction, common to all FS struct file_operation read, write, readdir, ioctl, open, flush, release, fsync,

lock associate every file with its FS (method table)

inode has a pointer to file_operation