diff options
author | Nick Piggin <npiggin@suse.de> | 2007-10-16 01:24:58 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 09:42:54 -0700 |
commit | 4a9e5ef1f4f15205e477817a5cefc34bd3f65f55 (patch) | |
tree | 51f52086ecbccc3f41955d8d12293ef7a566a05b /mm/filemap.c | |
parent | eb2be189317d031895b5ca534fbf735eb546158b (diff) | |
download | lwn-4a9e5ef1f4f15205e477817a5cefc34bd3f65f55.tar.gz lwn-4a9e5ef1f4f15205e477817a5cefc34bd3f65f55.zip |
mm: write iovec cleanup
Hide some of the open-coded nr_segs tests into the iovec helpers. This is all
to simplify generic_file_buffered_write, because that gets more complex in the
next patch.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index fb4c1c0792e7..c59d5b3cd99a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1823,12 +1823,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, /* * handle partial DIO write. Adjust cur_iov if needed. */ - if (likely(nr_segs == 1)) - buf = iov->iov_base + written; - else { - filemap_set_next_iovec(&cur_iov, &iov_offset, written); - buf = cur_iov->iov_base + iov_offset; - } + filemap_set_next_iovec(&cur_iov, nr_segs, &iov_offset, written); do { struct page *page; @@ -1838,6 +1833,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, size_t bytes; /* Bytes to write to page */ size_t copied; /* Bytes copied from user */ + buf = cur_iov->iov_base + iov_offset; offset = (pos & (PAGE_CACHE_SIZE - 1)); index = pos >> PAGE_CACHE_SHIFT; bytes = PAGE_CACHE_SIZE - offset; @@ -1869,13 +1865,10 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, if (unlikely(status)) goto fs_write_aop_error; - if (likely(nr_segs == 1)) - copied = filemap_copy_from_user(page, offset, - buf, bytes); - else - copied = filemap_copy_from_user_iovec(page, offset, - cur_iov, iov_offset, bytes); + copied = filemap_copy_from_user(page, offset, + cur_iov, nr_segs, iov_offset, bytes); flush_dcache_page(page); + status = a_ops->commit_write(file, page, offset, offset+bytes); if (unlikely(status < 0 || status == AOP_TRUNCATED_PAGE)) goto fs_write_aop_error; @@ -1886,20 +1879,11 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, if (unlikely(status > 0)) /* filesystem did partial write */ copied = status; - if (likely(copied > 0)) { - written += copied; - count -= copied; - pos += copied; - buf += copied; - if (unlikely(nr_segs > 1)) { - filemap_set_next_iovec(&cur_iov, - &iov_offset, copied); - if (count) - buf = cur_iov->iov_base + iov_offset; - } else { - iov_offset += copied; - } - } + written += copied; + count -= copied; + pos += copied; + filemap_set_next_iovec(&cur_iov, nr_segs, &iov_offset, copied); + unlock_page(page); mark_page_accessed(page); page_cache_release(page); |