diff options
author | Maxim Patlasov <MPatlasov@parallels.com> | 2013-06-13 12:16:39 +0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2013-06-18 01:39:03 +0200 |
commit | 14c14414d157ea851119c96c61a17306a2b4a035 (patch) | |
tree | de18c44d2398a16d3248847b424d5cabd619b7bf /fs/configfs | |
parent | 8177a9d79c0e942dcac3312f15585d0344d505a5 (diff) | |
download | linux-stable-14c14414d157ea851119c96c61a17306a2b4a035.tar.gz linux-stable-14c14414d157ea851119c96c61a17306a2b4a035.tar.bz2 linux-stable-14c14414d157ea851119c96c61a17306a2b4a035.zip |
fuse: hold i_mutex in fuse_file_fallocate()
Changing size of a file on server and local update (fuse_write_update_size)
should be always protected by inode->i_mutex. Otherwise a race like this is
possible:
1. Process 'A' calls fallocate(2) to extend file (~FALLOC_FL_KEEP_SIZE).
fuse_file_fallocate() sends FUSE_FALLOCATE request to the server.
2. Process 'B' calls ftruncate(2) shrinking the file. fuse_do_setattr()
sends shrinking FUSE_SETATTR request to the server and updates local i_size
by i_size_write(inode, outarg.attr.size).
3. Process 'A' resumes execution of fuse_file_fallocate() and calls
fuse_write_update_size(inode, offset + length). But 'offset + length' was
obsoleted by ftruncate from previous step.
Changed in v2 (thanks Brian and Anand for suggestions):
- made relation between mutex_lock() and fuse_set_nowrite(inode) more
explicit and clear.
- updated patch description to use ftruncate(2) in example
Signed-off-by: Maxim V. Patlasov <MPatlasov@parallels.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/configfs')
0 files changed, 0 insertions, 0 deletions