Trigger Scripts For Trigger Scripts For Extensible File Extensible - - PDF document

trigger scripts for trigger scripts for extensible file
SMART_READER_LITE
LIVE PREVIEW

Trigger Scripts For Trigger Scripts For Extensible File Extensible - - PDF document

Trigger Scripts For Trigger Scripts For Extensible File Extensible File Systems Systems Cameron Macdonell Macdonell Cameron Overview Overview The The Scruf Scruf Framework Framework Examples of Extended File Systems


slide-1
SLIDE 1

Trigger Scripts For Trigger Scripts For Extensible File Extensible File Systems Systems

Cameron Cameron Macdonell Macdonell

Cameron Macdonell

Overview Overview

  • The

The Scruf Scruf Framework Framework

  • Examples of Extended File Systems

Examples of Extended File Systems

  • Experiments

Experiments

  • Concluding Remarks

Concluding Remarks

slide-2
SLIDE 2

Cameron Macdonell

Scruf Scruf -

  • SCR

SCRiptable iptable U User-level ser-level F File system ile system

  • Scruf

Scruf executes a user script as a user-level executes a user script as a user-level process whenever a file operation occurs in the process whenever a file operation occurs in the directory (CWD) containing the script directory (CWD) containing the script

  • Scruf

Scruf passes the name of the file being accessed as passes the name of the file being accessed as a parameter ( a parameter ($1 $1) to the script ) to the script

  • Locates a script based on its name -

Locates a script based on its name - .on.open .on.open for for example example

  • Allows extension without changing the

Allows extension without changing the applications applications

Cameron Macdonell

The The Scruf Scruf Framework: A Diagram Framework: A Diagram

User-level Kernel Unmodifed Application VFS Scruf-VFS /usr/scovil2 /proc/scruf User-Level Daemon

Trigger files

  • pen() read() write() …

.on.open .on.read .on.write …

/usr/ntfs

slide-3
SLIDE 3

Cameron Macdonell

Example Extended File Example Extended File Systems Systems

  • We have built five sample extended file systems:

We have built five sample extended file systems:

  • Scruf

Scruf-CVS

  • CVS
  • Backs up files with open-close semantics

Backs up files with open-close semantics

  • Scruf

Scruf-Trace

  • Trace
  • Logs all file operations

Logs all file operations

  • Scruf

Scruf-Crypt

  • Crypt
  • Transparent access to encrypted files

Transparent access to encrypted files

  • Scruf

Scruf-Compress

  • Compress
  • Transparent access to compressed files

Transparent access to compressed files

  • Scruf

Scruf-Trellis

  • Trellis
  • Remote Data Access

Remote Data Access

  • Average 40 lines of code

Average 40 lines of code

Cameron Macdonell

Andrew100 Andrew100

50 50 100 100 150 150 200 200 250 250 300 300 350 350 400 400 1 2 3 4 5 Phase Phase Numbers Numbers Time Time (s) (s) ext2 ext2 Scruf-Trace Scruf-Trace

21.7% 0% 13% 6.2% 0%

slide-4
SLIDE 4

Cameron Macdonell

Build of the Linux Kernel Build of the Linux Kernel

50 50 100 100 150 150 200 200 250 250 300 300 350 350 400 400 450 450 make make dep dep make make bzImage bzImage Build Build Stage Stage Time Time (s) (s) ext2 ext2 Scruf-Trace Scruf-Trace

21.5% 3.2%

Cameron Macdonell

Running Running Scruf Scruf with No with No Scripts Scripts

  • Measures the overhead of the framework

Measures the overhead of the framework

  • Applications should not be hindered if no extensions

Applications should not be hindered if no extensions are used are used

  • Framework is in place,the daemon is running,

Framework is in place,the daemon is running, there are there are no no scripts in the hierarchy scripts in the hierarchy

  • What operations are involved?

What operations are involved?

  • IPC to user-level

IPC to user-level

  • Search for, and attempted inheritance of, Scripts

Search for, and attempted inheritance of, Scripts

  • Filters are setup in kernel

Filters are setup in kernel

  • The highest overhead noted is

The highest overhead noted is 0.91% 0.91%

  • Overheads are a function of the scripts

Overheads are a function of the scripts

slide-5
SLIDE 5

Cameron Macdonell

Concluding Remarks Concluding Remarks

  • Scruf

Scruf is simple, effective and flexible is simple, effective and flexible

  • Useful extensions can be implemented

Useful extensions can be implemented quickly quickly

  • Trigger scripts average 40 lines of code

Trigger scripts average 40 lines of code

  • Applications do not need to be modified

Applications do not need to be modified

  • Performance

Performance

  • Negligible overhead from the framework

Negligible overhead from the framework

  • Asynchronous and Persistent Scripts can

Asynchronous and Persistent Scripts can improve performance when they can be used improve performance when they can be used

Cameron Macdonell

slide-6
SLIDE 6

Cameron Macdonell

Making Life Easier Making Life Easier

  • Inheritance

Inheritance

  • Simplifies installation and removal of scripts

Simplifies installation and removal of scripts

  • With inheritance, trigger scripts are inherited

With inheritance, trigger scripts are inherited into lower directories into lower directories

/usr bin alberta cam paullu

.on.read .on.write .on.open

thesis

Inherits

Cameron Macdonell

Making Life Easier Making Life Easier

Kernel / Scruf-VFS User-Level / CWD .on.open read write

  • pen

.on.read Filtered, no IPC

  • Filtering

Filtering

  • Keeps track of which directory contain which

Keeps track of which directory contain which scripts scripts

  • Eliminates unnecessary IPC

Eliminates unnecessary IPC

slide-7
SLIDE 7

Cameron Macdonell

Making Life Easier Making Life Easier

  • Inheritance

Inheritance

  • Simplifies installation and removal of scripts

Simplifies installation and removal of scripts

  • With inheritance, trigger scripts are inherited

With inheritance, trigger scripts are inherited into lower directories into lower directories

/usr /usr/home /usr/home/cam .on.open .on.read .on.write inherits

Cameron Macdonell

Sync v. Sync v. Async Async Scripts Scripts

Daemon Script

fork() exec() SCRUF_API_ARGS … computes SCRUF_API_NOOP return to kernel

Daemon Script

fork() exec() computes return to kernel

Synchronous Script Asynchronous Script

SCRUF_API_ARGS … waits Time Time

slide-8
SLIDE 8

Cameron Macdonell

Scruf Scruf-Trellis

  • Trellis

20 20 40 40 60 60 80 80 100 100 120 120 140 140 160 160 180 180 200 200 50 50 MB MB 100 100 MB MB Size Size of

  • f File

File Trellis Trellis scp; scp; bzip2 bzip2

  • With development

With development Scruf Scruf-Trellis should

  • Trellis should

beat its equivalent beat its equivalent

  • Overlapped copying

Overlapped copying and compression and compression

0.26% 0.08%

Cameron Macdonell

Making Life Easier Making Life Easier

  • Symbolic Links

Symbolic Links

[cam@sunset ~/test]$ ls -al [cam@sunset ~/test]$ ls -al total 16 total 16 drwx drwx--S--- 2 cam grad 4096 Aug 15 14:48 .

  • -S--- 2 cam grad 4096 Aug 15 14:48 .

drwxr drwxr-sr-x 69 cam grad 4096 Aug 15 14:48 ..

  • sr-x 69 cam grad 4096 Aug 15 14:48 ..

lrwxrwxrwx lrwxrwxrwx 1 cam grad 8 Aug 15 14:47 .on. 1 cam grad 8 Aug 15 14:47 .on.lseek lseek -> .on.open

  • > .on.open
  • rwx

rwx------ 1 cam grad 43 Aug 15 14:46 .on.open

  • ----- 1 cam grad 43 Aug 15 14:46 .on.open

lrwxrwxrwx lrwxrwxrwx 1 cam grad 8 Aug 15 14:47 .on.read -> .on.open 1 cam grad 8 Aug 15 14:47 .on.read -> .on.open lrwxrwxrwx lrwxrwxrwx 1 cam grad 8 Aug 15 14:47 .on.release -> .on.open 1 cam grad 8 Aug 15 14:47 .on.release -> .on.open lrwxrwxrwx lrwxrwxrwx 1 cam grad 8 Aug 15 14:47 .on.write -> .on.open 1 cam grad 8 Aug 15 14:47 .on.write -> .on.open

  • rw

rw------- 1 cam grad 951 Aug 15 14:48

  • ------ 1 cam grad 951 Aug 15 14:48 anyfile

anyfile [cam@sunset ~/test]$ cat .on.open [cam@sunset ~/test]$ cat .on.open #!/bin/ #!/bin/sh sh echo $2 >> / echo $2 >> /usr usr/scovil3/ /scovil3/logfile logfile [cam@sunset ~/test]$ [cam@sunset ~/test]$

slide-9
SLIDE 9

Cameron Macdonell

The The Scruf Scruf Framework: At User-Level Framework: At User-Level

  • Run when their corresponding file

Run when their corresponding file

  • peration occurs
  • peration occurs
  • Can perform two actions

Can perform two actions

1) 1) Interposed Interposed Action Action

  • File operation continues as normal

File operation continues as normal

2) 2) Redirection Redirection Action Action

  • Redirect

Redirect Scruf Scruf-VFS to a different file

  • VFS to a different file
  • Currently, can only come from

Currently, can only come from .on.open .on.open

Cameron Macdonell

Back to Our Example Back to Our Example

  • For our purpose instead of storing editor

For our purpose instead of storing editor preferences, we want to store an executable preferences, we want to store an executable command command

  • cvs commit

cvs commit filename filename

  • Important:

Important: we don we don’ ’t want to have to re-write t want to have to re-write every application to run the script every application to run the script

  • Solution:

Solution: Have the file system look for and Have the file system look for and execute the scripts when certain file operations execute the scripts when certain file operations (i.e., open) occur (i.e., open) occur

slide-10
SLIDE 10

Cameron Macdonell

VFS Trigger Scripts VFS Trigger Scripts

  • Allows extension of five file operations

Allows extension of five file operations

  • pen, read, write, seek, release
  • pen, read, write, seek, release
  • release is like close

release is like close

  • Extends these operations by running specially-

Extends these operations by running specially- named, user-defined scripts in the CWD when named, user-defined scripts in the CWD when they occur they occur

  • pen
  • pen

.on.open .on.open

  • read

read .on.read .on.read

  • Passes data describing the operation to the

Passes data describing the operation to the script script

  • /

/usr usr/home/cam/ /home/cam/myfile myfile.c,read,0,4096,2024,14:24:37.215 .c,read,0,4096,2024,14:24:37.215

Cameron Macdonell

Path Trigger Scripts Path Trigger Scripts

  • Explicitly invoked in a pathname

Explicitly invoked in a pathname

  • trellis

trellis: :scp scp:sunset:~/ :sunset:~/myfile myfile.c .c

  • Assume path before colon is an

Assume path before colon is an executable executable

  • Text following colon is passed on the

Text following colon is passed on the command line to the path script command line to the path script

  • Equivalent to

Equivalent to

[cam]$ [cam]$ trellis trellis scp scp:sunset:~/ :sunset:~/myfile myfile.c .c

slide-11
SLIDE 11

Cameron Macdonell

The The Scruf Scruf Framework Framework

  • Three main components:

Three main components:

1) 1) A kernel module, called A kernel module, called Scruf Scruf-VFS

  • VFS
  • A modified

A modified ext2 ext2 module module

  • Communicates to user-level when file operations occur

Communicates to user-level when file operations occur

2) 2) A user-level daemon A user-level daemon

  • Searches for and executes the scripts

Searches for and executes the scripts

3) 3) The trigger scripts The trigger scripts

  • Specially named files which encapsulate the functionality

Specially named files which encapsulate the functionality which extend the file system which extend the file system’ ’s operation s operation

  • What does not change?

What does not change?

  • The applications!

The applications!

Cameron Macdonell

The The Scruf Scruf Framework: At User-Level Framework: At User-Level

  • The Daemon

The Daemon

  • A

A multiplexor multiplexor in a one-to-many environment in a one-to-many environment

  • One:

One: Scruf Scruf-VFS in the kernel

  • VFS in the kernel
  • Communicate with the daemon via /proc file system

Communicate with the daemon via /proc file system

  • Many:

Many: The Trigger Scripts The Trigger Scripts

  • Communicate with the daemon via pipe IPC

Communicate with the daemon via pipe IPC

  • Locates and runs scripts, if they exist

Locates and runs scripts, if they exist

[cam@sunset ~/test]$ ls -al [cam@sunset ~/test]$ ls -al total 16 total 16 drwx drwx--S--- 2 cam grad 4096 Aug 15 14:48 .

  • -S--- 2 cam grad 4096 Aug 15 14:48 .

drwxr drwxr-sr-x 69 cam grad 4096 Aug 15 14:48 ..

  • sr-x 69 cam grad 4096 Aug 15 14:48 ..
  • rwx

rwx------ 1 cam grad 43 Aug 15 14:46 .on.open

  • ----- 1 cam grad 43 Aug 15 14:46 .on.open
  • rw

rw------- 1 cam grad 951 Aug 15 14:48

  • ------ 1 cam grad 951 Aug 15 14:48 anyfile

anyfile [cam@sunset ~/test]$ [cam@sunset ~/test]$

slide-12
SLIDE 12

Cameron Macdonell

Trigger Scripts Trigger Scripts

  • General Operation

General Operation

  • Receive data describing file operation

Receive data describing file operation

  • Receive data two ways

Receive data two ways

  • Command line and pipe IPC (

Command line and pipe IPC (stdin stdin, , stdout stdout) )

  • usr

usr/alberta/ /alberta/myfile myfile.c,read,0,4096,1665,16:41:30.716 .c,read,0,4096,1665,16:41:30.716

  • Perform computation

Perform computation

  • Compression, encryption, write to log file,

Compression, encryption, write to log file, … …

  • Return an code to the daemon which is the

Return an code to the daemon which is the passed to the kernel passed to the kernel

Cameron Macdonell

Scruf Scruf-Trace

  • Trace
  • Helps understand file I/O patterns in

Helps understand file I/O patterns in applications applications

  • Used to trace the file I/O in

Used to trace the file I/O in gcc gcc

  • Traces all opens, reads, writes,

Traces all opens, reads, writes, lseeks lseeks and and releases releases

  • Can log thousands of file ops per second

Can log thousands of file ops per second

  • Each trigger file is 64 lines of compiled C

Each trigger file is 64 lines of compiled C code code

slide-13
SLIDE 13

Cameron Macdonell

Scruf Scruf-Trace

  • Trace

Cameron Macdonell

Scruf Scruf-Trace

  • Trace
slide-14
SLIDE 14

Cameron Macdonell

The The Scruf Scruf Framework: In the kernel Framework: In the kernel

  • Underneath is exactly like

Underneath is exactly like ext2 ext2

  • Storage and access of files does not change

Storage and access of files does not change

  • When no trigger scripts are present,

When no trigger scripts are present, Scruf Scruf behaves just like behaves just like ext2 ext2

  • An

An ext2 ext2 partition can be mounted as a partition can be mounted as a Scruf Scruf partition without reformatting partition without reformatting

  • Changes are restricted to a Linux kernel

Changes are restricted to a Linux kernel loadable module loadable module

  • No patching, recompilation or rebooting

No patching, recompilation or rebooting

Cameron Macdonell

Making Life Easier Making Life Easier

  • Four mechanisms which make trigger

Four mechanisms which make trigger scripts easier to user and more efficient scripts easier to user and more efficient

  • Symbolic links

Symbolic links

  • Persistence

Persistence

  • Inheritance

Inheritance

  • Filtering

Filtering

slide-15
SLIDE 15

Cameron Macdonell

Motivating Example Motivating Example

  • File Back-up

File Back-up

  • For software development, paper writing

For software development, paper writing

  • Revisions are created using versioning software like CVS

Revisions are created using versioning software like CVS

  • They are recovered in case of lost data, or to

They are recovered in case of lost data, or to “ “start fresh start fresh” ”

  • Encapsulate the command into a script

Encapsulate the command into a script

  • Then we need the system to run the script every time

Then we need the system to run the script every time a file is opened (or closed). a file is opened (or closed).

#!/bin/sh cvs commit $1

Cameron Macdonell

What are Trigger Scripts? What are Trigger Scripts?

  • Trigger scripts are executable scripts

Trigger scripts are executable scripts which extend file system functionality which extend file system functionality

  • They are regular user-level programs

They are regular user-level programs which can be implemented in any which can be implemented in any language language

  • C, Python,

C, Python, Perl Perl, etc. , etc.

  • Supported by the

Supported by the Scruf Scruf framework framework

  • But, why would anyone want to extend the

But, why would anyone want to extend the file system? file system?

slide-16
SLIDE 16

Cameron Macdonell

Similar Idea: RC files Similar Idea: RC files

  • A similar idea already exists with RC files

A similar idea already exists with RC files

  • Editors such as Vim and

Editors such as Vim and Emacs Emacs have thousands have thousands

  • f options
  • f options
  • i.e., colors, spacing, syntax highlighting

i.e., colors, spacing, syntax highlighting

  • No user would tolerate inputting these options

No user would tolerate inputting these options every time they open a file in the editor every time they open a file in the editor

  • Instead, the save their preferences in a file, with a

Instead, the save their preferences in a file, with a predefined name (. predefined name (.vimrc vimrc, . , .emacs emacs) that the application ) that the application looks for and reads when it is started. looks for and reads when it is started.

Cameron Macdonell

Making Life Easier Making Life Easier

  • Persistent Scripts

Persistent Scripts

  • Scripts that do not exit after handling a single

Scripts that do not exit after handling a single file operation file operation

  • Remains running for subsequent operations

Remains running for subsequent operations

  • Saves startup overhead

Saves startup overhead

  • Scruf

Scruf-Trace logs 2,300 access/second

  • Trace logs 2,300 access/second
  • Daemon keeps a pipe open between itself

Daemon keeps a pipe open between itself and each persistent script and each persistent script

slide-17
SLIDE 17

Cameron Macdonell

Experiments Experiments

  • Scruf

Scruf-Trace was run on two benchmarks

  • Trace was run on two benchmarks
  • Andrew100

Andrew100

  • Based on the well-known Modified Andrew

Based on the well-known Modified Andrew Benchmark(MAB) Benchmark(MAB)

  • Five stages

Five stages

  • mkdir

mkdir, cp, ls -l, wc & , cp, ls -l, wc & grep grep, , gcc gcc

  • MAB is too small on modern system

MAB is too small on modern system

  • Andrew100 performs MAB 100 times

Andrew100 performs MAB 100 times

  • Build of the Linux Kernel

Build of the Linux Kernel

  • A full compilation of the 2.4.18 kernel

A full compilation of the 2.4.18 kernel

Cameron Macdonell

Testing Path Scripts Testing Path Scripts

  • Path scripts are a second type of trigger script

Path scripts are a second type of trigger script

  • Explicitly named and executed

Explicitly named and executed

  • Scruf

Scruf-Trellis

  • Trellis
  • Remote data access

Remote data access

  • Compare

Compare

[cam]$ bzip2 -c trellis: [cam]$ bzip2 -c trellis:scp scp:sunset:/ :sunset:/usr usr/cam/ /cam/mymail mymail > /dev/null > /dev/null [cam]$ [cam]$ scp scp sunset:/ sunset:/usr usr/cam/ /cam/mymail tmp mymail tmp ; bzip2 -c ; bzip2 -c tmp tmp > /dev/null > /dev/null

  • Tested on 50 MB and 100 MB files

Tested on 50 MB and 100 MB files

  • Written in 30 lines of Python code

Written in 30 lines of Python code

slide-18
SLIDE 18

Cameron Macdonell

Trigger Script API Trigger Script API

  • Scripts interact with the Daemon via API

Scripts interact with the Daemon via API

  • Language-independent, using ASCII strings

Language-independent, using ASCII strings

  • Examples:

Examples:

  • Behaviour

Behaviour Codes Codes

  • SCRUF_API_ASYNC, SCRUF_API_PERSIST

SCRUF_API_ASYNC, SCRUF_API_PERSIST

  • Return Codes

Return Codes

  • SCRUF_API_NOOP, SCRUF_API_RELOAD

SCRUF_API_NOOP, SCRUF_API_RELOAD

  • Control Codes

Control Codes

  • SCRUF_API_ARGS, SCRUF_API_KILL

SCRUF_API_ARGS, SCRUF_API_KILL

Cameron Macdonell

Making Life Easier Making Life Easier

  • Asynchronous Scripts

Asynchronous Scripts

  • Non-blocking scripts

Non-blocking scripts

  • Daemon does not wait for a return code from

Daemon does not wait for a return code from the script the script

  • Assumes

Assumes interposed action interposed action and returns and returns SCRUF_API_NOOP SCRUF_API_NOOP to kernel to kernel

  • Daemon is not blocked waiting for a return

Daemon is not blocked waiting for a return values, instead returns immediately to kernel values, instead returns immediately to kernel and retrieves next operation and retrieves next operation

  • Most useful with persistent scripts

Most useful with persistent scripts