Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uw-beaver!ssc-vax!bcsaic!paula From: paula@bcsaic.UUCP (Paul Allen) Newsgroups: comp.os.minix Subject: Re: badblocks (1.5.9) still broken Keywords: badblocks Message-ID: <24133@bcsaic.UUCP> Date: 8 May 90 01:11:09 GMT References: <368@cancol.oz> Reply-To: paula@bcsaic.UUCP (Paul Allen) Organization: Boeing Computer Services AI Center, Seattle Lines: 67 In article <368@cancol.oz> eyal@cancol.oz (Eyal Lebedinsky) writes: >Some time ago I reported a problem with badblocks. I am now on 1.5.9 and >the problem is still there. The two functions blk_ok() and set_bit() will >access the first inode bit-map block even if a later one is needed. The >bit offset is converted into a block number and a block offset (see lines >429/430) but later the block number is not used again. The lseek() is done >to the first block in all cases. From looking at the 1.5.9 badblocks.c, I think Eyal's right. When it's calculating how far into the partition to seek, it computes whole-block and fractional-block components of the offset and then forgets about the whole-block component. I fixed this in the 1.3 version in order to get my disk working, but either I didn't post my diffs or they didn't get incorporated into subsequent versions. :-( I think I see what's wrong, but I won't be able to test it for a week or more. One ought to be able to test this out on any filesystem with more than 8192 zones. By eyeballing the code, I've generated a patch that I think might fix the problem, but I have not tested it. Somebody please try this out and report what happens. (Actually, the first step is to look real closely at this patch to verify for yourself that it does what I think it will.) Just try to mark a bad block with a number >8192, and then look at the zone bit-map to see if the right bit got marked. (This patch is relative to 1.5.9, but the crc for badblocks.c hasn't changed since at least 1.5.3.) Paul Allen ------------------------ start of patch -------------------------- *** badblocks.c Sat Mar 3 23:53:24 1990 --- fixed.badblocks.c Mon May 7 17:53:05 1990 *************** *** 430,438 **** offset = z_num - (block << BIT_MAP_SHIFT); /* offset */ words = z_num / INT_BITS; /* which word */ ! blk_offset = (long) (2 + sp->s_imap_block); /* zone map */ ! blk_offset *= (long) BLOCK_SIZE; /* of course in block */ ! blk_offset += (long) (words * SIZE_OF_INT); /* offset */ lseek(fd, 0L, SEEK_SET); /* rewind */ --- 430,439 ---- offset = z_num - (block << BIT_MAP_SHIFT); /* offset */ words = z_num / INT_BITS; /* which word */ ! blk_offset = (long) (2 + sp->s_imap_block); /* zone map start block */ ! blk_offset += (long) block; /* add in zone-map block number */ ! blk_offset *= (long) BLOCK_SIZE; /* convert to bytes */ ! blk_offset += (long) (words * SIZE_OF_INT); /* add in offset within last block*/ lseek(fd, 0L, SEEK_SET); /* rewind */ *************** *** 472,477 **** --- 473,479 ---- words = offset / INT_BITS; /* which word */ blk_offset = (long) (2 + sp->s_imap_block); + blk_offset += (long) block; /* add in zone-map block number */ blk_offset *= (long) BLOCK_SIZE; blk_offset += (long) (words * SIZE_OF_INT); --------------------------- end ---------------------------------- -- ------------------------------------------------------------------------ Paul L. Allen | pallen@atc.boeing.com Boeing Advanced Technology Center | ...!uw-beaver!bcsaic!pallen