Re: [Ext4 punch hole 4/5] Ext4 Punch Hole Support: Enable Punch Hole

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 1, 2011 at 11:09 AM, Allison Henderson
<achender@xxxxxxxxxxxxxxxxxx> wrote:
> This patch adds the Ânew "ext4_punch_hole" "ext4_ext_punch_hole" routines.
>
> fallocate has been modified to call ext4_punch_hole when the punch hole
> flag is passed. ÂAt the moment, we only support punching holes in
> extents, so this routine is pretty much a wrapper for the ext4_ext_punch_hole
> routine.
>
> The ext4_ext_punch_hole routine zeros out the pages that are
> covered by the hole. ÂThe blocks to be punched out
> are then identified as mapped, delayed, or already punched out.
> The blocks that mapped are the converted to into uninitialized
> extents. ÂThe blocks are then punched out using the
> "ext4_ext_release_blocks" routine.
>
> Some minor utility functions have also been added.
> A new ext4_ext_lookup_hole routine is used by
> ext4_ext_punch_hole to check if a range of blocks
> have already been punched out.
>
> A new ext4_ext_test_block_flag has also been
> added to identify the state of a block (ie mapped,
> delayed, ect)
>
> Signed-off-by: Allison Henderson <achender@xxxxxxxxxx>
> ---
> :100644 100644 43a5772... aeb86d6... M Âfs/ext4/ext4.h
> :100644 100644 efbc3ef... 5713258... M Âfs/ext4/extents.c
> :100644 100644 28c9137... 493c908... M Âfs/ext4/inode.c
> Âfs/ext4/ext4.h  Â|  Â2 +
> Âfs/ext4/extents.c | Â321 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
> Âfs/ext4/inode.c  |  26 +++++
> Â3 files changed, 345 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 43a5772..aeb86d6 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -1729,6 +1729,7 @@ extern int ext4_change_inode_journal_flag(struct inode *, int);
> Âextern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
> Âextern int ext4_can_truncate(struct inode *inode);
> Âextern void ext4_truncate(struct inode *);
> +extern long Âext4_punch_hole(struct inode *inode,loff_t offset, loff_t length);
> Âextern int ext4_truncate_restart_trans(handle_t *, struct inode *, int nblocks);
> Âextern void ext4_set_inode_flags(struct inode *);
> Âextern void ext4_get_inode_flags(struct ext4_inode_info *);
> @@ -2066,6 +2067,7 @@ extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks,
> Âextern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct ext4_map_blocks *map, int flags);
> Âextern void ext4_ext_truncate(struct inode *);
> +extern void ext4_ext_punch_hole(struct inode *inode, loff_t offset, loff_t length);
> Âextern void ext4_ext_init(struct super_block *);
> Âextern void ext4_ext_release(struct super_block *);
> Âextern long ext4_fallocate(struct file *file, int mode, loff_t offset,
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index efbc3ef..5713258 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -2776,6 +2776,154 @@ out:
> Â}
>
> Â/*
> + * lookup_hole()
> + * Returns the numbers of consecutive blocks starting at "start"
> + * that are not contained within an extent
> + */
> +static int ext4_ext_lookup_hole(struct inode *inode, ext4_lblk_t start){
> + Â Âstruct super_block *sb = inode->i_sb;
> + Â Â Â int depth = ext_depth(inode);
> + Â Â Â struct ext4_ext_path *path;
> + Â Â Â struct ext4_extent_header *eh;
> + Â Â Â struct ext4_extent *ex;
> + Â Â Â struct buffer_head *bh;
> + Â Â Â ext4_lblk_t last_block;
> + Â Â Â handle_t *handle;
> + Â Â Â int i, err;
> +
> + Â Â Â ext_debug("lookup hole since %u\n", start);
> +
> + Â Â Â /* Make sure start is valid */
> + Â Â Â last_block = inode->i_size >> EXT4_BLOCK_SIZE_BITS(sb);
> + Â Â Â if(start >= last_block)
> + Â Â Â Â Â Â Â return -EIO;
> +
> + Â Â Â handle = ext4_journal_start(inode, depth + 1);
> + Â Â Â if (IS_ERR(handle))
> + Â Â Â Â Â Â Â Â Â Â Â return PTR_ERR(handle);
> +
> + Â Â Â /*
> + Â Â Â Â* We start scanning from right side, looking for
> + Â Â Â Â* the left most block contained in the leaf, and
> + Â Â Â Â* stopping when "start" is crossed.
> + Â Â Â Â*/
> + Â Â Â depth = ext_depth(inode);
> + Â Â Â path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_NOFS);
> + Â Â Â if (path == NULL) {
> + Â Â Â Â Â Â Â Â Â Â Â ext4_journal_stop(handle);
> + Â Â Â Â Â Â Â Â Â Â Â return -ENOMEM;
> + Â Â Â }
> + Â Â Â path[0].p_depth = depth;
> + Â Â Â path[0].p_hdr = ext_inode_hdr(inode);
> + Â Â Â if (ext4_ext_check(inode, path[0].p_hdr, depth)) {
> + Â Â Â Â Â Â Â err = -EIO;
> + Â Â Â Â Â Â Â goto out;
> + Â Â Â }
> + Â Â Â i = err = 0;
> +
> + Â Â Â while (i >= 0 && err == 0) {
> + Â Â Â Â Â Â Â if (i == depth) {
> + Â Â Â Â Â Â Â Â Â Â Â /* this is leaf block */
> +
> + Â Â Â Â Â Â Â Â Â Â Â eh = path[i].p_hdr;
> + Â Â Â Â Â Â Â Â Â Â Â if (eh != NULL){
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (eh->eh_entries == 0){
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â err = -EIO;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â goto out;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ex = EXT_LAST_EXTENT(eh);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â while (ex != NULL && ex >= EXT_FIRST_EXTENT(eh)){
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* If the entire extent apears before start
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* then we have passed the hole.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if(ex->ee_block + ex->ee_len <= start)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â goto out;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* If the start of the extent appears after
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* or on start, then mark this as the edge
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* of the hole
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if(ex->ee_block >= start)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â last_block = ex->ee_block;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* If the extent contains start, then there
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* is no hole.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else if(ex->ee_block + ex->ee_len > start){
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â last_block = start;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â goto out;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ex--;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â Â Â Â Â /* root level has p_bh == NULL, brelse() eats this */
> + Â Â Â Â Â Â Â Â Â Â Â brelse(path[i].p_bh);
> + Â Â Â Â Â Â Â Â Â Â Â path[i].p_bh = NULL;
> + Â Â Â Â Â Â Â Â Â Â Â i--;
> + Â Â Â Â Â Â Â Â Â Â Â continue;
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â /* this is index block */
> + Â Â Â Â Â Â Â if (!path[i].p_hdr)
> + Â Â Â Â Â Â Â Â Â Â Â path[i].p_hdr = ext_block_hdr(path[i].p_bh);
> +
> + Â Â Â Â Â Â Â if (!path[i].p_idx) {
> + Â Â Â Â Â Â Â Â Â Â Â /* this level hasn't been touched yet */
> + Â Â Â Â Â Â Â Â Â Â Â path[i].p_idx = EXT_LAST_INDEX(path[i].p_hdr);
> + Â Â Â Â Â Â Â Â Â Â Â path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries)+1;
> + Â Â Â Â Â Â Â Â Â Â Â ext_debug("init index ptr: hdr 0x%p, num %d\n",
> + Â Â Â Â Â Â Â Â Â Â Â path[i].p_hdr,
> + Â Â Â Â Â Â Â Â Â Â Â le16_to_cpu(path[i].p_hdr->eh_entries));
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â else {
> + Â Â Â Â Â Â Â Â Â Â Â /* we were already here, see at next index */
> + Â Â Â Â Â Â Â Â Â Â Â path[i].p_idx--;
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â ext_debug("level %d - index, first 0x%p, cur 0x%p\n",
> + Â Â Â Â Â Â Â i, EXT_FIRST_INDEX(path[i].p_hdr),
> + Â Â Â Â Â Â Â path[i].p_idx);
> +
> + Â Â Â Â Â Â Â /* go to the next level */
> + Â Â Â Â Â Â Â ext_debug("move to level %d (block %llu)\n",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â i + 1, ext4_idx_pblock(path[i].p_idx));
> + Â Â Â Â Â Â Â memset(path + i + 1, 0, sizeof(*path));
> + Â Â Â Â Â Â Â bh = sb_bread(sb, ext4_idx_pblock(path[i].p_idx));
> + Â Â Â Â Â Â Â if (!bh) {
> + Â Â Â Â Â Â Â Â Â Â Â err = -EIO;
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â if (WARN_ON(i + 1 > depth)) {
> + Â Â Â Â Â Â Â Â Â Â Â err = -EIO;
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â if (ext4_ext_check(inode, ext_block_hdr(bh), depth - i - 1)) {
> + Â Â Â Â Â Â Â Â Â Â Â err = -EIO;
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â path[i + 1].p_bh = bh;
> +
> + Â Â Â Â Â Â Â i++;
> +
> + Â Â Â }
> +out:
> + Â Â Â ext4_ext_drop_refs(path);
> + Â Â Â kfree(path);
> + Â Â Â ext4_journal_stop(handle);
> +
> + Â Â Â return err ? err : last_block - start;
> +
> +}
> +
> +/*
> Â* called at mount time
> Â*/
> Âvoid ext4_ext_init(struct super_block *sb)
> @@ -4029,6 +4177,172 @@ next:
> Â Â Â Âreturn ret;
> Â}
>
> +/*
> + * ext4_ext_test_block_flag
> + * Tests the buffer head associated with the given block
> + * to see if the state contains flag
> + *
> + * @inode: ÂThe inode of the given file
> + * @block: ÂThe block to test
> + * @flag: Â The flag to check for
> + *
> + * Returns 0 on sucess or negative on err
> + */
> +static int ext4_ext_test_block_flag(struct inode *inode, ext4_lblk_t block, enum bh_state_bits flag){
> + Â Â Â struct buffer_head *bh;
> + Â Â Â struct page *page;
> + Â Â Â struct address_space *mapping = inode->i_mapping;
> + Â Â Â loff_t block_offset;
> + Â Â Â int i, ret;
> + Â Â Â unsigned long flag_mask = 1 << flag;
> +
> + Â Â Â block_offset = block << EXT4_BLOCK_SIZE_BITS(inode->i_sb);
> + Â Â Â page = find_or_create_page(mapping, block_offset >> PAGE_CACHE_SHIFT,
> + Â Â Â mapping_gfp_mask(mapping) & ~__GFP_FS);
> +
> + Â Â Â if (!page)
> + Â Â Â Â Â Â Â return -EIO;
> +
> + Â Â Â if (!page_has_buffers(page))
> + Â Â Â Â Â Â Â create_empty_buffers(page, EXT4_BLOCK_SIZE(inode->i_sb), 0);
> +
> + Â Â Â /* advance to the buffer that has the block offset Â*/
> + Â Â Â bh = page_buffers(page);
> + Â Â Â for (i = 0; i < block_offset; i+=EXT4_BLOCK_SIZE(inode->i_sb)) {
> + Â Â Â Â Â Â Â bh = bh->b_this_page;
> + Â Â Â }
> +
> + Â Â Â if(bh->b_state & flag_mask)
> + Â Â Â Â Â Â Â ret = 0;
> + Â Â Â else
> + Â Â Â Â Â Â Â ret = -1;
> +
> + Â Â Â unlock_page(page);
> + Â Â Â page_cache_release(page);
> +
> + Â Â Â return ret;
> +
> +}
> +
> +/*
> + * ext4_ext_punch_hole
> + *
> + * Punches a hole of "length" bytes in a file starting
> + * at byte "offset"
> + *
> + * @inode: ÂThe inode of the file to punch a hole in
> + * @offset: The starting byte offset of the hole
> + * @length: The length of the hole
> + *
> + */
> +void ext4_ext_punch_hole(struct inode *inode, loff_t offset, loff_t length)

IMHO, should return error value instead of void

> +{
> + Â Â Â struct super_block *sb = inode->i_sb;
> + Â Â Â ext4_lblk_t first_block, last_block, num_blocks, iblock = 0;
> + Â Â Â struct address_space *mapping = inode->i_mapping;
> + Â Â Â struct ext4_map_blocks map;
> + Â Â Â handle_t *handle;
> + Â Â Â loff_t first_block_offset, last_block_offset, block_len;
> + Â Â Â int get_blocks_flags, err, ret = 0;
> +
> + Â Â Â first_block = (offset + sb->s_blocksize - 1)
> + Â Â Â Â Â Â Â Â Â Â Â >> EXT4_BLOCK_SIZE_BITS(sb);
> + Â Â Â last_block = (offset+length) Â>> EXT4_BLOCK_SIZE_BITS(sb);
> +
> + Â Â Â first_block_offset = first_block << EXT4_BLOCK_SIZE_BITS(sb);
> + Â Â Â last_block_offset = last_block << EXT4_BLOCK_SIZE_BITS(sb);
> +
> + Â Â Â err = ext4_writepage_trans_blocks(inode);
> + Â Â Â handle = ext4_journal_start(inode, err);
> + Â Â Â if (IS_ERR(handle))
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â /*
> + Â Â Â Â* Now we need to zero out the un block aligned data.
> + Â Â Â Â* If the file is smaller than a block, just
> + Â Â Â Â* zero out the middle and return
> + Â Â Â Â*/
> + Â Â Â if(first_block > last_block)
> + Â Â Â Â Â Â Â ext4_block_zero_page_range(handle, mapping, offset, length);
> + Â Â Â else{
> + Â Â Â Â Â Â Â /* zero out the head of the hole before the first block */
> + Â Â Â Â Â Â Â block_len Â= first_block_offset - offset;
> + Â Â Â Â Â Â Â if(block_len > 0)
> + Â Â Â Â Â Â Â Â Â Â Â ext4_block_zero_page_range(handle, mapping, offset, block_len);
> +
> + Â Â Â Â Â Â Â /* zero out the tail of the hole after the last block */
> + Â Â Â Â Â Â Â block_len = offset + length - last_block_offset;
> + Â Â Â Â Â Â Â if(block_len > 0)
> + Â Â Â Â Â Â Â Â Â Â Â ext4_block_zero_page_range(handle, mapping,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â last_block_offset, block_len);
> + Â Â Â }
> +
> + Â Â Â /* If there are no blocks to remove, return now */
> + Â Â Â if(first_block >= last_block){
> + Â Â Â Â Â Â Â ext4_journal_stop(handle);
> + Â Â Â Â Â Â Â return;
> + Â Â Â }
> +
> + Â Â Â /* Clear pages associated with the hole */
> + Â Â Â if (mapping->nrpages)
> + Â Â Â Â Â Â Â invalidate_inode_pages2_range(mapping, offset >> PAGE_CACHE_SHIFT,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (offset+length) >> PAGE_CACHE_SHIFT );
> +
> +
> + Â Â Â /* Loop over all the blocks and identify blocks that need to be punched out */
> + Â Â Â iblock = first_block;
> + Â Â Â while(iblock < last_block){
> + Â Â Â Â Â Â Â map.m_lblk = iblock;
> + Â Â Â Â Â Â Â map.m_len = last_block - iblock;
> + Â Â Â Â Â Â Â ret = ext4_map_blocks(handle, inode, &map, 0);
> +
> + Â Â Â Â Â Â Â /* If the blocks are mapped, release them */
> + Â Â Â Â Â Â Â if(ret > 0){
> + Â Â Â Â Â Â Â Â Â Â Â num_blocks = ret;
> + Â Â Â Â Â Â Â Â Â Â Â ext4_ext_convert_blocks_uninit(inode, handle, iblock, num_blocks);
> + Â Â Â Â Â Â Â Â Â Â Â ext4_ext_release_blocks(inode, iblock, iblock+num_blocks);
> + Â Â Â Â Â Â Â Â Â Â Â goto next;
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â* If they are not mapped
> + Â Â Â Â Â Â Â Â* check to see if they are punched out
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â ret = ext4_ext_lookup_hole(inode, iblock);
> + Â Â Â Â Â Â Â if(ret > 0){
> + Â Â Â Â Â Â Â Â Â Â Â num_blocks = ret;
> + Â Â Â Â Â Â Â Â Â Â Â goto next;
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â* If the block could not be mapped, and
> + Â Â Â Â Â Â Â Â* its not already punched out,
> + Â Â Â Â Â Â Â Â* check to see if the block is delayed
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â if(ext4_ext_test_block_flag(inode, iblock, BH_Delay) == 0){
> + Â Â Â Â Â Â Â Â Â Â Â get_blocks_flags = EXT4_GET_BLOCKS_CREATE | EXT4_GET_BLOCKS_DELALLOC_RESERVE;
> + Â Â Â Â Â Â Â Â Â Â Â ret = ext4_map_blocks(handle, inode, &map, get_blocks_flags);
> + Â Â Â Â Â Â Â Â Â Â Â /* If the blocks are found, release them */
> +
> + Â Â Â Â Â Â Â Â Â Â Â if(ret > 0){
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â num_blocks = ret;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ext4_ext_release_blocks(inode, iblock, iblock+num_blocks);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â goto next;
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â /* If the block cannot be identified, just skip it */
> + Â Â Â Â Â Â Â num_blocks = 1;
> +
> +next:
> + Â Â Â Â Â Â Â iblock+=num_blocks;
> + Â Â Â }
> + Â Â Â ext4_mark_inode_dirty(handle, inode);
> +
> + Â Â Â ext4_journal_stop(handle);
> +
> +}
> +
>
> Âstatic void ext4_falloc_update_inode(struct inode *inode,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âint mode, loff_t new_size, int update_ctime)
> @@ -4079,10 +4393,6 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> Â Â Â Âstruct ext4_map_blocks map;
> Â Â Â Âunsigned int credits, blkbits = inode->i_blkbits;
>
> - Â Â Â /* We only support the FALLOC_FL_KEEP_SIZE mode */
> - Â Â Â if (mode & ~FALLOC_FL_KEEP_SIZE)
> - Â Â Â Â Â Â Â return -EOPNOTSUPP;
> -
> Â Â Â Â/*
> Â Â Â Â * currently supporting (pre)allocate mode for extent-based
> Â Â Â Â * files _only_
> @@ -4090,6 +4400,9 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
> Â Â Â Âif (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
> Â Â Â Â Â Â Â Âreturn -EOPNOTSUPP;
>
> + Â Â Â if (mode & FALLOC_FL_PUNCH_HOLE)
> + Â Â Â Â Â Â Â return ext4_punch_hole(inode, offset, len);
> +
> Â Â Â Âmap.m_lblk = offset >> blkbits;
> Â Â Â Â/*
> Â Â Â Â * We can't just convert len to max_blocks because
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 28c9137..493c908 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4487,6 +4487,32 @@ int ext4_can_truncate(struct inode *inode)
> Â}
>
> Â/*
> + * ext4_punch_hole: punches a hole in a file by releaseing the blocks
> + * associated with the given offset and length
> + *
> + * @inode: ÂFile inode
> + * @offset: The offset where the hole will begin
> + * @len: Â ÂThe length of the hole
> + *
> + * Returns: 0 on sucess or negative on failure
> + */
> +
> +long Âext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)

For error value, int is enough here

> +{
> +
> + Â Â Â if (!S_ISREG(inode->i_mode)==1)
> + Â Â Â Â Â Â Â Âreturn -ENOTSUPP;
> +
> + Â Â Â if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
> + Â Â Â Â Â Â Â //TODO: Add support for non extent hole punching
> + Â Â Â Â Â Â Â return -ENOTSUPP;
> + Â Â Â }
> +
> + Â Â Â ext4_ext_punch_hole(inode, offset, length);

deal with error path

> + Â Â Â return 0;
> +}
> +
> +/*
> Â* ext4_truncate()
> Â*
> Â* We block out ext4_get_block() block instantiations across the entire
> --
> 1.7.1
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
>



-- 
Sorry for line wrapping with gmail web interface
ÿô.nlj·Ÿ®‰­†+%ŠË±é¥Šwÿº{.nlj·¥Š{±ý¶›¡Ü}©ž²ÆzÚj:+v‰¨þø®w¥þŠàÞ¨è&¢)ß«a¶Úÿûz¹ÞúŽŠÝjÿŠwèf



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux