Introduction. Secondary Storage. File concept. File attributes

Similar documents
Secondary Storage (Chp. 5.4 disk hardware, Chp. 6 File Systems, Tanenbaum)

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

A file system is a clearly-defined method that the computer's operating system uses to store, catalog, and retrieve files.

File Layout and Directories

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

Typical File Extensions File Structure

File Systems. CS170 Fall 2018

File System: Interface and Implmentation

File. File System Implementation. File Metadata. File System Implementation. Direct Memory Access Cont. Hardware background: Direct Memory Access

File Systems. What do we need to know?

File. File System Implementation. Operations. Permissions and Data Layout. Storing and Accessing File Data. Opening a File

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

CS 537 Fall 2017 Review Session

CS6401- Operating System QUESTION BANK UNIT-IV

File Systems: Fundamentals

Operating Systems. Operating Systems Professor Sina Meraji U of T

File Systems: Fundamentals

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

Module 13: Secondary-Storage Structure

MODULE 4. FILE SYSTEM AND SECONDARY STORAGE

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

CSE380 - Operating Systems

File Management. Ezio Bartocci.

Files. File Structure. File Systems. Structure Terms. File Management System. Chapter 12 File Management 12/6/2018

Chapter 11: File System Implementation. Objectives

File Systems. File system interface (logical view) File system implementation (physical view)

CSC 453 Operating Systems

Chapter 14: Mass-Storage Systems. Disk Structure

V. Mass Storage Systems

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

File Management By : Kaushik Vaghani

Chapter 10: Mass-Storage Systems

Preview. COSC350 System Software, Fall

COMP 530: Operating Systems File Systems: Fundamentals

Disks and I/O Hakan Uraz - File Organization 1

Chapter 13: Mass-Storage Systems. Disk Scheduling. Disk Scheduling (Cont.) Disk Structure FCFS. Moving-Head Disk Mechanism

Chapter 13: Mass-Storage Systems. Disk Structure

Chapter 10: Mass-Storage Systems. Operating System Concepts 9 th Edition

CS370 Operating Systems

I/O and file systems. Dealing with device heterogeneity

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

CS3600 SYSTEMS AND NETWORKS

CS720 - Operating Systems

CSC 553 Operating Systems

File Systems Management and Examples

CS370 Operating Systems

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

File Management. Chapter 12

Today: Secondary Storage! Typical Disk Parameters!

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

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

TDDB68 Concurrent Programming and Operating Systems. Lecture: File systems

Announcements/Reminders

File Systems. Information Server 1. Content. Motivation. Motivation. File Systems. File Systems. Files

Operating Systems: Lecture 12. File-System Interface and Implementation

File systems: outline

Last Class: Memory management. Per-process Replacement

Advanced Operating Systems

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

Disk Scheduling. Based on the slides supporting the text

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

File Management 1/34

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

Table 12.2 Information Elements of a File Directory

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

Page 1. Recap: File System Goals" Recap: Linked Allocation"

412 Notes: Filesystem

Final Exam Preparation Questions

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

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

Chapter 12: File System Implementation

Chapter 4 File Systems. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

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

Computer Systems Laboratory Sungkyunkwan University

CS 4284 Systems Capstone

Chapter 1 Disk Storage, Basic File Structures, and Hashing.

19 File Structure, Disk Scheduling

Chapter 13 Disk Storage, Basic File Structures, and Hashing.

SMD149 - Operating Systems - File systems

Chapter 7: File-System

File Systems: Interface and Implementation

File Systems: Interface and Implementation

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

Chapter 14: Mass-Storage Systems

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

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

Mass Storage. 2. What are the difference between Primary storage and secondary storage devices? Primary Storage is Devices. Secondary Storage devices

File System Internals. Jo, Heeseung

Chapter 10: File System. Operating System Concepts 9 th Edition

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

ICS Principles of Operating Systems

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

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

OPERATING SYSTEMS CS136

Silberschatz, et al. Topics based on Chapter 13

Fall COMP3511 Review

Disk Scheduling. Chapter 14 Based on the slides supporting the text and B.Ramamurthy s slides from Spring 2001

UNIT V SECONDARY STORAGE MANAGEMENT

CS370 Operating Systems

Chapter 11: File System Implementation

Transcription:

Introduction Secondary storage is the non-volatile repository for (both user and system) data and programs As (integral or separate) part of an operating system, the file system manages this information on secondary storage Uses of secondary storage include storing various forms of programs (source, object, executable) and temporary storage of virtual memory pages (paging device or swap space) Information in secondary storage may be in a variety of forms, including readable text and raw data (eg, binary) Secondary Storage Secondary Storage Secondary Storage 1 File concept File attributes A file is a named collection of related information, usually as a sequence of bytes, with two views: Logical (programmer s ) view, as the users see it Physical (operating system) view, as it actually resides on secondary storage What is the difference between a file and a data structure in memory? Basically, files are intended to be non-volatile; hence in principle, they are long lasting, files are intended to be moved around (ie, copied from one place to another), accessed by different programs and users, and so on Each file is associated with a collection of information, known as attributes: NAME, owner, creator type (eg, source, data, binary) location (eg, I-node or disk address) organization (eg, sequential, indexed, random) access permissions time and date (creation, modification, and last accessed) size variety of other (eg, maintenance) information Secondary Storage 2 Secondary Storage 3

File operations File types There are six basic operations for file manipulation: create, write, read, delete, reposition r/w pointer (aka seek), and truncate (not very common) read pointer write pointer delete??? seek read write read pointer truncate E O F E O F E-O-F pointer create E-O-F pointer A common implementation technique (as organizational help with consistent usage) is to include the type as an extension to the file name: File type Extension Function Executable exe, com, bin ready-to-run code Text txt, doc textual data, documents Source c, f77, asm source in various languages Object obj, o object code Library lib, a library routines Archive tar, zip, arc grouped files Compressed Z, gz compressed Print/view ps, eps, pdf printing or viewing Word processor ppt, wp, tex various word processors Files are structured internally to meet the expectations of the program(s) that manipulate them write pointer Secondary Storage 4 Secondary Storage 5 File access methods Directories The information stored in a file can be accessed in a variety of methods: Sequential: in order, one record after another Direct (random): in any order, skipping the previous records Keyed: in any order, but with particular value(s); eg, hash table or dictionary TLB lookup is one example of a keyed search Other access methods, such as indexed, can be built on top of the above basic techniques IBM s indexed sequential access method (ISAM) is built on random and sequential access A directory is a symbol table, which can be searched for information about the files Also, it is the fundamental way of organizing files Usually, a directory is itself a file A typical directory entry contains information (attributes) about a file Directory entries are added as files are created, and are removed when files are deleted Common directory structures are: Single-level (flat): shared by all users Two-level: one level for each user Tree: arbitrary (sub)-tree for each user Secondary Storage 6 Secondary Storage 7

An example: UNIX directories UNIX uses an advanced form of tree structure, known as directed acyclic-graph (DAG) directory / Root directory bin usr lib tmp lib Basically a tree, but links convert to DAGs (no cycles!) File sharing Allowing users to share files raises a major issue: protection A general approach is to provide controlled access to files through a set of operations such as read, write, delete, list, and append Then permit users to perform one or more operations One popular protection mechanism is a condensed version of access list, where the system recognizes three classifications of users with each file and directory: user group other Libca X11newa trash /usr/lib/libca or /lib/libca Secondary Storage 8 Secondary Storage 9 File systems File system abstraction A file system provides a mapping between the logical and physical views of a file, through a set of services and an interface Simply put, the file system hides all the device-specific aspects of file manipulation from users The basic services of a file system include: keeping track of files (knowing location), I/O support, especially the transmission mechanism to and from main memory, management of secondary storage, sharing of I/O devices, providing protection mechanisms for information held on the system Interactive (Shells) Applications and system programs Devices Objects files logical elements (records) physical elements (head, cylinder, ) Typical operations copy, delete, rename open/close, buffering seek (logical) file system check soft repair partitioning raw read/write, seek (physical) low-level format Secondary Storage 1 0 Secondary Storage 1 1

Addressing levels File organization There are three basic mapping levels (abstractions) from a logical to physical view of a file (contents): File relative: <filename, offset> form is used at the higher levels, where the file system is viewed as a collection of files Volume (partition) relative: device-independent part of a file system use <sector, offset> (eg, a partition is viewed as an array of sectors) One of the key elements of a file system is the way the files are organized File organization is the logical structuring as well as the access method(s) of files Common file organization schemes are: Sequential Indexed-sequential Indexed Direct (or hashed) Drive relative: at the lowest level, <cylinder, head, sector> (also known as <track, platter, sector>) is used Secondary Storage 1 2 Secondary Storage 1 3 File allocation Contiguous allocation The file system allocates disk space, when a file is created With many files residing on the same disk, the main problem is how to allocate space for them File allocation scheme has impact on the efficient use of disk space and file access time Common file allocation techniques are: Contiguous Chained (linked) Indexed All these techniques allocate disk space on a per block (smallest addressable disk unit) basis 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 Directory name start len aout hw1c reporttex 00 3 12 6 20 11 Allocate disk space like paged, segmented memory Keep a free list of unused disk space Advantages: easy access, both sequential and random simple few seeks Disadvantages: external fragmentation may not know the file size in advance Secondary Storage 1 4 Secondary Storage 1 5

Chained (linked) allocation Indexed allocation 00 0112 02 03 04 05 06 07 08 09 10 11 1220 13 14 15 16 17 18 19 20-1 21 22 23 24 25 26 27 28 29 30 31 32 33 34 Directory name start len aout hw1c reporttex 01 3 Space allocation is similar to page frame allocation Mark allocated blocks as in-use Advantages: no external fragmentation files can grow easily Disadvantages: lots of seeking random access difficult Example: MSDOS (FAT) file system 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 13 07 21 28 11 02 Directory name index aout hw1c 17 reporttex Allocate an array of pointers during file creation Fill the array as new disk blocks are assigned Advantages: small internal fragmentation easy sequential and direct access Disadvantages: lots of seeks if the file is big maximum file size is limited to the size of a block Example: UNIX file system Secondary Storage 1 6 Secondary Storage 1 7 Free space management An example: UNIX I-nodes Since the amount of disk space is limited (posing a management problem similar to that of physical memory), it is necessary to reuse the space released by deleted files In general, file systems keep a list of free disk blocks (initially, all the blocks are free) and manage this list by one of the following techniques: Bit vectors Linked lists or chains single list of a set of free block lists Indexing single level, multiple levels Mode Link count Uid Gid Size Times Disk block 1 Disk block 2 Disk block 3 Disk block 10 Disk block 11 Disk block 12 Single indirect Double indirect Triple indirect Data Block Directory entry File name Assume data block is 1Kb, index is 32 bits Hence, 256 indices per block 12 Kb direct access + 256 Kb 1-indirect + 64 Mb 2-indirect + 16 Gb 3-indirect Data Block Data Block Secondary Storage 1 8 Secondary Storage 1 9

Other file system issues Case study UNIX file system Disk blocking multiple sectors per block for efficiency Disk (partition) layout in traditional UNIX systems Disk quotas Reliability Backup/restore (disaster scenarios) File system (consistency) check (eg, UNIX fsck) Performance Block or buffer caches (a collection of blocks kept in memory) Boot block Super block I nodes Data Blocks The boot block usually contains (bootstrap) code to boot the system The super block contains critical information about the layout of the file system, such as number of I-nodes and the number of disk blocks Each I-node entry contains the file attributes, except the name The first I-node points to the block containing the root directory of the file system Secondary Storage 2 0 Secondary Storage 2 1 Case study UNIX file system cont Case study UNIX file system cont There are three different indirection to access a file: File Descriptor Table: one per process, keeping track of open files Open File Table: one per system, keeping track of all the files currently open I-node Table: one per system (disk volume or partition) keeping track all files Directories are stored just like ordinary files User programs can read directories, but special care is needed to write a directory Each directory contains <file name, I-node number> pairs Root (ie, /) is a special directory with no name Process i (parent) Process k File Descriptor Tables Process j (child) Open File Descriptor Table R/W pointers --- --- I-node ptr I-node ptr I-node ptr Active files I-nodes I-nodes In memory On disk(s) Secondary Storage 2 2 Secondary Storage 2 3

Case study UNIX file system cont Disk structure revisited Mapping file systems to disks /bin /usr /usr2 root swap bin Surface Sectors logical file system usr Cylinder Platter Spindle Tracks usr2 file systems logical disks physical disks R/W head Secondary Storage 2 4 Secondary Storage 2 5 Disk scheduling Disk scheduling strategies In multiprogramming systems, there may be several disk I/O requests at the same time As a result, a disk driver is typically faced with a pool of I/O requests: Commonly used strategies include (in addition to some common CPU scheduling policies!): First Come First Served (FCFS) or FIFO I/O requests Disk Driver Disk Shortest Service Time First (SSTF) SCAN back and forth over disk C-SCAN circular SCAN or one way SCAN and fast return The most costly component of a disk I/O operation is the seek time By scheduling multiple disk requests, the total seek time can be reduced For example, shortest seek time first LOOK look for a request before moving in that direction C-LOOK circular LOOK Secondary Storage 2 6 Secondary Storage 2 7

A comparative example 67 124 0 14 37 53 65 98 122 183 tracks Current head position FCFS 640 tracks SSTF 2 3 6 SCAN 2 3 6 C-SCAN 3 8 2 C-LOOK 3 2 2 199 Disk management issues Formatting Physical: divide the blank slate into sectors identified by headers containing such information as sector number; sector interleaving Logical: marking bad blocks; partitioning (optional) and writing a blank directory on disk; installing file allocation tables, and other relevant information (file system initialization) Reliability disk interleaving or striping RAIDs (Redundant Array of Inexpensive Disks): various levels, eg, level 0 is disk mirroring or shadowing, consists of keeping a duplicate of each disk) Controller caches newer disks have on-disk caches (128KB 512KB) Request queue: 98, 183, 37, 122, 14, 124, 65, 67 Secondary Storage 2 8 Secondary Storage 2 9 Elements of storage management Users Access control File Structure Access methods Records Buffering Block Caches File allocation Free space management Directory management File manipulation Disk scheduling Controller Caches Secondary Storage 3 0