Skip to content

Commit

Permalink
fuse: update inode size and invalidate attributes on fallocate
Browse files Browse the repository at this point in the history
An fallocate request without FALLOC_FL_KEEP_SIZE set can extend the
size of a file. Update the inode size after a successful fallocate.

Also invalidate the inode attributes after a successful fallocate
to ensure we pick up the latest attribute values (i.e., i_blocks).

Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
  • Loading branch information
Brian Foster authored and Miklos Szeredi committed May 20, 2013
1 parent 3634a63 commit bee6c30
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2492,11 +2492,20 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
}
fuse_put_request(fc, req);

if (err)
goto out;

/* we could have extended the file */
if (!(mode & FALLOC_FL_KEEP_SIZE))
fuse_write_update_size(inode, offset + length);

if (mode & FALLOC_FL_PUNCH_HOLE)
truncate_pagecache_range(inode, offset, offset + length - 1);

fuse_invalidate_attr(inode);

out:
if (mode & FALLOC_FL_PUNCH_HOLE) {
if (!err)
truncate_pagecache_range(inode, offset,
offset + length - 1);
fuse_release_nowrite(inode);
mutex_unlock(&inode->i_mutex);
}
Expand Down

0 comments on commit bee6c30

Please sign in to comment.