Commit e3eea6fd authored by Hans Reiser's avatar Hans Reiser Committed by Linus Torvalds

[PATCH] 01-ioerrors-checks-2.diff

    Make sure all reiserfs_find_entry users correctly understand IO_ERROR retval.
parent 0e44d4c5
...@@ -340,7 +340,7 @@ static int reiserfs_find_entry (struct inode * dir, const char * name, int namel ...@@ -340,7 +340,7 @@ static int reiserfs_find_entry (struct inode * dir, const char * name, int namel
static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dentry) static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dentry)
{ {
int retval; int retval;
struct inode * inode = 0; struct inode * inode = NULL;
struct reiserfs_dir_entry de; struct reiserfs_dir_entry de;
INITIALIZE_PATH (path_to_entry); INITIALIZE_PATH (path_to_entry);
...@@ -358,6 +358,9 @@ static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dent ...@@ -358,6 +358,9 @@ static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dent
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
} }
} }
if ( retval == IO_ERROR ) {
return ERR_PTR(-EIO);
}
d_add(dentry, inode); d_add(dentry, inode);
return NULL; return NULL;
...@@ -443,6 +446,10 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in ...@@ -443,6 +446,10 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in
reiserfs_kfree (buffer, buflen, dir->i_sb); reiserfs_kfree (buffer, buflen, dir->i_sb);
pathrelse (&path); pathrelse (&path);
if ( retval == IO_ERROR ) {
return -EIO;
}
if (retval != NAME_FOUND) { if (retval != NAME_FOUND) {
reiserfs_warning ("zam-7002:" __FUNCTION__ ": \"reiserfs_find_entry\" has returned" reiserfs_warning ("zam-7002:" __FUNCTION__ ": \"reiserfs_find_entry\" has returned"
" unexpected value (%d)\n", retval); " unexpected value (%d)\n", retval);
...@@ -715,10 +722,14 @@ static int reiserfs_rmdir (struct inode * dir, struct dentry *dentry) ...@@ -715,10 +722,14 @@ static int reiserfs_rmdir (struct inode * dir, struct dentry *dentry)
windex = push_journal_writer("reiserfs_rmdir") ; windex = push_journal_writer("reiserfs_rmdir") ;
de.de_gen_number_bit_string = 0; de.de_gen_number_bit_string = 0;
if (reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de) == NAME_NOT_FOUND) { if ( (retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de)) == NAME_NOT_FOUND) {
retval = -ENOENT; retval = -ENOENT;
goto end_rmdir; goto end_rmdir;
} else if ( retval == IO_ERROR) {
retval = -EIO;
goto end_rmdir;
} }
inode = dentry->d_inode; inode = dentry->d_inode;
reiserfs_update_inode_transaction(inode) ; reiserfs_update_inode_transaction(inode) ;
...@@ -800,9 +811,12 @@ static int reiserfs_unlink (struct inode * dir, struct dentry *dentry) ...@@ -800,9 +811,12 @@ static int reiserfs_unlink (struct inode * dir, struct dentry *dentry)
windex = push_journal_writer("reiserfs_unlink") ; windex = push_journal_writer("reiserfs_unlink") ;
de.de_gen_number_bit_string = 0; de.de_gen_number_bit_string = 0;
if (reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de) == NAME_NOT_FOUND) { if ( (retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de)) == NAME_NOT_FOUND) {
retval = -ENOENT; retval = -ENOENT;
goto end_unlink; goto end_unlink;
} else if (retval == IO_ERROR) {
retval = -EIO;
goto end_unlink;
} }
reiserfs_update_inode_transaction(inode) ; reiserfs_update_inode_transaction(inode) ;
...@@ -1065,8 +1079,10 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry, ...@@ -1065,8 +1079,10 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
retval = reiserfs_find_entry (old_dir, old_dentry->d_name.name, old_dentry->d_name.len, retval = reiserfs_find_entry (old_dir, old_dentry->d_name.name, old_dentry->d_name.len,
&old_entry_path, &old_de); &old_entry_path, &old_de);
pathrelse (&old_entry_path); pathrelse (&old_entry_path);
if (retval == IO_ERROR)
return -EIO;
if (retval != NAME_FOUND || old_de.de_objectid != old_inode->i_ino) { if (retval != NAME_FOUND || old_de.de_objectid != old_inode->i_ino) {
// FIXME: IO error is possible here
return -ENOENT; return -ENOENT;
} }
...@@ -1138,6 +1154,8 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry, ...@@ -1138,6 +1154,8 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
new_de.de_gen_number_bit_string = 0; new_de.de_gen_number_bit_string = 0;
retval = reiserfs_find_entry (new_dir, new_dentry->d_name.name, new_dentry->d_name.len, retval = reiserfs_find_entry (new_dir, new_dentry->d_name.name, new_dentry->d_name.len,
&new_entry_path, &new_de); &new_entry_path, &new_de);
// reiserfs_add_entry should not return IO_ERROR, because it is called with essentially same parameters from
// reiserfs_add_entry above, and we'll catch any i/o errors before we get here.
if (retval != NAME_FOUND_INVISIBLE && retval != NAME_FOUND) if (retval != NAME_FOUND_INVISIBLE && retval != NAME_FOUND)
BUG (); BUG ();
......
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