aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index d504d6e98886..648f2c0c8e18 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2069,7 +2069,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2069{ 2069{
2070 struct file *file = iocb->ki_filp; 2070 struct file *file = iocb->ki_filp;
2071 struct address_space * mapping = file->f_mapping; 2071 struct address_space * mapping = file->f_mapping;
2072 struct address_space_operations *a_ops = mapping->a_ops; 2072 const struct address_space_operations *a_ops = mapping->a_ops;
2073 struct inode *inode = mapping->host; 2073 struct inode *inode = mapping->host;
2074 long status = 0; 2074 long status = 0;
2075 struct page *page; 2075 struct page *page;
@@ -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
@@ -2219,7 +2226,7 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
2219 unsigned long nr_segs, loff_t *ppos) 2226 unsigned long nr_segs, loff_t *ppos)
2220{ 2227{
2221 struct file *file = iocb->ki_filp; 2228 struct file *file = iocb->ki_filp;
2222 struct address_space * mapping = file->f_mapping; 2229 const struct address_space * mapping = file->f_mapping;
2223 size_t ocount; /* original count */ 2230 size_t ocount; /* original count */
2224 size_t count; /* after file limit checks */ 2231 size_t count; /* after file limit checks */
2225 struct inode *inode = mapping->host; 2232 struct inode *inode = mapping->host;