PATCH: 2.4.0-test1-ac13: MD Linear driver ofs_by_one bug fix

From: Anton Altaparmakov (aia21@cus.cam.ac.uk)
Date: Sun Jun 11 2000 - 20:53:07 EST


Alan, Ingo and LKML,

This little patch fixes a offset by one error in the Linear MD - Software
Raid - driver.

This bug was only triggered when the block size is set to 512 (bytes),
which is the case for many NTFS partitions for example! (I was hacking
towards getting my volume set to work with the linux driver.)

The bug is that in the function linear_make_request there is a
        block = bh->b_rsector >> 1;
and later on a:
        bh->b_rsector = (block - tmp_dev->offset) << 1;
This however looses the least significant bit of bh->b_rsector!

The effect was that looking at /dev/md0 (my volume set) after mounting the
device using the NTFS driver the first 512 (bytes) of data were repeated
again at offset 512 and the original data that was supposed to
be at offset 512 had disappeared into the ether...
And the same repeated itself ad infinitum: offset 1024, 512bytes repeated
at offset 1536,... you get the picture.

The fix (IMHO obviously correct) is to change the bh->b_rsector =... to:
        bh->b_rsector = ((block - tmp_dev->offset) << 1) + (bh->b_rsector & 1);

A patch is attached which fixes this.

With the patch mounting the volume set and doing a hexedit /dev/md0 shows
the correct data (check by comparing with /dev/sda6, my first volume set
partition).

Unless Ingo or someone else has any reasons for _not_ making this change,
I would like to ask Alan to apply the attached patch to the latest
2.4.0-test1-acXX kernel. (patch is against 2.4.0-test1-ac13)

Regards,

        Anton

-- 
Anton Altaparmakov
Christ's College         eMail: AntonA@bigfoot.com
Cambridge CB2 3BU          WWW: http://www-stu.christs.cam.ac.uk/~aia21/
United Kingdom             ICQ: 8561279

--- linux-2.4.0-test1-ac13/drivers/block/linear.c Fri May 12 19:36:30 2000 +++ linux/drivers/block/linear.c Mon Jun 12 02:20:52 2000 @@ -3,6 +3,7 @@ Copyright (C) 1994-96 Marc ZYNGIER <zyngier@ufr-info-p7.ibp.fr> or <maz@gloups.fdn.fr> + Copyright (C) 2000 Anton Altaparmakov (antona@bigfoot.com) Linear mode management functions. @@ -148,7 +149,7 @@ return -1; } bh->b_rdev = tmp_dev->dev; - bh->b_rsector = (block - tmp_dev->offset) << 1; + bh->b_rsector = ((block - tmp_dev->offset) << 1) + (bh->b_rsector & 1); return 1; }

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jun 15 2000 - 21:00:24 EST