Skip to contentSkip to conversation

md/raid10: wait up frozen array in handle_write_completed

PATCH Applied Guoqing Jiang 3 participants 3 messages Apr 17, 2017 – Apr 20, 2017 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md/raid10: wait up frozen array in handle_write_completed

Since nr_queued is changed, we need to call wake_up here if the array is already frozen and waiting for condition "nr_pending == nr_queued + extra" to be true.

And commit 824e47daddbf ("RAID1: avoid unnecessary spin locks in I/O barrier code") which has already added the wake_up for raid1.

---
 drivers/md/raid10.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/md/raid10.c +5 -0
index 4167091..acb3f46 100644
@@ -2704,6 +2704,11 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
 			list_add(&r10_bio->retry_list, &conf->bio_end_io_list);
 			conf->nr_queued++;
 			spin_unlock_irq(&conf->device_lock);
+			/*
+			 * In case freeze_array() is waiting for condition
+			 * nr_pending == nr_queued + extra to be true.
+			 */
+			wake_up(&conf->wait_barrier);
 			md_wakeup_thread(conf->mddev->thread);
 		} else {
 			if (test_bit(R10BIO_WriteError,
Signature · 1 line
2.10.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Guoqing Jiang

Since nr_queued is changed, we need to call wake_up here if the array is already frozen and waiting for condition "nr_pending == nr_queued + extra" to be true.

And commit 824e47daddbf ("RAID1: avoid unnecessary spin locks in I/O barrier code") which has already added the wake_up for raid1.

---
 drivers/md/raid10.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/md/raid10.c +5 -0
index 4167091..acb3f46 100644
@@ -2704,6 +2704,11 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
 			list_add(&r10_bio->retry_list, &conf->bio_end_io_list);
 			conf->nr_queued++;
 			spin_unlock_irq(&conf->device_lock);
+			/*
+			 * In case freeze_array() is waiting for condition
+			 * nr_pending == nr_queued + extra to be true.
+			 */
+			wake_up(&conf->wait_barrier);
 			md_wakeup_thread(conf->mddev->thread);
 		} else {
 			if (test_bit(R10BIO_WriteError,
Signature · 1 line
2.10.0

I think I looked at this once before and convinced myself that md_wakeup_thread() would wake up the only thread that might be waiting in freeze_array(). This is completely wrong, so I don't know why I thought it:-(

Thanks,
NeilBrown

Applied
#2 lore raw
In reply to Guoqing Jiang
Quoted 7 lines · Guoqing Jiang

Since nr_queued is changed, we need to call wake_up here if the array is already frozen and waiting for condition "nr_pending == nr_queued + extra" to be true.

And commit 824e47daddbf ("RAID1: avoid unnecessary spin locks in I/O barrier code") which has already added the wake_up for raid1.

thanks, applied!

Quoted 24 lines
---
 drivers/md/raid10.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/md/raid10.c +5 -0
index 4167091..acb3f46 100644
@@ -2704,6 +2704,11 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
 			list_add(&r10_bio->retry_list, &conf->bio_end_io_list);
 			conf->nr_queued++;
 			spin_unlock_irq(&conf->device_lock);
+			/*
+			 * In case freeze_array() is waiting for condition
+			 * nr_pending == nr_queued + extra to be true.
+			 */
+			wake_up(&conf->wait_barrier);
 			md_wakeup_thread(conf->mddev->thread);
 		} else {
 			if (test_bit(R10BIO_WriteError,
Signature · 1 line
2.10.0