diff options
| -rw-r--r-- | fs/bfs/file.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/bfs/file.c b/fs/bfs/file.c index f20e8a71062f..ad3ea1497cc3 100644 --- a/fs/bfs/file.c +++ b/fs/bfs/file.c | |||
| @@ -161,6 +161,14 @@ static int bfs_readpage(struct file *file, struct page *page) | |||
| 161 | return block_read_full_page(page, bfs_get_block); | 161 | return block_read_full_page(page, bfs_get_block); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | static void bfs_write_failed(struct address_space *mapping, loff_t to) | ||
| 165 | { | ||
| 166 | struct inode *inode = mapping->host; | ||
| 167 | |||
| 168 | if (to > inode->i_size) | ||
| 169 | truncate_pagecache(inode, to, inode->i_size); | ||
| 170 | } | ||
| 171 | |||
| 164 | static int bfs_write_begin(struct file *file, struct address_space *mapping, | 172 | static int bfs_write_begin(struct file *file, struct address_space *mapping, |
| 165 | loff_t pos, unsigned len, unsigned flags, | 173 | loff_t pos, unsigned len, unsigned flags, |
| 166 | struct page **pagep, void **fsdata) | 174 | struct page **pagep, void **fsdata) |
| @@ -169,11 +177,8 @@ static int bfs_write_begin(struct file *file, struct address_space *mapping, | |||
| 169 | 177 | ||
| 170 | ret = block_write_begin(mapping, pos, len, flags, pagep, | 178 | ret = block_write_begin(mapping, pos, len, flags, pagep, |
| 171 | bfs_get_block); | 179 | bfs_get_block); |
| 172 | if (unlikely(ret)) { | 180 | if (unlikely(ret)) |
| 173 | loff_t isize = mapping->host->i_size; | 181 | bfs_write_failed(mapping, pos + len); |
| 174 | if (pos + len > isize) | ||
| 175 | vmtruncate(mapping->host, isize); | ||
| 176 | } | ||
| 177 | 182 | ||
| 178 | return ret; | 183 | return ret; |
| 179 | } | 184 | } |
