UNRM Hacking the filesystem Jessica Yu WHOOPS... GMAIL: UNDO SEND - - PowerPoint PPT Presentation

unrm
SMART_READER_LITE
LIVE PREVIEW

UNRM Hacking the filesystem Jessica Yu WHOOPS... GMAIL: UNDO SEND - - PowerPoint PPT Presentation

UNRM Hacking the filesystem Jessica Yu WHOOPS... GMAIL: UNDO SEND unrm operates on the same idea as Gmail's undo send. UNRM: USAGE Goal : after an rm , want to be able to recover all removed files under a certain directory within a set period


slide-1
SLIDE 1

UNRM

Hacking the filesystem

Jessica Yu

slide-2
SLIDE 2

WHOOPS...

slide-3
SLIDE 3

GMAIL: UNDO SEND

unrm operates on the same idea as Gmail's undo send.

slide-4
SLIDE 4

UNRM: USAGE Goal: after an rm, want to be able to recover all removed files under a certain directory within a set period of time.

$ ls document.pdf image.png file.txt dir/ $ rm -r * # rm all files $ ls -l # all gone! total 0 $ unrm # undo $ ls document.pdf image.png file.txt dir/ # all back!

slide-5
SLIDE 5

RM: UNDER THE HOOD

Application Application Application C-Standard Library (libc) Virtual Filesystem (VFS) Ext4 Btrfs XFS

USERSPACE KERNELSPACE

What happens during an rm?

slide-6
SLIDE 6

RM: UNDER THE HOOD

Application rm Application C-Standard Library (libc) Virtual Filesystem (VFS) Ext4 Btrfs XFS

USERSPACE KERNELSPACE

What happens during an rm?

$ strace rm file ... unlinkat(AT_FDCWD, "file", 0) ...

slide-7
SLIDE 7

RM: UNDER THE HOOD

Application rm Application C-Standard Library (libc) Virtual Filesystem (VFS) Ext4 Btrfs XFS

USERSPACE KERNELSPACE

What happens during an rm?

$ strace rm file ... unlinkat(AT_FDCWD, "file", 0) ... do_unlinkat(...) → vfs_unlink(...)

slide-8
SLIDE 8

RM: UNDER THE HOOD

Application rm Application C-Standard Library (libc) Virtual Filesystem (VFS) Ext4 Btrfs XFS

USERSPACE KERNELSPACE

What happens during an rm?

$ strace rm file ... unlinkat(AT_FDCWD, "file", 0) ... do_unlinkat(...) → vfs_unlink(...) → dir->i_op->unlink(...)

slide-9
SLIDE 9

RM: UNDER THE HOOD

Application rm Application C-Standard Library (libc) Virtual Filesystem (VFS) Ext4 Btrfs XFS

USERSPACE KERNELSPACE

What happens during an rm?

$ strace rm file ... unlinkat(AT_FDCWD, "file", 0) ... do_unlinkat(...) → vfs_unlink(...) → dir->i_op->unlink(...) → ext4_unlink(....)

slide-10
SLIDE 10

UNRM: UNDER THE HOOD

Application rm Application C-Standard Library (libc) Virtual Filesystem (VFS) Ext4 Btrfs XFS

USERSPACE KERNELSPACE

What happens during an rm?

$ strace rm file ... unlinkat(AT_FDCWD, "file", 0) ... do_unlinkat(...) → vfs_unlink(...) → dir->i_op->unlink(...) → ext4_unlink(....) → ext4_unrm_save(...)

slide-11
SLIDE 11

UNRM: OVERVIEW ○ Idea: Intercept unlinking process at the fs layer ○ When we run rm, we want it to look like the file has been removed already ('ls' shouldn't show file) □ But file should still exist somewhere □ And the file is finally removed after a period of time ○ accomplish this via work queues

slide-12
SLIDE 12

UNRM: OVERVIEW

○ Create a tree

□ "second chance tree" □ radix tree rooted at ext4 superblock info struct ○ indexed by directory inode # □ each node in the tree points to a linked list

○ Linked lists

□ For each directory, use a linked list to keep track

  • f individual rm'd files from that dir

○ Work queues

□ Finish unlinking process after set period of time ext4_sb_info

... struct radix_tree_root s_unrm; ... file file file

3 s e c . 3 s e c . 3 s e c .

...

dir 123

slide-13
SLIDE 13

UNRM: OVERVIEW

○ Create a tree

□ "second chance tree" □ radix tree rooted at ext4 superblock info struct ○ indexed by directory inode # □ each node in the tree points to a linked list

○ Linked lists

□ For each directory, use a linked list to keep track

  • f individual rm'd files from that dir

○ Work queues

□ Finish unlinking process after set period of time ext4_sb_info

... struct radix_tree_root s_unrm; ... file file file

R I N G ! ! 3 s e c . 3 s e c .

...

dir 123

slide-14
SLIDE 14

UNRM: OVERVIEW

○ Create a tree

□ "second chance tree" □ radix tree rooted at ext4 superblock info struct ○ indexed by directory inode # □ each node in the tree points to a linked list

○ Linked lists

□ For each directory, use a linked list to keep track

  • f individual rm'd files from that dir

○ Work queues

□ Finish unlinking process after set period of time □ File is removed + entry from linked list removed ext4_sb_info

... struct radix_tree_root s_unrm; ... file file file

3 s e c . 3 s e c .

...

dir 123 goodbye world :(

slide-15
SLIDE 15

UNRM: OVERVIEW

○ Create a tree

□ "second chance tree" □ radix tree rooted at ext4 superblock info struct ○ indexed by directory inode # □ each node in the tree points to a linked list

○ Linked lists

□ For each directory, use a linked list to keep track

  • f individual rm'd files from that dir

○ Work queues

□ Finish unlinking process after set period of time □ File is removed + entry from linked list removed ext4_sb_info

... struct radix_tree_root s_unrm; ... file file

3 s e c . 3 s e c .

...

dir 123

slide-16
SLIDE 16

UNRM: ext4_unrm_save()

○ Idea: Intercept unlinking process at the fs layer

□ Want to invalidate associated dentry (negate it) ○ So that lookups fail □ ...but keep around the inode secretly (link count > 0) □ keep around the negative dentry too ○ we'll need to "instantiate" it again if we call unrm ○ ...i.e., make the path lookup succeed again!

$ ls testfile testfile: No such file or directory $ ▌

slide-17
SLIDE 17

UNRM: ext4_unrm_save()

○ Idea: Intercept unlinking process at the fs layer

□ ext4_unlink()

○ Inserts new entry in our radix tree

□ Save relevant info that will let us unrm □ i.e. Save pointers to the inode and dentry

○ But do not drop the inode's i_nlink (# of hard links) ext4_unrm_save():

slide-18
SLIDE 18

UNRM: ext4_unrm_save()

$ pwd /home/jyu/ $ ls -lih /home/jyu

795 drwx------ 41 jyu jyu 4.0K Aug 12 22:37 /home/jyu

$ ls testfile.pdf track01.mp3 important.doc $ ls -lih testfile.pdf

901 -rw-r--r-- 1 jyu jyu 94K Jun 23 18:04 testfile.pdf

$ ▌

radix_tree_root s_unrm

ext4_sb_info

slide-19
SLIDE 19

UNRM: ext4_unrm_save()

$ pwd /home/jyu/ $ ls -lih /home/jyu

795 drwx------ 41 jyu jyu 4.0K Aug 12 22:37 /home/jyu

$ ls testfile.pdf track01.mp3 important.doc $ ls -lih testfile.pdf

901 -rw-r--r-- 1 jyu jyu 94K Jun 23 18:04 testfile.pdf

$ rm testfile.pdf $ ▌

radix_tree_root s_unrm

▌ key: 795 ➞ Create a new list

head

➞ Insert into radix

tree with key 795

➞ Create list node

with:

ext4_sb_info

slide-20
SLIDE 20

UNRM: ext4_unrm_save()

$ pwd /home/jyu/ $ ls -lih /home/jyu

795 drwx------ 41 jyu jyu 4.0K Aug 12 22:37 /home/jyu

$ ls testfile.pdf track01.mp3 important.doc $ ls -lih testfile.pdf

901 -rw-r--r-- 1 jyu jyu 94K Jun 23 18:04 testfile.pdf

$ rm testfile.pdf $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 901 □ dentry

➞ Create a new list

head

➞ Insert into radix

tree with key 795

➞ Create list node

with: □ pointer to inode □ pointer to dentry □ allocated work

ext4_sb_info

slide-21
SLIDE 21

UNRM: ext4_unrm_save()

$ pwd /home/jyu/ $ ls -lih /home/jyu ### inode 795

795 drwx------ 41 jyu jyu 4.0K Aug 12 22:37 /home/jyu

$ ls testfile.pdf track01.mp3 important.doc $ ls -lih testfile.pdf

901 -rw-r--r-- 1 jyu jyu 94K Jun 23 18:04 testfile.pdf

$ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 901 □ dentry

➞ Create a new list

head

➞ Insert into radix

tree with key 795

➞ Create list node

with: □ pointer to inode □ pointer to dentry □ allocated work

□ inode 941 □ dentry

ext4_sb_info

slide-22
SLIDE 22

UNRM: ext4_unrm_save()

$ pwd /home/jyu/ $ ls -lih /home/jyu ### inode 795

795 drwx------ 41 jyu jyu 4.0K Aug 12 22:37 /home/jyu

$ ls testfile.pdf track01.mp3 important.doc $ ls -lih testfile.pdf

901 -rw-r--r-- 1 jyu jyu 94K Jun 23 18:04 testfile.pdf

$ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 901 □ dentry

➞ Create a new list

head

➞ Insert into radix

tree with key 795

➞ Create list node

with: □ pointer to inode □ pointer to dentry □ allocated work

➞ Negative dentries

created as unlink process finishes

□ inode 941 □ dentry

ext4_sb_info

slide-23
SLIDE 23

UNRM: RECURSIVE RM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ ▌

radix_tree_root s_unrm

ext4_sb_info

slide-24
SLIDE 24

UNRM: RECURSIVE RM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ ▌

radix_tree_root s_unrm

ext4_sb_info

slide-25
SLIDE 25

UNRM: RECURSIVE RM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ testfile.pdf □ dentry □ music/ □ dentry

*

inode #'s replaced with filenames for simplicity

slide-26
SLIDE 26

UNRM: RECURSIVE RM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ echo * testfile.pdf music ### rm -r * uses this order $ rm -r * ### BOOM $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ testfile.pdf □ dentry □ music/ □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1

Mark dir entries so that we can recurse into them when unrm is called later

slide-27
SLIDE 27

UNRM: RECURSIVE RM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ echo * testfile.pdf music ### rm -r * uses this order $ rm -r * ### BOOM $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ testfile.pdf □ dentry □ music/ □ dentry key: music/ □ track01.mp3 □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1

slide-28
SLIDE 28

UNRM: BACK TO USERSPACE

○ The "unrm" command □ a simple C program ○ issues an ioctl() to ext4 (ext4_ioctl())

○ ext4_ioctl()

ext4_do_unrm()

slide-29
SLIDE 29

UNRM: ext4_do_unrm()

int ext4_do_unrm(struct super_block *sb, struct inode *dir) Arguments: ○ @sb: superblock struct

□ should be an ext4fs superblock □ from superblock can access our unrm radix tree

○ @dir: directory in which to look for recently rm'd files □ use this dir's inode number as key into radix tree

slide-30
SLIDE 30

UNRM: ext4_do_unrm()

int ext4_do_unrm(struct super_block *sb, struct inode *dir) What does ext4_do_unrm() do?

○ Lookup dir->i_no with radix_tree_lookup()

□ key: directory inode number. □ entry: linked list of deleted files

○ iterate list of deleted files: list_for_each_entry(...) □ For each deleted file:

○ add the file back to the directory

(remember, directories are just files that are lists of other files, so we're technically just adding an entry back)

○ re-instantiate saved dentry with saved inode ○ cancel scheduled work

slide-31
SLIDE 31

UNRM: ext4_do_unrm()

$ pwd /home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 901 □ dentry □ inode 941 □ dentry

ext4_sb_info

slide-32
SLIDE 32

UNRM: ext4_do_unrm()

$ pwd /home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 901 □ dentry □ inode 941 □ dentry

ext4_sb_info

What directory was 'unrm' executed in? ..Oh, /home/jyu, inode 795 Is it in our radix tree?

slide-33
SLIDE 33

UNRM: ext4_do_unrm()

$ pwd

/home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 901 □ dentry □ inode 941 □ dentry

ext4_sb_info

What directory was 'unrm' executed in? ..Oh, /home/jyu, inode 795 Is it in our radix tree? radix_tree_lookup(..,795);

slide-34
SLIDE 34

UNRM: ext4_do_unrm()

$ pwd

/home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 901 □ dentry □ inode 941 □ dentry

ext4_sb_info

What directory was 'unrm' executed in? ..Oh, /home/jyu, inode 795 Is it in our radix tree? radix_tree_lookup(..,795);

slide-35
SLIDE 35

UNRM: ext4_do_unrm()

$ pwd

/home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 901 □ dentry □ inode 941 □ dentry

ext4_sb_info

radix_tree_lookup(..,795); Found our linked list. Iterate through it: list_for_each_entry(...)

slide-36
SLIDE 36

UNRM: ext4_do_unrm()

$ pwd

/home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 941 □ dentry

ext4_sb_info

Iterate through it: list_for_each_entry(...) ➞ add inode+dentry back to directory (/home/jyu in this case) ➞ reinstantiate dentry (so it's no longer negative) ➞ cancel scheduled work ➞ remove from list

□ inode 901 □ dentry

slide-37
SLIDE 37

UNRM: ext4_do_unrm()

$ pwd

/home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 941 □ dentry

ext4_sb_info

Iterate through it: list_for_each_entry(...) ➞ add inode+dentry back to directory (/home/jyu in this case) ➞ reinstantiate dentry (so it's no longer negative) ➞ cancel scheduled work ➞ remove from list

slide-38
SLIDE 38

UNRM: ext4_do_unrm()

$ pwd

/home/jyu

$ ls

testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 941 □ dentry

ext4_sb_info

Iterate through it: list_for_each_entry(...) ➞ add inode+dentry back to directory (/home/jyu in this case) ➞ reinstantiate dentry (so it's no longer negative) ➞ cancel scheduled work ➞ remove from list

slide-39
SLIDE 39

UNRM: ext4_do_unrm()

$ pwd

/home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

▌ key: 795

□ inode 941 □ dentry

ext4_sb_info

Iterate through it: list_for_each_entry(...) ➞ add inode+dentry back to directory (/home/jyu in this case) ➞ reinstantiate dentry (so it's no longer negative) ➞ cancel scheduled work ➞ remove from list

slide-40
SLIDE 40

UNRM: ext4_do_unrm()

$ pwd

/home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

▌ key: 795

ext4_sb_info

Iterate through it: list_for_each_entry(...) ➞ add inode+dentry back to directory (/home/jyu in this case) ➞ reinstantiate dentry (so it's no longer negative) ➞ cancel scheduled work ➞ remove from list

slide-41
SLIDE 41

UNRM: ext4_do_unrm()

$ pwd

/home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

▌ key: 795

ext4_sb_info

Iterate through it: list_for_each_entry(...) ➞ add inode+dentry back to directory (/home/jyu in this case) ➞ reinstantiate dentry (so it's no longer negative) ➞ cancel scheduled work ➞ remove from list

slide-42
SLIDE 42

UNRM: ext4_do_unrm()

$ pwd

/home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

List empty, looks like we're all done here.

slide-43
SLIDE 43

UNRM: ext4_do_unrm()

$ pwd

/home/jyu $ ls testfile.pdf track01.mp3 important.doc $ rm testfile.pdf ### inode 901 $ rm track01.mp3 ### inode 941 $ ls track01.mp3 track01.mp3: No such file or directory $ unrm $ ls ### success! testfile.pdf track01.mp3 important.doc $ ▌

radix_tree_root s_unrm

ext4_sb_info

List empty, looks like we're all done here.

slide-44
SLIDE 44

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ testfile.pdf □ dentry □ music/ □ dentry key: music/ □ track01.mp3 □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1

slide-45
SLIDE 45

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ testfile.pdf □ dentry □ music/ □ dentry key: music/ □ track01.mp3 □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1

slide-46
SLIDE 46

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ testfile.pdf □ dentry □ music/ □ dentry key: music/ □ track01.mp3 □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1

slide-47
SLIDE 47

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ music/ □ dentry key: music/ □ track01.mp3 □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1

slide-48
SLIDE 48

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ music/ □ dentry key: music/ □ track01.mp3 □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1 hey, it's a directory

slide-49
SLIDE 49

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ music/ □ dentry key: music/ □ track01.mp3 □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1 RECURSE: Grab inode num for music/, recursively call ext4_do_unrm() passing in the ino

slide-50
SLIDE 50

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ music/ □ dentry key: music/ □ track01.mp3 □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1

ext4_do_unrm()

➞ radix_tree_lookup()

➞ found it!

RECURSE: Grab inode num for music/, recursively call ext4_do_unrm() passing in the ino ➞

slide-51
SLIDE 51

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ music/ □ dentry key: music/ □ track01.mp3 □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1 RECURSE: Grab inode num for music/, recursively call ext4_do_unrm() passing in the ino ➞

slide-52
SLIDE 52

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ music/ □ dentry key: music/

*

inode #'s replaced with filenames for simplicity

dir=1 RECURSE: Grab inode num for music/, recursively call ext4_do_unrm() passing in the ino ➞

slide-53
SLIDE 53

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu □ music/ □ dentry

*

inode #'s replaced with filenames for simplicity

dir=1 RECURSE: Grab inode num for music/, recursively call ext4_do_unrm() passing in the ino ➞

slide-54
SLIDE 54

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ ▌

radix_tree_root s_unrm

ext4_sb_info

key:/home/jyu

*

inode #'s replaced with filenames for simplicity

slide-55
SLIDE 55

RECURSIVE UNRM

$ pwd /home/jyu/ $ ls testfile.pdf music/ $ ls music/ track01.mp3 $ rm -r * ### BOOM $ unrm $ tree ### Show dir tree . ├── music ### Hurray! │ └── track01.mp3 └── testfile.pdf

radix_tree_root s_unrm

ext4_sb_info

*

inode #'s replaced with filenames for simplicity

➞ List empty, looks like we're all done here.

slide-56
SLIDE 56

DEMO

...Let's hope nothing explodes

%_

slide-57
SLIDE 57

UNRM: ISSUES & FUTURE WORK

○ Warning! unrm is just a fun hack! Was never meant to be used in production With that said...Here are some ideas for future work... ○ Memory hog! Removal of thousands of files = thousands

  • f nodes in memory

○ Security - take permissions into account ○ Make work queue delay adjustable - make the period of time adjustable (currently hardcoded at 30 seconds) ○ Filesystem can be left inconsistent in the event of a sudden crash (before unlinking or unrm process finishes) ○ ....probably more! Feel free to send pull requests!

slide-58
SLIDE 58

FULL KERNEL SOURCE GITHUB.COM/FLAMING-TOAST/UNRM

Thanks!

CONTACT JYU AT EISEN.IO