From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Ming Lei <ming.lei@redhat.com>,
Salman Qazi <sqazi@google.com>,
Jesse Barnes <jsbarnes@google.com>,
Christoph Hellwig <hch@lst.de>,
Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH 2/2] block: add blk_io_schedule() for avoiding task hung in sync dio
Date: Tue, 28 Apr 2020 15:46:57 +0800 [thread overview]
Message-ID: <20200428074657.645441-3-ming.lei@redhat.com> (raw)
In-Reply-To: <20200428074657.645441-1-ming.lei@redhat.com>
Sync dio could be big, or may take long time in discard or in case of
IO failure.
We have prevented task hung in submit_bio_wait() and blk_execute_rq(),
so apply the similar trick for prevent task hung from happening in
sync dio.
Add helper of blk_io_schedule() and use io_schedule_timeout(
blk_default_io_timeout()) to prevent task hung warning.
Cc: Salman Qazi <sqazi@google.com>
Cc: Jesse Barnes <jsbarnes@google.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
fs/block_dev.c | 4 ++--
fs/direct-io.c | 2 +-
fs/iomap/direct-io.c | 2 +-
include/linux/blkdev.h | 6 ++++++
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 5eb30a474f6d..3b396f8c967c 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -256,7 +256,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
break;
if (!(iocb->ki_flags & IOCB_HIPRI) ||
!blk_poll(bdev_get_queue(bdev), qc, true))
- io_schedule();
+ blk_io_schedule();
}
__set_current_state(TASK_RUNNING);
@@ -450,7 +450,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
if (!(iocb->ki_flags & IOCB_HIPRI) ||
!blk_poll(bdev_get_queue(bdev), qc, true))
- io_schedule();
+ blk_io_schedule();
}
__set_current_state(TASK_RUNNING);
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 00b4d15bb811..6d5370eac2a8 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -500,7 +500,7 @@ static struct bio *dio_await_one(struct dio *dio)
spin_unlock_irqrestore(&dio->bio_lock, flags);
if (!(dio->iocb->ki_flags & IOCB_HIPRI) ||
!blk_poll(dio->bio_disk->queue, dio->bio_cookie, true))
- io_schedule();
+ blk_io_schedule();
/* wake up sets us TASK_RUNNING */
spin_lock_irqsave(&dio->bio_lock, flags);
dio->waiter = NULL;
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 20dde5aadcdd..fd3bd06fabb6 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -561,7 +561,7 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
!dio->submit.last_queue ||
!blk_poll(dio->submit.last_queue,
dio->submit.cookie, true))
- io_schedule();
+ blk_io_schedule();
}
__set_current_state(TASK_RUNNING);
}
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 3d594406b96c..c47c76cbbd97 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -28,6 +28,7 @@
#include <linux/scatterlist.h>
#include <linux/blkzoned.h>
#include <linux/sched/sysctl.h>
+#include <linux/sched.h>
struct module;
struct scsi_ioctl_command;
@@ -1837,4 +1838,9 @@ static inline unsigned long blk_default_io_timeout(void)
return sysctl_hung_task_timeout_secs * (HZ / 2);
}
+static inline void blk_io_schedule(void)
+{
+ io_schedule_timeout(blk_default_io_timeout());
+}
+
#endif
--
2.25.2
prev parent reply other threads:[~2020-04-28 7:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-28 7:46 [PATCH 0/2] block: prevent task hung from being triggered in sync dio Ming Lei
2020-04-28 7:46 ` [PATCH 1/2] block: add blk_default_io_timeout() for avoiding task hung in sync IO Ming Lei
2020-04-28 8:05 ` Hannes Reinecke
2020-04-28 8:30 ` Ming Lei
2020-04-28 14:19 ` Bart Van Assche
2020-04-29 1:17 ` Ming Lei
2020-04-30 3:08 ` Bart Van Assche
2020-05-03 1:43 ` Ming Lei
2020-04-28 7:46 ` Ming Lei [this message]
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=20200428074657.645441-3-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=jsbarnes@google.com \
--cc=linux-block@vger.kernel.org \
--cc=sqazi@google.com \
/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;
as well as URLs for NNTP newsgroup(s).