Frequently asked questions from the previous class survey

Similar documents
CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Frequently asked questions from the previous class survey

Frequently asked questions from the previous class survey

CS370 Operating Systems

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

Frequently asked questions from the previous class survey

Frequently asked questions from the previous class survey

e-pg Pathshala Subject: Computer Science Paper: Operating Systems Module 35: File Allocation Methods Module No: CS/OS/35 Quadrant 1 e-text

Outlook. File-System Interface Allocation-Methods Free Space Management

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370 Operating Systems

FILE SYSTEM IMPLEMENTATION. Sunu Wibirama

Introduction to OS. File Management. MOS Ch. 4. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

File System Implementation. Sunu Wibirama

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

Chapter 11: Implementing File Systems. Operating System Concepts 8 th Edition,

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

UNIX File Systems. How UNIX Organizes and Accesses Files on Disk

File System CS170 Discussion Week 9. *Some slides taken from TextBook Author s Presentation

Chapter 14: File-System Implementation

CS3600 SYSTEMS AND NETWORKS

File System Internals. Jo, Heeseung

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

Chapter 11: File System Implementation. Objectives

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Frequently asked questions from the previous class survey

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

CHAPTER 11: IMPLEMENTING FILE SYSTEMS (COMPACT) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

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

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

File System: Interface and Implmentation

CS370: Operating Systems [Spring 2016] Dept. Of Computer Science, Colorado State University

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

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

Preview. COSC350 System Software, Fall

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

Computer Systems Laboratory Sungkyunkwan University

Chapter 12: File System Implementation

File Directories Associated with any file management system and collection of files is a file directories The directory contains information about

Motivation. Operating Systems. File Systems. Outline. Files: The User s Point of View. File System Concepts. Solution? Files!

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

Chapter 11: Implementing File Systems

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

Frequently asked questions from the previous class survey

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

Operating Systems. Lecture File system implementation. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Frequently asked questions from the previous class survey

Operating Systems. Operating Systems Professor Sina Meraji U of T

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

File System. Preview. File Name. File Structure. File Types. File Structure. Three essential requirements for long term information storage

Chapter 11: Implementing File

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

File Systems: Interface and Implementation

File Systems: Interface and Implementation

File Systems: Interface and Implementation

Frequently asked questions from the previous class survey

File Management By : Kaushik Vaghani

Files & I/O. Today. Comp 104: Operating Systems Concepts. Operating System An Abstract View. Files and Filestore Allocation

Principles of Operating Systems

File Systems. Kartik Gopalan. Chapter 4 From Tanenbaum s Modern Operating System

CSE 4/521 Introduction to Operating Systems. Lecture 23 File System Implementation II (Allocation Methods, Free-Space Management) Summer 2018

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

File-System Structure. Allocation Methods. Free-Space Management. Directory Implementation. Efficiency and Performance. Recovery

Advanced Operating Systems

CS370 Operating Systems

Main Points. File layout Directory layout

Frequently asked questions from the previous class survey

CS370: Operating Systems [Spring 2016] Dept. Of Computer Science, Colorado State University

Chapter 10: File System Implementation

CS370 Operating Systems

CS 4284 Systems Capstone

CS 550 Operating Systems Spring File System

makes floppy bootable o next comes root directory file information ATTRIB command used to modify name

Chapter 12: File System Implementation. Operating System Concepts 9 th Edition

Operating System Concepts Ch. 11: File System Implementation

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

Chapter 12: File System Implementation

There is a general need for long-term and shared data storage: Files meet these requirements The file manager or file system within the OS

File Systems. CS170 Fall 2018

V. File System. SGG9: chapter 11. Files, directories, sharing FS layers, partitions, allocations, free space. TDIU11: Operating Systems

Chapter 7: File-System

Chapter 11: Implementing File-Systems

ICS Principles of Operating Systems

Week 12: File System Implementation

Workloads. CS 537 Lecture 16 File Systems Internals. Goals. Allocation Strategies. Michael Swift

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

OPERATING SYSTEM. Chapter 12: File System Implementation

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

File Systems. CS 4410 Operating Systems. [R. Agarwal, L. Alvisi, A. Bracy, M. George, E. Sirer, R. Van Renesse]

OPERATING SYSTEMS CS136

Chapter 11: Implementing File Systems

Operating Systems. File Systems. Thomas Ropars.

File Management. Chapter 12

Chapter 12: File System Implementation

Transcription:

CS 370: OPERATING SYSTEMS [FILE SYSTEMS] Shrideep Pallickara Computer Science Colorado State University L28.1 Frequently asked questions from the previous class survey How are files recovered if the drive is accidentally formatted? Are file systems optimized for the storage type? BIOS and UEFI: BIOS will disappear in 2020 Unified Extensible Firmware Interface (UEFI) Spec in 2007 Difference between data and information Does the OS manage fragmentation when reading/writing data? Who manages the actual writes at the end? OS or device? L28.2 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.1

Topics covered in this lecture Block Allocations Contiguous allocations Linked allocations Indexed allocations n inodes Free space management Memory mapped files L28.3 Allocation methods: Objective and approaches How to allocate space for files such that: Disk space is utilized effectively is accessed quickly Major Methods Contiguous Linked Indexed L28.4 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.2

What s in a name? That which we call a rose By any other name would smell as sweet. Juliet Romeo and Juliet (II, ii, 1-2) (Shakespeare) NOMENCLATURE L28.5 Terminology Storage hardware arranges data in sectors (for magnetic disk) or pages (for flash) systems often group together a fixed number of disk sectors or flash pages into a larger allocation unit called a. E.g.: format file system to run on a disk with 512b sectors to use 4 KB s Windows FAT and NTFS refer to s as clusters Control Block (FCBs) organize info about s comprising a file inode in UFS and MFT Record in NTFS; Master Table (MFT) L28.6 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.3

CONTIGUOUS ALLOCATIONS L28.7 Contiguous Allocation Each file occupies a set of contiguous s on the disk If file is of size n s and starts at location b n Occupies s b, b+1,, b+n-1 Disk head movements None for moving from b to (b+1) Only when moving to a different track L28.8 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.4

Sequential and direct access in contiguous allocations Sequential accesses Remember disk address of the last referenced When needed, read the next Direct access to i of file that starts at b? b + i L28.9 Contiguous allocations suffer from external fragmentation Free space is broken up into chunks Space is fragmented Largest continuous chunk may be insufficient for meeting request Compaction is very slow on large disks Needs several hours L28.10 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.5

Determining how much space is needed for a file is another problem Preallocate if eventual size of file is known? Inefficient if the file grows very slowly n Much of the allocated space is unused for a long time Modified contiguous allocation scheme Allocate space in a continuous chunk initially When space runs out allocate another set of chunks (extent) L28.11 LINKED ALLOCATIONS L28.12 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.6

Linked Allocation: Each file is a linked list of disk s Pointer to next A Physical 0 4 1 7 2 2 3 10 4 12 Physical 0 6 1 3 2 11 B 3 14 L28.13 Linked List Allocations: Advantages Every disk can be used No space is lost in external fragmentation Sufficient for directory entry to merely store disk address of first Rest can be found starting there L28.14 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.7

Linked List Allocation: Disadvantages Used effectively only for sequential accesses Extremely slow random access Space in each set aside for pointers Each file requires slightly more space Reliability What if a pointer is lost or damaged? L28.15 Linked List Allocations: Reading and writing files is much less efficient Amount of data storage in is no longer a power of two Pointer takes up some space Peculiar size is less efficient Programs read/write in s that is a power of two L28.16 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.8

Linked list allocation: Take pointers from disk and put in table 0 1 2 3 4 5 6 7 8 9 10 11 12 13 10 11 7 3 2 12 14 EOF 0 4 1 7 2 2 3 10 Table tracks EVERY disk in the system 4 12 L28.17 Linked list allocation using an index Entire disk is available for data Random access is much easier Chain must still be followed n But this chain could be cached in memory MS-DOS and OS/2 operating systems Use such a file allocation table (FAT) L28.18 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.9

Linked list allocation using an index: Disadvantages Table must be cached in memory for efficient access A large disk will have a large number of data s Table consumes a large amount of physical memory L28.19 INDEXED ALLOCATIONS L28.20 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.10

Indexed allocations Bring all pointers together into one location index Each file has its own index Directory contains address of the index L28.21 Indexed allocation supports direct access without external fragmentation Every disk can be utilized No external fragmentation Space wasted by pointers is generally higher than linked listed allocations Example: has two s n Linked listed allocations: 2 pointers are utilized n Indexed allocations: Entire index must be allocated L28.22 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.11

inodes L28.23 inode Fixed-length data structure One per file Contains information about attributes n Size, owner, creation/modification time etc. Disk addresses n s that comprise file L28.24 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.12

inode The inode is used to encapsulate information about a large number of file s. For e.g. Block size = 8 KB, and file size = 8 GB There would be a million file-s n inode will store info about the pointers to these s inode allows us to access info for all these s n Storing pointers to these file s also takes up storage L28.25 Managing information about data s in the inode: The first few pointers to the data s of the file stored in the inode If the file is large: Indirect pointer To a of pointers that point to additional data s If the file is larger: Double indirect pointer Pointer to a of indirect pointers If the file is huge: Triple indirect pointer Pointer to a of double-indirect pointers L28.26 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.13

Schematic structure of the inode Attributes: Size (bytes) Owner UID/GID Relevant times Link and Block counts Permissions Address of disk Direct pointers to first few file s Single indirect pointer Double indirect pointer Triple indirect pointer Pointers to next file s L28.27 i-node: How the pointers to the file s are organized i-node Attributes Single indirect Double indirect Triple indirect L28.28 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.14

Disk Layout in traditional UNIX systems Boot Block Super Block i-nodes Data Blocks... An integral number of inodes fit in a single data L28.29 Super Block describes the state of the file system Total size of partition Block size and number of disk s Number of inodes List of free s inode number of the root directory Destruction of super? Will render file system unreadable L28.30 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.15

A linear array of inodes follows the data inodes are numbered from 1 to some max Each inode is identified by its inode number inode number contains info needed to locate inode on the disk Users think of files as filenames UNIX thinks of files in terms of inodes L28.31 UNIX directory structure Contains only file names and the corresponding inode numbers i-node Number name Use ls i to retrieve inode numbers of the files in the directory L28.32 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.16

Directory entry, inode and data for a simple file i-node Number 12345 inode 12345.. 1 23567 name name1 Block 23567 Fragment of the text in the file.. L28.33 Looking up path names in UNIX Example: /usr/tom/mbox Root directory 1. 1.. 4 bin 7 dev 14 lib 9 etc 6 usr 8 tmp Looking up usr yields i-node 6 i-node 6 is for /usr Mode, size.. attributes 132 i-node 6 says that /usr is in 132 Block 132 is /usr directory 6. 1.. 19 dick 30 eve 51 jim 26 tom 45 zac /usr/tom is in i-node 26 i-node 26 is /usr/tom Mode, size.. attributes 406 i-node 26 says that /usr/tom is in 406 Block 406 is /usr/tom dir 26. 6.. 64 grants 92 dev 60 mbox 81 docs 17 src /usr/tom/mbox is in i-node 60 L28.34 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.17

Advantages of directory entries that have name and inode information Changing filename only requires changing the directory entry Only 1 physical copy of file needs to be on disk may have several names (or the same name) in different directories Directory entries are small Most file info is kept in the inode L28.35 Two hard links to the same file Directory entry in /dira i-node name 12345 name1.. 1 23567 Block 23567 Fragment of the text in the file.. inode 12345 L28.36 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.18

Two hard links to the same file Directory entry in /dira i-node name 12345 name1 Directory entry in /dirb i-node name 12345 name2.. 2 23567 Block 23567 Fragment of the text in the file.. inode 12345 L28.37 with a symbolic link Directory entry in /dira i-node name 12345 name1 Directory entry in /dirb i-node name 13579 name2.. 1 23567.. inode 12345 Block 23567 Fragment of the text in the file.. 1.. 15213 inode 13579 /dira/name1 Block 15213 L28.38 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.19

Maximum size of your hard disk (8 KB s and 32-bit pointers) 32-bit pointers can address 2 32 s At 8 KB per- Hard disk can be 2 13 x 2 32 = 2 45 bytes (32 TB) L28.39 The case for larger sizes Larger partitions for a fixed pointer size Retrieval is more efficient Better system throughput Problem Internal fragmentation L28.40 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.20

Limitations of a file system based on inodes must fit in a single disk partition Partition size and number of files are fixed when system is set up L28.41 inode preallocation and distribution inodes are preallocated on a volume Even on empty disks % of space lost to inodes Preallocating inodes and spreading them Improves performance Keep file s data close to its inode Reduce seek times L28.42 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.21

Checking up on the inodes: The df i command (disk free) inode statistics for a given set of file systems Total, free and used inodes L28.43 inode: A quantitative look BLOCK Size = 8 KB and Pointers = 4 bytes Attributes: 68 bytes 128 bytes Direct pointers to first few file s Single indirect pointer Double indirect pointer Triple indirect pointer 128 68 12 =48 Number of direct pointers? 48/4 = 12 3x4 = 12 bytes L28.44 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.22

inode: A quantitative look BLOCK Size = 8 KB and Pointers = 4 bytes 12 direct pointers to file s Each file = 8KB Size of file that can be represented with direct pointers 12 x 8 KB = 96 KB L28.45 inode i-node Attributes Single indirect Double indirect Triple indirect L28.46 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.23

inode: A quantitative look BLOCK Size = 8 KB and Pointers = 4 bytes Block size = 8 KB Single indirect = size = 8 KB (8192 bytes) Number of pointers held in a single-indirect- Block-size/Pointer-size 8192/4 = 2048 With single-indirect pointer Additional 2048 x 8 KB = 2 11 x 2 3 x 2 10 = 2 24 (16 MB) of a file can be addressed L28.47 inode i-node Attributes Single indirect Double indirect Triple indirect L28.48 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.24

inode: A quantitative look BLOCK Size = 8 KB and Pointers = 4 bytes With a double indirect pointer in the inode The double-indirect has 2048 pointers n Each pointer points to a different single-indirect- n So, there are 2048 single-indirect s Each single-indirect has 2048 pointers to file s Double indirect addressing allows the file to have an additional size of 2048 x 2048 x 8 KB = 2 11 x 2 24 = 2 35. (32 GB) L28.49 inode: A quantitative look BLOCK Size = 8 KB and Pointers = 4 bytes Triple indirect addressing Triple indirect points to 2048 double indirect s Each double indirect points to 2048 single indirect Each single direct points to 2048 file s Allows the file to have an additional size of 2048 x 2048 x 2048 x 8 KB = 2 11 x 2 35 = 2 46 (64 TB) L28.50 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.25

Limits of triple indirect addressing In our example: There can be 2048 x 2048 x 2048 data s i.e., 2 11 x 2 11 x 2 11 = 2 33 Pointers would need to be longer than 32-bits to fully address this storage L28.51 What if we increase the size of the pointers to 64-bits (data is still 8 KB)? What is the maximum size of the file that we can hold? 8 KB data can hold (8192/8) = 1024 pointers Single indirect can add 1024 x 8 KB = 2 10 x 2 3 x 2 10 = 2 23 (8MB) of additional bytes to the file L28.52 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.26

What if we increase the size of the pointers to 64-bits (data is still 8 KB)? Double indirect addressing allows the file to have an additional size of 1024 x 1024 x 8 KB = 2 10 x 2 23 = 2 33. (8 GB) Triple indirect addressing allows the file to have an additional size of 1024 x 1024 x 1024 x 8 KB = 2 10 x 2 33 = 2 43 (8 TB) L28.53 The contents of this slide-set are based on the following references Avi Silberschatz, Peter Galvin, Greg Gagne. Operating Systems Concepts, 9 th edition. John Wiley & Sons, Inc. ISBN-13: 978-1118063330. [Chapter 11] Andrew S Tanenbaum amd Herbert Bos. Modern Operating Systems. 4 th Edition, 2014. Prentice Hall. ISBN: 013359162X/ 978-0133591620. [Chapter 4] Kay Robbins & Steve Robbins. Unix Systems Programming, 2nd edition, Prentice Hall ISBN-13: 978-0-13-042411-2. [Chapter 4] Thomas Anderson and Michael Dahlin. Operating Systems Principles and Practice. 2nd Edition. Recursive Books. ISBN: 978-0985673529. [Chapter 12] L28.54 SLIDES CREATED BY: SHRIDEEP PALLICKARA L28.27