Hi,

try the attached patch please.

On Friday 21 October 2005 12:44, Vladimir V. Saveliev wrote:
> Hello
> 
> Konstantin Mьnning wrote:
> > Hi!
> > 
> > Just tried to add some badblocks like this:
> > 
> > reiserfstune -b /tmp/badblocklist /dev/hda5
> > 
> > and I get the error:
> > 
> > 
> > block allocator is not defined
> > 
> > Aborted
> > 
> > 
> > The same when I try it with -B. As this message means nothing to me, has
> > somebody any idea what the problem might be? The man pages and
> > interestingly a web search gave me nothing about it. Or is reiserfstune
> > not to be used for adding bad blocks to the fs?
> 
> reiserfstune is supposed to be use for that. You encountered reiserfstune bug.
> We are working on a fix.
> 
> 
> 

-- 
Vitaly
diff -rup ./reiserfsprogs-3.6.19/reiserfscore/reiserfslib.c ./reiserfsprogs-3.6.19-2/reiserfscore/reiserfslib.c
--- ./reiserfsprogs-3.6.19/reiserfscore/reiserfslib.c	2005-10-21 18:42:23.088825144 +0400
+++ ./reiserfsprogs-3.6.19-2/reiserfscore/reiserfslib.c	2005-10-21 19:01:46.558950800 +0400
@@ -1346,6 +1346,24 @@ void mark_badblock(reiserfs_filsys_t *fs
 	pathrelse (badblock_path);
 }
 
+static int reiserfs_alloc_blocks (reiserfs_filsys_t * fs,
+				  unsigned long *blknr,
+				  unsigned long start, 
+				  int count)
+{
+    int i;
+    
+    for (i = 0; i < count; i ++) {
+	blknr[i] = 0;
+	if (reiserfs_bitmap_find_zero_bit(fs->fs_bitmap2, blknr + i))
+	    die ("%s: failed to allocate a block.", __FUNCTION__);
+	
+	reiserfs_bitmap_set_bit(fs->fs_bitmap2, blknr[i]);
+    }
+    
+    return CARRY_ON;
+}
+
 void add_badblock_list (reiserfs_filsys_t * fs, int replace) {
     struct tree_balance tb;
     struct path badblock_path;
@@ -1372,7 +1390,8 @@ void add_badblock_list (reiserfs_filsys_
     set_type (KEY_FORMAT_2, &badblock_ih.ih_key, TYPE_INDIRECT);
 
     j = 0;
-
+    fs->block_allocator = reiserfs_alloc_blocks;
+    
     /* insert all badblock pointers */
     for (i = 0; i < fs->fs_badblocks_bm->bm_bit_size; i++) {
         int retval;

Reply via email to