diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-02-03 22:09:09 +0100 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-02-23 01:07:23 +0100 |
commit | b439b103a6c9eb3417f34b4a609d4e00b4c59aca (patch) | |
tree | 490073a7acb4bb018c43246f27251e87ae8cf1d3 /fs/f2fs/file.c | |
parent | f2fs: fix missing skip pages info (diff) | |
download | linux-b439b103a6c9eb3417f34b4a609d4e00b4c59aca.tar.xz linux-b439b103a6c9eb3417f34b4a609d4e00b4c59aca.zip |
f2fs: move dio preallocation into f2fs_file_write_iter
This patch moves preallocation code for direct IOs into f2fs_file_write_iter.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to '')
-rw-r--r-- | fs/f2fs/file.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 50fa296efa67..9e210b51261d 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1873,14 +1873,32 @@ long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { - struct inode *inode = file_inode(iocb->ki_filp); + struct file *file = iocb->ki_filp; + struct inode *inode = file_inode(file); + ssize_t ret; if (f2fs_encrypted_inode(inode) && !f2fs_has_encryption_key(inode) && f2fs_get_encryption_info(inode)) return -EACCES; - return generic_file_write_iter(iocb, from); + inode_lock(inode); + ret = generic_write_checks(iocb, from); + if (ret > 0) { + ret = f2fs_preallocate_blocks(iocb, from); + if (!ret) + ret = __generic_file_write_iter(iocb, from); + } + inode_unlock(inode); + + if (ret > 0) { + ssize_t err; + + err = generic_write_sync(file, iocb->ki_pos - ret, ret); + if (err < 0) + ret = err; + } + return ret; } #ifdef CONFIG_COMPAT |