CS370 Operating Systems

Similar documents
CS370 Operating Systems

Chapter 12: File System Implementation

CS370 Operating Systems

Chapter 11: Implementing File

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

CS370 Operating Systems

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

Chapter 10: File System Implementation

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

OPERATING SYSTEM. Chapter 12: File System Implementation

Chapter 12: File System Implementation

Chapter 11: Implementing File Systems

CS3600 SYSTEMS AND NETWORKS

Chapter 12: File System Implementation

Week 12: File System Implementation

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

Chapter 7: File-System

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

OPERATING SYSTEMS II DPL. ING. CIPRIAN PUNGILĂ, PHD.

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

File Systems: Interface and Implementation

File Systems: Interface and Implementation

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

Chapter 11: File System Implementation. Objectives

TDDB68 Concurrent Programming and Operating Systems. Lecture: File systems

File Systems: Interface and Implementation

CS307: Operating Systems

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

Chapter 11: File-System Interface

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

File System & Device Drive Mass Storage. File Attributes (Meta Data) File Operations. Directory Structure. Operations Performed on Directory

Chapter 11: File System Implementation

UNIT V SECONDARY STORAGE MANAGEMENT

Chapter 10: File-System Interface. Operating System Concepts with Java 8 th Edition

Lecture 17. Edited from slides for Operating System Concepts by Silberschatz, Galvin, Gagne

F 4. Both the directory structure and the files reside on disk Backups of these two structures are kept on tapes

CS720 - Operating Systems

Chapter 9: Virtual Memory. Chapter 9: Virtual Memory. Objectives. Background. Virtual-address address Space

Chapter 9: Virtual Memory

File System: Interface and Implmentation

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

Chapter 8: Virtual Memory. Operating System Concepts

Chap 12: File System Implementa4on

File System Implementation

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

Chapter 11: File-System Interface. Operating System Concepts 9 th Edition

Chapter 11: Implementing File-Systems

Lecture 10 File Systems - Interface (chapter 10)

Chapter 12 File-System Implementation

Chapter 9: Virtual Memory

Sharing may be done through a protection scheme. Network File System (NFS) is a common distributed file-sharing method

Chapter 11: Implementing File Systems

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

ICS Principles of Operating Systems

CHAPTER 10 AND 11 - FILE SYSTEM & IMPLEMENTING FILE- SYSTEMS

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

Chapter 9: Virtual Memory

Chapter 11: File-System Interface

Chapter 9: Virtual-Memory

File Management By : Kaushik Vaghani

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

Chapter 11: File-System Interface

Chapter 3: Virtual Memory ว ตถ ประสงค. Background สามารถอธ บายข อด ในการท ระบบใช ว ธ การจ ดการหน วยความจ าแบบเสม อนได

Operating System Concepts

File System Implementation. Sunu Wibirama

Advanced Operating Systems. File Systems Lecture 9

Chapter 11: Implementing File Systems

Chapter 6 Storage Management File-System Interface 11.1

File System Internals. Jo, Heeseung

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

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory. Demand Paging

File System Management

CS370 Operating Systems

CSE325 Principles of Operating Systems. File Systems. David P. Duggan. March 21, 2013

File-System Interface. File Structure. File Concept. File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection

Chapter 11: File System Implementation

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

Operating System Concepts Ch. 11: File System Implementation

Chapter 11: Implementing File Systems

Chapter 10: Virtual Memory

Chapter 11: File-System Interface

Operating System Concepts 9 th Edition

Chapter 10: File-System Interface. Operating System Concepts 8 th Edition

Optimal Algorithm. Replace page that will not be used for longest period of time Used for measuring how well your algorithm performs

FILE SYSTEM IMPLEMENTATION. Sunu Wibirama

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

Principles of Operating Systems

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

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

Frequently asked questions from the previous class survey

Computer Systems Laboratory Sungkyunkwan University

CS307: Operating Systems

Chapter 9: Virtual Memory

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

File System Implementation

First-In-First-Out (FIFO) Algorithm

CS370 Operating Systems

File System (FS) Highlights

CS3600 SYSTEMS AND NETWORKS

OPERATING SYSTEM. Chapter 9: Virtual Memory

Transcription:

CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 24 File Systems Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1

Questions from last time How are pages shared? Include in address space of both processes Difference between logical and virtual memory: Virtual memory is the term often used when a part of physical memory is implemented in disk. Details soon 2

Page Replacement Algorithms Algorithms FIFO Optimal The Least Recently Used (LRU) Exact Implementations Time of use field, Stack Approximate implementations Reference bit Reference bit with shift register Second chance: clock Enhanced second chance: dirty or not? Other 3

Allocating Kernel Memory Treated differently from user memory Often allocated from a free-memory pool Kernel requests memory for structures of varying sizes Process descriptors, semaphores, file objects etc. Often much smaller than page size Some kernel memory needs to be contiguous I.e. for device I/O approaches (skipped) 4

Other Considerations -- Prepaging Prepaging To reduce the large number of page faults that occurs at process startup Prepage all or some of the pages a process will need, before they are referenced But if prepaged pages are unused, I/O and memory was wasted Assume s pages are prepaged and fraction α of the pages is used Is cost of s * α saved pages faults > or < than the cost of prepaging s * (1- α) unnecessary pages? α near zero greater prepaging loses 5

Other Issues Page Size Sometimes OS designers have a choice Especially if running on custom-built CPU Page size selection must take into consideration: Fragmentation Page table size I/O overhead Number of page faults Locality TLB size and effectiveness Always power of 2, usually in the range 2 12 (4,096 bytes) to 2 22 (4,194,304 bytes) On average, growing over time 6

Page size issues TLB Reach TLB Reach - The amount of memory accessible from the TLB TLB Reach = (TLB Size) X (Page Size) Ideally, the working set of each process is stored in the TLB Otherwise there is a high degree of page faults 7

Other Issues Program Structure Program structure int[128,128] data; i: row, j: column Each row is stored in one page Program 1 for (j = 0; j <128; j++) for (i = 0; i < 128; i++) multiple pages data[i,j] = 0; 128 x 128 = 16,384 page faults Program 2 inner loop = 1 row = 1 page for (i = 0; i < 128; i++) for (j = 0; j < 128; j++)same page data[i,j] = 0; 128 page faults 8

Other Issues I/O interlock I/O Interlock Pages must sometimes be locked into memory Consider I/O - Pages that are used for copying a file from a device must be locked from being selected for eviction by a page replacement algorithm Pinning of pages to lock into memory 9

Windows Uses demand paging with clustering. Clustering brings in pages surrounding the faulting page Processes are assigned working set minimum and working set maximum Working set minimum is the minimum number of pages the process is guaranteed to have in memory A process may be assigned as many pages up to its working set maximum When the amount of free memory in the system falls below a threshold, automatic working set trimming is performed to restore the amount of free memory Working set trimming removes pages from processes that have pages in excess of their working set minimum 10

CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 24 File-system Interface Slides based on Text by Silberschatz, Galvin, Gagne Various sources 11 11

Chapter 11: File-System Interface File Concept Access Methods Disk and Directory Structure File-System Mounting File Sharing Protection 12

13 File Systems

Outline File Concept, types Attributes, Access Methods, operations, Protection Directory Structure, namespace, File-System Mounting, File Sharing Next in File System Implementation Storage abstraction: File system metadata (size, freelists), File metadata(attributes, disk block maps), datablocks Allocation of blocks to files: contiguous, sequential, linked list allocation, indexed In memory info: Mount table, directory structure cache, open file table, buffers Unix: inodes numbers for directories and files 14

File types Type used by programs not OS 15

File Attributes Name only information kept in human-readable form Identifier unique tag (number) identifies file within file system Type needed for systems that support different types Location pointer to file location on device Size current file size Protection controls who can do reading, writing, executing Time, date, and user identification data for protection, security, and usage monitoring Information about files are kept in the directory structure, which is maintained on the disk Many variations, including extended file attributes such as file checksum 16

Disk Structure Disk can be subdivided into partitions Disks or partitions can be RAID protected against failure Partition can be formatted with a file system Entity containing file system known as a volume Each volume containing file system also tracks that file system s info in device directory or volume table of contents As well as general-purpose file systems there are many special-purpose file systems, frequently all within the same operating system or computer 17

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 files reside on disk 18

Operations Performed on Directory Traverse the file system List a directory Search for a file Create/Delete/Rename a file 19

Directory Organization The directory is organized logically to obtain Efficiency locating a file quickly Naming convenient to users Two users can have same name for different files The same file can have several different names Grouping logical grouping of files by properties, (e.g., all Java programs, all games, ) 20

Directory Organization Single level directory Two-level directory Tree-structured directories: efficient grouping, searching, absolute or relative path names Acyclic graph directories Shared sub-directory, files 21

File System Mounting A file system must be mounted before it can be accessed A unmounted file system is mounted at a mount point Merges the file system 22

File Sharing Sharing of files on multi-user systems is desirable Sharing may be done through a protection scheme On distributed systems, files may be shared across a network Network File System (NFS) is a common distributed file-sharing method If multi-user system User IDs identify users, allowing permissions and protections to be per-user Group IDs allow users to be in groups, permitting group access rights Owner of a file / directory Group of a file / directory 23

Protection: Access Lists and Groups Mode of access: read, write, execute Three classes of users on Unix / Linux RWX a) owner access 7 1 1 1 RWX b) group access 6 1 1 0 RWX c) public access 1 0 0 1 Ask manager to create a group (unique name), say G, and add some users to the group. For a particular file (say game) or subdirectory, define an appropriate access. Attach a group to a file chgrp G game 25

26 Windows 7 Access-Control List Management

27 A Sample UNIX Directory Listing

CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2016 Lecture 38+ File-system Implementation Slides based on Text by Silberschatz, Galvin, Gagne Various sources 28 28

Chap 12: File System Implementation File-System Structure File-System Implementation Directory Implementation Allocation Methods Free-Space Management Efficiency and Performance Recovery 29

File-System Structure File structure Logical storage unit Collection of related information File system resides on secondary storage (disks/ssd) Provides user interface to storage, mapping logical to physical Provides efficient and convenient access to disk by allowing data to be stored, located retrieved easily Can be on other media (flash etc), with different file system Disk provides in-place rewrite and random access I/O transfers performed in blocks of sectors (usually 512 bytes) File control block storage structure -information about a file ( inode in Linux) inc location of data Device driver controls the physical device 30

Layered File System Files, metadata File system Logical blocks to physical blocks Linear array of blocks Device drivers 31

File System Layers (from bottom) Device drivers manage I/O devices at the I/O control layer Given commands like read drive1, cylinder 72, track 2, sector 10, into memory location 1060 outputs low-level hardware specific commands to hardware controller Basic file system given command like retrieve block 123 translates to device driver Also manages memory buffers and caches (allocation, freeing, replacement) Buffers hold data in transit Caches hold frequently used data File organization module understands files, logical address, and physical blocks - Translates logical block # to physical block # - Manages free space, disk allocation 33

File System Layers (Cont.) Logical file system manages metadata information Translates file name into file number, file handle, location by maintaining file control blocks (inodes in UNIX) Directory management Protection 34

File Systems Many file systems, sometimes several within an operating system Each with its own format Windows has FAT (1977), FAT32 (1996), NTFS (1993) Linux has more than 40 types, with extended file system (1992) ext2 (1993), ext3 (2001), ext4 (2008); plus distributed file systems floppy, CD, DVD Blu-ray New ones still arriving ZFS, GoogleFS, Oracle ASM, FUSE, xfat (USB/SD cards) 35

Data and Metadata Storage abstraction: File system metadata (size, free lists), File metadata (attributes, disk block maps), Data blocks 36

OS File Data Structures Open file table - shared by all processes with an open file. open count file attributes, including ownership, protection information, access times,... location(s) of file on disk pointers to location(s) of file in memory Per-process file descriptor table - for each file, pointer to entry in the open file table FD: int current position in file (offset) mode in which the process will access the file (r, w, rw) pointers to file buffer 37

File System Max File Size Common File Systems Max Partition Size Journaling Notes Journaling: keeps track of changes not yet committed: allows recovery Fat32 4 GiB 8 TiB No Commonly supported ExFAT 128 PiB 128 PiB No Optimized for flash NTFS 2 TiB 256 TiB Yes For Windows Compatibility ext2 2 TiB 32 TiB No Legacy ext3 2 TiB 32 TiB Yes Standard linux filesystem for many years. ext4 16 TiB 1 EiB Yes Modern iteration of ext3. 38

File-System Implementation Based on several on-disk and in-memory structures. On-disk Boot control block (per volume) boot block in unix Volume control block (per volume) master file table in UNIX Directory structure (per file system) file names and pointers to corresponding FCBs File control block (per file) inode in unix In-memory Mount table about mounted volumes The open-file tables (system-wide and per process) Directory structure cache Buffers of the file-system blocks Volume: logical disk drive, perhaps a partition 39

On-disk File-System Structures 1. Boot control block contains info needed by system to boot OS from that volume Needed if volume contains OS, usually first block of volume Volume: logical disk drive, perhaps a partition 2. Volume control block (superblock ext or master file tablentfs) contains volume details Total # of blocks, # of free blocks, block size, free block pointers or array 3. Directory structure organizes the files File Names and inode numbers UFS, master file table NTFS Boot block Super block Directory, FCBs File data blocks 40

File-System Implementation (Cont.) 4. Per-file File Control Block (FCB or inode ) contains many details about the file Indexed using inode number; permissions, size, dates UFS (unix file system) master file table using relational DB structures NTFS 41

Create a file Allocates a new FCB. Update directory Reads the appropriate directory into memory, in unix a directory is a file with special type field up-dates it with the new file name and FCB, writes it back to the disk. 42

Partitions and Mounting Partition can be a volume containing a file system (cooked) or raw just a sequence of blocks with no file system perhaps for swap space Boot block can point to boot volume or boot loader set of blocks that contain enough code to know how to load the kernel from the file system Root partition contains the OS, Mounted at boot time other partitions can hold other OSes, other file systems, or be raw Other partitions can mount automatically or manually At mount time, file system consistency checked 43

Virtual File Systems Virtual File Systems (VFS) on Unix provide an objectoriented way of implementing file systems VFS allows the same system call interface (the API) to be used for different types of file systems The API (POSIX system calls) is to the VFS interface, rather than any specific type of file system Virtual to specific FS interface 44

Directory Implementation Linear list of file names with pointer to the data blocks Simple to program Time-consuming to execute Linear search time Could keep ordered alphabetically via linked list or use B+ tree Hash Table linear list with hash data structure Decreases directory search time Collisions situations where two file names hash to the same location. use chained-overflow method Each hash entry can be a linked list instead of an individual value. 45