17
CSCI-3753: Operating Systems Fall 2019 Anh Nguyen Department of Computer Science University of Colorado Boulder

CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

CSCI-3753: Operating SystemsFall 2019

Anh NguyenDepartment of Computer Science University of Colorado Boulder

Page 2: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

Week 13: Virtual File System

CSCI 3753 Fall 2019 2

Page 3: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

•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

Page 4: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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?

Page 5: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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

Page 6: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

VFS Implementation

6

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

CSCI 3753 Fall 2019

Page 7: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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

Page 8: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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

Page 9: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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

Page 10: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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/

Page 11: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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

Page 12: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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

Page 13: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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

Page 14: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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

Page 15: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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

Page 16: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

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

Page 17: CSCI-3753: Operating Systems Fall 2019mnslab.org/.../F19_3753_Anh_Recitation_Week13.pdf · F19_3753_Anh_Recitation_Week13 Created Date: 11/22/2019 6:25:53 PM

Week 13 – Checklist

q Discuss Virtual file systemq Work on PA4

17CSCI 3753 Fall 2019