Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177758
b: refs/heads/master
c: ec8e2f7
h: refs/heads/master
v: v3
  • Loading branch information
Jan Kara authored and Linus Torvalds committed Dec 17, 2009
1 parent aab0b45 commit 6c39771
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2bf212b9e48e1c35eaf8f0cc1729d7c4a39b7b5a
refs/heads/master: ec8e2f7466ca370f5e09000ca40a71759afc9ac8
18 changes: 14 additions & 4 deletions trunk/fs/reiserfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2538,6 +2538,12 @@ static int reiserfs_writepage(struct page *page, struct writeback_control *wbc)
return reiserfs_write_full_page(page, wbc);
}

static void reiserfs_truncate_failed_write(struct inode *inode)
{
truncate_inode_pages(inode->i_mapping, inode->i_size);
reiserfs_truncate_file(inode, 0);
}

static int reiserfs_write_begin(struct file *file,
struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
Expand Down Expand Up @@ -2604,6 +2610,8 @@ static int reiserfs_write_begin(struct file *file,
if (ret) {
unlock_page(page);
page_cache_release(page);
/* Truncate allocated blocks */
reiserfs_truncate_failed_write(inode);
}
return ret;
}
Expand Down Expand Up @@ -2701,9 +2709,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
** transaction tracking stuff when the size changes. So, we have
** to do the i_size updates here.
*/
pos += copied;

if (pos > inode->i_size) {
if (pos + copied > inode->i_size) {
struct reiserfs_transaction_handle myth;
lock_depth = reiserfs_write_lock_once(inode->i_sb);
locked = true;
Expand All @@ -2721,7 +2727,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
goto journal_error;

reiserfs_update_inode_transaction(inode);
inode->i_size = pos;
inode->i_size = pos + copied;
/*
* this will just nest into our transaction. It's important
* to use mark_inode_dirty so the inode gets pushed around on the
Expand Down Expand Up @@ -2751,6 +2757,10 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
reiserfs_write_unlock_once(inode->i_sb, lock_depth);
unlock_page(page);
page_cache_release(page);

if (pos + len > inode->i_size)
reiserfs_truncate_failed_write(inode);

return ret == 0 ? copied : ret;

journal_error:
Expand Down

0 comments on commit 6c39771

Please sign in to comment.