diff options
-rw-r--r-- | fs/ocfs2/file.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index bfaaba5373b9..64909ac2be43 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -2233,15 +2233,13 @@ out: | |||
2233 | return ret; | 2233 | return ret; |
2234 | } | 2234 | } |
2235 | 2235 | ||
2236 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | 2236 | static ssize_t ocfs2_file_write_iter(struct kiocb *iocb, |
2237 | const struct iovec *iov, | 2237 | struct iov_iter *from) |
2238 | unsigned long nr_segs, | ||
2239 | loff_t pos) | ||
2240 | { | 2238 | { |
2241 | int ret, direct_io, appending, rw_level, have_alloc_sem = 0; | 2239 | int ret, direct_io, appending, rw_level, have_alloc_sem = 0; |
2242 | int can_do_direct, has_refcount = 0; | 2240 | int can_do_direct, has_refcount = 0; |
2243 | ssize_t written = 0; | 2241 | ssize_t written = 0; |
2244 | size_t count; /* after file limit checks */ | 2242 | size_t count = iov_iter_count(from); |
2245 | loff_t old_size, *ppos = &iocb->ki_pos; | 2243 | loff_t old_size, *ppos = &iocb->ki_pos; |
2246 | u32 old_clusters; | 2244 | u32 old_clusters; |
2247 | struct file *file = iocb->ki_filp; | 2245 | struct file *file = iocb->ki_filp; |
@@ -2250,16 +2248,12 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
2250 | int full_coherency = !(osb->s_mount_opt & | 2248 | int full_coherency = !(osb->s_mount_opt & |
2251 | OCFS2_MOUNT_COHERENCY_BUFFERED); | 2249 | OCFS2_MOUNT_COHERENCY_BUFFERED); |
2252 | int unaligned_dio = 0; | 2250 | int unaligned_dio = 0; |
2253 | struct iov_iter from; | ||
2254 | |||
2255 | count = iov_length(iov, nr_segs); | ||
2256 | iov_iter_init(&from, WRITE, iov, nr_segs, count); | ||
2257 | 2251 | ||
2258 | trace_ocfs2_file_aio_write(inode, file, file->f_path.dentry, | 2252 | trace_ocfs2_file_aio_write(inode, file, file->f_path.dentry, |
2259 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 2253 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
2260 | file->f_path.dentry->d_name.len, | 2254 | file->f_path.dentry->d_name.len, |
2261 | file->f_path.dentry->d_name.name, | 2255 | file->f_path.dentry->d_name.name, |
2262 | (unsigned int)nr_segs); | 2256 | (unsigned int)from->nr_segs); /* GRRRRR */ |
2263 | 2257 | ||
2264 | if (iocb->ki_nbytes == 0) | 2258 | if (iocb->ki_nbytes == 0) |
2265 | return 0; | 2259 | return 0; |
@@ -2362,16 +2356,16 @@ relock: | |||
2362 | if (ret) | 2356 | if (ret) |
2363 | goto out_dio; | 2357 | goto out_dio; |
2364 | 2358 | ||
2365 | iov_iter_truncate(&from, count); | 2359 | iov_iter_truncate(from, count); |
2366 | if (direct_io) { | 2360 | if (direct_io) { |
2367 | written = generic_file_direct_write(iocb, &from, *ppos); | 2361 | written = generic_file_direct_write(iocb, from, *ppos); |
2368 | if (written < 0) { | 2362 | if (written < 0) { |
2369 | ret = written; | 2363 | ret = written; |
2370 | goto out_dio; | 2364 | goto out_dio; |
2371 | } | 2365 | } |
2372 | } else { | 2366 | } else { |
2373 | current->backing_dev_info = file->f_mapping->backing_dev_info; | 2367 | current->backing_dev_info = file->f_mapping->backing_dev_info; |
2374 | written = generic_perform_write(file, &from, *ppos); | 2368 | written = generic_perform_write(file, from, *ppos); |
2375 | if (likely(written >= 0)) | 2369 | if (likely(written >= 0)) |
2376 | iocb->ki_pos = *ppos + written; | 2370 | iocb->ki_pos = *ppos + written; |
2377 | current->backing_dev_info = NULL; | 2371 | current->backing_dev_info = NULL; |
@@ -2606,7 +2600,7 @@ static ssize_t ocfs2_file_read_iter(struct kiocb *iocb, | |||
2606 | /* buffered aio wouldn't have proper lock coverage today */ | 2600 | /* buffered aio wouldn't have proper lock coverage today */ |
2607 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); | 2601 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); |
2608 | 2602 | ||
2609 | /* see ocfs2_file_aio_write */ | 2603 | /* see ocfs2_file_write_iter */ |
2610 | if (ret == -EIOCBQUEUED || !ocfs2_iocb_is_rw_locked(iocb)) { | 2604 | if (ret == -EIOCBQUEUED || !ocfs2_iocb_is_rw_locked(iocb)) { |
2611 | rw_level = -1; | 2605 | rw_level = -1; |
2612 | have_alloc_sem = 0; | 2606 | have_alloc_sem = 0; |
@@ -2700,13 +2694,13 @@ const struct inode_operations ocfs2_special_file_iops = { | |||
2700 | const struct file_operations ocfs2_fops = { | 2694 | const struct file_operations ocfs2_fops = { |
2701 | .llseek = ocfs2_file_llseek, | 2695 | .llseek = ocfs2_file_llseek, |
2702 | .read = new_sync_read, | 2696 | .read = new_sync_read, |
2703 | .write = do_sync_write, | 2697 | .write = new_sync_write, |
2704 | .mmap = ocfs2_mmap, | 2698 | .mmap = ocfs2_mmap, |
2705 | .fsync = ocfs2_sync_file, | 2699 | .fsync = ocfs2_sync_file, |
2706 | .release = ocfs2_file_release, | 2700 | .release = ocfs2_file_release, |
2707 | .open = ocfs2_file_open, | 2701 | .open = ocfs2_file_open, |
2708 | .read_iter = ocfs2_file_read_iter, | 2702 | .read_iter = ocfs2_file_read_iter, |
2709 | .aio_write = ocfs2_file_aio_write, | 2703 | .write_iter = ocfs2_file_write_iter, |
2710 | .unlocked_ioctl = ocfs2_ioctl, | 2704 | .unlocked_ioctl = ocfs2_ioctl, |
2711 | #ifdef CONFIG_COMPAT | 2705 | #ifdef CONFIG_COMPAT |
2712 | .compat_ioctl = ocfs2_compat_ioctl, | 2706 | .compat_ioctl = ocfs2_compat_ioctl, |
@@ -2748,13 +2742,13 @@ const struct file_operations ocfs2_dops = { | |||
2748 | const struct file_operations ocfs2_fops_no_plocks = { | 2742 | const struct file_operations ocfs2_fops_no_plocks = { |
2749 | .llseek = ocfs2_file_llseek, | 2743 | .llseek = ocfs2_file_llseek, |
2750 | .read = new_sync_read, | 2744 | .read = new_sync_read, |
2751 | .write = do_sync_write, | 2745 | .write = new_sync_write, |
2752 | .mmap = ocfs2_mmap, | 2746 | .mmap = ocfs2_mmap, |
2753 | .fsync = ocfs2_sync_file, | 2747 | .fsync = ocfs2_sync_file, |
2754 | .release = ocfs2_file_release, | 2748 | .release = ocfs2_file_release, |
2755 | .open = ocfs2_file_open, | 2749 | .open = ocfs2_file_open, |
2756 | .read_iter = ocfs2_file_read_iter, | 2750 | .read_iter = ocfs2_file_read_iter, |
2757 | .aio_write = ocfs2_file_aio_write, | 2751 | .write_iter = ocfs2_file_write_iter, |
2758 | .unlocked_ioctl = ocfs2_ioctl, | 2752 | .unlocked_ioctl = ocfs2_ioctl, |
2759 | #ifdef CONFIG_COMPAT | 2753 | #ifdef CONFIG_COMPAT |
2760 | .compat_ioctl = ocfs2_compat_ioctl, | 2754 | .compat_ioctl = ocfs2_compat_ioctl, |