aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/filemap.c9
-rw-r--r--mm/filemap.h4
2 files changed, 10 insertions, 3 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 4082b3b3cea7..648f2c0c8e18 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2125,6 +2125,12 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2125 break; 2125 break;
2126 } 2126 }
2127 2127
2128 if (unlikely(bytes == 0)) {
2129 status = 0;
2130 copied = 0;
2131 goto zero_length_segment;
2132 }
2133
2128 status = a_ops->prepare_write(file, page, offset, offset+bytes); 2134 status = a_ops->prepare_write(file, page, offset, offset+bytes);
2129 if (unlikely(status)) { 2135 if (unlikely(status)) {
2130 loff_t isize = i_size_read(inode); 2136 loff_t isize = i_size_read(inode);
@@ -2154,7 +2160,8 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2154 page_cache_release(page); 2160 page_cache_release(page);
2155 continue; 2161 continue;
2156 } 2162 }
2157 if (likely(copied > 0)) { 2163zero_length_segment:
2164 if (likely(copied >= 0)) {
2158 if (!status) 2165 if (!status)
2159 status = copied; 2166 status = copied;
2160 2167
diff --git a/mm/filemap.h b/mm/filemap.h
index 536979fb4ba7..3f2a343c6015 100644
--- a/mm/filemap.h
+++ b/mm/filemap.h
@@ -88,7 +88,7 @@ filemap_set_next_iovec(const struct iovec **iovp, size_t *basep, size_t bytes)
88 const struct iovec *iov = *iovp; 88 const struct iovec *iov = *iovp;
89 size_t base = *basep; 89 size_t base = *basep;
90 90
91 while (bytes) { 91 do {
92 int copy = min(bytes, iov->iov_len - base); 92 int copy = min(bytes, iov->iov_len - base);
93 93
94 bytes -= copy; 94 bytes -= copy;
@@ -97,7 +97,7 @@ filemap_set_next_iovec(const struct iovec **iovp, size_t *basep, size_t bytes)
97 iov++; 97 iov++;
98 base = 0; 98 base = 0;
99 } 99 }
100 } 100 } while (bytes);
101 *iovp = iov; 101 *iovp = iov;
102 *basep = base; 102 *basep = base;
103} 103}