CSE 451: Operating Systems Section 7 File Systems; Project 3.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
CS140 Review Session Project 4 – File Systems Samir Selman 02/27/09cs140 Review Session Due Thursday March,11.
The Linux Kernel: Memory Management
File Systems.
File Systems Examples.
File System Basics Brandon Checketts. Some terminology Superblocks Inodes Journaling Hard links Symbolic links Directory entries.
CSE506: Operating Systems Block Cache. CSE506: Operating Systems Address Space Abstraction Given a file, which physical pages store its data? Each file.
CSE 451: Operating Systems Section 8 Linux buffer cache; design principles.
File Management Systems
Project 4 Work with a real file system Given: Goals:
Operating Systems File Systems (in a Day) Ch
Lecture 10: The FAT, VFAT, and NTFS Filesystems 6/17/2003 CSCE 590 Summer 2003.
1 Administrivia Project 4 due in a week Turnin only, no report Homework 4 due next Wednesday EC Today: Project 4 and file system stuff EC questions?
1 Administrivia Project 4 out today, due next Friday (March 10) Design exercise only Today: Project 4 and file system stuff.
Project 3: File System Design COS318 Fall Last Time Web Server Extensive use of a file system on server machine without actually worrying about.
Chapter 40 File System Implementation
CS140 Review Session Project 4 – File Systems Varun Arora Based on Vincenzo Di Nicola’s slide 7/16/2015cs140 Review Session1.
File System. NET+OS 6 File System Architecture Design Goals File System Layer Design Storage Services Layer Design RAM Services Layer Design Flash Services.
CS 6560 Operating System Design Lecture 13 Finish File Systems Block I/O Layer.
1Fall 2008, Chapter 11 Disk Hardware Arm can move in and out Read / write head can access a ring of data as the disk rotates Disk consists of one or more.
CS 346 – Chapter 12 File systems –Structure –Information to maintain –How to access a file –Directory implementation –Disk allocation methods  efficient.
Faculty of Engineering and Applied Science University of Ontario Institute of Technology Canada Faculty of Engineering and Applied Science University of.
Files CS Spring Overview Example: FAT File System File Organization File System Organization –File Directories and File Sharing –Record Blocking.
SIMULATED UNIX FILE SYSTEM Implementation in C Tarek Youssef Bipanjit Sihra.
CSE 451: Operating Systems
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Files & File system. A Possible File System Layout Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
Project 6 Unix File System. Administrative No Design Review – A design document instead 2-3 pages max No collaboration with peers – Piazza is for clarifications.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
UNIX File System (UFS) Chapter Five.
Jeff's Filesystem Papers Review Part I. Review of "Design and Implementation of The Second Extended Filesystem"
File Systems. 2 What is a file? A repository for data Is long lasting (until explicitly deleted).
Lecture 10 Page 1 CS 111 Summer 2013 File Systems Control Structures A file is a named collection of information Primary roles of file system: – To store.
Project 4. “File System Implementation”
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems File systems.
CS 3204 Operating Systems Godmar Back Lecture 21.
NCHU System & Network Lab Lab 14 File and Directory.
THE FILE SYSTEM Files long-term storage RAM short-term storage Programs, data, and text are all stored in files, which is stored on.
File system In computing, a file system is a method of storing and organizing computer files and the data they contain to make it easy to find and access.
Lecture 19 Linux/Unix – File System
Linux file systems Name: Peijun Li Student ID: Prof. Morteza Anvari.
CSE 451: Operating Systems Section 9: Storage; networks.
CS140 Project 4 Due Thursday March 10th Slides adapted from Samir Selman’s Kiyoshi Shikuma.
1 The File System. 2 Linux File System Linux supports 15 file systems –ext, ext2, xia, minix, umsdos, msdos, vfat, proc, smb, ncp, iso9660, sysv, hpfs,
1 Reminders Project 3 due tomorrow in lecture turnin + report Today’s office hours in 006 changed to 5:30-6:30 Project 4 out soon, due last day of classes.
1 Section 8: File Systems Project 3. 2 Questions?
1 Administrivia ● Project 2b (parts 4, 5, 6) due tomorrow at 11:59 pm – Questions? ● Project 3 Light to be released tomorrow ● Project 3 Full will be same.
1 Section 9: Project 3 – The Buffer Cache Network File Systems.
File System Examples Unix Fast File System (FFS)
Introduction to Kernel
Today topics: File System Implementation
Chapter 11: File System Implementation
Chapter 12: File System Implementation
File System Structure How do I organize a disk into a file system?
Filesystems.
COEN 252: Computer Forensics
Chapter 8: Main Memory.
Operation System Program 4
Chapter 11: File System Implementation
File System Implementation
Chap 4: Distributed File Systems
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451 Fall 2003 Section 11/20/2003.
Computer Science and Engineering Four Hundred and Fifty One
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Reminders Project 4 due Dec 10 If you used your late pass on HW5
Week 9 March 4, 2004 Adrienne Noble.
Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps
Presentation transcript:

CSE 451: Operating Systems Section 7 File Systems; Project 3

Project 2  Done! 11/18/102

Project 3  Due: Thursday, December 9, 11:59pm 11/18/103

Project 3  Work with a real file system  cse451fs: simple file system for Linux  Goals:  Understand how it works  Modify implementation to:  Increase maximum size of files (currently 10KB)  Allow for longer file names (currently 30 chars)  Allow for more files (currently ~8000) 11/18/104

Project 3 procedure  Build a kernel module for cse451fs  On a virtual machine running Linux kernel:  Load the cse451fs module  Format the file system using (modified) mkfs tool  Mount the file system  Test using tools like ls, cat, etc.  Try this procedure with given code first  Then carefully read writeup again, and go! 11/18/105

6 Linux file system layers Disk drivers Buffer cache Application VFS ext2ext3vfatcse451fs  cache for disk blocks  “block device” Blocks Inodes, direntries Files, directories User Kernel

Inodes  Inode: a structure maintaining all metadata about a file (or directory)  Inode number (unique ID of inode)  Permissions, timestamps  Pointers to data blocks  Inode does not contain: name of file  One or more file names can point (link) to the same inode 11/18/107

Directories  Directory entry (“dirent”): a name + inode number pair  Directory: a file that contains a list of directory entries 11/18/108

cse451fs disk layout  Superblock: knows layout of rest of disk  Contains parameters such as size and location of inode blocks, data blocks  Contains inode map:  Bit array, tracks which inodes are currently in use  Data map:  Bit array, tracks which data blocks are in use 11/18/109

cse451fs disk layout  Inode blocks:  All inodes reside here  Data blocks:  File / directory data resides in blocks here 11/18/1010

11 Example disk layout struct cse451_super_block { 1365 __u16 s_nNumInodes; // inode map is tail of superblock 2__u16 s_nDataMapStart;// block # of first data map block 1__u32 s_nDataMapBlocks; // data map size, in blocks 3__u32 s_nInodeStart; // block # of first inode block 85 __u32 s_nNumInodeBlocks;// number of blocks of inodes 88__u32 s_nDataBlocksStart;// block # of first data block 4008__u32 s_nDataBlocks; // number of blocks of data 0x451f__u16 s_magic; // magic number unsigned long s_imap; // name for inode map }; Size in blocks: Sample values for a 4MB disk with 4 files and 3 dirs using 1KB blocks

cse451fs inode structure #define CSE451_NUMDATAPTRS 10 struct cse451_inode { __u16 i_mode; __u16 i_nlinks; __u16 i_uid; __u16 i_gid; time_t i_atime; time_t i_mtime; time_t i_ctime; __u32 i_filesize; __u32 i_datablocks[CSE451_NUMDATAPTRS]; }; 11/18/1012

cse451fs inode structure  Remember, inodes themselves are stored in blocks  What’s the size of the inode struct?  So how many inside a 1K block?  Max number of inodes (max number of files) usually decided when file system is formatted  mkfs heuristic: create an inode for every three data blocks 11/18/1013

Data blocks  Blocks for regular files contain file data  Blocks for directories contain directory entries: #define MAXDIRNAMELENGTH 30 struct cse451_dir_entry { __u16 inode; char name [MAXDIRNAMELENGTH]; }; 11/18/1014 Dir. entryFieldValue 0Inode1 Name“.” 1Inode1 Name“..” 2Inode2 Name“etc” 3Inode3 Name“bin” 4Inode0 Name0 Data block for /

Example data block usage  For a 4MB file system with 1KB blocks, with hierarchy: / etc passwd fstab bin sh date 11/18/1015 File/DirectorySizeData Blocks /4 entries + 1 null entry1 /etc4 entries + 1 null entry1 /bin4 entries + 1 null entry1 /etc/passwd1024 bytes1 /etc/fstab100 bytes1 /bin/sh10,000 bytes10 /bin/date5,000 bytes5 Total:20

Project 3 requirements  Increase the maximum file size  Increase the maximum file name length  Increase the maximum number of files 11/18/1016

Larger file sizes  One way: add more pointers to data blocks  Just changing this constant is not enough!!  Goal: be efficient for small files but allow large files  Come up with a better design/structure for locating data blocks  See lecture slides: indirect block pointers  You don’t have to support arbitrarily large files  But max file size should be much larger than it used to be 11/18/1017

Longer file names  Goal (again): be efficient for short file names but allow large file names  Again, just changing the constant is not sufficient  Recommended approach:  Store long names in a separate data block, and keep a pointer to that in the directory entry  Short names can be stored as they are 11/18/1018

Longer file names  Other possible approaches:  Combine multiple fixed-length dir entries into a single long dir entry  Easier if the entries are adjacent  Past Windows file systems have done this  Put a length field in the dir entry and store variable length strings  Need to make sure that when reading a directory, you are positioned at the beginning of an entry 11/18/1019

More files  Number of inodes is decided at format time  Total number of inodes is limited by the number of bits in the inode map  The inode map is at the end of the superblock  How many inodes will you need? 11/18/1020

Getting started with the code  Understand the source of the limits in the existing implementation (both cse451fs and mkfs)  Larger file sizes:  super.c: get_block()  References to i_datablock[] array in an inode will have to change 11/18/1021

Getting started with the code  Longer file names:  Code changes largely in dir.c: add_entry(), find_entry()  In mkfs, change how the first two entries (for “.” and “..”) are stored  More files:  super.c: cse451_fill_super() reads maps  inode.c: cse451_new_inode() uses inode map  In mkfs, change how formatting and superblock init is performed 11/18/1022

Linux buffer cache code  To manipulate disk blocks, file system goes through the buffer cache  Two data structures: buffer_head, b_data  For a given disk block, buffer manager could be:  Completely unaware of it (cache miss)  No buffer_head exists, block not in memory  Aware of block information (cache miss)  buffer_head exists, but block data (b_data) not in memory  Aware of block information and data (cache hit)  Both the buffer_head and its b_data are valid 11/18/1023

Accessing blocks  To read a block, FS uses sb_bread():  Finds the corresponding buffer_head  Creates if doesn’t exist  Reads data from buffer cache if it’s already in memory; otherwise, reads from disk (and stores it in the cache)  To write a block:  mark_buffer_dirty(): mark buffer as changed  brelse(): release to kernel (which does the writing) 11/18/1024

Tool limitation warning  Some items in Linux kernel are limited to 256 chars  e.g. VFS, ls  Be careful when testing long filenames!  dd is useful for creating large test files dd if=/dev/zero of=200k bs=1024 count=200  df is useful to check that you’re freeing everything correctly 11/18/1025

gcc warning  gcc might insert extra space into structs  How big do you think this is? struct foo { char a; int b; }  Why is this a problem?  What if foo represents something you want on disk (i.e. directory entries)?  Discrepancy between the disk layout and memory layout 11/18/1026

gcc warning  Fix: struct bar { char a; int b; } __attribute__((packed));  sizeof(bar) is now 5  Real fix: don’t make any assumptions in your code about size of structs! 11/18/1027

11/18/1028