Skip to contentSkip to conversation

Fix reiserfs oops on small fs

PATCH In review Jan Kara 2 participants 3 messages Nov 18, 2004 – Nov 19, 2004 VFS

lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 Fix reiserfs oops on small fs

Hello!

Attached patch fixes oops of reiserfs on a filesystem with just one
bitmap block - current code always tries to return second bitmap even if there's not any. Could someone review it please so that it can be merged in mainline?

Honza

Fix block allocation code of reiserfs to give correct bitmap numbers for small filesystems (with just one bitmap block).

fs/reiserfs/bitmap.c +5 -2
diff -rupNX /home/jack/.kerndiffexclude linux-2.6.10-rc2-mm1-3-reiserdebug/fs/reiserfs/bitmap.c linux-2.6.10-rc2-mm1-4-reisersmall/fs/reiserfs/bitmap.c
@@ -229,6 +229,9 @@ static int bmap_hash_id(struct super_blo
     unsigned long hash;
     unsigned bm;
 
+    /* If there is only one bitmap, we have no choice... */
+    if (SB_BMAP_NR(s) == 1)
+	return 0;
     if (id <= 2) {
 	bm = 1;
     } else {
@@ -613,7 +616,7 @@ dirid_groups (reiserfs_blocknr_hint_t *h
 	/* give a portion of the block group to metadata */
 	if (hint->inode)
 	    hash += sb->s_blocksize/2;
-	hint->search_start = hash;
+	hint->search_start = hash >= SB_BLOCK_COUNT(sb) ? SB_BLOCK_COUNT(sb)-1 : hash;
     }
 }
 
@@ -642,7 +645,7 @@ oid_groups (reiserfs_blocknr_hint_t *hin
 	    bm = bmap_hash_id(hint->inode->i_sb, oid);
 	    hash = bm * (hint->inode->i_sb->s_blocksize << 3);
 	}
-	hint->search_start = hash;
+	hint->search_start = hash >= SB_BLOCK_COUNT(hint->inode->i_sb) ? SB_BLOCK_COUNT(hint->inode->i_sb)-1 : hash;
     }
 }
 
#1 lore raw
Quoted 6 lines · Jan Kara

Hello!

Attached patch fixes oops of reiserfs on a filesystem with just one
bitmap block - current code always tries to return second bitmap even if there's not any. Could someone review it please so that it can be merged in mainline?

Hi Jan,

A slightly different form of this patch is in already. Look for the checks in bmap_hash_id. Are you still able to reproduce this bug on kernels newer than October 18?

-chris

author reviewer
#2 lore raw
Quoted 11 lines · Jan Kara
Quoted 6 lines

Hello!

Attached patch fixes oops of reiserfs on a filesystem with just one
bitmap block - current code always tries to return second bitmap even if there's not any. Could someone review it please so that it can be merged in mainline?

A slightly different form of this patch is in already. Look for the checks in bmap_hash_id. Are you still able to reproduce this bug on kernels newer than October 18?

Sorry. I've missed that the bug was already fixed in the other place.
It looks OK now.
Honza

Signature · 2 lines
Jan Kara <[email protected]>
SuSE CR Labs