From 296c98be74fc01721b6e8a97f257e173bf5496da Mon Sep 17 00:00:00 2001 From: "Vladimir V. Saveliev" Date: Tue, 27 Jun 2006 02:53:57 -0700 Subject: [PATCH] --- yaml --- r: 30751 b: refs/heads/master c: 6527c2bdf1f833cc18e8f42bd97973d583e4aa83 h: refs/heads/master i: 30749: 487986847d880d71bc54b8a5a13872622e46fd1b 30747: 1f17bd17bdca5142390dc31493db7c47182a3883 30743: 31f9214090901348d674f9950312f5075eca8051 30735: 3b728a53fd2d3cd3009f5740bbbc21cda7d28a5a 30719: 9991833e64508655770c042b36e7664ece7b545d v: v3 --- [refs] | 2 +- trunk/mm/filemap.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/[refs] b/[refs] index dfb84aa950f8..621d0e76137a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 1c0f16e5cdff59f3b132a1b0c0d44a941f8813d2 +refs/heads/master: 6527c2bdf1f833cc18e8f42bd97973d583e4aa83 diff --git a/trunk/mm/filemap.c b/trunk/mm/filemap.c index 9c7334bafda8..d504d6e98886 100644 --- a/trunk/mm/filemap.c +++ b/trunk/mm/filemap.c @@ -2095,14 +2095,21 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, do { unsigned long index; unsigned long offset; - unsigned long maxlen; size_t copied; offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ index = pos >> PAGE_CACHE_SHIFT; bytes = PAGE_CACHE_SIZE - offset; - if (bytes > count) - bytes = count; + + /* Limit the size of the copy to the caller's write size */ + bytes = min(bytes, count); + + /* + * Limit the size of the copy to that of the current segment, + * because fault_in_pages_readable() doesn't know how to walk + * segments. + */ + bytes = min(bytes, cur_iov->iov_len - iov_base); /* * Bring in the user page that we will copy from _first_. @@ -2110,10 +2117,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, * same page as we're writing to, without it being marked * up-to-date. */ - maxlen = cur_iov->iov_len - iov_base; - if (maxlen > bytes) - maxlen = bytes; - fault_in_pages_readable(buf, maxlen); + fault_in_pages_readable(buf, bytes); page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec); if (!page) {