diff options
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r-- | drivers/md/raid5.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 70ffbd071b2e..20e48401910e 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #include <linux/async.h> | 50 | #include <linux/async.h> |
51 | #include <linux/seq_file.h> | 51 | #include <linux/seq_file.h> |
52 | #include <linux/cpu.h> | 52 | #include <linux/cpu.h> |
53 | #include <linux/slab.h> | ||
53 | #include "md.h" | 54 | #include "md.h" |
54 | #include "raid5.h" | 55 | #include "raid5.h" |
55 | #include "bitmap.h" | 56 | #include "bitmap.h" |
@@ -1649,8 +1650,8 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector, | |||
1649 | int previous, int *dd_idx, | 1650 | int previous, int *dd_idx, |
1650 | struct stripe_head *sh) | 1651 | struct stripe_head *sh) |
1651 | { | 1652 | { |
1652 | long stripe; | 1653 | sector_t stripe; |
1653 | unsigned long chunk_number; | 1654 | sector_t chunk_number; |
1654 | unsigned int chunk_offset; | 1655 | unsigned int chunk_offset; |
1655 | int pd_idx, qd_idx; | 1656 | int pd_idx, qd_idx; |
1656 | int ddf_layout = 0; | 1657 | int ddf_layout = 0; |
@@ -1670,17 +1671,12 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector, | |||
1670 | */ | 1671 | */ |
1671 | chunk_offset = sector_div(r_sector, sectors_per_chunk); | 1672 | chunk_offset = sector_div(r_sector, sectors_per_chunk); |
1672 | chunk_number = r_sector; | 1673 | chunk_number = r_sector; |
1673 | BUG_ON(r_sector != chunk_number); | ||
1674 | 1674 | ||
1675 | /* | 1675 | /* |
1676 | * Compute the stripe number | 1676 | * Compute the stripe number |
1677 | */ | 1677 | */ |
1678 | stripe = chunk_number / data_disks; | 1678 | stripe = chunk_number; |
1679 | 1679 | *dd_idx = sector_div(stripe, data_disks); | |
1680 | /* | ||
1681 | * Compute the data disk and parity disk indexes inside the stripe | ||
1682 | */ | ||
1683 | *dd_idx = chunk_number % data_disks; | ||
1684 | 1680 | ||
1685 | /* | 1681 | /* |
1686 | * Select the parity disk based on the user selected algorithm. | 1682 | * Select the parity disk based on the user selected algorithm. |
@@ -1869,14 +1865,14 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i, int previous) | |||
1869 | : conf->algorithm; | 1865 | : conf->algorithm; |
1870 | sector_t stripe; | 1866 | sector_t stripe; |
1871 | int chunk_offset; | 1867 | int chunk_offset; |
1872 | int chunk_number, dummy1, dd_idx = i; | 1868 | sector_t chunk_number; |
1869 | int dummy1, dd_idx = i; | ||
1873 | sector_t r_sector; | 1870 | sector_t r_sector; |
1874 | struct stripe_head sh2; | 1871 | struct stripe_head sh2; |
1875 | 1872 | ||
1876 | 1873 | ||
1877 | chunk_offset = sector_div(new_sector, sectors_per_chunk); | 1874 | chunk_offset = sector_div(new_sector, sectors_per_chunk); |
1878 | stripe = new_sector; | 1875 | stripe = new_sector; |
1879 | BUG_ON(new_sector != stripe); | ||
1880 | 1876 | ||
1881 | if (i == sh->pd_idx) | 1877 | if (i == sh->pd_idx) |
1882 | return 0; | 1878 | return 0; |
@@ -1969,7 +1965,7 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i, int previous) | |||
1969 | } | 1965 | } |
1970 | 1966 | ||
1971 | chunk_number = stripe * data_disks + i; | 1967 | chunk_number = stripe * data_disks + i; |
1972 | r_sector = (sector_t)chunk_number * sectors_per_chunk + chunk_offset; | 1968 | r_sector = chunk_number * sectors_per_chunk + chunk_offset; |
1973 | 1969 | ||
1974 | check = raid5_compute_sector(conf, r_sector, | 1970 | check = raid5_compute_sector(conf, r_sector, |
1975 | previous, &dummy1, &sh2); | 1971 | previous, &dummy1, &sh2); |