diff options
author | Brian Foster <bfoster@redhat.com> | 2013-05-17 15:27:34 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2013-05-20 16:58:58 +0200 |
commit | bee6c307800bbb26ba1a855b1841c2f0c4b7622a (patch) | |
tree | 0efacb944f7b0b40cc02e896303bdd9f13da4ab5 /fs/fuse | |
parent | 3634a6327815d39dd93e5c44a602daae91c66297 (diff) | |
download | op-kernel-dev-bee6c307800bbb26ba1a855b1841c2f0c4b7622a.zip op-kernel-dev-bee6c307800bbb26ba1a855b1841c2f0c4b7622a.tar.gz |
fuse: update inode size and invalidate attributes on fallocate
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>
Diffstat (limited to 'fs/fuse')
-rw-r--r-- | fs/fuse/file.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index a200a2d..d9f4679 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -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); } |