Network File System (NFS)

Similar documents
Network File System (NFS)

Remote Procedure Call (RPC) and Transparency

NFS: Naming indirection, abstraction. Abstraction, abstraction, abstraction! Network File Systems: Naming, cache control, consistency

Distributed File Systems

Network File Systems

416 Distributed Systems. Distributed File Systems 1: NFS Sep 18, 2018

416 Distributed Systems. Distributed File Systems 2 Jan 20, 2016

GFS: The Google File System

Network File System (NFS)

DISTRIBUTED FILE SYSTEMS & NFS

Distributed File Systems I

Dr. Robert N. M. Watson

Distributed File Systems. CS 537 Lecture 15. Distributed File Systems. Transfer Model. Naming transparency 3/27/09

COS 318: Operating Systems. NSF, Snapshot, Dedup and Review

Background: Operating Systems

Background: I/O Concurrency

Filesystems Lecture 11

Filesystems Lecture 13

What is a file system

Operating Systems CMPSC 473. File System Implementation April 1, Lecture 19 Instructor: Trent Jaeger

Dynamo: Key-Value Cloud Storage

Distributed File Systems: Design Comparisons

Motivation: I/O is Important. CS 537 Lecture 12 File System Interface. File systems

Da-Wei Chang CSIE.NCKU. Professor Hao-Ren Ke, National Chiao Tung University Professor Hsung-Pin Chang, National Chung Hsing University

File Systems: Consistency Issues

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

File System Structure. Kevin Webb Swarthmore College March 29, 2018

File System Internals. Jo, Heeseung

Today: Distributed File Systems. File System Basics

Today: Distributed File Systems

File Systems. Todays Plan. Vera Goebel Thomas Plagemann. Department of Informatics University of Oslo

OPERATING SYSTEM. Chapter 12: File System Implementation

Distributed File Systems. CS432: Distributed Systems Spring 2017

NETWORKED STORAGE AND REMOTE PROCEDURE CALLS (RPC)

Administrative Details. CS 140 Final Review Session. Pre-Midterm. Plan For Today. Disks + I/O. Pre-Midterm, cont.

Fall 2017 :: CSE 306. File Systems Basics. Nima Honarmand

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

Chapter 11: Implementing File

Operating Systems CMPSC 473 File System Implementation April 10, Lecture 21 Instructor: Trent Jaeger

Lecture 19: File System Implementation. Mythili Vutukuru IIT Bombay

Virtual File System. Don Porter CSE 306

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission

COS 318: Operating Systems. Journaling, NFS and WAFL

Chapter 11: Implementing File Systems. Operating System Concepts 9 9h Edition

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O

Let s Make Parallel File System More Parallel

CSE 120: Principles of Operating Systems. Lecture 10. File Systems. November 6, Prof. Joe Pasquale

DFS Case Studies, Part 1

How do modules communicate? Enforcing modularity. Modularity: client-server organization. Tradeoffs of enforcing modularity

Chapter 11: Implementing File Systems

CS 4284 Systems Capstone

CS 537: Introduction to Operating Systems Fall 2015: Midterm Exam #4 Tuesday, December 15 th 11:00 12:15. Advanced Topics: Distributed File Systems

Distributed File Systems. Case Studies: Sprite Coda

Background. 20: Distributed File Systems. DFS Structure. Naming and Transparency. Naming Structures. Naming Schemes Three Main Approaches

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ECE 598 Advanced Operating Systems Lecture 18

Chapter 10: File System Implementation

Case study: ext2 FS 1

File Systems 1. File Systems

File Systems 1. File Systems

File Systems. Before We Begin. So Far, We Have Considered. Motivation for File Systems. CSE 120: Principles of Operating Systems.

Distributed Systems. Lecture 07 Distributed File Systems (1) Tuesday, September 18 th, 2018

The Google File System

CS 550 Operating Systems Spring File System

Virtual File System. Don Porter CSE 506

PERSISTENCE: FSCK, JOURNALING. Shivaram Venkataraman CS 537, Spring 2019

Case study: ext2 FS 1

CSE 120: Principles of Operating Systems. Lecture 10. File Systems. February 22, Prof. Joe Pasquale

Sandboxing Untrusted Code: Software-Based Fault Isolation (SFI)

ò Server can crash or be disconnected ò Client can crash or be disconnected ò How to coordinate multiple clients accessing same file?

File-System Structure

Distributed Filesystem

File. File System Implementation. File Metadata. File System Implementation. Direct Memory Access Cont. Hardware background: Direct Memory Access

NFS. Don Porter CSE 506

Distributed Systems. Lec 9: Distributed File Systems NFS, AFS. Slide acks: Dave Andersen

Advanced Operating Systems

Chapter 12: File System Implementation

Midterm Exam Answers

What s Wrong with the Operating System Interface? Collin Lee and John Ousterhout

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

Lecture 10: Crash Recovery, Logging

University of Wisconsin-Madison

Introduction to the Network File System (NFS)

Chapter 11: Implementing File-Systems

Name: Instructions. Problem 1 : Short answer. [48 points] CMU / Storage Systems 20 April 2011 Spring 2011 Exam 2

Current Topics in OS Research. So, what s hot?

Announcements. P4: Graded Will resolve all Project grading issues this week P5: File Systems

we are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Chapter 11: File System Implementation

Advanced file systems: LFS and Soft Updates. Ken Birman (based on slides by Ben Atkin)

Chapter 11: File System Implementation

Distributed Systems 16. Distributed File Systems II

Petal and Frangipani

File Systems: Naming

Distributed File Systems. Directory Hierarchy. Transfer Model

Ext3/4 file systems. Don Porter CSE 506

Chapter 12 Distributed File Systems. Copyright 2015 Prof. Amr El-Kadi

File. File System Implementation. Operations. Permissions and Data Layout. Storing and Accessing File Data. Opening a File

File System Management

Transcription:

Network File System (NFS) Brad Karp UCL Computer Science CS GZ03 / M030 19 th October, 2009

NFS Is Relevant Original paper from 1985 Very successful, still widely used today Early result; much subsequent research in networked filesystems fixing shortcomings of NFS NFS is a great substrate for cool distributed systems DCNDS projects! 2

Why Build NFS? Why not just store your files on local disk? Sharing data: many users reading/writing same files (e.g., code repository), but running on separate machines Manageability: ease of backing up one server Disks may be expensive (true when NFS built; no longer true) Displays may be expensive (true when NFS built; no longer true) 3

Goals for NFS Work with existing, unmodified apps: Same semantics as local UNIX filesystem Easily deployed Easy to add to existing UNIX systems Compatible with non-unix OSes Wire protocol cannot be too UNIX-specific Efficient enough Needn t offer same performance as local UNIX filesystem 4

Goals for NFS Work with existing, unmodified apps: Same semantics as local UNIX filesystem Easily deployed Easy to add to existing UNIX systems Compatible with non-unix OSes Wire protocol cannot be too UNIX-specific Efficient enough Ambitious, conflicting goals! Does Needn t NFS achieve offer same them performance all fully? as local UNIX Hint: filesystem Recall New Jersey approach 5

NFS Architecture App1 App2 Clients LAN Server (w/disk) syscalls Filesystem User Kernel RPCs 6

Simple Example: Reading a File What RPCs would we expect for: fd = open( f, 0); read(fd, buf, 8192); close(fd); 7

Simple Example: NFS RPCs for Reading a File Where are RPCs for close()? 8

File Handle: Function and Contents 32-byte name, opaque to client Identifies object on remote server Must be included in all NFS RPCs File handle contains: filesystem ID i-number (essentially, physical block ID on disk) generation number 9

Generation Number: Motivation Client 1 opens file Client 2 opens same file Client 1 deletes the file, creates new one UNIX local filesystem semantics: Client 2 (App 2) sees old file In NFS, suppose server re-uses i-node Same i-number for new file as old RPCs from client 2 refer to new file s i-number Client 2 sees new file! 10

Generation Number: Solution Each time server frees i-node, increments its generation number Client 2 s RPCs now use old file handle Server can distinguish requests for old vs. new file Semantics still not same as local UNIX fs! Apps 1 and 2 sharing local fs: client 2 will see old file Clients 1 and 2 on different workstations sharing NFS fs: client 2 gets error stale file handle 11

Generation Number: Solution Each time server frees i-node, increments its generation number Trade Client precise 2 s RPCs UNIX now fs semantics use old file handle for simplicity Server can distinguish requests for old vs. New Jersey approach new file Semantics still not same as local UNIX fs! Apps 1 and 2 sharing local fs: client 2 will see old file Clients 1 and 2 on different workstations sharing NFS fs: client 2 gets error stale file handle 12

Why i-numbers, not Filenames? Local UNIX fs: client 1 reads dir2/f NFS with pathnames: client 1 reads dir1/f Concurrent access by clients can change object referred to by filename Why not a problem in local UNIX fs? i-number refers to actual object, not filename 13

Where Does Client Learn File Handles? Before READ, client obtains file handle using LOOKUP or CREATE Client stores returned file handle in vnode Client s file descriptor refers to vnode Where does client get very first file handle? 14

NFS Implementation Layering Why not just send syscalls over wire? UNIX semantics defined in terms of files, not just filenames: file s identity is i-number on disk Even after rename, all these refer to same object as before: File descriptor Home directory Cache contents 15

NFS Implementation Layering vnode s purpose: remember file handles! Why not just send syscalls over wire? UNIX semantics defined in terms of files, not just filenames: file s identity is i-number on disk Even after rename, all these refer to same object as before: File descriptor Home directory Cache contents 16

Example: Creating a File over NFS Suppose client does: fd = creat( d/f, 0666); write(fd, foo, 3); close(fd); RPCs sent by client: newfh = LOOKUP (fh, d ) filefh = CREATE (newfh, f, 0666) WRITE (filefh, 0, 3, foo ) 17

Server Crashes and Robustness Suppose server crashes and reboots Will client requests still work? Will client s file handles still make sense? Yes! File handle is disk address of i-node What if server crashes just after client sends an RPC? Before server replies: client doesn t get reply, retries What if server crashes just after replying to WRITE RPC? 18

WRITE RPCs and Crash Robustness What must server do to ensure correct behavior when crash after WRITE from client? Client s data safe on disk i-node with new block number and new length safe on disk Indirect block safe on disk Three writes, three seeks: 45 ms 22 WRITEs/s, so 180 KB/s 19

WRITEs and Throughput Design for higher write throughput: Client writes entire file sequentially at Ethernet speed (few MB/s) Update inode, &c. afterwards Why doesn t NFS use this approach? What happens if server crashes and reboots? Does client believe write completed? Improved in NFSv3: WRITEs async, COMMIT on close() 20

Client Caches in NFS Server caches disk blocks Client caches file content blocks, some clean, some dirty Client caches file attributes Client caches name-to-file-handle mappings Client caches directory contents General concern: what if client A caches data, but client B changes it? 21

Multi-Client Consistency Real-world examples of data cached on one host, changed on another: Save in emacs on one host, make on other host make on one host, run program on other host (No problem if users all run on one workstation, or don t share files) 22

Consistency Protocol: First Try On every read(), client asks server whether file has changed if not, use cached data for file if so, issue READ RPCs to get fresh data from server Is this protocol sufficient to make each read() see latest write()? What s effect on performance? Do we need such strong consistency? 23

Compromise: Close-to-Open Consistency Implemented by most NFS clients Contract: if client A write()s a file, then close()s it, then client B open()s the file, and read()s it, client B s reads will reflect client A s writes Benefit: clients need only contact server during open() and close() not on every read() and write() 24

Compromise: Close-to-Open Consistency Fixes emacs save, then make example so long as user waits until emacs says it s done saving file! 25

Close-to-Open Implementation FreeBSD UNIX client (not part of protocol spec): Client keeps file mtime and size for each cached file block close() starts WRITEs for all file s dirty blocks close() waits for all of server s replies to those WRITEs open() always sends GETATTR to check file s mtime and size, caches file attributes read() uses cached blocks only if mtime/length have not changed client checks cached directory contents with GETATTR and ctime 26

Name Caching in Practice Name-to-file-handle cache not always checked for consistency on each LOOKUP If file deleted, may get stale file handle error from server If file renamed and new file created with same name, may even get wrong file s contents 27

NFS: Secure? What prevents unauthorized users from issuing RPCs to an NFS server? e.g., remove files, overwrite data, &c. What prevents unauthorized users from forging NFS replies to an NFS client? e.g., return data other than on real server IP-address-based authentication of mount requests weak at best; no auth of server to client Security not a first-order goal in original NFS 28

Limitations of NFS Security: what if untrusted users can be root on client machines? Scalability: how many clients can share one server? Writes always go through to server Some writes are to private, unshared files that are deleted soon after creation Can you run NFS on a large, complex network? Effects of latency? Packet loss? Bottlenecks? 29

Limitations of NFS Security: what if untrusted users can be root on client machines? Scalability: how many clients can share one server? Despite its limitations, NFS a huge success: Simple enough to build for many OSes Correct Writes enough always and go through performs to server well enough to be practically useful in deployment Some writes are to private, unshared files that are deleted soon after creation Can you run NFS on a large, complex network? Effects of latency? Packet loss? Bottlenecks? 30