Project

General

Profile

FallocateHole Punching Support for Ceph » History » Version 3

Jessica Mack, 06/09/2015 06:39 AM

1 1 Jessica Mack
h1. FallocateHole Punching Support for Ceph
2 1 Jessica Mack
3 1 Jessica Mack
h3. Summary
4 1 Jessica Mack
5 1 Jessica Mack
Hole punching in file-systems is to mark a portion of a file as being unneeded and the associated storage to that file portion can then be freed. This is very useful for a file system being used as virtual machine image file storage. By virtue of hole punching, VMM could free host space while guest occupies less space. Hole punching has been implemented by xfs and btrfs etc. Given VM image storage is an important use case for Ceph, it is beneficial to equip Ceph with hole punching.
6 1 Jessica Mack
7 1 Jessica Mack
h3. Owners
8 1 Jessica Mack
9 1 Jessica Mack
* Li Wang (UbuntuKylin)
10 1 Jessica Mack
11 1 Jessica Mack
h3. Interested Parties
12 1 Jessica Mack
13 1 Jessica Mack
* Greg Farnum
14 1 Jessica Mack
* Loic Dachary
15 1 Jessica Mack
16 1 Jessica Mack
h3. Current Status
17 1 Jessica Mack
18 1 Jessica Mack
Under design
19 1 Jessica Mack
20 1 Jessica Mack
h3. Detailed Description
21 1 Jessica Mack
22 1 Jessica Mack
It shoule be simple. Implement the file_operations fallocate(struct file *file, int mode, loff_t offset, loff_t len) call back function, support the argument FALLOC_FL_PUNCH_HOLE. It uses the metadata retrieved from mds and the offset as well as len to calculate the objects fit into the hole,  and communicate with OSDs to delete those objects.
23 3 Jessica Mack
24 3 Jessica Mack
h3. Algorithm
25 3 Jessica Mack
26 1 Jessica Mack
long ceph_fallocate(struct file *file, int mode, loff_t offset, loff_t length)
27 1 Jessica Mack
28 1 Jessica Mack
{
29 1 Jessica Mack
30 2 Jessica Mack
p((.    if (mode & (~ FALLOC_FL_PUNCH_HOLE))
31 2 Jessica Mack
32 2 Jessica Mack
p(((.   return -EOPNOTSUPP;
33 2 Jessica Mack
34 2 Jessica Mack
p((.    if (!S_ISREG(inode->i_mode))
35 2 Jessica Mack
         
36 2 Jessica Mack
p(((.   return -EOPNOTSUPP;
37 2 Jessica Mack
              
38 2 Jessica Mack
p((.     filemap_write_and_wait_range(mapping, offset, offset + length - 1);
39 1 Jessica Mack
         first_page_offset = ((offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT) << PAGE_CACHE_SHIFT;
40 1 Jessica Mack
         last_page_offset = (offset + length) >> PAGE_CACHE_SHIFT; << PAGE_CACHE_SHIFT;
41 1 Jessica Mack
         truncate_pagecache_range(inode, first_page_offset, last_page_offset - 1);
42 1 Jessica Mack
         zero out the non-object -aligned data in the objects at the start and tail of the hole
43 1 Jessica Mack
         tell osd to delete the objects fit into the hole
44 1 Jessica Mack
45 1 Jessica Mack
}
46 1 Jessica Mack
47 1 Jessica Mack
h3. Work items