Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems Engineering Based on MIT 6.828 (2012, lec9) Recitation 5: File Systems.

Similar presentations


Presentation on theme: "Operating Systems Engineering Based on MIT 6.828 (2012, lec9) Recitation 5: File Systems."— Presentation transcript:

1 Operating Systems Engineering Based on MIT 6.828 (2012, lec9) Recitation 5: File Systems

2 What Does a File System Do? Durable Storage Multiplexing Sharing Organization

3 Why is the FS Interesting? Critical in many aspects of the system Performance Security Fault tolerance API design User interface You will implement one for JOS

4 FS - The Unix (& xv6) Choices Granularity: Files vs virtual disks, databases File content: Byte array vs 80-byte records, numbers, boolean values Organization: Name hierarchy vs flat names, GUIDs Synchronization: None vs locks, transaction rollbacks

5 File System API fd = open("x/y", O_CREATE); write(fd, "abc", 3); link("x/y", "x/z"); unlink("x/y");

6 FS Abstraction is Quite Useful Pipes, Sockets Devices /dev/console, /dev/urandom Linux’s /proc Apps can regard them all the same

7 Implications of Unix API FD (file descriptor) needs to remain valid after name change or even deletion A file can have many (symmetrical) names Thus - a file is independent of its names It’s contained in an “inode” inodes must keep counters For links in the FS For open FDs

8 A bit about xv6 FS software layers: System calls Name ops or file descriptors inode ops inode cache (for active inodes) Transactions Buffer cache Disk driver

9 xv6 – on-disk layout Viewing disk as a 512-byte sector array: 0: unused 1: super block (size, ninodes, root, …) 2+: array of inodes X: block in-use bitmap (0=free, 1=inuse) Y: file (or dir) content blocks Z: transaction log

10 xv6 –inodes On-disk layout: Type (free, file, directory, device) Nlink Size addrs[12+1] Direct and indirect blocks Each inode has an i-number inode location: sector 2 + 64*inum

11 xv6 - directories Directories are much like files Except user can’t directly write the content Content is an array of dirents Dirent: i-number 14-byte file name Dirent is free if the i-number is zero

12 xv6 – The code Q: How does xv6 create a file? create (sheet 56) calls: ialloc (sheet 46) iupdate (sheet 46) dirlink (sheet 50) calls: readi (sheet 49) writei (sheet 49)

13 xv6 – The code Q: What about concurrent calls to ialloc? will they get the same inode? bread (sheet 41) calls: bget (sheet 40) brelse (sheet 41)


Download ppt "Operating Systems Engineering Based on MIT 6.828 (2012, lec9) Recitation 5: File Systems."

Similar presentations


Ads by Google