diff options
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 1d33fec7bac6..4a2fee2cb62b 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1968,6 +1968,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, | |||
1968 | do { | 1968 | do { |
1969 | unsigned long index; | 1969 | unsigned long index; |
1970 | unsigned long offset; | 1970 | unsigned long offset; |
1971 | unsigned long maxlen; | ||
1971 | size_t copied; | 1972 | size_t copied; |
1972 | 1973 | ||
1973 | offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ | 1974 | offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ |
@@ -1982,7 +1983,10 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, | |||
1982 | * same page as we're writing to, without it being marked | 1983 | * same page as we're writing to, without it being marked |
1983 | * up-to-date. | 1984 | * up-to-date. |
1984 | */ | 1985 | */ |
1985 | fault_in_pages_readable(buf, bytes); | 1986 | maxlen = cur_iov->iov_len - iov_base; |
1987 | if (maxlen > bytes) | ||
1988 | maxlen = bytes; | ||
1989 | fault_in_pages_readable(buf, maxlen); | ||
1986 | 1990 | ||
1987 | page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec); | 1991 | page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec); |
1988 | if (!page) { | 1992 | if (!page) { |
@@ -2024,6 +2028,8 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, | |||
2024 | filemap_set_next_iovec(&cur_iov, | 2028 | filemap_set_next_iovec(&cur_iov, |
2025 | &iov_base, status); | 2029 | &iov_base, status); |
2026 | buf = cur_iov->iov_base + iov_base; | 2030 | buf = cur_iov->iov_base + iov_base; |
2031 | } else { | ||
2032 | iov_base += status; | ||
2027 | } | 2033 | } |
2028 | } | 2034 | } |
2029 | } | 2035 | } |