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 System - INSTITUTO DE COMPUTAÇÃOislene/2s2013-mo806/vfs/andre-zhen.pdf · The Virtual File System (also known as the Virtual Filesystem Switch) is the software

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

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

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

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

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

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

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

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

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

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

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

Linux’s Virtual Filesystem Overview

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Linux’s Virtual Filesystem Core Elements

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

file system type

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

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

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

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

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

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

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

vfsmount

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

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

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

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

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

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

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

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

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

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

super block

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

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

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

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

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

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

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

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

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

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

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

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

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

inode

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

dentry

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

file object

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Mount activity diagram

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

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

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

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

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

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

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

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

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

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

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

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

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

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

FUSE basic workings

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

FUSE Architecture

Source: FUSE Kernel Operations, Vikas Gera, 2006Andre Esteve and Zhenlei Ji (IC\UNICAMP) Linux VFS 10/20/2011 43 / 44

Questions?

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