Skip to contentSkip to conversation

corrupted reiserfs may cause kernel to panic on lookup() sometimes.

PATCH In review Oleg Drokin 2 participants 3 messages Jan 3, 2002 – Jan 14, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 corrupted reiserfs may cause kernel to panic on lookup() sometimes.

Hello!

Certain disk corruptions and i/o errors may cause lookup() to panic, which is wrong. This patch fixes the problem.
Please apply.

Bye,
Oleg

fs/reiserfs/namei.c renamed from fs/reiserfs/namei.c.orig +4 -3
@@ -309,9 +309,10 @@
 
     while (1) {
 	retval = search_by_entry_key (dir->i_sb, &key_to_search, path_to_entry, de);
-	if (retval == IO_ERROR)
-	    // FIXME: still has to be dealt with
-	    reiserfs_panic (dir->i_sb, "zam-7001: io error in " __FUNCTION__ "\n");
+	if (retval == IO_ERROR) {
+	    reiserfs_warning ("zam-7001: io error in " __FUNCTION__ "\n");
+	    return IO_ERROR;
+	}
 
 	/* compare names for all entries having given hash value */
 	retval = linear_search_in_dir_item (&key_to_search, de, name, namelen);
#1 lore raw
Quoted 5 lines · On Thursday, January 03, 2002 10:18:30 AM +0300 Oleg Drokin…

Hello!

Certain disk corruptions and i/o errors may cause lookup() to panic,
which is wrong. This patch fixes the problem.
Please apply.

Hmmm, none of the callers of reiserfs_find_entry have been changed to check for IO_ERROR. We should at least change reiserfs_add_entry to check for IO_ERROR, so it doesn't try to create a name after getting io error during the lookup.

-chris

fs/reiserfs/namei.c renamed from fs/reiserfs/namei.c.orig +4 -3
@@ -309,9 +309,10 @@
 
     while (1) {
 	retval = search_by_entry_key (dir->i_sb, &key_to_search, path_to_entry, de);
-	if (retval == IO_ERROR)
-	    // FIXME: still has to be dealt with
-	    reiserfs_panic (dir->i_sb, "zam-7001: io error in " __FUNCTION__ "\n");
+	if (retval == IO_ERROR) {
+	    reiserfs_warning ("zam-7001: io error in " __FUNCTION__ "\n");
+	    return IO_ERROR;
+	}
 
 	/* compare names for all entries having given hash value */
 	retval = linear_search_in_dir_item (&key_to_search, de, name, namelen);
#2 lore raw
In reply to Oleg Drokin

Hello!

Quoted 7 lines · Chris Mason
Quoted 3 lines

Certain disk corruptions and i/o errors may cause lookup() to panic,
which is wrong. This patch fixes the problem.
Please apply.

Hmmm, none of the callers of reiserfs_find_entry have been changed to check for IO_ERROR. We should at least change reiserfs_add_entry to check for IO_ERROR, so it doesn't try to create a name after getting io error during the lookup.

Well, in fact reiserfs_add_entry won't do that anyway, consider this code:

    retval = reiserfs_find_entry (dir, name, namelen, &path, &de);
    if( retval != NAME_NOT_FOUND ) {
        if (buffer != small_buf)
            reiserfs_kfree (buffer, buflen, dir->i_sb);
        pathrelse (&path);

        if (retval != NAME_FOUND) {
            reiserfs_warning ("zam-7002:" __FUNCTION__ ": \"reiserfs_find_entry\" has returned"
                              " unexpected value (%d)\n", retval);
       }

        return -EEXIST;
    }

Though I see other places where code is not that smart. I'll come up with additional patch later today. Thanks for noticing.

Bye,
Oleg