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
static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dentry)
{
int retval;
struct inode * inode = 0;
struct inode * inode = NULL;
struct reiserfs_dir_entry de;
INITIALIZE_PATH (path_to_entry);
......@@ -358,6 +358,9 @@ static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dent
return ERR_PTR(-EACCES);
}
}
if ( retval == IO_ERROR ) {
return ERR_PTR(-EIO);
}
d_add(dentry, inode);
return NULL;
......@@ -443,6 +446,10 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in
reiserfs_kfree (buffer, buflen, dir->i_sb);
pathrelse (&path);
if ( retval == IO_ERROR ) {
return -EIO;
}
if (retval != NAME_FOUND) {
reiserfs_warning ("zam-7002:" __FUNCTION__ ": \"reiserfs_find_entry\" has returned"
" unexpected value (%d)\n", retval);
......@@ -715,10 +722,14 @@ static int reiserfs_rmdir (struct inode * dir, struct dentry *dentry)
windex = push_journal_writer("reiserfs_rmdir") ;
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;
goto end_rmdir;
} else if ( retval == IO_ERROR) {
retval = -EIO;
goto end_rmdir;
}
inode = dentry->d_inode;
reiserfs_update_inode_transaction(inode) ;
......@@ -800,9 +811,12 @@ static int reiserfs_unlink (struct inode * dir, struct dentry *dentry)
windex = push_journal_writer("reiserfs_unlink") ;
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;
goto end_unlink;
} else if (retval == IO_ERROR) {
retval = -EIO;
goto end_unlink;
}
reiserfs_update_inode_transaction(inode) ;
......@@ -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,
&old_entry_path, &old_de);
pathrelse (&old_entry_path);
if (retval == IO_ERROR)
return -EIO;
if (retval != NAME_FOUND || old_de.de_objectid != old_inode->i_ino) {
// FIXME: IO error is possible here
return -ENOENT;
}
......@@ -1138,6 +1154,8 @@ static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
new_de.de_gen_number_bit_string = 0;
retval = reiserfs_find_entry (new_dir, new_dentry->d_name.name, new_dentry->d_name.len,
&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)
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