Project

General

Profile

FallocateHole Punching Support for Ceph » History » Revision 2

Revision 1 (Jessica Mack, 06/08/2015 11:45 PM) → Revision 2/3 (Jessica Mack, 06/09/2015 06:38 AM)

h1. FallocateHole Punching Support for Ceph 

 h3. Summary 

 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. 

 h3. Owners 

 * Li Wang (UbuntuKylin) 

 h3. Interested Parties 

 * Greg Farnum 
 * Loic Dachary 

 h3. Current Status 

 Under design 

 h3. Detailed Description 

 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. 
 Algorithm 
 long ceph_fallocate(struct file *file, int mode, loff_t offset, loff_t length) 

 { 

 p((.      p(((.          if (mode & (~ FALLOC_FL_PUNCH_HOLE)) 

 p(((.     
              return -EOPNOTSUPP; 

 p((.      
          if (!S_ISREG(inode->i_mode)) 
         
 p(((.     
               return -EOPNOTSUPP; 
              
 p((.       
          filemap_write_and_wait_range(mapping, offset, offset + length - 1); 
          first_page_offset = ((offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT) << PAGE_CACHE_SHIFT; 
          last_page_offset = (offset + length) >> PAGE_CACHE_SHIFT; << PAGE_CACHE_SHIFT; 
          truncate_pagecache_range(inode, first_page_offset, last_page_offset - 1); 
          zero out the non-object -aligned data in the objects at the start and tail of the hole 
          tell osd to delete the objects fit into the hole 

 } 

 h3. Work items