aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-18 12:26:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-18 12:26:42 -0400
commitd9f5d41569731189e519fcee8578fcef5c916978 (patch)
treeec90968350d618431921f327f0dc3e378ea9a157 /drivers
parent86ea51d4a27ec79e9da7d2ce0c4a58f1dc4544c0 (diff)
parent2c7d46ec192e4f2b350f67a0e185b9bce646cd6b (diff)
Merge branch 'for-linus' of git://neil.brown.name/md
* 'for-linus' of git://neil.brown.name/md: md raid-1/10 Fix bio_rw bit manipulations again md: provide appropriate return value for spare_active functions. md: Notify sysfs when RAID1/5/10 disk is In_sync. Update recovery_offset even when external metadata is used.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/md.c44
-rw-r--r--drivers/md/raid1.c21
-rw-r--r--drivers/md/raid10.c17
-rw-r--r--drivers/md/raid5.c13
4 files changed, 48 insertions, 47 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 11567c7999a2..c148b6302154 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2136,16 +2136,6 @@ static void sync_sbs(mddev_t * mddev, int nospares)
2136 * with the rest of the array) 2136 * with the rest of the array)
2137 */ 2137 */
2138 mdk_rdev_t *rdev; 2138 mdk_rdev_t *rdev;
2139
2140 /* First make sure individual recovery_offsets are correct */
2141 list_for_each_entry(rdev, &mddev->disks, same_set) {
2142 if (rdev->raid_disk >= 0 &&
2143 mddev->delta_disks >= 0 &&
2144 !test_bit(In_sync, &rdev->flags) &&
2145 mddev->curr_resync_completed > rdev->recovery_offset)
2146 rdev->recovery_offset = mddev->curr_resync_completed;
2147
2148 }
2149 list_for_each_entry(rdev, &mddev->disks, same_set) { 2139 list_for_each_entry(rdev, &mddev->disks, same_set) {
2150 if (rdev->sb_events == mddev->events || 2140 if (rdev->sb_events == mddev->events ||
2151 (nospares && 2141 (nospares &&
@@ -2167,12 +2157,27 @@ static void md_update_sb(mddev_t * mddev, int force_change)
2167 int sync_req; 2157 int sync_req;
2168 int nospares = 0; 2158 int nospares = 0;
2169 2159
2170 mddev->utime = get_seconds();
2171 if (mddev->external)
2172 return;
2173repeat: 2160repeat:
2161 /* First make sure individual recovery_offsets are correct */
2162 list_for_each_entry(rdev, &mddev->disks, same_set) {
2163 if (rdev->raid_disk >= 0 &&
2164 mddev->delta_disks >= 0 &&
2165 !test_bit(In_sync, &rdev->flags) &&
2166 mddev->curr_resync_completed > rdev->recovery_offset)
2167 rdev->recovery_offset = mddev->curr_resync_completed;
2168
2169 }
2170 if (mddev->external || !mddev->persistent) {
2171 clear_bit(MD_CHANGE_DEVS, &mddev->flags);
2172 clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
2173 wake_up(&mddev->sb_wait);
2174 return;
2175 }
2176
2174 spin_lock_irq(&mddev->write_lock); 2177 spin_lock_irq(&mddev->write_lock);
2175 2178
2179 mddev->utime = get_seconds();
2180
2176 set_bit(MD_CHANGE_PENDING, &mddev->flags); 2181 set_bit(MD_CHANGE_PENDING, &mddev->flags);
2177 if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags)) 2182 if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags))
2178 force_change = 1; 2183 force_change = 1;
@@ -2221,19 +2226,6 @@ repeat:
2221 MD_BUG(); 2226 MD_BUG();
2222 mddev->events --; 2227 mddev->events --;
2223 } 2228 }
2224
2225 /*
2226 * do not write anything to disk if using
2227 * nonpersistent superblocks
2228 */
2229 if (!mddev->persistent) {
2230 if (!mddev->external)
2231 clear_bit(MD_CHANGE_PENDING, &mddev->flags);
2232
2233 spin_unlock_irq(&mddev->write_lock);
2234 wake_up(&mddev->sb_wait);
2235 return;
2236 }
2237 sync_sbs(mddev, nospares); 2229 sync_sbs(mddev, nospares);
2238 spin_unlock_irq(&mddev->write_lock); 2230 spin_unlock_irq(&mddev->write_lock);
2239 2231
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 73cc74ffc26b..ad83a4dcadc3 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -787,8 +787,8 @@ static int make_request(mddev_t *mddev, struct bio * bio)
787 struct bio_list bl; 787 struct bio_list bl;
788 struct page **behind_pages = NULL; 788 struct page **behind_pages = NULL;
789 const int rw = bio_data_dir(bio); 789 const int rw = bio_data_dir(bio);
790 const bool do_sync = (bio->bi_rw & REQ_SYNC); 790 const unsigned long do_sync = (bio->bi_rw & REQ_SYNC);
791 bool do_barriers; 791 unsigned long do_barriers;
792 mdk_rdev_t *blocked_rdev; 792 mdk_rdev_t *blocked_rdev;
793 793
794 /* 794 /*
@@ -1120,6 +1120,8 @@ static int raid1_spare_active(mddev_t *mddev)
1120{ 1120{
1121 int i; 1121 int i;
1122 conf_t *conf = mddev->private; 1122 conf_t *conf = mddev->private;
1123 int count = 0;
1124 unsigned long flags;
1123 1125
1124 /* 1126 /*
1125 * Find all failed disks within the RAID1 configuration 1127 * Find all failed disks within the RAID1 configuration
@@ -1131,15 +1133,16 @@ static int raid1_spare_active(mddev_t *mddev)
1131 if (rdev 1133 if (rdev
1132 && !test_bit(Faulty, &rdev->flags) 1134 && !test_bit(Faulty, &rdev->flags)
1133 && !test_and_set_bit(In_sync, &rdev->flags)) { 1135 && !test_and_set_bit(In_sync, &rdev->flags)) {
1134 unsigned long flags; 1136 count++;
1135 spin_lock_irqsave(&conf->device_lock, flags); 1137 sysfs_notify_dirent(rdev->sysfs_state);
1136 mddev->degraded--;
1137 spin_unlock_irqrestore(&conf->device_lock, flags);
1138 } 1138 }
1139 } 1139 }
1140 spin_lock_irqsave(&conf->device_lock, flags);
1141 mddev->degraded -= count;
1142 spin_unlock_irqrestore(&conf->device_lock, flags);
1140 1143
1141 print_conf(conf); 1144 print_conf(conf);
1142 return 0; 1145 return count;
1143} 1146}
1144 1147
1145 1148
@@ -1640,7 +1643,7 @@ static void raid1d(mddev_t *mddev)
1640 * We already have a nr_pending reference on these rdevs. 1643 * We already have a nr_pending reference on these rdevs.
1641 */ 1644 */
1642 int i; 1645 int i;
1643 const bool do_sync = (r1_bio->master_bio->bi_rw & REQ_SYNC); 1646 const unsigned long do_sync = (r1_bio->master_bio->bi_rw & REQ_SYNC);
1644 clear_bit(R1BIO_BarrierRetry, &r1_bio->state); 1647 clear_bit(R1BIO_BarrierRetry, &r1_bio->state);
1645 clear_bit(R1BIO_Barrier, &r1_bio->state); 1648 clear_bit(R1BIO_Barrier, &r1_bio->state);
1646 for (i=0; i < conf->raid_disks; i++) 1649 for (i=0; i < conf->raid_disks; i++)
@@ -1696,7 +1699,7 @@ static void raid1d(mddev_t *mddev)
1696 (unsigned long long)r1_bio->sector); 1699 (unsigned long long)r1_bio->sector);
1697 raid_end_bio_io(r1_bio); 1700 raid_end_bio_io(r1_bio);
1698 } else { 1701 } else {
1699 const bool do_sync = r1_bio->master_bio->bi_rw & REQ_SYNC; 1702 const unsigned long do_sync = r1_bio->master_bio->bi_rw & REQ_SYNC;
1700 r1_bio->bios[r1_bio->read_disk] = 1703 r1_bio->bios[r1_bio->read_disk] =
1701 mddev->ro ? IO_BLOCKED : NULL; 1704 mddev->ro ? IO_BLOCKED : NULL;
1702 r1_bio->read_disk = disk; 1705 r1_bio->read_disk = disk;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index a88aeb5198c7..84718383124d 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -799,7 +799,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
799 int i; 799 int i;
800 int chunk_sects = conf->chunk_mask + 1; 800 int chunk_sects = conf->chunk_mask + 1;
801 const int rw = bio_data_dir(bio); 801 const int rw = bio_data_dir(bio);
802 const bool do_sync = (bio->bi_rw & REQ_SYNC); 802 const unsigned long do_sync = (bio->bi_rw & REQ_SYNC);
803 struct bio_list bl; 803 struct bio_list bl;
804 unsigned long flags; 804 unsigned long flags;
805 mdk_rdev_t *blocked_rdev; 805 mdk_rdev_t *blocked_rdev;
@@ -1116,6 +1116,8 @@ static int raid10_spare_active(mddev_t *mddev)
1116 int i; 1116 int i;
1117 conf_t *conf = mddev->private; 1117 conf_t *conf = mddev->private;
1118 mirror_info_t *tmp; 1118 mirror_info_t *tmp;
1119 int count = 0;
1120 unsigned long flags;
1119 1121
1120 /* 1122 /*
1121 * Find all non-in_sync disks within the RAID10 configuration 1123 * Find all non-in_sync disks within the RAID10 configuration
@@ -1126,15 +1128,16 @@ static int raid10_spare_active(mddev_t *mddev)
1126 if (tmp->rdev 1128 if (tmp->rdev
1127 && !test_bit(Faulty, &tmp->rdev->flags) 1129 && !test_bit(Faulty, &tmp->rdev->flags)
1128 && !test_and_set_bit(In_sync, &tmp->rdev->flags)) { 1130 && !test_and_set_bit(In_sync, &tmp->rdev->flags)) {
1129 unsigned long flags; 1131 count++;
1130 spin_lock_irqsave(&conf->device_lock, flags); 1132 sysfs_notify_dirent(tmp->rdev->sysfs_state);
1131 mddev->degraded--;
1132 spin_unlock_irqrestore(&conf->device_lock, flags);
1133 } 1133 }
1134 } 1134 }
1135 spin_lock_irqsave(&conf->device_lock, flags);
1136 mddev->degraded -= count;
1137 spin_unlock_irqrestore(&conf->device_lock, flags);
1135 1138
1136 print_conf(conf); 1139 print_conf(conf);
1137 return 0; 1140 return count;
1138} 1141}
1139 1142
1140 1143
@@ -1734,7 +1737,7 @@ static void raid10d(mddev_t *mddev)
1734 raid_end_bio_io(r10_bio); 1737 raid_end_bio_io(r10_bio);
1735 bio_put(bio); 1738 bio_put(bio);
1736 } else { 1739 } else {
1737 const bool do_sync = (r10_bio->master_bio->bi_rw & REQ_SYNC); 1740 const unsigned long do_sync = (r10_bio->master_bio->bi_rw & REQ_SYNC);
1738 bio_put(bio); 1741 bio_put(bio);
1739 rdev = conf->mirrors[mirror].rdev; 1742 rdev = conf->mirrors[mirror].rdev;
1740 if (printk_ratelimit()) 1743 if (printk_ratelimit())
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 866d4b5a144c..69b0a169e43d 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5330,6 +5330,8 @@ static int raid5_spare_active(mddev_t *mddev)
5330 int i; 5330 int i;
5331 raid5_conf_t *conf = mddev->private; 5331 raid5_conf_t *conf = mddev->private;
5332 struct disk_info *tmp; 5332 struct disk_info *tmp;
5333 int count = 0;
5334 unsigned long flags;
5333 5335
5334 for (i = 0; i < conf->raid_disks; i++) { 5336 for (i = 0; i < conf->raid_disks; i++) {
5335 tmp = conf->disks + i; 5337 tmp = conf->disks + i;
@@ -5337,14 +5339,15 @@ static int raid5_spare_active(mddev_t *mddev)
5337 && tmp->rdev->recovery_offset == MaxSector 5339 && tmp->rdev->recovery_offset == MaxSector
5338 && !test_bit(Faulty, &tmp->rdev->flags) 5340 && !test_bit(Faulty, &tmp->rdev->flags)
5339 && !test_and_set_bit(In_sync, &tmp->rdev->flags)) { 5341 && !test_and_set_bit(In_sync, &tmp->rdev->flags)) {
5340 unsigned long flags; 5342 count++;
5341 spin_lock_irqsave(&conf->device_lock, flags); 5343 sysfs_notify_dirent(tmp->rdev->sysfs_state);
5342 mddev->degraded--;
5343 spin_unlock_irqrestore(&conf->device_lock, flags);
5344 } 5344 }
5345 } 5345 }
5346 spin_lock_irqsave(&conf->device_lock, flags);
5347 mddev->degraded -= count;
5348 spin_unlock_irqrestore(&conf->device_lock, flags);
5346 print_raid5_conf(conf); 5349 print_raid5_conf(conf);
5347 return 0; 5350 return count;
5348} 5351}
5349 5352
5350static int raid5_remove_disk(mddev_t *mddev, int number) 5353static int raid5_remove_disk(mddev_t *mddev, int number)