diff options
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index caaaa7adfdf9..4bf7d1ab6c2a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1865,21 +1865,14 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, | |||
1865 | do { | 1865 | do { |
1866 | unsigned long index; | 1866 | unsigned long index; |
1867 | unsigned long offset; | 1867 | unsigned long offset; |
1868 | unsigned long maxlen; | ||
1868 | size_t copied; | 1869 | size_t copied; |
1869 | 1870 | ||
1870 | offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ | 1871 | offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ |
1871 | index = pos >> PAGE_CACHE_SHIFT; | 1872 | index = pos >> PAGE_CACHE_SHIFT; |
1872 | bytes = PAGE_CACHE_SIZE - offset; | 1873 | bytes = PAGE_CACHE_SIZE - offset; |
1873 | 1874 | if (bytes > count) | |
1874 | /* Limit the size of the copy to the caller's write size */ | 1875 | bytes = count; |
1875 | bytes = min(bytes, count); | ||
1876 | |||
1877 | /* | ||
1878 | * Limit the size of the copy to that of the current segment, | ||
1879 | * because fault_in_pages_readable() doesn't know how to walk | ||
1880 | * segments. | ||
1881 | */ | ||
1882 | bytes = min(bytes, cur_iov->iov_len - iov_base); | ||
1883 | 1876 | ||
1884 | /* | 1877 | /* |
1885 | * Bring in the user page that we will copy from _first_. | 1878 | * Bring in the user page that we will copy from _first_. |
@@ -1887,7 +1880,10 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, | |||
1887 | * same page as we're writing to, without it being marked | 1880 | * same page as we're writing to, without it being marked |
1888 | * up-to-date. | 1881 | * up-to-date. |
1889 | */ | 1882 | */ |
1890 | fault_in_pages_readable(buf, bytes); | 1883 | maxlen = cur_iov->iov_len - iov_base; |
1884 | if (maxlen > bytes) | ||
1885 | maxlen = bytes; | ||
1886 | fault_in_pages_readable(buf, maxlen); | ||
1891 | 1887 | ||
1892 | page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec); | 1888 | page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec); |
1893 | if (!page) { | 1889 | if (!page) { |