Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 175305
b: refs/heads/master
c: 68eb3db
h: refs/heads/master
i:
  175303: edd37c0
v: v3
  • Loading branch information
Jan Kara committed Dec 10, 2009
1 parent aba71e1 commit 7d01db2
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: 5a20bdfcdc5c5e5f0647d8d99a998066ef5496ac
refs/heads/master: 68eb3db08344286733adac48304d9fb7a0e53b27
18 changes: 14 additions & 4 deletions trunk/fs/ext3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,16 @@ static int do_journal_get_write_access(handle_t *handle,
return ext3_journal_get_write_access(handle, bh);
}

/*
* Truncate blocks that were not used by write. We have to truncate the
* pagecache as well so that corresponding buffers get properly unmapped.
*/
static void ext3_truncate_failed_write(struct inode *inode)
{
truncate_inode_pages(inode->i_mapping, inode->i_size);
ext3_truncate(inode);
}

static int ext3_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
Expand Down Expand Up @@ -1209,7 +1219,7 @@ static int ext3_write_begin(struct file *file, struct address_space *mapping,
unlock_page(page);
page_cache_release(page);
if (pos + len > inode->i_size)
ext3_truncate(inode);
ext3_truncate_failed_write(inode);
}
if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
goto retry;
Expand Down Expand Up @@ -1304,7 +1314,7 @@ static int ext3_ordered_write_end(struct file *file,
page_cache_release(page);

if (pos + len > inode->i_size)
ext3_truncate(inode);
ext3_truncate_failed_write(inode);
return ret ? ret : copied;
}

Expand All @@ -1330,7 +1340,7 @@ static int ext3_writeback_write_end(struct file *file,
page_cache_release(page);

if (pos + len > inode->i_size)
ext3_truncate(inode);
ext3_truncate_failed_write(inode);
return ret ? ret : copied;
}

Expand Down Expand Up @@ -1383,7 +1393,7 @@ static int ext3_journalled_write_end(struct file *file,
page_cache_release(page);

if (pos + len > inode->i_size)
ext3_truncate(inode);
ext3_truncate_failed_write(inode);
return ret ? ret : copied;
}

Expand Down

0 comments on commit 7d01db2

Please sign in to comment.