Commit a8f5293aac161f9dfd70d0c03c3e407d417fafe1

Authored by Marco Stornelli
Committed by Al Viro
1 parent 46f6955710

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>

Showing 1 changed file with 15 additions and 7 deletions Side-by-side Diff

... ... @@ -306,6 +306,16 @@
306 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 319 static int omfs_write_begin(struct file *file, struct address_space *mapping,
310 320 loff_t pos, unsigned len, unsigned flags,
311 321 struct page **pagep, void **fsdata)
... ... @@ -314,11 +324,8 @@
314 324  
315 325 ret = block_write_begin(mapping, pos, len, flags, pagep,
316 326 omfs_get_block);
317   - if (unlikely(ret)) {
318   - loff_t isize = mapping->host->i_size;
319   - if (pos + len > isize)
320   - vmtruncate(mapping->host, isize);
321   - }
  327 + if (unlikely(ret))
  328 + omfs_write_failed(mapping, pos + len);
322 329  
323 330 return ret;
324 331 }
325 332  
... ... @@ -350,9 +357,11 @@
350 357  
351 358 if ((attr->ia_valid & ATTR_SIZE) &&
352 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 361 if (error)
355 362 return error;
  363 + truncate_setsize(inode, attr->ia_size);
  364 + omfs_truncate(inode);
356 365 }
357 366  
358 367 setattr_copy(inode, attr);
... ... @@ -362,7 +371,6 @@
362 371  
363 372 const struct inode_operations omfs_file_inops = {
364 373 .setattr = omfs_setattr,
365   - .truncate = omfs_truncate
366 374 };
367 375  
368 376 const struct address_space_operations omfs_aops = {