csci-3753: operating systems fall 2019mnslab.org/.../f19_3753_anh_recitation_week13.pdf ·...

Post on 03-Oct-2020

0 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CSCI-3753: Operating SystemsFall 2019

Anh NguyenDepartment of Computer Science University of Colorado Boulder

Week 13: Virtual File System

CSCI 3753 Fall 2019 2

•Control how data is stored and retrieved•Types of file system• Local data storage• NTFS, FAT16, FAT32, exFAT• ext2, ext3, ext4, jfs, …• ISO 9660 • CDFS• Removable USB flash drive (UFD)• …

•Network data storage• NFS• Plan 9• …

File System

3CSCI 3753 Fall 2019

How to check out what filesystems are on your machine?à df -T

How to check out the partitioning table on your machine?à sudo parted -l

File System

4CSCI 3753 Fall 2019

Hard drive CD-ROM NIC USB Stick

Block Layer / Device Drivers

Abstraction layer (VFS)

ext3 NTFS CDFS NFS UFS

User

System Call Interface

QuestionHow to bridge the differences in Windows, Mac OS, and Unix file systems so that applications can access files on local file systems of those types without having to know what type of file system they are accessing?

Virtual File System

5

•An abstraction layer on top of a more concrete file system•Purpose: • To allow client applications to access different types of

concrete file systems in a uniform way• To manage all of the different file systems that are mounted

at any given time•Method:• Provide a set of standard interfaces for upper-layer

applications to perform file I/O over a diverse set of file systems• Describe the system's files in terms of superblocks and inodes

CSCI 3753 Fall 2019

VFS Implementation

6

•Major objects• Superblock• Index nodes (or inodes)• Directory entries (or dentries)• File objects

CSCI 3753 Fall 2019

VFS Implementation

7

•Major objects• Superblock• Index nodes (or inodes)• Directory entries (or dentries)• File objects

• Auxiliary objects• Filesystem types• Struct vfsmount• Struct nameidata• Struct address_space

CSCI 3753 Fall 2019

VFS Implementation

8

•Superblock: • A container for essentially high-level metadata about a

file system• A critical structure that • exists on disk and also in memory • is stored in multiple redundant copies for each file system

• Provide the basis for dealing with the on-disk file system, as it defines the file system's managing parameters• File system type• File system size• File system status• Information about other metadata structures (metadata of

metadata)

CSCI 3753 Fall 2019

VFS Implementation

9

• Index node (inode) – 1:• An object through which Linux uses to manage a bunch of

attributes about all objects in a file system• Stored permanently

CSCI 3753 Fall 2019

VFS Implementation

10

• Index node (inode) – 2:• Stores information like • File type - regular file, directory, character device, etc• Owner• Group• Access permissions• Timestamps - mtime (time of last file modification), ctime

(time of last attribute change), atime (time of last access)• Number of hardlinks to the file• Size of the file• Number of blocks allocated to the file• Pointers to the data blocks of the file - most important!

CSCI 3753 Fall 2019

How to check view inode number?à ls -lià stat ~/Desktop/

VFS Implementation

11

• Index node (inode) – 3:•When are inodes created?• When a filesystem is created, the space for inodes is allocated

as well. • Determining how much inode space needed depends on the

volume of the disk and more.• Rare but possible to happen: errors for out of inodes !!!à Unable to create more files

CSCI 3753 Fall 2019

VFS Implementation

12

• Index node (inode) – 4:• How do inodes locate files?

CSCI 3753 Fall 2019

Illustration of a file system

15 p

oint

ers

12 p

oint

ers

VFS Implementation

13

•Directory entry (dentry) – 1:• A glue that holds inodes and files together by relating

inode numbers to file names• Also play a role in directory caching which, ideally, keeps

the most frequently used files on-hand for faster access. •Maintain a relationship between directories and their

files for file system traversal

• The dentry objects exist only in file system memory and are not stored on disk as they are used to improve performance only.

CSCI 3753 Fall 2019

VFS Implementation

14

•Directory entry (dentry) – 2:• A file system will have one root dentryà Superblockà The only dentry without a parent. • All other dentries have parents, and some have children.

• How many dentry objects are created if the following file is opened?

/home/user/name

CSCI 3753 Fall 2019

VFS Implementation

15

•File object:• For each opened file in a Linux system, a file object exists. • Contain information specific to the opening instance for a

given user•Where the file is stored •What processes are using it• …

• Thrown away when the file is closed

CSCI 3753 Fall 2019

Object Relationship

16CSCI 3753 Fall 2019

super_block object

inode object

dentry object

inode object

dentry object

dentry object

file object file object file object

vfsmount

Week 13 – Checklist

q Discuss Virtual file systemq Work on PA4

17CSCI 3753 Fall 2019

top related