From: Bart Van Assche <bart.vanassche@wdc.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
=Oleksandr Natalenko <oleksandr@natalenko.name>,
Bart Van Assche <bart.vanassche@wdc.com>,
Shaohua Li <shli@kernel.org>,
linux-raid@vger.kernel.org, Ming Lei <ming.lei@redhat.com>,
Hannes Reinecke <hare@suse.com>,
Johannes Thumshirn <jthumshirn@suse.de>
Subject: [PATCH v3 1/6] md: Make md resync and reshape threads freezable
Date: Fri, 22 Sep 2017 15:14:00 -0700 [thread overview]
Message-ID: <20170922221405.22091-2-bart.vanassche@wdc.com> (raw)
In-Reply-To: <20170922221405.22091-1-bart.vanassche@wdc.com>
Some people use the md driver on laptops and use the suspend and
resume functionality. Since it is essential that submitting of
new I/O requests stops before device quiescing starts, make the
md resync and reshape threads freezable.
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Shaohua Li <shli@kernel.org>
Cc: linux-raid@vger.kernel.org
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
drivers/md/md.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 08fcaebc61bd..26a12bd0db65 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -66,6 +66,7 @@
#include <linux/raid/md_u.h>
#include <linux/slab.h>
#include <linux/percpu-refcount.h>
+#include <linux/freezer.h>
#include <trace/events/block.h>
#include "md.h"
@@ -7424,6 +7425,7 @@ static int md_thread(void *arg)
*/
allow_signal(SIGKILL);
+ set_freezable();
while (!kthread_should_stop()) {
/* We need to wait INTERRUPTIBLE so that
@@ -7434,7 +7436,7 @@ static int md_thread(void *arg)
if (signal_pending(current))
flush_signals(current);
- wait_event_interruptible_timeout
+ wait_event_freezable_timeout
(thread->wqueue,
test_bit(THREAD_WAKEUP, &thread->flags)
|| kthread_should_stop() || kthread_should_park(),
@@ -8133,6 +8135,8 @@ void md_do_sync(struct md_thread *thread)
return;
}
+ set_freezable();
+
if (mddev_is_clustered(mddev)) {
ret = md_cluster_ops->resync_start(mddev);
if (ret)
@@ -8324,7 +8328,7 @@ void md_do_sync(struct md_thread *thread)
mddev->curr_resync_completed > mddev->resync_max
)) {
/* time to update curr_resync_completed */
- wait_event(mddev->recovery_wait,
+ wait_event_freezable(mddev->recovery_wait,
atomic_read(&mddev->recovery_active) == 0);
mddev->curr_resync_completed = j;
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) &&
@@ -8342,10 +8346,10 @@ void md_do_sync(struct md_thread *thread)
* to avoid triggering warnings.
*/
flush_signals(current); /* just in case */
- wait_event_interruptible(mddev->recovery_wait,
- mddev->resync_max > j
- || test_bit(MD_RECOVERY_INTR,
- &mddev->recovery));
+ wait_event_freezable(mddev->recovery_wait,
+ mddev->resync_max > j ||
+ test_bit(MD_RECOVERY_INTR,
+ &mddev->recovery));
}
if (test_bit(MD_RECOVERY_INTR, &mddev->recovery))
@@ -8421,7 +8425,7 @@ void md_do_sync(struct md_thread *thread)
* Give other IO more of a chance.
* The faster the devices, the less we wait.
*/
- wait_event(mddev->recovery_wait,
+ wait_event_freezable(mddev->recovery_wait,
!atomic_read(&mddev->recovery_active));
}
}
@@ -8433,7 +8437,8 @@ void md_do_sync(struct md_thread *thread)
* this also signals 'finished resyncing' to md_stop
*/
blk_finish_plug(&plug);
- wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active));
+ wait_event_freezable(mddev->recovery_wait,
+ !atomic_read(&mddev->recovery_active));
if (!test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
!test_bit(MD_RECOVERY_INTR, &mddev->recovery) &&
--
2.14.1
next prev parent reply other threads:[~2017-09-22 22:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-22 22:13 [PATCH v3 0/6] Make SCSI device suspend and resume work reliably Bart Van Assche
2017-09-22 22:14 ` Bart Van Assche [this message]
2017-09-25 2:38 ` [PATCH v3 1/6] md: Make md resync and reshape threads freezable Ming Lei
2017-09-25 16:22 ` Bart Van Assche
2017-09-25 22:45 ` Ming Lei
2017-09-25 22:48 ` Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 2/6] block: Convert RQF_PREEMPT into REQ_PREEMPT Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 3/6] block: Add the QUEUE_FLAG_PREEMPT_ONLY request queue flag Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 4/6] scsi: Set QUEUE_FLAG_PREEMPT_ONLY while quiesced Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 5/6] block: Make SCSI device suspend and resume work reliably Bart Van Assche
2017-09-25 2:26 ` Ming Lei
2017-09-25 16:20 ` Bart Van Assche
2017-09-25 22:51 ` Ming Lei
2017-09-25 23:06 ` Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 6/6] scsi-mq: Reduce suspend latency Bart Van Assche
2017-09-25 2:28 ` Ming Lei
2017-09-25 2:36 ` [PATCH v3 0/6] Make SCSI device suspend and resume work reliably Ming Lei
2017-09-25 16:17 ` Bart Van Assche
2017-09-25 16:20 ` hch
2017-09-26 9:11 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170922221405.22091-2-bart.vanassche@wdc.com \
--to=bart.vanassche@wdc.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=jthumshirn@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.com \
--cc=oleksandr@natalenko.name \
--cc=shli@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox