aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2007-10-16 04:24:58 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:42:54 -0400
commit4a9e5ef1f4f15205e477817a5cefc34bd3f65f55 (patch)
tree51f52086ecbccc3f41955d8d12293ef7a566a05b /mm/filemap.c
parenteb2be189317d031895b5ca534fbf735eb546158b (diff)
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.c36
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,
1823 /* 1823 /*
1824 * handle partial DIO write. Adjust cur_iov if needed. 1824 * handle partial DIO write. Adjust cur_iov if needed.
1825 */ 1825 */
1826 if (likely(nr_segs == 1)) 1826 filemap_set_next_iovec(&cur_iov, nr_segs, &iov_offset, written);
1827 buf = iov->iov_base + written;
1828 else {
1829 filemap_set_next_iovec(&cur_iov, &iov_offset, written);
1830 buf = cur_iov->iov_base + iov_offset;
1831 }
1832 1827
1833 do { 1828 do {
1834 struct page *page; 1829 struct page *page;
@@ -1838,6 +1833,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
1838 size_t bytes; /* Bytes to write to page */ 1833 size_t bytes; /* Bytes to write to page */
1839 size_t copied; /* Bytes copied from user */ 1834 size_t copied; /* Bytes copied from user */
1840 1835
1836 buf = cur_iov->iov_base + iov_offset;
1841 offset = (pos & (PAGE_CACHE_SIZE - 1)); 1837 offset = (pos & (PAGE_CACHE_SIZE - 1));
1842 index = pos >> PAGE_CACHE_SHIFT; 1838 index = pos >> PAGE_CACHE_SHIFT;
1843 bytes = PAGE_CACHE_SIZE - offset; 1839 bytes = PAGE_CACHE_SIZE - offset;
@@ -1869,13 +1865,10 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
1869 if (unlikely(status)) 1865 if (unlikely(status))
1870 goto fs_write_aop_error; 1866 goto fs_write_aop_error;
1871 1867
1872 if (likely(nr_segs == 1)) 1868 copied = filemap_copy_from_user(page, offset,
1873 copied = filemap_copy_from_user(page, offset, 1869 cur_iov, nr_segs, iov_offset, bytes);
1874 buf, bytes);
1875 else
1876 copied = filemap_copy_from_user_iovec(page, offset,
1877 cur_iov, iov_offset, bytes);
1878 flush_dcache_page(page); 1870 flush_dcache_page(page);
1871
1879 status = a_ops->commit_write(file, page, offset, offset+bytes); 1872 status = a_ops->commit_write(file, page, offset, offset+bytes);
1880 if (unlikely(status < 0 || status == AOP_TRUNCATED_PAGE)) 1873 if (unlikely(status < 0 || status == AOP_TRUNCATED_PAGE))
1881 goto fs_write_aop_error; 1874 goto fs_write_aop_error;
@@ -1886,20 +1879,11 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
1886 if (unlikely(status > 0)) /* filesystem did partial write */ 1879 if (unlikely(status > 0)) /* filesystem did partial write */
1887 copied = status; 1880 copied = status;
1888 1881
1889 if (likely(copied > 0)) { 1882 written += copied;
1890 written += copied; 1883 count -= copied;
1891 count -= copied; 1884 pos += copied;
1892 pos += copied; 1885 filemap_set_next_iovec(&cur_iov, nr_segs, &iov_offset, copied);
1893 buf += copied; 1886
1894 if (unlikely(nr_segs > 1)) {
1895 filemap_set_next_iovec(&cur_iov,
1896 &iov_offset, copied);
1897 if (count)
1898 buf = cur_iov->iov_base + iov_offset;
1899 } else {
1900 iov_offset += copied;
1901 }
1902 }
1903 unlock_page(page); 1887 unlock_page(page);
1904 mark_page_accessed(page); 1888 mark_page_accessed(page);
1905 page_cache_release(page); 1889 page_cache_release(page);