aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoern Engel <joern@logfs.org>2010-03-27 04:56:58 -0400
committerJoern Engel <joern@logfs.org>2010-03-28 06:40:42 -0400
commit193219172691e29813821dc8433317768c6ed1a3 (patch)
tree9df87e5fa573deddd1d7b89da3005567308a2ab3
parent6f2e9e6a950a165a7d2c399ab7557e6745ef2bfd (diff)
Prevent data corruption in logfs_rewrite_block()
The comment was correct, so make the code match the comment. As the new comment indicates, we might be able to do a little less work. But for the current -rc series let's keep it simple and just fix the bug. Signed-off-by: Joern Engel <joern@logfs.org>
-rw-r--r--fs/logfs/readwrite.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/logfs/readwrite.c b/fs/logfs/readwrite.c
index 7a23b3e7c0a7..c3a3a6814b84 100644
--- a/fs/logfs/readwrite.c
+++ b/fs/logfs/readwrite.c
@@ -1594,7 +1594,6 @@ int logfs_delete(struct inode *inode, pgoff_t index,
1594 return ret; 1594 return ret;
1595} 1595}
1596 1596
1597/* Rewrite cannot mark the inode dirty but has to write it immediatly. */
1598int logfs_rewrite_block(struct inode *inode, u64 bix, u64 ofs, 1597int logfs_rewrite_block(struct inode *inode, u64 bix, u64 ofs,
1599 gc_level_t gc_level, long flags) 1598 gc_level_t gc_level, long flags)
1600{ 1599{
@@ -1611,6 +1610,18 @@ int logfs_rewrite_block(struct inode *inode, u64 bix, u64 ofs,
1611 if (level != 0) 1610 if (level != 0)
1612 alloc_indirect_block(inode, page, 0); 1611 alloc_indirect_block(inode, page, 0);
1613 err = logfs_write_buf(inode, page, flags); 1612 err = logfs_write_buf(inode, page, flags);
1613 if (!err && shrink_level(gc_level) == 0) {
1614 /* Rewrite cannot mark the inode dirty but has to
1615 * write it immediatly.
1616 * Q: Can't we just create an alias for the inode
1617 * instead? And if not, why not?
1618 */
1619 if (inode->i_ino == LOGFS_INO_MASTER)
1620 logfs_write_anchor(inode->i_sb);
1621 else {
1622 err = __logfs_write_inode(inode, flags);
1623 }
1624 }
1614 } 1625 }
1615 logfs_put_write_page(page); 1626 logfs_put_write_page(page);
1616 return err; 1627 return err;