diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-04-05 04:34:23 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-06-12 00:21:10 -0400 |
commit | 6dc8bc0fb300f6a878a4ed41ed833743a0dcf70e (patch) | |
tree | dbc8b023608509876af99631f66529875c781002 /fs | |
parent | 8d0207652cbe27d1f962050737848e5ad4671958 (diff) |
ocfs2: switch to iter_file_splice_write()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/file.c | 82 |
1 files changed, 2 insertions, 80 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 64909ac2be43..465c95016a39 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -2430,84 +2430,6 @@ out_sems: | |||
2430 | return ret; | 2430 | return ret; |
2431 | } | 2431 | } |
2432 | 2432 | ||
2433 | static int ocfs2_splice_to_file(struct pipe_inode_info *pipe, | ||
2434 | struct file *out, | ||
2435 | struct splice_desc *sd) | ||
2436 | { | ||
2437 | int ret; | ||
2438 | |||
2439 | ret = ocfs2_prepare_inode_for_write(out, &sd->pos, | ||
2440 | sd->total_len, 0, NULL, NULL); | ||
2441 | if (ret < 0) { | ||
2442 | mlog_errno(ret); | ||
2443 | return ret; | ||
2444 | } | ||
2445 | |||
2446 | return splice_from_pipe_feed(pipe, sd, pipe_to_file); | ||
2447 | } | ||
2448 | |||
2449 | static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe, | ||
2450 | struct file *out, | ||
2451 | loff_t *ppos, | ||
2452 | size_t len, | ||
2453 | unsigned int flags) | ||
2454 | { | ||
2455 | int ret; | ||
2456 | struct address_space *mapping = out->f_mapping; | ||
2457 | struct inode *inode = mapping->host; | ||
2458 | struct splice_desc sd = { | ||
2459 | .total_len = len, | ||
2460 | .flags = flags, | ||
2461 | .pos = *ppos, | ||
2462 | .u.file = out, | ||
2463 | }; | ||
2464 | |||
2465 | |||
2466 | trace_ocfs2_file_splice_write(inode, out, out->f_path.dentry, | ||
2467 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
2468 | out->f_path.dentry->d_name.len, | ||
2469 | out->f_path.dentry->d_name.name, len); | ||
2470 | |||
2471 | pipe_lock(pipe); | ||
2472 | |||
2473 | splice_from_pipe_begin(&sd); | ||
2474 | do { | ||
2475 | ret = splice_from_pipe_next(pipe, &sd); | ||
2476 | if (ret <= 0) | ||
2477 | break; | ||
2478 | |||
2479 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_CHILD); | ||
2480 | ret = ocfs2_rw_lock(inode, 1); | ||
2481 | if (ret < 0) | ||
2482 | mlog_errno(ret); | ||
2483 | else { | ||
2484 | ret = ocfs2_splice_to_file(pipe, out, &sd); | ||
2485 | ocfs2_rw_unlock(inode, 1); | ||
2486 | } | ||
2487 | mutex_unlock(&inode->i_mutex); | ||
2488 | } while (ret > 0); | ||
2489 | splice_from_pipe_end(pipe, &sd); | ||
2490 | |||
2491 | pipe_unlock(pipe); | ||
2492 | |||
2493 | if (sd.num_spliced) | ||
2494 | ret = sd.num_spliced; | ||
2495 | |||
2496 | if (ret > 0) { | ||
2497 | int err; | ||
2498 | |||
2499 | err = generic_write_sync(out, *ppos, ret); | ||
2500 | if (err) | ||
2501 | ret = err; | ||
2502 | else | ||
2503 | *ppos += ret; | ||
2504 | |||
2505 | balance_dirty_pages_ratelimited(mapping); | ||
2506 | } | ||
2507 | |||
2508 | return ret; | ||
2509 | } | ||
2510 | |||
2511 | static ssize_t ocfs2_file_splice_read(struct file *in, | 2433 | static ssize_t ocfs2_file_splice_read(struct file *in, |
2512 | loff_t *ppos, | 2434 | loff_t *ppos, |
2513 | struct pipe_inode_info *pipe, | 2435 | struct pipe_inode_info *pipe, |
@@ -2708,7 +2630,7 @@ const struct file_operations ocfs2_fops = { | |||
2708 | .lock = ocfs2_lock, | 2630 | .lock = ocfs2_lock, |
2709 | .flock = ocfs2_flock, | 2631 | .flock = ocfs2_flock, |
2710 | .splice_read = ocfs2_file_splice_read, | 2632 | .splice_read = ocfs2_file_splice_read, |
2711 | .splice_write = ocfs2_file_splice_write, | 2633 | .splice_write = iter_file_splice_write, |
2712 | .fallocate = ocfs2_fallocate, | 2634 | .fallocate = ocfs2_fallocate, |
2713 | }; | 2635 | }; |
2714 | 2636 | ||
@@ -2755,7 +2677,7 @@ const struct file_operations ocfs2_fops_no_plocks = { | |||
2755 | #endif | 2677 | #endif |
2756 | .flock = ocfs2_flock, | 2678 | .flock = ocfs2_flock, |
2757 | .splice_read = ocfs2_file_splice_read, | 2679 | .splice_read = ocfs2_file_splice_read, |
2758 | .splice_write = ocfs2_file_splice_write, | 2680 | .splice_write = iter_file_splice_write, |
2759 | .fallocate = ocfs2_fallocate, | 2681 | .fallocate = ocfs2_fallocate, |
2760 | }; | 2682 | }; |
2761 | 2683 | ||