diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-03-22 06:51:37 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-06 17:32:54 -0400 |
commit | 0c949334a9e2581646c6ff0d1470a805b1e5be99 (patch) | |
tree | 60a4d6bc2260d648915baa9b78626cd4b6915431 /mm/filemap.c | |
parent | 28060d5d9b261da110afe48aae7a2aa6555f798f (diff) |
iov_iter_truncate()
Now It Can Be Done(tm) - we don't need to do iov_shorten() in
generic_file_direct_write() anymore, now that all ->direct_IO()
instances are converted to proper iov_iter methods and honour
iter->count and iter->iov_offset properly.
Get rid of count/ocount arguments of generic_file_direct_write(),
while we are at it.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 3aeaf2df4135..c0404b763a17 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -2345,8 +2345,7 @@ int pagecache_write_end(struct file *file, struct address_space *mapping, | |||
2345 | EXPORT_SYMBOL(pagecache_write_end); | 2345 | EXPORT_SYMBOL(pagecache_write_end); |
2346 | 2346 | ||
2347 | ssize_t | 2347 | ssize_t |
2348 | generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from, | 2348 | generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos) |
2349 | loff_t pos, size_t count, size_t ocount) | ||
2350 | { | 2349 | { |
2351 | struct file *file = iocb->ki_filp; | 2350 | struct file *file = iocb->ki_filp; |
2352 | struct address_space *mapping = file->f_mapping; | 2351 | struct address_space *mapping = file->f_mapping; |
@@ -2356,10 +2355,7 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from, | |||
2356 | pgoff_t end; | 2355 | pgoff_t end; |
2357 | struct iov_iter data; | 2356 | struct iov_iter data; |
2358 | 2357 | ||
2359 | if (count != ocount) | 2358 | write_len = iov_iter_count(from); |
2360 | from->nr_segs = iov_shorten((struct iovec *)from->iov, from->nr_segs, count); | ||
2361 | |||
2362 | write_len = iov_length(from->iov, from->nr_segs); | ||
2363 | end = (pos + write_len - 1) >> PAGE_CACHE_SHIFT; | 2359 | end = (pos + write_len - 1) >> PAGE_CACHE_SHIFT; |
2364 | 2360 | ||
2365 | written = filemap_write_and_wait_range(mapping, pos, pos + write_len - 1); | 2361 | written = filemap_write_and_wait_range(mapping, pos, pos + write_len - 1); |
@@ -2568,7 +2564,6 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2568 | { | 2564 | { |
2569 | struct file *file = iocb->ki_filp; | 2565 | struct file *file = iocb->ki_filp; |
2570 | struct address_space * mapping = file->f_mapping; | 2566 | struct address_space * mapping = file->f_mapping; |
2571 | size_t ocount; /* original count */ | ||
2572 | size_t count; /* after file limit checks */ | 2567 | size_t count; /* after file limit checks */ |
2573 | struct inode *inode = mapping->host; | 2568 | struct inode *inode = mapping->host; |
2574 | loff_t pos = iocb->ki_pos; | 2569 | loff_t pos = iocb->ki_pos; |
@@ -2577,7 +2572,8 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2577 | ssize_t status; | 2572 | ssize_t status; |
2578 | struct iov_iter from; | 2573 | struct iov_iter from; |
2579 | 2574 | ||
2580 | count = ocount = iov_length(iov, nr_segs); | 2575 | count = iov_length(iov, nr_segs); |
2576 | iov_iter_init(&from, WRITE, iov, nr_segs, count); | ||
2581 | 2577 | ||
2582 | /* We can write back this queue in page reclaim */ | 2578 | /* We can write back this queue in page reclaim */ |
2583 | current->backing_dev_info = mapping->backing_dev_info; | 2579 | current->backing_dev_info = mapping->backing_dev_info; |
@@ -2588,6 +2584,8 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2588 | if (count == 0) | 2584 | if (count == 0) |
2589 | goto out; | 2585 | goto out; |
2590 | 2586 | ||
2587 | iov_iter_truncate(&from, count); | ||
2588 | |||
2591 | err = file_remove_suid(file); | 2589 | err = file_remove_suid(file); |
2592 | if (err) | 2590 | if (err) |
2593 | goto out; | 2591 | goto out; |
@@ -2596,14 +2594,11 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2596 | if (err) | 2594 | if (err) |
2597 | goto out; | 2595 | goto out; |
2598 | 2596 | ||
2599 | iov_iter_init(&from, WRITE, iov, nr_segs, count); | ||
2600 | |||
2601 | /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ | 2597 | /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ |
2602 | if (unlikely(file->f_flags & O_DIRECT)) { | 2598 | if (unlikely(file->f_flags & O_DIRECT)) { |
2603 | loff_t endbyte; | 2599 | loff_t endbyte; |
2604 | 2600 | ||
2605 | written = generic_file_direct_write(iocb, &from, pos, | 2601 | written = generic_file_direct_write(iocb, &from, pos); |
2606 | count, ocount); | ||
2607 | if (written < 0 || written == count) | 2602 | if (written < 0 || written == count) |
2608 | goto out; | 2603 | goto out; |
2609 | 2604 | ||