file systems (2). readings r silbershatz et al: 11.8

28
File Systems (2)

Upload: frederica-lang

Post on 23-Dec-2015

222 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: File Systems (2). Readings r Silbershatz et al: 11.8

File Systems (2)

Page 2: File Systems (2). Readings r Silbershatz et al: 11.8

Readings

Silbershatz et al: 11.8

Page 3: File Systems (2). Readings r Silbershatz et al: 11.8

Network-Attached Storage

Client machines may also have storage

Page 4: File Systems (2). Readings r Silbershatz et al: 11.8

Do this ….

Login into two different linux machines You should see your home directory Now go to /tmp on one of the machines Create a file with your last name and

put your full name in the file on that machine

Now go to the other machine

Page 5: File Systems (2). Readings r Silbershatz et al: 11.8

Virtual File System

How does an operating system allow multiple types of file systems to be integrated into a directory structure?

Data structures and procedures are used to isolate the basic system-call functionality from implementation

Page 6: File Systems (2). Readings r Silbershatz et al: 11.8

Virtual File System

Three layers File system interface: open(), read(), write() Virtual file system (VFS): Layer

• VFS allows the same system call interface (the API) to be used for different types of file systems.

• The API is to the VFS interface, rather than any specific type of file system

Page 7: File Systems (2). Readings r Silbershatz et al: 11.8

Schematic View of Virtual File System

Page 8: File Systems (2). Readings r Silbershatz et al: 11.8

Network File Systems

I’m on a Linux machine I go to another Linux machine

I see the same files in my home directory Why?

This is because you are using a networked file system (NFS)

NFS also provides the protocols needed for an integrated view of directories

Page 9: File Systems (2). Readings r Silbershatz et al: 11.8

The Sun Network File System (NFS)

An implementation and a specification of a software system for accessing remote files across Local area networks (LANs)

The implementation is part of the Solaris and SunOS operating systems running on Sun workstations using an unreliable datagram protocol (UDP/IP or TCP protocol) and Ethernet

Page 10: File Systems (2). Readings r Silbershatz et al: 11.8

NFS An NFS file server runs on a machine

(which may have large disks) that has a local file system.

An NFS client runs on an arbitrary machine and access the files on machines that run NFS servers.

Page 11: File Systems (2). Readings r Silbershatz et al: 11.8

NFS Directories can be mounted which

means that they can appear in the tree structure The directories can be on remote machines The remote machines may use a different

OS than the client machine

Page 12: File Systems (2). Readings r Silbershatz et al: 11.8

NFS Structures Export List

Maintained by server Information:

• List of local directories that server exports for mounting

• Names of machines that are permitted to mount them

File handle Refers to a set of information

• Identifier• An inode number to identify the mounted

directory

Page 13: File Systems (2). Readings r Silbershatz et al: 11.8

NFS Mount Protocol Establishes initial logical connection

between server and client Client sends a mount request message

to a server Request includes name of remote directory

to be mounted and name of server machine storing it

Page 14: File Systems (2). Readings r Silbershatz et al: 11.8

NFS Mount Protocol Following a mount request that

conforms to its export list, the server returns a file handle—a key for further accesses

The mount operation changes only the user’s view and does not affect the server side

Page 15: File Systems (2). Readings r Silbershatz et al: 11.8

NFSSupport access to files on remote serversMust support concurrency

Make varying guarantees about locking, who “wins” with concurrent writes, etc...

Must gracefully handle dropped connections

Page 16: File Systems (2). Readings r Silbershatz et al: 11.8

NFS When an application program calls

open() to obtain access to a file it is making a call to the NFS client

If the path refers to a local file, the system uses the computer’s standard file system software to access the file

If the path refers to a remote file, the system uses NFS client software to access the remote file through the NFS server

Page 17: File Systems (2). Readings r Silbershatz et al: 11.8

NFS

The NFS server handles incoming client requests

These requests are mapped to local file system operations

Page 18: File Systems (2). Readings r Silbershatz et al: 11.8

NFS Protocol All requests have a sequence number,

allowing the server to determine if a request is duplicated or if any are missing

Modern implementations use TCP/IP

What is UDP and TCP/IP? TCP provides reliable delivery of messages in

the network UDP does not

Page 19: File Systems (2). Readings r Silbershatz et al: 11.8

NFS Files are assumed to be shared by

multiple clients Synchronization is needed Problem

There is a performance problem if every time a client wants to access a file it has to go to the server

Thus clients are allowed to keep a local copy of the file while they are reading and writing its contents• This is referred to as caching

Page 20: File Systems (2). Readings r Silbershatz et al: 11.8

Now Try this

Go to /faculty/hanan Open the file helloThere Edit the file by adding your name and

then save and close.

Page 21: File Systems (2). Readings r Silbershatz et al: 11.8

NFS

UNIX Semantics When a read follows a write the read returns

the value just written When two writes happen in quick succession

followed by a read, the value read is the value stored by the last write

In a centralized systems this is easy to implement

If there is no caching in NFS then this is also easy to implement

Page 22: File Systems (2). Readings r Silbershatz et al: 11.8

NFS

NFS allows clients to cache for performance reasons

How then is UNIX semantics provided? Approach 1:

Propagate all changes to cached files back to the server as they happen

Not efficient• Lots of network traffic

Page 23: File Systems (2). Readings r Silbershatz et al: 11.8

NFS

Approach 2: Change the semantics NFS implements session semantics

• Changes to an open file are initially visible only to the process that modified the file

Implementation• When a process closes the file, it sends a copy to

the NFS server so that subsequent reads get the new value

What if two clients are caching and modifying the file at the same time?

Page 24: File Systems (2). Readings r Silbershatz et al: 11.8

NFS Client CachingNFS Clients are allowed to cache copies of

remote files for subsequent accessesSupports close-to-open cache consistency

When client A closes a file, its contents are synchronized with the server (which has the master copy), and timestamp is changed

When client B opens the file, it checks that local timestamp agrees with server timestamp. If not, it discards local copy

Page 25: File Systems (2). Readings r Silbershatz et al: 11.8

Other

SUN ZFS

Linux Btrfs

• ZFS for Linux• Still in prototype stage

Page 26: File Systems (2). Readings r Silbershatz et al: 11.8

ZFS

Integrated into Solaris 10 (2006)

The major feature that distinguishes ZFS from other file systems is ZFS’s focus on data integrity

Page 27: File Systems (2). Readings r Silbershatz et al: 11.8

ZFS

Data integrity Assume mirrored disk Application tries the first disk Checksum reveals the block is corrupt on

the disk ZFS tries the second disk Checksum indicates that the block is good ZFS delivers the data to the application and

repairs the first disk Before ZFS the file system didn’t use

checksum

Page 28: File Systems (2). Readings r Silbershatz et al: 11.8

Summary

Studied NFS