mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 06:12:08 +00:00
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>
This commit is contained in:
parent
6f2e9e6a95
commit
1932191726
@ -1594,7 +1594,6 @@ int logfs_delete(struct inode *inode, pgoff_t index,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Rewrite cannot mark the inode dirty but has to write it immediatly. */
|
|
||||||
int logfs_rewrite_block(struct inode *inode, u64 bix, u64 ofs,
|
int logfs_rewrite_block(struct inode *inode, u64 bix, u64 ofs,
|
||||||
gc_level_t gc_level, long flags)
|
gc_level_t gc_level, long flags)
|
||||||
{
|
{
|
||||||
@ -1611,6 +1610,18 @@ int logfs_rewrite_block(struct inode *inode, u64 bix, u64 ofs,
|
|||||||
if (level != 0)
|
if (level != 0)
|
||||||
alloc_indirect_block(inode, page, 0);
|
alloc_indirect_block(inode, page, 0);
|
||||||
err = logfs_write_buf(inode, page, flags);
|
err = logfs_write_buf(inode, page, flags);
|
||||||
|
if (!err && shrink_level(gc_level) == 0) {
|
||||||
|
/* Rewrite cannot mark the inode dirty but has to
|
||||||
|
* write it immediatly.
|
||||||
|
* Q: Can't we just create an alias for the inode
|
||||||
|
* instead? And if not, why not?
|
||||||
|
*/
|
||||||
|
if (inode->i_ino == LOGFS_INO_MASTER)
|
||||||
|
logfs_write_anchor(inode->i_sb);
|
||||||
|
else {
|
||||||
|
err = __logfs_write_inode(inode, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
logfs_put_write_page(page);
|
logfs_put_write_page(page);
|
||||||
return err;
|
return err;
|
||||||
|
Loading…
Reference in New Issue
Block a user