Commit 8956fa9f authored by Hans Reiser's avatar Hans Reiser Committed by Linus Torvalds

[PATCH] ReiserFS get_block fix

This patch is to convert pap14030 panic into warning. While doing this,
a bug was uncovered, that when get_block() returns a failure, buffer
is still marked as mapped, and on subsequent access to this buffer
get_block() was not called anymore. This is also fixed.
parent 5ebb0457
...@@ -752,6 +752,11 @@ int reiserfs_get_block (struct inode * inode, sector_t block, ...@@ -752,6 +752,11 @@ int reiserfs_get_block (struct inode * inode, sector_t block,
goto research ; goto research ;
} }
retval = direct2indirect (&th, inode, &path, unbh, tail_offset); retval = direct2indirect (&th, inode, &path, unbh, tail_offset);
if (retval) {
reiserfs_unmap_buffer(unbh);
reiserfs_free_block (&th, allocated_block_nr);
goto failure;
}
/* it is important the mark_buffer_uptodate is done after /* it is important the mark_buffer_uptodate is done after
** the direct2indirect. The buffer might contain valid ** the direct2indirect. The buffer might contain valid
** data newer than the data on disk (read by readpage, changed, ** data newer than the data on disk (read by readpage, changed,
...@@ -761,10 +766,7 @@ int reiserfs_get_block (struct inode * inode, sector_t block, ...@@ -761,10 +766,7 @@ int reiserfs_get_block (struct inode * inode, sector_t block,
** the disk ** the disk
*/ */
mark_buffer_uptodate (unbh, 1); mark_buffer_uptodate (unbh, 1);
if (retval) {
reiserfs_free_block (&th, allocated_block_nr);
goto failure;
}
/* we've converted the tail, so we must /* we've converted the tail, so we must
** flush unbh before the transaction commits ** flush unbh before the transaction commits
*/ */
......
...@@ -49,9 +49,13 @@ int direct2indirect (struct reiserfs_transaction_handle *th, struct inode * inod ...@@ -49,9 +49,13 @@ int direct2indirect (struct reiserfs_transaction_handle *th, struct inode * inod
make_cpu_key (&end_key, inode, tail_offset, TYPE_INDIRECT, 4); make_cpu_key (&end_key, inode, tail_offset, TYPE_INDIRECT, 4);
// FIXME: we could avoid this // FIXME: we could avoid this
if ( search_for_position_by_key (sb, &end_key, path) == POSITION_FOUND ) if ( search_for_position_by_key (sb, &end_key, path) == POSITION_FOUND ) {
reiserfs_panic (sb, "PAP-14030: direct2indirect: " reiserfs_warning ("PAP-14030: direct2indirect: "
"pasted or inserted byte exists in the tree"); "pasted or inserted byte exists in the tree %K. "
"Use fsck to repair.\n", &end_key);
pathrelse(path);
return -EIO;
}
p_le_ih = PATH_PITEM_HEAD (path); p_le_ih = PATH_PITEM_HEAD (path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment