aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Stornelli <marco.stornelli@gmail.com>2012-12-15 05:49:42 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-12-20 14:00:01 -0500
commita8f5293aac161f9dfd70d0c03c3e407d417fafe1 (patch)
tree078be908f33b4d9b958da506b1687585fdbc8d3a
parent46f69557103e11fb963ae5c98b7777e90493241b (diff)
omfs: drop vmtruncate
Removed vmtruncate Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com> Acked-by: Bob Copeland <me@bobcopeland.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/omfs/file.c22
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
309static 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
309static int omfs_write_begin(struct file *file, struct address_space *mapping, 319static 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
363const struct inode_operations omfs_file_inops = { 372const struct inode_operations omfs_file_inops = {
364 .setattr = omfs_setattr, 373 .setattr = omfs_setattr,
365 .truncate = omfs_truncate
366}; 374};
367 375
368const struct address_space_operations omfs_aops = { 376const struct address_space_operations omfs_aops = {