diff options
Diffstat (limited to 'fs/omfs/file.c')
| -rw-r--r-- | fs/omfs/file.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/fs/omfs/file.c b/fs/omfs/file.c index 77e3cb2962b4..e0d9b3e722bd 100644 --- a/fs/omfs/file.c +++ b/fs/omfs/file.c | |||
| @@ -306,6 +306,16 @@ omfs_writepages(struct address_space *mapping, struct writeback_control *wbc) | |||
| 306 | return mpage_writepages(mapping, wbc, omfs_get_block); | 306 | return mpage_writepages(mapping, wbc, omfs_get_block); |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | static void omfs_write_failed(struct address_space *mapping, loff_t to) | ||
| 310 | { | ||
| 311 | struct inode *inode = mapping->host; | ||
| 312 | |||
| 313 | if (to > inode->i_size) { | ||
| 314 | truncate_pagecache(inode, to, inode->i_size); | ||
| 315 | omfs_truncate(inode); | ||
| 316 | } | ||
| 317 | } | ||
| 318 | |||
| 309 | static int omfs_write_begin(struct file *file, struct address_space *mapping, | 319 | static int omfs_write_begin(struct file *file, struct address_space *mapping, |
| 310 | loff_t pos, unsigned len, unsigned flags, | 320 | loff_t pos, unsigned len, unsigned flags, |
| 311 | struct page **pagep, void **fsdata) | 321 | struct page **pagep, void **fsdata) |
| @@ -314,11 +324,8 @@ static int omfs_write_begin(struct file *file, struct address_space *mapping, | |||
| 314 | 324 | ||
| 315 | ret = block_write_begin(mapping, pos, len, flags, pagep, | 325 | ret = block_write_begin(mapping, pos, len, flags, pagep, |
| 316 | omfs_get_block); | 326 | omfs_get_block); |
| 317 | if (unlikely(ret)) { | 327 | if (unlikely(ret)) |
| 318 | loff_t isize = mapping->host->i_size; | 328 | omfs_write_failed(mapping, pos + len); |
| 319 | if (pos + len > isize) | ||
| 320 | vmtruncate(mapping->host, isize); | ||
| 321 | } | ||
| 322 | 329 | ||
| 323 | return ret; | 330 | return ret; |
| 324 | } | 331 | } |
| @@ -350,9 +357,11 @@ static int omfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 350 | 357 | ||
| 351 | if ((attr->ia_valid & ATTR_SIZE) && | 358 | if ((attr->ia_valid & ATTR_SIZE) && |
| 352 | attr->ia_size != i_size_read(inode)) { | 359 | attr->ia_size != i_size_read(inode)) { |
| 353 | error = vmtruncate(inode, attr->ia_size); | 360 | error = inode_newsize_ok(inode, attr->ia_size); |
| 354 | if (error) | 361 | if (error) |
| 355 | return error; | 362 | return error; |
| 363 | truncate_setsize(inode, attr->ia_size); | ||
| 364 | omfs_truncate(inode); | ||
| 356 | } | 365 | } |
| 357 | 366 | ||
| 358 | setattr_copy(inode, attr); | 367 | setattr_copy(inode, attr); |
| @@ -362,7 +371,6 @@ static int omfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 362 | 371 | ||
| 363 | const struct inode_operations omfs_file_inops = { | 372 | const struct inode_operations omfs_file_inops = { |
| 364 | .setattr = omfs_setattr, | 373 | .setattr = omfs_setattr, |
| 365 | .truncate = omfs_truncate | ||
| 366 | }; | 374 | }; |
| 367 | 375 | ||
| 368 | const struct address_space_operations omfs_aops = { | 376 | const struct address_space_operations omfs_aops = { |
