diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-09 12:55:47 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-11 22:30:21 -0400 |
commit | 3309dd04cbcd2cdad168485af5cf3576b5051e49 (patch) | |
tree | 3e01f865306dee01b31f34c9e7e819a5f42a4087 /fs/ocfs2 | |
parent | 90320251db0fe3d05f2b10686ec936c7d6ecd99a (diff) |
switch generic_write_checks() to iocb and iter
... returning -E... upon error and amount of data left in iter after
(possible) truncation upon success. Note, that normal case gives
a non-zero (positive) return value, so any tests for != 0 _must_ be
updated.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Conflicts:
fs/ext4/file.c
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/file.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index fc53ff065364..b93919f50f0f 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -2250,9 +2250,10 @@ out: | |||
2250 | static ssize_t ocfs2_file_write_iter(struct kiocb *iocb, | 2250 | static ssize_t ocfs2_file_write_iter(struct kiocb *iocb, |
2251 | struct iov_iter *from) | 2251 | struct iov_iter *from) |
2252 | { | 2252 | { |
2253 | int ret, direct_io, appending, rw_level, have_alloc_sem = 0; | 2253 | int direct_io, appending, rw_level, have_alloc_sem = 0; |
2254 | int can_do_direct, has_refcount = 0; | 2254 | int can_do_direct, has_refcount = 0; |
2255 | ssize_t written = 0; | 2255 | ssize_t written = 0; |
2256 | ssize_t ret; | ||
2256 | size_t count = iov_iter_count(from), orig_count; | 2257 | size_t count = iov_iter_count(from), orig_count; |
2257 | loff_t old_size; | 2258 | loff_t old_size; |
2258 | u32 old_clusters; | 2259 | u32 old_clusters; |
@@ -2319,13 +2320,14 @@ relock: | |||
2319 | ocfs2_inode_unlock(inode, 1); | 2320 | ocfs2_inode_unlock(inode, 1); |
2320 | } | 2321 | } |
2321 | 2322 | ||
2322 | orig_count = count; | 2323 | orig_count = iov_iter_count(from); |
2323 | ret = generic_write_checks(file, &iocb->ki_pos, &count); | 2324 | ret = generic_write_checks(iocb, from); |
2324 | if (ret < 0) { | 2325 | if (ret <= 0) { |
2325 | mlog_errno(ret); | 2326 | if (ret) |
2327 | mlog_errno(ret); | ||
2326 | goto out; | 2328 | goto out; |
2327 | } | 2329 | } |
2328 | iov_iter_truncate(from, count); | 2330 | count = ret; |
2329 | 2331 | ||
2330 | can_do_direct = direct_io; | 2332 | can_do_direct = direct_io; |
2331 | ret = ocfs2_prepare_inode_for_write(file, iocb->ki_pos, count, appending, | 2333 | ret = ocfs2_prepare_inode_for_write(file, iocb->ki_pos, count, appending, |
@@ -2349,7 +2351,7 @@ relock: | |||
2349 | rw_level = -1; | 2351 | rw_level = -1; |
2350 | 2352 | ||
2351 | direct_io = 0; | 2353 | direct_io = 0; |
2352 | iov_iter_reexpand(from, count = orig_count); | 2354 | iov_iter_reexpand(from, orig_count); |
2353 | goto relock; | 2355 | goto relock; |
2354 | } | 2356 | } |
2355 | 2357 | ||
@@ -2377,7 +2379,7 @@ relock: | |||
2377 | loff_t endbyte; | 2379 | loff_t endbyte; |
2378 | ssize_t written_buffered; | 2380 | ssize_t written_buffered; |
2379 | written = generic_file_direct_write(iocb, from, iocb->ki_pos); | 2381 | written = generic_file_direct_write(iocb, from, iocb->ki_pos); |
2380 | if (written < 0 || written == count) { | 2382 | if (written < 0 || !iov_iter_count(from)) { |
2381 | ret = written; | 2383 | ret = written; |
2382 | goto out_dio; | 2384 | goto out_dio; |
2383 | } | 2385 | } |
@@ -2385,7 +2387,6 @@ relock: | |||
2385 | /* | 2387 | /* |
2386 | * for completing the rest of the request. | 2388 | * for completing the rest of the request. |
2387 | */ | 2389 | */ |
2388 | count -= written; | ||
2389 | written_buffered = generic_perform_write(file, from, iocb->ki_pos); | 2390 | written_buffered = generic_perform_write(file, from, iocb->ki_pos); |
2390 | /* | 2391 | /* |
2391 | * If generic_file_buffered_write() returned a synchronous error | 2392 | * If generic_file_buffered_write() returned a synchronous error |