aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-04-22 17:08:28 -0400
committerNeilBrown <neilb@suse.de>2010-04-22 17:08:28 -0400
commit6e3b96ed610e5a1838e62ddae9fa0c3463f235fa (patch)
treec0c3f0d3e5f16c04d417160e5bca1d4abf562651
parent35f2a591192d0a5d9f7fc696869c76f0b8e49c3d (diff)
md/raid5: fix previous patch.
Previous patch changes stripe and chunk_number to sector_t but mistakenly did not update all of the divisions to use sector_dev(). This patch changes all the those divisions (actually the '%' operator) to sector_div. Signed-off-by: NeilBrown <neilb@suse.de> Cc: stable@kernel.org Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
-rw-r--r--drivers/md/raid5.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 20e48401910e..58ea0ecae7c3 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1650,7 +1650,7 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1650 int previous, int *dd_idx, 1650 int previous, int *dd_idx,
1651 struct stripe_head *sh) 1651 struct stripe_head *sh)
1652{ 1652{
1653 sector_t stripe; 1653 sector_t stripe, stripe2;
1654 sector_t chunk_number; 1654 sector_t chunk_number;
1655 unsigned int chunk_offset; 1655 unsigned int chunk_offset;
1656 int pd_idx, qd_idx; 1656 int pd_idx, qd_idx;
@@ -1677,7 +1677,7 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1677 */ 1677 */
1678 stripe = chunk_number; 1678 stripe = chunk_number;
1679 *dd_idx = sector_div(stripe, data_disks); 1679 *dd_idx = sector_div(stripe, data_disks);
1680 1680 stripe2 = stripe;
1681 /* 1681 /*
1682 * Select the parity disk based on the user selected algorithm. 1682 * Select the parity disk based on the user selected algorithm.
1683 */ 1683 */
@@ -1689,21 +1689,21 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1689 case 5: 1689 case 5:
1690 switch (algorithm) { 1690 switch (algorithm) {
1691 case ALGORITHM_LEFT_ASYMMETRIC: 1691 case ALGORITHM_LEFT_ASYMMETRIC:
1692 pd_idx = data_disks - stripe % raid_disks; 1692 pd_idx = data_disks - sector_div(stripe2, raid_disks);
1693 if (*dd_idx >= pd_idx) 1693 if (*dd_idx >= pd_idx)
1694 (*dd_idx)++; 1694 (*dd_idx)++;
1695 break; 1695 break;
1696 case ALGORITHM_RIGHT_ASYMMETRIC: 1696 case ALGORITHM_RIGHT_ASYMMETRIC:
1697 pd_idx = stripe % raid_disks; 1697 pd_idx = sector_div(stripe2, raid_disks);
1698 if (*dd_idx >= pd_idx) 1698 if (*dd_idx >= pd_idx)
1699 (*dd_idx)++; 1699 (*dd_idx)++;
1700 break; 1700 break;
1701 case ALGORITHM_LEFT_SYMMETRIC: 1701 case ALGORITHM_LEFT_SYMMETRIC:
1702 pd_idx = data_disks - stripe % raid_disks; 1702 pd_idx = data_disks - sector_div(stripe2, raid_disks);
1703 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks; 1703 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks;
1704 break; 1704 break;
1705 case ALGORITHM_RIGHT_SYMMETRIC: 1705 case ALGORITHM_RIGHT_SYMMETRIC:
1706 pd_idx = stripe % raid_disks; 1706 pd_idx = sector_div(stripe2, raid_disks);
1707 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks; 1707 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks;
1708 break; 1708 break;
1709 case ALGORITHM_PARITY_0: 1709 case ALGORITHM_PARITY_0:
@@ -1723,7 +1723,7 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1723 1723
1724 switch (algorithm) { 1724 switch (algorithm) {
1725 case ALGORITHM_LEFT_ASYMMETRIC: 1725 case ALGORITHM_LEFT_ASYMMETRIC:
1726 pd_idx = raid_disks - 1 - (stripe % raid_disks); 1726 pd_idx = raid_disks - 1 - sector_div(stripe2, raid_disks);
1727 qd_idx = pd_idx + 1; 1727 qd_idx = pd_idx + 1;
1728 if (pd_idx == raid_disks-1) { 1728 if (pd_idx == raid_disks-1) {
1729 (*dd_idx)++; /* Q D D D P */ 1729 (*dd_idx)++; /* Q D D D P */
@@ -1732,7 +1732,7 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1732 (*dd_idx) += 2; /* D D P Q D */ 1732 (*dd_idx) += 2; /* D D P Q D */
1733 break; 1733 break;
1734 case ALGORITHM_RIGHT_ASYMMETRIC: 1734 case ALGORITHM_RIGHT_ASYMMETRIC:
1735 pd_idx = stripe % raid_disks; 1735 pd_idx = sector_div(stripe2, raid_disks);
1736 qd_idx = pd_idx + 1; 1736 qd_idx = pd_idx + 1;
1737 if (pd_idx == raid_disks-1) { 1737 if (pd_idx == raid_disks-1) {
1738 (*dd_idx)++; /* Q D D D P */ 1738 (*dd_idx)++; /* Q D D D P */
@@ -1741,12 +1741,12 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1741 (*dd_idx) += 2; /* D D P Q D */ 1741 (*dd_idx) += 2; /* D D P Q D */
1742 break; 1742 break;
1743 case ALGORITHM_LEFT_SYMMETRIC: 1743 case ALGORITHM_LEFT_SYMMETRIC:
1744 pd_idx = raid_disks - 1 - (stripe % raid_disks); 1744 pd_idx = raid_disks - 1 - sector_div(stripe2, raid_disks);
1745 qd_idx = (pd_idx + 1) % raid_disks; 1745 qd_idx = (pd_idx + 1) % raid_disks;
1746 *dd_idx = (pd_idx + 2 + *dd_idx) % raid_disks; 1746 *dd_idx = (pd_idx + 2 + *dd_idx) % raid_disks;
1747 break; 1747 break;
1748 case ALGORITHM_RIGHT_SYMMETRIC: 1748 case ALGORITHM_RIGHT_SYMMETRIC:
1749 pd_idx = stripe % raid_disks; 1749 pd_idx = sector_div(stripe2, raid_disks);
1750 qd_idx = (pd_idx + 1) % raid_disks; 1750 qd_idx = (pd_idx + 1) % raid_disks;
1751 *dd_idx = (pd_idx + 2 + *dd_idx) % raid_disks; 1751 *dd_idx = (pd_idx + 2 + *dd_idx) % raid_disks;
1752 break; 1752 break;
@@ -1765,7 +1765,7 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1765 /* Exactly the same as RIGHT_ASYMMETRIC, but or 1765 /* Exactly the same as RIGHT_ASYMMETRIC, but or
1766 * of blocks for computing Q is different. 1766 * of blocks for computing Q is different.
1767 */ 1767 */
1768 pd_idx = stripe % raid_disks; 1768 pd_idx = sector_div(stripe2, raid_disks);
1769 qd_idx = pd_idx + 1; 1769 qd_idx = pd_idx + 1;
1770 if (pd_idx == raid_disks-1) { 1770 if (pd_idx == raid_disks-1) {
1771 (*dd_idx)++; /* Q D D D P */ 1771 (*dd_idx)++; /* Q D D D P */
@@ -1780,7 +1780,8 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1780 * D D D P Q rather than 1780 * D D D P Q rather than
1781 * Q D D D P 1781 * Q D D D P
1782 */ 1782 */
1783 pd_idx = raid_disks - 1 - ((stripe + 1) % raid_disks); 1783 stripe2 += 1;
1784 pd_idx = raid_disks - 1 - sector_div(stripe2, raid_disks);
1784 qd_idx = pd_idx + 1; 1785 qd_idx = pd_idx + 1;
1785 if (pd_idx == raid_disks-1) { 1786 if (pd_idx == raid_disks-1) {
1786 (*dd_idx)++; /* Q D D D P */ 1787 (*dd_idx)++; /* Q D D D P */
@@ -1792,7 +1793,7 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1792 1793
1793 case ALGORITHM_ROTATING_N_CONTINUE: 1794 case ALGORITHM_ROTATING_N_CONTINUE:
1794 /* Same as left_symmetric but Q is before P */ 1795 /* Same as left_symmetric but Q is before P */
1795 pd_idx = raid_disks - 1 - (stripe % raid_disks); 1796 pd_idx = raid_disks - 1 - sector_div(stripe2, raid_disks);
1796 qd_idx = (pd_idx + raid_disks - 1) % raid_disks; 1797 qd_idx = (pd_idx + raid_disks - 1) % raid_disks;
1797 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks; 1798 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks;
1798 ddf_layout = 1; 1799 ddf_layout = 1;
@@ -1800,27 +1801,27 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1800 1801
1801 case ALGORITHM_LEFT_ASYMMETRIC_6: 1802 case ALGORITHM_LEFT_ASYMMETRIC_6:
1802 /* RAID5 left_asymmetric, with Q on last device */ 1803 /* RAID5 left_asymmetric, with Q on last device */
1803 pd_idx = data_disks - stripe % (raid_disks-1); 1804 pd_idx = data_disks - sector_div(stripe2, raid_disks-1);
1804 if (*dd_idx >= pd_idx) 1805 if (*dd_idx >= pd_idx)
1805 (*dd_idx)++; 1806 (*dd_idx)++;
1806 qd_idx = raid_disks - 1; 1807 qd_idx = raid_disks - 1;
1807 break; 1808 break;
1808 1809
1809 case ALGORITHM_RIGHT_ASYMMETRIC_6: 1810 case ALGORITHM_RIGHT_ASYMMETRIC_6:
1810 pd_idx = stripe % (raid_disks-1); 1811 pd_idx = sector_div(stripe2, raid_disks-1);
1811 if (*dd_idx >= pd_idx) 1812 if (*dd_idx >= pd_idx)
1812 (*dd_idx)++; 1813 (*dd_idx)++;
1813 qd_idx = raid_disks - 1; 1814 qd_idx = raid_disks - 1;
1814 break; 1815 break;
1815 1816
1816 case ALGORITHM_LEFT_SYMMETRIC_6: 1817 case ALGORITHM_LEFT_SYMMETRIC_6:
1817 pd_idx = data_disks - stripe % (raid_disks-1); 1818 pd_idx = data_disks - sector_div(stripe2, raid_disks-1);
1818 *dd_idx = (pd_idx + 1 + *dd_idx) % (raid_disks-1); 1819 *dd_idx = (pd_idx + 1 + *dd_idx) % (raid_disks-1);
1819 qd_idx = raid_disks - 1; 1820 qd_idx = raid_disks - 1;
1820 break; 1821 break;
1821 1822
1822 case ALGORITHM_RIGHT_SYMMETRIC_6: 1823 case ALGORITHM_RIGHT_SYMMETRIC_6:
1823 pd_idx = stripe % (raid_disks-1); 1824 pd_idx = sector_div(stripe2, raid_disks-1);
1824 *dd_idx = (pd_idx + 1 + *dd_idx) % (raid_disks-1); 1825 *dd_idx = (pd_idx + 1 + *dd_idx) % (raid_disks-1);
1825 qd_idx = raid_disks - 1; 1826 qd_idx = raid_disks - 1;
1826 break; 1827 break;