2013-2014. 1. Concepts about the file system 2. The disk structure 3. Files in disk – The ext2 FS 4. The Virtual File System (c) 2013, Prof. Jordi Garcia.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

Chapter 4 : File Systems What is a file system?
File Systems.
Allocation Methods - Contiguous
File Systems Examples.
Chapter 10: File-System Interface
Ext2/Ext3 Linux File System Reporter: Po-Liang, Wu.
File System Interface CSCI 444/544 Operating Systems Fall 2008.
CS503: Operating Systems Spring 2014 General File Systems
Operating Systems File Systems (in a Day) Ch
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
Files. System Calls for File System Accessing files –Open, read, write, lseek, close Creating files –Create, mknod.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (4) File Management & Input/Out Systems 10/14/2008 Yang Song (Prepared.
GNU/Linux Filesystem 1 st AUT GNU/Linux Festival Computer Engineering & IT Department Bahador Bakhshi.
Ceng Operating Systems
Operating Systems File Systems (Select parts of Ch 6)
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
Guide To UNIX Using Linux Third Edition
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
Ext* Content Areas Inodes, Directories & Files. Review Recall …the file system metadata The superblock describes the file system The group descriptor.
Chapter 10 File System Interface
Guide To UNIX Using Linux Fourth Edition
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
CSC 322 Operating Systems Concepts Lecture - 4: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Silberschatz, Galvin and Gagne  Operating System Concepts File Concept Contiguous logical address space Smallest user allocation Non-volatile.
CSE 451: Operating Systems
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
Operating System Concepts and Techniques Lecture 17
1 Interface Two most common types of interfaces –SCSI: Small Computer Systems Interface (servers and high-performance desktops) –IDE/ATA: Integrated Drive.
Chapter 4. INTERNAL REPRESENTATION OF FILES
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
File System Interface. File Concept Access Methods Directory Structure File-System Mounting File Sharing (skip)‏ File Protection.
Chapter 5 File Management File System Implementation.
UNIX Files File organization and a few primitives.
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.
Files & File system. A Possible File System Layout Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
Computer Science Lecture 19, page 1 CS677: Distributed OS Last Class: Fault tolerance Reliable communication –One-one communication –One-many communication.
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.
Lecture 18 Windows – NT File System (NTFS)
UNIX File System (UFS) Chapter Five.
Jeff's Filesystem Papers Review Part I. Review of "Design and Implementation of The Second Extended Filesystem"
THE FILE SYSTEM Files long-term storage RAM short-term storage Programs, data, and text are all stored in files, which is stored on.
Lecture 19 Linux/Unix – File System
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10 & 11: File-System Interface and Implementation.
Linux file systems Name: Peijun Li Student ID: Prof. Morteza Anvari.
Lecture Topics: 11/29 File System Interface –Files and Directories –Access Methods –Protection –Consistency.
MINIX Presented by: Clinton Morse, Joseph Paetz, Theresa Sullivan, and Angela Volk.
File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314.
W4118 Operating Systems Instructor: Junfeng Yang.
Computer Science Lecture 19, page 1 CS677: Distributed OS Last Class: Fault tolerance Reliable communication –One-one communication –One-many communication.
SVBIT SUBJECT:- Operating System TOPICS:- File Management
Operating Systems, Winter Semester 2011 Practical Session 11 File Systems, part 1 1.
Day 28 File System.
Chapter 11: File System Implementation
Chapter 12: File System Implementation
Chapter 11: File-System Interface
Day 27 File System.
File Structure 2018, Spring Pusan National University Joon-Seok Kim
An overview of the kernel structure
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Directory Structure A collection of nodes containing information about all files Directory Files F 1 F 2 F 3 F 4 F n Both the directory structure and the.
Chapter 10: File-System Interface
Files Management – The interfacing
Department of Computer Science
Internal Representation of Files
Chapter 12: File-System Implementation CSS503 Systems Programming
Chapter 5 File Systems -Compiled for MCA, PU
The File Manager Implementation issues
Presentation transcript:

1. Concepts about the file system 2. The disk structure 3. Files in disk – The ext2 FS 4. The Virtual File System (c) 2013, Prof. Jordi Garcia | 1 Contents 1. Concepts about the file system  The user view 2. The disk structure 3. Files in disk – The ext2 FS 4. The Virtual File System

 Disk: Device that stores information (files)  Many files x many users: OS management  Files organization ▪ Directories ▪ Links  Files protection: rwx rwx rwx ▪ Data file: read / write / execute ▪ Directory: ▪ r allows reading directory contents ▪ w allows writing directory contents (add or remove files) ▪ x allows changing directory (c) 2013, Prof. Jordi Garcia | 2 Concepts (1)

 File system: Logical view of a disc  The information is organized: files, directories  Features  Inverted tree structure ▪ Or graph (acyclic / cyclic), when links  Root directory: /  Current directory:.  Parent directory:.. ▪ Exception: Parent of root directory  All processes have a working directory: cwd  Relative path (assuming cwd )  Absolute path ( cwd not assumed) (c) 2013, Prof. Jordi Garcia | 3 Concepts (2)

 File: Any object with a name in the File System  File types  Regular file ▪ Contains data  Directory ▪ Contains files (regular, directory, …)  Link ▪ Soft / symbolic (points to the name) ▪ Hard (points to the content)  Device ▪ Type, major, minor  Named pipe ▪ Type p  … (c) 2013, Prof. Jordi Garcia | 4 Concepts (3)

 With. and.. files in each directory  If there are links, the tree becomes a graph (c) 2013, Prof. Jordi Garcia | 5 Example f1 fff bbb aaa f1.of1.c josep jordi lib homebinusrdevetcmnt /

 Usual I/O system calls, and  And other system calls to manage  Permissions  Relationship  Features  … (c) 2013, Prof. Jordi Garcia | 6 Additional system calls ServiceSystem call Create / remove link link / unlink / symlink Change file permissions chmod Change file proprietary / group chown / chgrp Get inode information stat / lstat / fstat

 Organize files (namespace, directories)  Manage file contents in disk  Manage disk space (allocated/free)  … and guarantee correctness, robustness, protection and efficiency (c) 2013, Prof. Jordi Garcia | 7 OS responsibilities IN MEMORY IN DISK

1. Concepts about the file system 2. The disk structure 3. Files in disk – The ext2 FS 4. The Virtual File System (c) 2013, Prof. Jordi Garcia | 8 Contents 1. Concepts about the file system 2. The disk structure  Disk structure  Disk contents 3. Files in disk – The ext2 FS 4. The Virtual File System

 Consists of: Platter/head/track/sector  All sectors have the same size  It can also be seen as a list of sectors (c) 2013, Prof. Jordi Garcia | 9 The disk SECTOR-1SECTOR-2SECTOR-3SECTOR-4…SECTOR-N

 Metadata  Boot sector (optional, only if bootable disk)  Super block (one, or several through the disk) ▪ Disk structure (metadata / data), size, … ▪ List of free sectors  Info about files (the data) storage  Data: organized in blocks  1 block (OS view) = N sectors (disk view)  The actual format depends on specific FS ▪ ext2, ext3, NTFS, … (c) 2013, Prof. Jordi Garcia | 10 Disk contents BOOT sector Super block Info about files storage Data block Super block Info about files storage Data block ……

 Disk allocation strategies  Continuous ▪ For write-once disks  Discontinuous (at block level) ▪ Linked list: FAT ▪ Index table: inode ▪ The ext2 file system  Free space management  Depends on allocation strategy ▪ Bitmap of free blocks (c) 2013, Prof. Jordi Garcia | 11 Space allocation/free

1. Concepts about the file system 2. The disk structure 3. Files in disk – The ext2 FS 4. The Virtual File System (c) 2013, Prof. Jordi Garcia | 12 Contents 1. Concepts about the file system 2. The disk structure 3. Files in disk – The ext2 FS  Regular file  Directory  Links  Other types 4. The Virtual File System

 Contains: data (any type)  Where: In data blocks, discontinuously  File attributes  Packed into one data structure: inode ▪ Metadata with all information about the file ▪ … including the index table ▪ … except the file name (!) (c) 2013, Prof. Jordi Garcia | 13 Regular file (1) Index table BOOT sector Super block List of inodesData Super block List of inodesData …… Info Inode

 The inode data structure ▪ 1 inode per file  File type: data (dir, link, device, pipe, …)  Size (determines #blocks and offset in last block)  Permissions  Proprietary  Dates (creation, modification, access)  Number of references (later)  …  Index table (13 pointers) ▪ 10 direct pointers ▪ 1 single indirect pointer ▪ 1 double indirect pointer ▪ 1 triple indirect pointer (c) 2013, Prof. Jordi Garcia | 14 Regular file (2)

 Contains: List of files/inodes  Where: In data blocks ▪ Usually 1 block but, if more, discontinuously  Data block contents ▪ file name - #inode  Always, at least,. and.. directories (c) 2013, Prof. Jordi Garcia | 15 Directory file (1) Index table BOOT sector Super block List of inodesData Super block List of inodesData …… Info Inode file name … #inode …

 The inode data structure  File type: dir  All other fields are similar than regular file  Considerations in Linux  Root directory inode is always # 0 . directory points to the same directory .. directory points to the parent ▪Except for root, that points to itself (c) 2013, Prof. Jordi Garcia | 16 Directory file (2)

 In Linux, the root inode is always # 0  Build the following file system:  Inodes  Data blocks (c) 2013, Prof. Jordi Garcia | 17 Example (1) type: DIR 6 #0 type: DATA 3 #1 type: DIR 2 #2 type: DATA 15 #3 type: DIR 11 #4 type: DATA 7 #5 type: DIR 18 #6 type: DIR 8 # A f1 6 #2 # A B C 4 7 #6 # # #11 # f1 f2 1 #18 patim patampatum

 Soft Link (or symbolic link)  New file object that points to a path name  The inode data structure contains ▪ File type: link ▪ All other fields are similar than regular files  The data block contains the path name  Hard link  New directory entry (name) that points to an existing inode  There is not any specific inode for it ▪ Number of references ++  There are not data blocks for it  Note that. and.. are hard links (c) 2013, Prof. Jordi Garcia | 18 Links

 Device  File object that represents a device in the FS  The inode data structure contains ▪ File type: char / block ▪ Major, minor, … ▪ No data blocks are used  Named pipe  File object that represents a pipe in the FS  The inode data structure contains ▪ File type: pipe ▪ No data blocks are used  And more: Sockets, … (c) 2013, Prof. Jordi Garcia | 19 Other types

 In Linux, the root inode is always # 0  Build the following file system:  Inodes  Data blocks (c) 2013, Prof. Jordi Garcia | 20 Example (2) type: DIR #refs = 5 6 #0 type: DATA #refs = #1 type: DIR #refs = 2 2 #2 type: LINK #refs = 1 15 #3 type: DIR #refs = 2 11 #4 type: DATA #refs = 2 3 #5 type: DIR #refs = 3 8 # file3 D 5 # A B C 4 7 # file41 # file1 file2 3 #11#3 /B/file3 #7 patim #15 /B/file3 #18 patam

1. Concepts about the file system 2. The disk structure 3. Files in disk – The ext2 FS 4. The Virtual File System (c) 2013, Prof. Jordi Garcia | 21 Contents 1. Concepts about the file system 2. The disk structure 3. Files in disk – The ext2 FS 4. The Virtual File System  Overview  Internal VFS data structures  System calls and the VFS

 Abstraction layer on top of a specific FS (c) 2013, Prof. Jordi Garcia | 22 Overview Virtual File System Procs & memory management IPC Blocks server (buffer cache) Syscalls interface ext2 ext3 NTFS … FAT device driver void main() { read(…); write(…); } void main() { read(…); write(…); } User System

 FS: Information in disk, non-volatile, to store and organize files according to a predetermined format (ie: ext2, FAT, NTFS, …)  Different FS offer different options, attributes, security levels, … but it is independent of the user interface and VFS implementation  VFS: Information in memory, part of the OS, to access and manage the files at run- time (from a process)  Contains a copy of the information in disk (metadata) to speed up the access times (c) 2013, Prof. Jordi Garcia | 23 So …

 Different devices and/or partitions can be accessed in a system  Devices: hard disks, pen drives, network units  Partitions: Set of consecutive sectors in disk (metadata and data blocks), managed as independent logic entity  Each device and/or partition has its own directory structure and FS implementation  In order to access them, they have to be mounted in the main directory tree ▪ mount –t ext2 /dev/hda1 /home (c) 2013, Prof. Jordi Garcia | 24 Mounting FS f1 bbb aaa f1.of1.c usr2 usr1 lib homebinusrdevetcmnt / bbb aaa dir2 dir3dir1 /

 Channels Table  done!  Defines the files that can be accessed by a process  Open Files Table  done!  Represents the opened files in the system  Inodes Table  done!  Contains the used files, a “copy” of the inode object ▪ And other run-time information, such as #refs ▪ Actually, inodes in memory (IT) are called vnodes, and are a superset to represent the inodes info + other FS related info  Buffer cache  new!  Contains a copy of data blocks (for any device)  Used to speed access times and facilitate sharing  Also, dentry cache with a copy of directory entries (c) 2013, Prof. Jordi Garcia | 25 Internal VFS data structures

 The open syscall receives a file name (path) as a parameter and, therefore, it has to access the VFS  Sequence of inodes and directory data blocks  Until the last inode is reached (and added to the IT, if first time) ▪ No data blocks are accessed!  1 OFT entry is added  1 CT entry is added  In case of caches, most of these disk access may be avoided or, later, reused (c) 2013, Prof. Jordi Garcia | 26 open and the VFS (1)

 If the opened file is new (create), a new line in the directory data block will be added  Create new indode (and write to the disk)  Modify directory data block  Modify directory inode (data, size)  And modify super block (list of free inodes) (c) 2013, Prof. Jordi Garcia | 27 open and the VFS (2)

 Compute number of disk accesses to execute: ▪ open(“/A/file1”, O_RDONLY); ▪ open(“/A/file2”, O_RDONLY);  Assuming: ▪ 1 inode = 1 block ▪ 1 directory = 1 block ▪ No caches of any type are used (c) 2013, Prof. Jordi Garcia | 28 Example (3) file3 file2 file1 BA / #0 #4#2 #5 #3 link to /B/file3

 The read syscall reads data blocks from disk, as long as they are not in the buffer cache  1 or more, depending on size and offset  Also, depends on whether blocks are pointed by direct or indirect indexes in the inode (c) 2013, Prof. Jordi Garcia | 29 read and the VFS

 The write syscall writes data blocks to the buffer cache (if present)  Later (periodically), data blocks from the buffer cache are written back to the disk  Assuming N blocks have to be written (depending on size and offset), special attention has to be paid to the first and last  If initial offset is not block start, then this data block has to be read before writing  If final offset is not block end, then this data block has to be read before writing  All other data blocks are written directly  Also, depends on whether blocks are pointed by direct or indirect indexes in the inode (c) 2013, Prof. Jordi Garcia | 30 write and the VFS

 Regular file  Decrements #refs and if zero removes inode + data blocks  Removes directory entry for this file  Directory  Some VFS check if directory is empty; otherwise remove recursively all files included in it  Decrements #refs and if zero removes inode + data block  Removes directory entry for this file  Soft link  Decrements #refs and if zero removes inode + data blocks ▪ Does not remove the file pointed by this link  Removes directory entry for this file  Other special files, just remove the inode (c) 2013, Prof. Jordi Garcia | 31 File deletion in the VFS

 The presence of links in a FS turns the directory tree into a directory graph  If the graph is cyclic, the OS has to control infinite loops during file access, backup, …  Different OS strategies to manage this  Cycles with soft-links are easy to manage. For instance, the backup process does not follow any soft-link  Cycles with hard-links are really difficult to manage, so ▪ Deny hard links if they cause a cycle ▪ Implement some type of mechanism to detect cycles (c) 2013, Prof. Jordi Garcia | 32 Last considerations