176
Linux Virtual File System The linux VFS and FUSE - Filesystem in User Space Andre Petris Esteve - [email protected] Zhenlei Ji - [email protected] MC806 - Operational System Topics October 20th, 2011

Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux Virtual File SystemThe linux VFS and FUSE - Filesystem in User Space

Andre Petris Esteve - [email protected] Ji - [email protected]

MC806 - Operational System Topics

October 20th, 2011

Page 2: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Agenda

1 Objectives

2 Overview

3 Core Elements

4 Operation example

5 Getting conFUSEed

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 2 / 44

Page 3: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Agenda1 Objectives2 Overview3 Core Elements

file system typevfsmountsuper blockinodedentry

Dentry cacheHard link vs Symbolic link

file object4 Operation example

Mount5 Getting conFUSEed

What is FUSE?FUSE Architecture

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 3 / 44

Page 4: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Objectives

What do we want?

View the Linux’s Virtual Filesystem as a series of object orientedentities (classes and objects)1

Construct UML models to easy understanding

Provide initial information so one can start developing a filesystemmodule for the Linux kernel

1Althought the linux kernel is written in C, it’s possible to profit from some objectoriented features through programming tricks. For further details see: OOC, AxelSchreiner

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 4 / 44

Page 5: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Objectives

What do we want?

View the Linux’s Virtual Filesystem as a series of object orientedentities (classes and objects)1

Construct UML models to easy understanding

Provide initial information so one can start developing a filesystemmodule for the Linux kernel

1Althought the linux kernel is written in C, it’s possible to profit from some objectoriented features through programming tricks. For further details see: OOC, AxelSchreiner

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 4 / 44

Page 6: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Objectives

What do we want?

View the Linux’s Virtual Filesystem as a series of object orientedentities (classes and objects)1

Construct UML models to easy understanding

Provide initial information so one can start developing a filesystemmodule for the Linux kernel

1Althought the linux kernel is written in C, it’s possible to profit from some objectoriented features through programming tricks. For further details see: OOC, AxelSchreiner

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 4 / 44

Page 7: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Warning

Please note!

All information here is based extensively on linux kernel 3.1-rc8 sourcecode1

Some models are represented at a certain level of abstraction and mayomit some implementation information

1You can easily find something in the kernel source code using this tools:http://lxr.linux.no/linux

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 5 / 44

Page 8: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Warning

Please note!

All information here is based extensively on linux kernel 3.1-rc8 sourcecode1

Some models are represented at a certain level of abstraction and mayomit some implementation information

1You can easily find something in the kernel source code using this tools:http://lxr.linux.no/linux

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 5 / 44

Page 9: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Agenda1 Objectives2 Overview3 Core Elements

file system typevfsmountsuper blockinodedentry

Dentry cacheHard link vs Symbolic link

file object4 Operation example

Mount5 Getting conFUSEed

What is FUSE?FUSE Architecture

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 6 / 44

Page 10: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What’s Linux’s Virtual Filesystem

Definition

The Virtual File System (also known as the Virtual Filesystem Switch) isthe software layer in the kernel that provides the filesystem interface touserspace programs. It also provides an abstraction within the kernelwhich allows different filesystem implementations to coexist. 1

1Overview of the Linux Virtual File System, Richard Gooch, from Linux”documentation”

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 7 / 44

Page 11: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 8 / 44

Page 12: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

• Abstraction layer to allow different fs1 to coexist

• Only point of access to fs calls

• Implements common fs operations

− Common initialization operations− Mounting (at a certain level) and managing mount points− Path look-up− Caching

1Short for ”filesystem”Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 9 / 44

Page 13: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

• Abstraction layer to allow different fs1 to coexist

• Only point of access to fs calls

• Implements common fs operations

− Common initialization operations− Mounting (at a certain level) and managing mount points− Path look-up− Caching

1Short for ”filesystem”Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 9 / 44

Page 14: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

• Abstraction layer to allow different fs1 to coexist

• Only point of access to fs calls

• Implements common fs operations

− Common initialization operations− Mounting (at a certain level) and managing mount points− Path look-up− Caching

1Short for ”filesystem”Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 9 / 44

Page 15: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

• Abstraction layer to allow different fs1 to coexist

• Only point of access to fs calls

• Implements common fs operations

− Common initialization operations

− Mounting (at a certain level) and managing mount points− Path look-up− Caching

1Short for ”filesystem”Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 9 / 44

Page 16: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

• Abstraction layer to allow different fs1 to coexist

• Only point of access to fs calls

• Implements common fs operations

− Common initialization operations− Mounting (at a certain level) and managing mount points

− Path look-up− Caching

1Short for ”filesystem”Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 9 / 44

Page 17: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

• Abstraction layer to allow different fs1 to coexist

• Only point of access to fs calls

• Implements common fs operations

− Common initialization operations− Mounting (at a certain level) and managing mount points− Path look-up

− Caching

1Short for ”filesystem”Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 9 / 44

Page 18: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

• Abstraction layer to allow different fs1 to coexist

• Only point of access to fs calls

• Implements common fs operations

− Common initialization operations− Mounting (at a certain level) and managing mount points− Path look-up− Caching

1Short for ”filesystem”Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 9 / 44

Page 19: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

How is a filesystem implemented?

With loadable kernel modules1 (LKM), or just modules for short.

• It’s possible to compile a LKM with the base kernel

• Or just load the LKM during system usage

1For an extensive discussion about LKM, see:http://www.tldp.org/HOWTO/Module-HOWTO/

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 10 / 44

Page 20: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

How is a filesystem implemented?

With loadable kernel modules1 (LKM), or just modules for short.

• It’s possible to compile a LKM with the base kernel

• Or just load the LKM during system usage

1For an extensive discussion about LKM, see:http://www.tldp.org/HOWTO/Module-HOWTO/

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 10 / 44

Page 21: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Overview

How is a filesystem implemented?

With loadable kernel modules1 (LKM), or just modules for short.

• It’s possible to compile a LKM with the base kernel

• Or just load the LKM during system usage

1For an extensive discussion about LKM, see:http://www.tldp.org/HOWTO/Module-HOWTO/

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 10 / 44

Page 22: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Agenda1 Objectives2 Overview3 Core Elements

file system typevfsmountsuper blockinodedentry

Dentry cacheHard link vs Symbolic link

file object4 Operation example

Mount5 Getting conFUSEed

What is FUSE?FUSE Architecture

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 11 / 44

Page 23: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Core Elements

file system type Information about a specific fs type

vfsmount Mount point information

super block Represents a mounted filesystem

inode Information about a file (on disk, memory or network)

dentry A directory entry

file A file abstraction - points to an inode

Note: Every element, except vfsmount, is defined atinclude/linux/fs.h.

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 12 / 44

Page 24: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Core Elements

file system type Information about a specific fs type

vfsmount Mount point information

super block Represents a mounted filesystem

inode Information about a file (on disk, memory or network)

dentry A directory entry

file A file abstraction - points to an inode

Note: Every element, except vfsmount, is defined atinclude/linux/fs.h.

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 12 / 44

Page 25: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Core Elements

file system type Information about a specific fs type

vfsmount Mount point information

super block Represents a mounted filesystem

inode Information about a file (on disk, memory or network)

dentry A directory entry

file A file abstraction - points to an inode

Note: Every element, except vfsmount, is defined atinclude/linux/fs.h.

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 12 / 44

Page 26: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Core Elements

file system type Information about a specific fs type

vfsmount Mount point information

super block Represents a mounted filesystem

inode Information about a file (on disk, memory or network)

dentry A directory entry

file A file abstraction - points to an inode

Note: Every element, except vfsmount, is defined atinclude/linux/fs.h.

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 12 / 44

Page 27: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Core Elements

file system type Information about a specific fs type

vfsmount Mount point information

super block Represents a mounted filesystem

inode Information about a file (on disk, memory or network)

dentry A directory entry

file A file abstraction - points to an inode

Note: Every element, except vfsmount, is defined atinclude/linux/fs.h.

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 12 / 44

Page 28: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Core Elements

file system type Information about a specific fs type

vfsmount Mount point information

super block Represents a mounted filesystem

inode Information about a file (on disk, memory or network)

dentry A directory entry

file A file abstraction - points to an inode

Note: Every element, except vfsmount, is defined atinclude/linux/fs.h.

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 12 / 44

Page 29: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Core Elements

file system type Information about a specific fs type

vfsmount Mount point information

super block Represents a mounted filesystem

inode Information about a file (on disk, memory or network)

dentry A directory entry

file A file abstraction - points to an inode

Note: Every element, except vfsmount, is defined atinclude/linux/fs.h.

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 12 / 44

Page 30: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Linux’s Virtual Filesystem Core Elements

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 13 / 44

Page 31: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file system type

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 14 / 44

Page 32: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file system type

• Represents a filesystem type (e.g. ext3, nfs, fuse)

• fs/filesystems.c has a linked list of filesystem types

• Each filesystem type must have a unique name

• Each filesystem type has a linked list of super blocks in use (i.e.mounted)

• Each filesystem type is owned by a module (which implements it)

• Each filesystem type has a function to mount a (possibly new)instance of the filesystem

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 15 / 44

Page 33: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file system type

• Represents a filesystem type (e.g. ext3, nfs, fuse)

• fs/filesystems.c has a linked list of filesystem types

• Each filesystem type must have a unique name

• Each filesystem type has a linked list of super blocks in use (i.e.mounted)

• Each filesystem type is owned by a module (which implements it)

• Each filesystem type has a function to mount a (possibly new)instance of the filesystem

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 15 / 44

Page 34: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file system type

• Represents a filesystem type (e.g. ext3, nfs, fuse)

• fs/filesystems.c has a linked list of filesystem types

• Each filesystem type must have a unique name

• Each filesystem type has a linked list of super blocks in use (i.e.mounted)

• Each filesystem type is owned by a module (which implements it)

• Each filesystem type has a function to mount a (possibly new)instance of the filesystem

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 15 / 44

Page 35: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file system type

• Represents a filesystem type (e.g. ext3, nfs, fuse)

• fs/filesystems.c has a linked list of filesystem types

• Each filesystem type must have a unique name

• Each filesystem type has a linked list of super blocks in use (i.e.mounted)

• Each filesystem type is owned by a module (which implements it)

• Each filesystem type has a function to mount a (possibly new)instance of the filesystem

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 15 / 44

Page 36: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file system type

• Represents a filesystem type (e.g. ext3, nfs, fuse)

• fs/filesystems.c has a linked list of filesystem types

• Each filesystem type must have a unique name

• Each filesystem type has a linked list of super blocks in use (i.e.mounted)

• Each filesystem type is owned by a module (which implements it)

• Each filesystem type has a function to mount a (possibly new)instance of the filesystem

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 15 / 44

Page 37: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file system type

• Represents a filesystem type (e.g. ext3, nfs, fuse)

• fs/filesystems.c has a linked list of filesystem types

• Each filesystem type must have a unique name

• Each filesystem type has a linked list of super blocks in use (i.e.mounted)

• Each filesystem type is owned by a module (which implements it)

• Each filesystem type has a function to mount a (possibly new)instance of the filesystem

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 15 / 44

Page 38: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

vfsmount

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 16 / 44

Page 39: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

vfsmount

• Defined at include/linux/mount.h

• Store information about a mount point

− Device name (if any)− Use count (if 0 the fs could be unmounted if mnt expiry mark is set)

• Refers to the parent mount point (the one its mounted on) and has alist of mounted children

• Points to the parent (mount point) dentry root

• Has a dentry for its own root

• Has the super block of the mounted filesystem

• Not directly handled by a filesystem implementation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 17 / 44

Page 40: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

vfsmount

• Defined at include/linux/mount.h

• Store information about a mount point

− Device name (if any)− Use count (if 0 the fs could be unmounted if mnt expiry mark is set)

• Refers to the parent mount point (the one its mounted on) and has alist of mounted children

• Points to the parent (mount point) dentry root

• Has a dentry for its own root

• Has the super block of the mounted filesystem

• Not directly handled by a filesystem implementation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 17 / 44

Page 41: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

vfsmount

• Defined at include/linux/mount.h

• Store information about a mount point

− Device name (if any)

− Use count (if 0 the fs could be unmounted if mnt expiry mark is set)

• Refers to the parent mount point (the one its mounted on) and has alist of mounted children

• Points to the parent (mount point) dentry root

• Has a dentry for its own root

• Has the super block of the mounted filesystem

• Not directly handled by a filesystem implementation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 17 / 44

Page 42: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

vfsmount

• Defined at include/linux/mount.h

• Store information about a mount point

− Device name (if any)− Use count (if 0 the fs could be unmounted if mnt expiry mark is set)

• Refers to the parent mount point (the one its mounted on) and has alist of mounted children

• Points to the parent (mount point) dentry root

• Has a dentry for its own root

• Has the super block of the mounted filesystem

• Not directly handled by a filesystem implementation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 17 / 44

Page 43: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

vfsmount

• Defined at include/linux/mount.h

• Store information about a mount point

− Device name (if any)− Use count (if 0 the fs could be unmounted if mnt expiry mark is set)

• Refers to the parent mount point (the one its mounted on) and has alist of mounted children

• Points to the parent (mount point) dentry root

• Has a dentry for its own root

• Has the super block of the mounted filesystem

• Not directly handled by a filesystem implementation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 17 / 44

Page 44: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

vfsmount

• Defined at include/linux/mount.h

• Store information about a mount point

− Device name (if any)− Use count (if 0 the fs could be unmounted if mnt expiry mark is set)

• Refers to the parent mount point (the one its mounted on) and has alist of mounted children

• Points to the parent (mount point) dentry root

• Has a dentry for its own root

• Has the super block of the mounted filesystem

• Not directly handled by a filesystem implementation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 17 / 44

Page 45: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

vfsmount

• Defined at include/linux/mount.h

• Store information about a mount point

− Device name (if any)− Use count (if 0 the fs could be unmounted if mnt expiry mark is set)

• Refers to the parent mount point (the one its mounted on) and has alist of mounted children

• Points to the parent (mount point) dentry root

• Has a dentry for its own root

• Has the super block of the mounted filesystem

• Not directly handled by a filesystem implementation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 17 / 44

Page 46: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

vfsmount

• Defined at include/linux/mount.h

• Store information about a mount point

− Device name (if any)− Use count (if 0 the fs could be unmounted if mnt expiry mark is set)

• Refers to the parent mount point (the one its mounted on) and has alist of mounted children

• Points to the parent (mount point) dentry root

• Has a dentry for its own root

• Has the super block of the mounted filesystem

• Not directly handled by a filesystem implementation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 17 / 44

Page 47: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

vfsmount

• Defined at include/linux/mount.h

• Store information about a mount point

− Device name (if any)− Use count (if 0 the fs could be unmounted if mnt expiry mark is set)

• Refers to the parent mount point (the one its mounted on) and has alist of mounted children

• Points to the parent (mount point) dentry root

• Has a dentry for its own root

• Has the super block of the mounted filesystem

• Not directly handled by a filesystem implementation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 17 / 44

Page 48: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 18 / 44

Page 49: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 50: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 51: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 52: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 53: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size

− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 54: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size

− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 55: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 56: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 57: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 58: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 59: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 60: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

super block

• Represents a filesystem instance

• When the filesystem is disk based, the super block usually is persistedon disk

• It’s kept on memory, but there’s a dirty flag so it can eventually beflush to disk (for disk based fs)

• Defines filesystem’s properties

− block size− maximum file size− access time granularity, among others

• Refers to its filesystem type (and thus module owner)

• Points to its dentry root

• Has a dentry for its own root

• Has lists for open files and inodes in use

• Has functions to handle quota operations and inode manipulation

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 19 / 44

Page 61: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 20 / 44

Page 62: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Each object in the filesytem is represented by an inode

• Each inode is identified by a unique inode number within thefilesystem

• The inode is only instantiated in memory at the time the file is opened

• Defines inode’s atributes

− i hash: Pointer for the hash list− i ino: inode number− i blksize, i block, i bytes: respectively block size, number of block and

block size of the last block− i atime, i mtime, i ctime: respectively time of the last file access, write

and change− i nlink: number of hard links− i sb: Pointer to superblock object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 21 / 44

Page 63: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Each object in the filesytem is represented by an inode

• Each inode is identified by a unique inode number within thefilesystem

• The inode is only instantiated in memory at the time the file is opened

• Defines inode’s atributes

− i hash: Pointer for the hash list− i ino: inode number− i blksize, i block, i bytes: respectively block size, number of block and

block size of the last block− i atime, i mtime, i ctime: respectively time of the last file access, write

and change− i nlink: number of hard links− i sb: Pointer to superblock object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 21 / 44

Page 64: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Each object in the filesytem is represented by an inode

• Each inode is identified by a unique inode number within thefilesystem

• The inode is only instantiated in memory at the time the file is opened

• Defines inode’s atributes

− i hash: Pointer for the hash list− i ino: inode number− i blksize, i block, i bytes: respectively block size, number of block and

block size of the last block− i atime, i mtime, i ctime: respectively time of the last file access, write

and change− i nlink: number of hard links− i sb: Pointer to superblock object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 21 / 44

Page 65: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Each object in the filesytem is represented by an inode

• Each inode is identified by a unique inode number within thefilesystem

• The inode is only instantiated in memory at the time the file is opened

• Defines inode’s atributes

− i hash: Pointer for the hash list− i ino: inode number− i blksize, i block, i bytes: respectively block size, number of block and

block size of the last block− i atime, i mtime, i ctime: respectively time of the last file access, write

and change− i nlink: number of hard links− i sb: Pointer to superblock object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 21 / 44

Page 66: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Each object in the filesytem is represented by an inode

• Each inode is identified by a unique inode number within thefilesystem

• The inode is only instantiated in memory at the time the file is opened

• Defines inode’s atributes

− i hash: Pointer for the hash list

− i ino: inode number− i blksize, i block, i bytes: respectively block size, number of block and

block size of the last block− i atime, i mtime, i ctime: respectively time of the last file access, write

and change− i nlink: number of hard links− i sb: Pointer to superblock object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 21 / 44

Page 67: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Each object in the filesytem is represented by an inode

• Each inode is identified by a unique inode number within thefilesystem

• The inode is only instantiated in memory at the time the file is opened

• Defines inode’s atributes

− i hash: Pointer for the hash list− i ino: inode number

− i blksize, i block, i bytes: respectively block size, number of block andblock size of the last block

− i atime, i mtime, i ctime: respectively time of the last file access, writeand change

− i nlink: number of hard links− i sb: Pointer to superblock object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 21 / 44

Page 68: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Each object in the filesytem is represented by an inode

• Each inode is identified by a unique inode number within thefilesystem

• The inode is only instantiated in memory at the time the file is opened

• Defines inode’s atributes

− i hash: Pointer for the hash list− i ino: inode number− i blksize, i block, i bytes: respectively block size, number of block and

block size of the last block

− i atime, i mtime, i ctime: respectively time of the last file access, writeand change

− i nlink: number of hard links− i sb: Pointer to superblock object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 21 / 44

Page 69: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Each object in the filesytem is represented by an inode

• Each inode is identified by a unique inode number within thefilesystem

• The inode is only instantiated in memory at the time the file is opened

• Defines inode’s atributes

− i hash: Pointer for the hash list− i ino: inode number− i blksize, i block, i bytes: respectively block size, number of block and

block size of the last block− i atime, i mtime, i ctime: respectively time of the last file access, write

and change

− i nlink: number of hard links− i sb: Pointer to superblock object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 21 / 44

Page 70: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Each object in the filesytem is represented by an inode

• Each inode is identified by a unique inode number within thefilesystem

• The inode is only instantiated in memory at the time the file is opened

• Defines inode’s atributes

− i hash: Pointer for the hash list− i ino: inode number− i blksize, i block, i bytes: respectively block size, number of block and

block size of the last block− i atime, i mtime, i ctime: respectively time of the last file access, write

and change− i nlink: number of hard links

− i sb: Pointer to superblock object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 21 / 44

Page 71: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Each object in the filesytem is represented by an inode

• Each inode is identified by a unique inode number within thefilesystem

• The inode is only instantiated in memory at the time the file is opened

• Defines inode’s atributes

− i hash: Pointer for the hash list− i ino: inode number− i blksize, i block, i bytes: respectively block size, number of block and

block size of the last block− i atime, i mtime, i ctime: respectively time of the last file access, write

and change− i nlink: number of hard links− i sb: Pointer to superblock object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 21 / 44

Page 72: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Defines inode operations

− create(dir, dentry, mode, nameidata)− lookup(dir, dentry, nameidata)− link(old dentry, dir, new dentry)− mkdir(dir, dentry, mode)− rmdir(dir, dentry)− rename(old dir, old dentry, new dir, new dentry)− permission(inode, mask, nameidada)

• A single inode can be pointed to by multiple dentries (hard links)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 22 / 44

Page 73: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Defines inode operations

− create(dir, dentry, mode, nameidata)

− lookup(dir, dentry, nameidata)− link(old dentry, dir, new dentry)− mkdir(dir, dentry, mode)− rmdir(dir, dentry)− rename(old dir, old dentry, new dir, new dentry)− permission(inode, mask, nameidada)

• A single inode can be pointed to by multiple dentries (hard links)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 22 / 44

Page 74: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Defines inode operations

− create(dir, dentry, mode, nameidata)− lookup(dir, dentry, nameidata)

− link(old dentry, dir, new dentry)− mkdir(dir, dentry, mode)− rmdir(dir, dentry)− rename(old dir, old dentry, new dir, new dentry)− permission(inode, mask, nameidada)

• A single inode can be pointed to by multiple dentries (hard links)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 22 / 44

Page 75: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Defines inode operations

− create(dir, dentry, mode, nameidata)− lookup(dir, dentry, nameidata)− link(old dentry, dir, new dentry)

− mkdir(dir, dentry, mode)− rmdir(dir, dentry)− rename(old dir, old dentry, new dir, new dentry)− permission(inode, mask, nameidada)

• A single inode can be pointed to by multiple dentries (hard links)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 22 / 44

Page 76: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Defines inode operations

− create(dir, dentry, mode, nameidata)− lookup(dir, dentry, nameidata)− link(old dentry, dir, new dentry)− mkdir(dir, dentry, mode)

− rmdir(dir, dentry)− rename(old dir, old dentry, new dir, new dentry)− permission(inode, mask, nameidada)

• A single inode can be pointed to by multiple dentries (hard links)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 22 / 44

Page 77: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Defines inode operations

− create(dir, dentry, mode, nameidata)− lookup(dir, dentry, nameidata)− link(old dentry, dir, new dentry)− mkdir(dir, dentry, mode)− rmdir(dir, dentry)

− rename(old dir, old dentry, new dir, new dentry)− permission(inode, mask, nameidada)

• A single inode can be pointed to by multiple dentries (hard links)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 22 / 44

Page 78: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Defines inode operations

− create(dir, dentry, mode, nameidata)− lookup(dir, dentry, nameidata)− link(old dentry, dir, new dentry)− mkdir(dir, dentry, mode)− rmdir(dir, dentry)− rename(old dir, old dentry, new dir, new dentry)

− permission(inode, mask, nameidada)

• A single inode can be pointed to by multiple dentries (hard links)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 22 / 44

Page 79: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Defines inode operations

− create(dir, dentry, mode, nameidata)− lookup(dir, dentry, nameidata)− link(old dentry, dir, new dentry)− mkdir(dir, dentry, mode)− rmdir(dir, dentry)− rename(old dir, old dentry, new dir, new dentry)− permission(inode, mask, nameidada)

• A single inode can be pointed to by multiple dentries (hard links)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 22 / 44

Page 80: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

inode

• Defines inode operations

− create(dir, dentry, mode, nameidata)− lookup(dir, dentry, nameidata)− link(old dentry, dir, new dentry)− mkdir(dir, dentry, mode)− rmdir(dir, dentry)− rename(old dir, old dentry, new dir, new dentry)− permission(inode, mask, nameidada)

• A single inode can be pointed to by multiple dentries (hard links)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 22 / 44

Page 81: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 23 / 44

Page 82: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• The VFS considers each directory a file that contains a list of filesand directories

• Once a directory entry is read into memory, it is transformed by theVFS into a dentry object

− Example: /tmp/textmp and tex are files, both represented by the inodes.

• The concept of input directory (dentry)

• Specific component of the path

• The VFS instantiates these objects ”on the fly”when you makeoperations on directories

• It’s kept on memory

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 24 / 44

Page 83: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• The VFS considers each directory a file that contains a list of filesand directories

• Once a directory entry is read into memory, it is transformed by theVFS into a dentry object

− Example: /tmp/textmp and tex are files, both represented by the inodes.

• The concept of input directory (dentry)

• Specific component of the path

• The VFS instantiates these objects ”on the fly”when you makeoperations on directories

• It’s kept on memory

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 24 / 44

Page 84: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• The VFS considers each directory a file that contains a list of filesand directories

• Once a directory entry is read into memory, it is transformed by theVFS into a dentry object

− Example: /tmp/textmp and tex are files, both represented by the inodes.

• The concept of input directory (dentry)

• Specific component of the path

• The VFS instantiates these objects ”on the fly”when you makeoperations on directories

• It’s kept on memory

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 24 / 44

Page 85: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• The VFS considers each directory a file that contains a list of filesand directories

• Once a directory entry is read into memory, it is transformed by theVFS into a dentry object

− Example: /tmp/textmp and tex are files, both represented by the inodes.

• The concept of input directory (dentry)

• Specific component of the path

• The VFS instantiates these objects ”on the fly”when you makeoperations on directories

• It’s kept on memory

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 24 / 44

Page 86: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• The VFS considers each directory a file that contains a list of filesand directories

• Once a directory entry is read into memory, it is transformed by theVFS into a dentry object

− Example: /tmp/textmp and tex are files, both represented by the inodes.

• The concept of input directory (dentry)

• Specific component of the path

• The VFS instantiates these objects ”on the fly”when you makeoperations on directories

• It’s kept on memory

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 24 / 44

Page 87: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• The VFS considers each directory a file that contains a list of filesand directories

• Once a directory entry is read into memory, it is transformed by theVFS into a dentry object

− Example: /tmp/textmp and tex are files, both represented by the inodes.

• The concept of input directory (dentry)

• Specific component of the path

• The VFS instantiates these objects ”on the fly”when you makeoperations on directories

• It’s kept on memory

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 24 / 44

Page 88: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• The VFS considers each directory a file that contains a list of filesand directories

• Once a directory entry is read into memory, it is transformed by theVFS into a dentry object

− Example: /tmp/textmp and tex are files, both represented by the inodes.

• The concept of input directory (dentry)

• Specific component of the path

• The VFS instantiates these objects ”on the fly”when you makeoperations on directories

• It’s kept on memory

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 24 / 44

Page 89: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename− d parent: dentry object of parent directory− d name: filename− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 90: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter

− d inode: inode associated with filename− d parent: dentry object of parent directory− d name: filename− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 91: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename

− d parent: dentry object of parent directory− d name: filename− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 92: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename− d parent: dentry object of parent directory

− d name: filename− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 93: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename− d parent: dentry object of parent directory− d name: filename

− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 94: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename− d parent: dentry object of parent directory− d name: filename− d lru: pointer for the list of unused dentries

− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 95: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename− d parent: dentry object of parent directory− d name: filename− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 96: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename− d parent: dentry object of parent directory− d name: filename− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 97: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename− d parent: dentry object of parent directory− d name: filename− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used

− Unused: valid information and is not used, may be discarted ifnecessary

− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 98: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename− d parent: dentry object of parent directory− d name: filename− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary

− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 99: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename− d parent: dentry object of parent directory− d name: filename− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary− In use: valid information and is used, cannot be discarted

− Negative: the inode associated with the dentry does not exist or isinvalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 100: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

dentry

• Defines dentry’s attributes

− d count: dentry object usage counter− d inode: inode associated with filename− d parent: dentry object of parent directory− d name: filename− d lru: pointer for the list of unused dentries− d alias: pointers for the list of dentries associated with the same inode

• Dentry States:

− Free: no valid information and is not used− Unused: valid information and is not used, may be discarted if

necessary− In use: valid information and is used, cannot be discarted− Negative: the inode associated with the dentry does not exist or is

invalid

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 25 / 44

Page 101: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Dentry cache

• Reading a directory entry from disk and constructing thecorresponding dentry object requires considerable time

• A set of dentries in the in-use, unused, or negative states

• A hash table to derive the dentry object associated with a givenfilename or directory quickly

• Stores dentry objects as follows

− All the ”unused”dentries are included in a doubly linked LRU1 listsorted by time of insertion

− Each ”in use”dentry object is inserted into a list specified by thei dentry field of the corresponding inode object. The dentry object maybecome ”negative”when the last hard link to the corresponding file isdeleted.

− A hash table to quickly resolve the association between a given pathand dentry object

1Last recently usedAndre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 26 / 44

Page 102: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Dentry cache

• Reading a directory entry from disk and constructing thecorresponding dentry object requires considerable time

• A set of dentries in the in-use, unused, or negative states

• A hash table to derive the dentry object associated with a givenfilename or directory quickly

• Stores dentry objects as follows

− All the ”unused”dentries are included in a doubly linked LRU1 listsorted by time of insertion

− Each ”in use”dentry object is inserted into a list specified by thei dentry field of the corresponding inode object. The dentry object maybecome ”negative”when the last hard link to the corresponding file isdeleted.

− A hash table to quickly resolve the association between a given pathand dentry object

1Last recently usedAndre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 26 / 44

Page 103: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Dentry cache

• Reading a directory entry from disk and constructing thecorresponding dentry object requires considerable time

• A set of dentries in the in-use, unused, or negative states

• A hash table to derive the dentry object associated with a givenfilename or directory quickly

• Stores dentry objects as follows

− All the ”unused”dentries are included in a doubly linked LRU1 listsorted by time of insertion

− Each ”in use”dentry object is inserted into a list specified by thei dentry field of the corresponding inode object. The dentry object maybecome ”negative”when the last hard link to the corresponding file isdeleted.

− A hash table to quickly resolve the association between a given pathand dentry object

1Last recently usedAndre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 26 / 44

Page 104: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Dentry cache

• Reading a directory entry from disk and constructing thecorresponding dentry object requires considerable time

• A set of dentries in the in-use, unused, or negative states

• A hash table to derive the dentry object associated with a givenfilename or directory quickly

• Stores dentry objects as follows

− All the ”unused”dentries are included in a doubly linked LRU1 listsorted by time of insertion

− Each ”in use”dentry object is inserted into a list specified by thei dentry field of the corresponding inode object. The dentry object maybecome ”negative”when the last hard link to the corresponding file isdeleted.

− A hash table to quickly resolve the association between a given pathand dentry object

1Last recently usedAndre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 26 / 44

Page 105: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Dentry cache

• Reading a directory entry from disk and constructing thecorresponding dentry object requires considerable time

• A set of dentries in the in-use, unused, or negative states

• A hash table to derive the dentry object associated with a givenfilename or directory quickly

• Stores dentry objects as follows

− All the ”unused”dentries are included in a doubly linked LRU1 listsorted by time of insertion

− Each ”in use”dentry object is inserted into a list specified by thei dentry field of the corresponding inode object. The dentry object maybecome ”negative”when the last hard link to the corresponding file isdeleted.

− A hash table to quickly resolve the association between a given pathand dentry object

1Last recently usedAndre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 26 / 44

Page 106: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Dentry cache

• Reading a directory entry from disk and constructing thecorresponding dentry object requires considerable time

• A set of dentries in the in-use, unused, or negative states

• A hash table to derive the dentry object associated with a givenfilename or directory quickly

• Stores dentry objects as follows

− All the ”unused”dentries are included in a doubly linked LRU1 listsorted by time of insertion

− Each ”in use”dentry object is inserted into a list specified by thei dentry field of the corresponding inode object. The dentry object maybecome ”negative”when the last hard link to the corresponding file isdeleted.

− A hash table to quickly resolve the association between a given pathand dentry object

1Last recently usedAndre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 26 / 44

Page 107: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Dentry cache

• Reading a directory entry from disk and constructing thecorresponding dentry object requires considerable time

• A set of dentries in the in-use, unused, or negative states

• A hash table to derive the dentry object associated with a givenfilename or directory quickly

• Stores dentry objects as follows

− All the ”unused”dentries are included in a doubly linked LRU1 listsorted by time of insertion

− Each ”in use”dentry object is inserted into a list specified by thei dentry field of the corresponding inode object. The dentry object maybecome ”negative”when the last hard link to the corresponding file isdeleted.

− A hash table to quickly resolve the association between a given pathand dentry object

1Last recently usedAndre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 26 / 44

Page 108: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 109: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file

− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 110: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect

− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 111: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work

− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 112: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories

− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 113: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 114: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 115: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut

− Contains a text string that is interpreted and followed by the OS as apath to another file or directory

− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 116: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory

− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 117: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected

− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 118: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work

− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 119: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories

− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 120: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Hard link vs Symbolic link

• Hard link is a directory entry that associates a name with a file on afilesystem

− Multiple hard link to be created for the same file− Aliasing effect− If target is moved, renamed or deleted, any hard link continues to work− Cannot link directories− Can only refer to data that exists on the same filesystem

• Soft link is a special type of file that contains a reference to anotherfile or directory in the form of an absolute or relative path.

− Similar to a shortcut− Contains a text string that is interpreted and followed by the OS as a

path to another file or directory− If a symbolic link is deleted, its target remains unaffected− If target is moved, renamed or deleted, the symbolic link wont’t work− Can create links between directories− Can cross filesystem boundaries

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 27 / 44

Page 121: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 28 / 44

Page 122: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 123: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 124: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 125: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 126: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 127: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)

− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 128: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file

− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 129: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter

− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 130: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 131: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 132: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)

− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 133: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)

− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 134: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)

− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 135: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

file object

• Describes how a process interacts with a file it has opened

• Created when the file is opened by a process

• Points to a dentry (which points to the inode)

• A dentry can be associated to many file objects

• Defines file’s attributes

− f list: Pointers to generic file (super block file list)− f dentry: Dentry object associated with the file− f count: File object’s reference counter− f pos: Current file offset(file pointer)

• Defines file operations

− llseek(file, offset, origin)− read(file, buf, count, offset)− write(file, buf, count, offset)− open(inode, file)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 29 / 44

Page 136: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Interaction between process and the VFS

Understanding the Linux Kernel, 3rd Edition, Daniel P. Bovet, Marco CesatiAndre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 30 / 44

Page 137: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Agenda1 Objectives2 Overview3 Core Elements

file system typevfsmountsuper blockinodedentry

Dentry cacheHard link vs Symbolic link

file object4 Operation example

Mount5 Getting conFUSEed

What is FUSE?FUSE Architecture

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 31 / 44

Page 138: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Mount activity diagram

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 32 / 44

Page 139: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Agenda1 Objectives2 Overview3 Core Elements

file system typevfsmountsuper blockinodedentry

Dentry cacheHard link vs Symbolic link

file object4 Operation example

Mount5 Getting conFUSEed

What is FUSE?FUSE Architecture

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 33 / 44

Page 140: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is FUSE?

Filesystem in User Space

An open source framework for implementing filesystem in user land1

1http://fuse.sourceforge.net/Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 34 / 44

Page 141: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is it good for?

Higher abstraction - it’s easier to write a fuse-based filesystem than a”native”linux filesystem

No kernel recompilation or module installs

FUSE is already compiled within the kernel in common distros (e.g.Ubuntu)

Applications in user space have lots of ready-to-use libraries

Write your filesystem in any programming language

You won’t crash the system :)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 35 / 44

Page 142: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is it good for?

Higher abstraction - it’s easier to write a fuse-based filesystem than a”native”linux filesystem

No kernel recompilation or module installs

FUSE is already compiled within the kernel in common distros (e.g.Ubuntu)

Applications in user space have lots of ready-to-use libraries

Write your filesystem in any programming language

You won’t crash the system :)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 35 / 44

Page 143: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is it good for?

Higher abstraction - it’s easier to write a fuse-based filesystem than a”native”linux filesystem

No kernel recompilation or module installs

FUSE is already compiled within the kernel in common distros (e.g.Ubuntu)

Applications in user space have lots of ready-to-use libraries

Write your filesystem in any programming language

You won’t crash the system :)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 35 / 44

Page 144: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is it good for?

Higher abstraction - it’s easier to write a fuse-based filesystem than a”native”linux filesystem

No kernel recompilation or module installs

FUSE is already compiled within the kernel in common distros (e.g.Ubuntu)

Applications in user space have lots of ready-to-use libraries

Write your filesystem in any programming language

You won’t crash the system :)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 35 / 44

Page 145: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is it good for?

Higher abstraction - it’s easier to write a fuse-based filesystem than a”native”linux filesystem

No kernel recompilation or module installs

FUSE is already compiled within the kernel in common distros (e.g.Ubuntu)

Applications in user space have lots of ready-to-use libraries

Write your filesystem in any programming language

You won’t crash the system :)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 35 / 44

Page 146: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is it good for?

Higher abstraction - it’s easier to write a fuse-based filesystem than a”native”linux filesystem

No kernel recompilation or module installs

FUSE is already compiled within the kernel in common distros (e.g.Ubuntu)

Applications in user space have lots of ready-to-use libraries

Write your filesystem in any programming language

You won’t crash the system :)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 35 / 44

Page 147: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is it NOT good for?

Performance penalty (switches between user and kernel modes andhigher indirection level)

If you need to override some kernel functionality (as the dentry cache,for instance)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 36 / 44

Page 148: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is it NOT good for?

Performance penalty (switches between user and kernel modes andhigher indirection level)

If you need to override some kernel functionality (as the dentry cache,for instance)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 36 / 44

Page 149: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is fuse-based?

Gmail filesystem1

sshfs2

WikipediaFS3

1http://richard.jones.name/google-hacks/gmail-filesystem/gmail-filesystem.html2http://fuse.sourceforge.net/sshfs.html3http://en.wikipedia.org/wiki/WikipediaFS

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 37 / 44

Page 150: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is fuse-based?

Gmail filesystem1

sshfs2

WikipediaFS3

1http://richard.jones.name/google-hacks/gmail-filesystem/gmail-filesystem.html2http://fuse.sourceforge.net/sshfs.html3http://en.wikipedia.org/wiki/WikipediaFS

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 37 / 44

Page 151: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

What is fuse-based?

Gmail filesystem1

sshfs2

WikipediaFS3

1http://richard.jones.name/google-hacks/gmail-filesystem/gmail-filesystem.html2http://fuse.sourceforge.net/sshfs.html3http://en.wikipedia.org/wiki/WikipediaFS

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 37 / 44

Page 152: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE basic workings

Source: http://fuse.sourceforge.net/Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 38 / 44

Page 153: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE in deep

FUSE is composed of two parts

− User space library - libfuse - provides to the filesystem application anAPI

− Kernel surrogate filesystem implementation - fs/fuse

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 39 / 44

Page 154: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE in deep

FUSE is composed of two parts

− User space library - libfuse - provides to the filesystem application anAPI

− Kernel surrogate filesystem implementation - fs/fuse

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 39 / 44

Page 155: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE in deep

FUSE is composed of two parts

− User space library - libfuse - provides to the filesystem application anAPI

− Kernel surrogate filesystem implementation - fs/fuse

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 39 / 44

Page 156: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - User space library (libfuse)

Provides an abstraction layer to the filesystem application

Binds the userland application to the FUSE kernel module

Application has to provided implementation to FUSE operations

Communicates with the FUSE kernel module in behalf of theapplication

Listen for FUSE kernel messages that should be forwarded to theapplication

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 40 / 44

Page 157: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - User space library (libfuse)

Provides an abstraction layer to the filesystem application

Binds the userland application to the FUSE kernel module

Application has to provided implementation to FUSE operations

Communicates with the FUSE kernel module in behalf of theapplication

Listen for FUSE kernel messages that should be forwarded to theapplication

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 40 / 44

Page 158: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - User space library (libfuse)

Provides an abstraction layer to the filesystem application

Binds the userland application to the FUSE kernel module

Application has to provided implementation to FUSE operations

Communicates with the FUSE kernel module in behalf of theapplication

Listen for FUSE kernel messages that should be forwarded to theapplication

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 40 / 44

Page 159: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - User space library (libfuse)

Provides an abstraction layer to the filesystem application

Binds the userland application to the FUSE kernel module

Application has to provided implementation to FUSE operations

Communicates with the FUSE kernel module in behalf of theapplication

Listen for FUSE kernel messages that should be forwarded to theapplication

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 40 / 44

Page 160: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - User space library (libfuse)

Provides an abstraction layer to the filesystem application

Binds the userland application to the FUSE kernel module

Application has to provided implementation to FUSE operations

Communicates with the FUSE kernel module in behalf of theapplication

Listen for FUSE kernel messages that should be forwarded to theapplication

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 40 / 44

Page 161: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - Kernel module (fusefs)

Manages bound filesystem (but to the kernel there’s just FUSE)

Selects the appropriate userland application to complete an operation,based on the mount point

Allows synchronous or multi-threaded operations (mount option)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 41 / 44

Page 162: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - Kernel module (fusefs)

Manages bound filesystem (but to the kernel there’s just FUSE)

Selects the appropriate userland application to complete an operation,based on the mount point

Allows synchronous or multi-threaded operations (mount option)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 41 / 44

Page 163: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - Kernel module (fusefs)

Manages bound filesystem (but to the kernel there’s just FUSE)

Selects the appropriate userland application to complete an operation,based on the mount point

Allows synchronous or multi-threaded operations (mount option)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 41 / 44

Page 164: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks− libfuse opens /dev/fuse− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as an

option parameter− The VFS passes the mount call down to fusefs− fusefs associates the mount point to the file from fd− libfuse reads the file and fusefs writes to the file− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 165: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks− libfuse opens /dev/fuse− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as an

option parameter− The VFS passes the mount call down to fusefs− fusefs associates the mount point to the file from fd− libfuse reads the file and fusefs writes to the file− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 166: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks− libfuse opens /dev/fuse− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as an

option parameter− The VFS passes the mount call down to fusefs− fusefs associates the mount point to the file from fd− libfuse reads the file and fusefs writes to the file− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 167: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks

− libfuse opens /dev/fuse− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as an

option parameter− The VFS passes the mount call down to fusefs− fusefs associates the mount point to the file from fd− libfuse reads the file and fusefs writes to the file− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 168: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks− libfuse opens /dev/fuse

− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as anoption parameter

− The VFS passes the mount call down to fusefs− fusefs associates the mount point to the file from fd− libfuse reads the file and fusefs writes to the file− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 169: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks− libfuse opens /dev/fuse− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as an

option parameter

− The VFS passes the mount call down to fusefs− fusefs associates the mount point to the file from fd− libfuse reads the file and fusefs writes to the file− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 170: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks− libfuse opens /dev/fuse− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as an

option parameter− The VFS passes the mount call down to fusefs

− fusefs associates the mount point to the file from fd− libfuse reads the file and fusefs writes to the file− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 171: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks− libfuse opens /dev/fuse− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as an

option parameter− The VFS passes the mount call down to fusefs− fusefs associates the mount point to the file from fd

− libfuse reads the file and fusefs writes to the file− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 172: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks− libfuse opens /dev/fuse− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as an

option parameter− The VFS passes the mount call down to fusefs− fusefs associates the mount point to the file from fd− libfuse reads the file and fusefs writes to the file

− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 173: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks− libfuse opens /dev/fuse− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as an

option parameter− The VFS passes the mount call down to fusefs− fusefs associates the mount point to the file from fd− libfuse reads the file and fusefs writes to the file− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 174: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE - How kernel and application communicates?

fusefs registers a special character file: /dev/fuse

The application wants to mount its filesystem implementation

The application issues a libfuse call to start and...

− libfuse forks− libfuse opens /dev/fuse− libfuse issues a mount call passing /dev/fuse file descriptor (fd) as an

option parameter− The VFS passes the mount call down to fusefs− fusefs associates the mount point to the file from fd− libfuse reads the file and fusefs writes to the file− libfuse forwards calls to the application through a UNIX socket

All above is done by libfuse and the user just need to implement someFUSE operations

Sources: FUSE Design Document, William Krier and Erick Liska, 2009)FUSE Kernel Operations, Vikas Gera, 2006)

Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 42 / 44

Page 175: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

FUSE Architecture

Source: FUSE Kernel Operations, Vikas Gera, 2006Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 43 / 44

Page 176: Linux Virtual File Systemislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides

Questions?

Andre Petris Esteve - [email protected] Ji - [email protected]