Project

General

Profile

FallocateHole Punching Support for Ceph » History » Version 2

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

1 1 Jessica Mack
h1. FallocateHole Punching Support for Ceph
2
3
h3. Summary
4
5
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
7
h3. Owners
8
9
* Li Wang (UbuntuKylin)
10
11
h3. Interested Parties
12
13
* Greg Farnum
14
* Loic Dachary
15
16
h3. Current Status
17
18
Under design
19
20
h3. Detailed Description
21
22
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
Algorithm
24
long ceph_fallocate(struct file *file, int mode, loff_t offset, loff_t length)
25
26
{
27
28 2 Jessica Mack
p((.    if (mode & (~ FALLOC_FL_PUNCH_HOLE))
29
30
p(((.   return -EOPNOTSUPP;
31
32
p((.    if (!S_ISREG(inode->i_mode))
33
         
34
p(((.   return -EOPNOTSUPP;
35
              
36
p((.     filemap_write_and_wait_range(mapping, offset, offset + length - 1);
37 1 Jessica Mack
         first_page_offset = ((offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT) << PAGE_CACHE_SHIFT;
38
         last_page_offset = (offset + length) >> PAGE_CACHE_SHIFT; << PAGE_CACHE_SHIFT;
39
         truncate_pagecache_range(inode, first_page_offset, last_page_offset - 1);
40
         zero out the non-object -aligned data in the objects at the start and tail of the hole
41
         tell osd to delete the objects fit into the hole
42
43
}
44
45
h3. Work items