Linux File system and VFS. A simple description of the UNIX system, also applicable to Linux, is this: "On a UNIX system, everything is a file; if something.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

Chapter 4 : File Systems What is a file system?
File Systems.
Allocation Methods - Contiguous
Chapter 10: File-System Interface
Linux Filesystem Features Evolution of a de facto standard file system for Linux: ‘ext2’
File Management. Persistent storage Shared device Why Programmers Need Files HTML Editor HTML Editor … … Web Browser Web Browser Structured information.
Chapter 11: File System Implementation
File System Implementation
File System Implementation
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
Chapter 12: File System Implementation
Linux Filesystem Features Evolution of a de facto standard file system for Linux: ‘ext2’
File System Structure §File structure l Logical storage unit l Collection of related information §File system resides on secondary storage (disks). §File.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
File System Implementation
File System Implementation
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
File Concept §Contiguous logical address space §Types: l Data: Numeric Character Binary l Program.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 4 File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
File system, VFS and Virtualization. A simple description of the UNIX system, also applicable to Linux, is this: "On a UNIX system, everything is a file;
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Chapter 10: File System Implementation.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 File-System Structure.
OSes: 11. FS Impl. 1 Operating Systems v Objectives –discuss file storage and access on secondary storage (a hard disk) Certificate Program in Software.
Chapter 5 File Management File System Implementation.
Dr. T. Doom 11.1 CEG 433/633 - Operating Systems I Chapter 11: File-System Implementation File structure –Logical storage unit –Collection of related information.
Silberschatz and Galvin  Operating System Concepts File-System Implementation File-System Structure Allocation Methods Free-Space Management.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
File System Implementation
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 Implementation.
Module 4.0: File Systems File is a contiguous logical address space.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 11: File-System Interface File Concept Access Methods Directory Structure.
12.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 12: File System Implementation Chapter 12: File System Implementation.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 11: File System Implementation Chapter.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
10.1 CSE Department MAITSandeep Tayal 10 :File-System Implementation File-System Structure Allocation Methods Free-Space Management Directory Implementation.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 11 File-System Implementation Slide 1 Chapter 11: File-System Implementation.
File Management cs431-cotter.
Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation  Overview  File system structure – layered, block based.
CE Operating Systems Lecture 17 File systems – interface and implementation.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File System Implementation.
Slide 13-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter File Management.
I MPLEMENTING FILES. Contiguous Allocation:  The simplest allocation scheme is to store each file as a contiguous run of disk blocks (a 50-KB file would.
Fall 2000M.B. Ibáñez Lecture 24 File-System III File System Implementation.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure.
11.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 11.5 Free-Space Management Bit vector (n blocks) … 012n-1 bit[i] =  1  block[i]
Operating Systems Files, Directory and File Systems Operating Systems Files, Directory and File Systems.
FILE SYSTEM IMPLEMENTATION 1. 2 File-System Structure File structure Logical storage unit Collection of related information File system resides on secondary.
操作系统原理 OPERATING SYSTEMS Chapter 4 File Systems 文件系统.
W4118 Operating Systems Instructor: Junfeng Yang.
Fall 2011 Nassau Community College ITE153 – Operating Systems 1 Session 5 Files.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 12: File System Implementation.
File-System Management
File System Implementation
File-System Implementation
Chapter 11: File System Implementation
FileSystems.
Chapter 11: File System Implementation
Filesystems.
Chapter 11: File System Implementation
Chapter 11: File System Implementation
Chapter 14: File-System Implementation
Chapter 11: File System Implementation
Presentation transcript:

Linux File system and VFS

A simple description of the UNIX system, also applicable to Linux, is this: "On a UNIX system, everything is a file; if something is not a file, it is a process.“ A file system is an organization of data and metadata on a storage device

Operating Systems: A Modern Perspective, Chapter 13 More Abstract Files Inverted files – System index for each datum in the file Databases – More elaborate indexing mechanism – DDL & DML Multimedia storage – Records contain radically different types – Access methods must be general

Operating Systems: A Modern Perspective, Chapter 13 Persistent storage Shared device Why Programmers Need Files HTML Editor HTML Editor … … Web Browser Web Browser Structured information Can be read by any applic Accessibility Protocol … … … … foo.html File Manager File Manager File Manager File Manager

Think of a disk as a linear sequence of fixed- size blocks and supporting reading and writing of blocks. The file system must keep track of which blocks belong to which files. – which blocks belong to which files. – In what order the blocks form the file. – which blocks are free for allocation.

Operating Systems: A Modern Perspective, Chapter 13 Disk Organization Blk 0 Blk 1 Blk k-1 Blk k Blk k+1 Blk 2k-1 Track 0, Cylinder 0 Track 0, Cylinder 1 Blk Track 1, Cylinder 0 Blk Track N-1, Cylinder 0 Blk Track N-1, Cylinder M-1 … … … … … … … … Boot SectorVolume Directory

Operating Systems: A Modern Perspective, Chapter 13 Low-level File System Architecture b 0 b 1 b 2 b 3 b n-1 …… Block 0... Sequential Device Randomly Accessed Device

A Possible File System Layout Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved Superblock contains info about the fs ( number of blocks in the partition, size of the blocks, free block count and free- block pointers etc) i-nodes contain info about files

File System A file system is consists of a sequence of logical blocks (512/1024 byte etc.) A file system has the following structure: Boot BlockSuper BlockInode ListData Blocks

Filesystem performance Two predominant performance criteria: – Speed of access to file’s contents – Efficiency of disk storage utilization How can these be meaningfully measured

Free-Space Management Since disk space is limited, we need to reuse the space from deleted files for new files, if possible. To keep track of free disk space, the system maintains a free-space list. The free-space list records all free disk blocks. To create a file, we search the free-space list for the required amount of space and allocate that space to the new file. When a file is deleted, its disk space is added to the free-space list.

Free space list implementation Bit Vector Linked List Grouping Counting

Bit vector Frequently, the free-space list is implemented as a bit map or bit vector. Each block is represented by 1 bit. If the block is free, the bit is 1; If the block is allocated, the bit is O. For example, consider a disk where blocks 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 17, 18,25,26, and 27 are free and the rest of the blocks are allocated

Unfortunately, bit vectors are inefficient unless the entire vector is kept in main memory (and is written to disk occasionally for recovery needs). Keeping it in main memory is possible for smaller disks but not necessarily for larger ones. A 500-GB disk with a 1-KB block and a 32-bit (4 bytes) disk block number, we need 488 million bits for the map, which requires just under KB blocks to store ( ).

Linked list Another approach to free-space management is to link together all the free disk blocks, keeping a pointer to the first free block in a special location on the disk and caching it in memory. This first block contains a pointer to the next free disk block, and so on.

Grouping A modification of the free-list approach is to store the addresses of n free blocks in the first free block. The first of n-1 these blocks are actually free. The last block contains the addresses of another n free blocks, and so on. The addresses of a large number of free blocks can now be found quickly, unlike the situation when the standard linked-list approach is used.

Counting Another approach is to take advantage of the fact that, generally, several contiguous blocks may be allocated or freed simultaneously, particularly when space is allocated with the contiguous- allocation algorithm or through clustering. Thus, rather than keeping a list of free disk addresses, we can keep the address of the first free block and the number of free contiguous blocks that follow the first block. Each entry in the free-space list then consists of a disk address and a count.

cs431-cotter18 Allocation Methods Contiguous Allocation Each file occupies a set of contiguous blocks on the disk. Number of blocks needed identified at file creation – May be increased using file extensions Advantages: – Simple to implement – Good for random access of data Disadvantages – Files cannot grow – Wastes space

cs431-cotter19 Contiguous Allocation FileA FileB FileC FileE FileD File Allocation Table File NameStart BlockLength FileA FileB FileC FileD FileE FileA

cs431-cotter20 Allocation Methods Linked Allocation Each file consists of a linked list of disk blocks. Advantages: – Simple to use (only need a starting address) – Good use of free space Disadvantages: – Random Access is difficult ptrdataptrdataptrdata Null data

cs431-cotter21 Linked Allocation FileB File Allocation Table File NameStart BlockEnd... FileB

cs431-cotter22 Linked Allocation FileB File Allocation Table File NameStart BlockEnd... FileB

cs431-cotter23 Allocation Methods Indexed Allocation Collect all block pointers into an index block. Advantages: – Random Access is easy – No external fragmentation Disadvantages – Overhead of index block Index Table

cs431-cotter24 Indexed Allocation File Allocation Table File Name Index Block Jeep24

cs431-cotter25 Indexed Allocation File Allocation Table File Name Index Block Jeep24

cs431-cotter26 direct blocks UNIX i-node mode owners(2) timestamps(3) size block count single indir triple indir double indir data

cs431-cotter27 Directory Structure Collection of nodes containing information on all files F1 F2 F3 F4 F5

cs431-cotter28 Information in a Device Directory File name: File Type: Address: Current Length Maximum Length Date Last accessed (for archiving) Date Last updated (for dumping) Owner ID Protection information

cs431-cotter29 Directory Operations Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system

cs431-cotter30 Alternative Directory Structures Single-Level Directory Issues: – Naming – Grouping cat bo a test data mail cont hex word calc

cs431-cotter31 Alternative Directory Structures Two-Level Directory User1 User2 User3

cs431-cotter32 Tree-Structured Directory

Partitions and Mounting Associating a file system to a storage device in Linux is a process called mounting During a mount, you provide a file system type, a file system The mount command is used to attach a file system to the current file system hierarchy (root). mount point.

Architectural view of Linux file system components

The VFS is the primary interface to the underlying file systems. This component exports a set of interfaces and then abstracts them to the individual file systems, which may behave very differently from one another

Linux file system : Cross-development Linux: first developed on a minix system Both OSs shared space on the same disk So Linux reimplemented minix file system Two severe limitations in the minix FS – Block addresses are 16-bits (64MB limit) – Directories use fixed-size entries (w/filename)

Extended File System Originally written by Chris Provenzano Extensively rewritten by Linux Torvalds Initially released in 1992 Removed the two big limitations in minix Used 32-bit file-pointers (filesizes to 2GB) Allowed long filenames (up to 255 chars) Question: How to integrate ext into Linux?

Xia and Ext2 filesystems Two new filesystems introduced in 1993 Both tried to overcome Ext’s limitations Xia was based on existing minix code Ext2 was based on Torvalds’ Ext code Xia was initially more stable (smaller) But flaws in Ext2 were eventually fixed Ext2 soon became a ‘de facto’ standard

VFS What is it ? VFS is a kernel software layer that handles all system calls related to file systems. Its main strength is providing a common interface to several kinds of file systems.

The Virtual File System idea Multiple file systems need to coexist But file systems share a core of common concepts and high-level operations So can create a file system abstraction ? Applications interact with this VFS Kernel translates abstract-to-actual

Task 1Task 2Task n … user space kernel space VIRTUAL FILE SYSTEM minixext2msdosproc device driver for hard disk device driver for floppy disk Buffer Cache software hardware Hard DiskFloppy Disk Linux Kernel

VFS provides a uniform interface

Layered archi of vfs