[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <31b118f3-bc8d-b18b-c4b9-e57d74a73f@redhat.com>
Date: Wed, 17 Apr 2024 19:49:17 +0200 (CEST)
From: Mikulas Patocka <mpatocka@...hat.com>
To: Mike Snitzer <msnitzer@...hat.com>, Jens Axboe <axboe@...nel.dk>,
Damien Le Moal <dlemoal@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
Waiman Long <longman@...hat.com>
cc: Guangwu Zhang <guazhang@...hat.com>, dm-devel@...ts.linux.dev,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] completion: move blk_wait_io to
kernel/sched/completion.c
The block layer has a function blk_wait_io - it works like
wait_for_completion_io, except that it doesn't warn if the wait takes too
long. This commit renames the function to wait_for_completion_long_io and
moves it to kernel/sched/completion.c so that other kernel subsystems can
use it. It will be needed by the dm-io subsystem.
Signed-off-by: Mikulas Patocka <mpatocka@...hat.com>
---
block/bio.c | 2 +-
block/blk-mq.c | 2 +-
block/blk.h | 12 ------------
include/linux/completion.h | 1 +
kernel/sched/completion.c | 20 ++++++++++++++++++++
5 files changed, 23 insertions(+), 14 deletions(-)
Index: linux-2.6/block/blk.h
===================================================================
--- linux-2.6.orig/block/blk.h 2024-04-17 19:41:14.000000000 +0200
+++ linux-2.6/block/blk.h 2024-04-17 19:41:14.000000000 +0200
@@ -72,18 +72,6 @@ static inline int bio_queue_enter(struct
return __bio_queue_enter(q, bio);
}
-static inline void blk_wait_io(struct completion *done)
-{
- /* Prevent hang_check timer from firing at us during very long I/O */
- unsigned long timeout = sysctl_hung_task_timeout_secs * HZ / 2;
-
- if (timeout)
- while (!wait_for_completion_io_timeout(done, timeout))
- ;
- else
- wait_for_completion_io(done);
-}
-
#define BIO_INLINE_VECS 4
struct bio_vec *bvec_alloc(mempool_t *pool, unsigned short *nr_vecs,
gfp_t gfp_mask);
Index: linux-2.6/include/linux/completion.h
===================================================================
--- linux-2.6.orig/include/linux/completion.h 2024-04-17 19:41:14.000000000 +0200
+++ linux-2.6/include/linux/completion.h 2024-04-17 19:41:14.000000000 +0200
@@ -112,6 +112,7 @@ extern long wait_for_completion_interrup
struct completion *x, unsigned long timeout);
extern long wait_for_completion_killable_timeout(
struct completion *x, unsigned long timeout);
+extern void wait_for_completion_long_io(struct completion *x);
extern bool try_wait_for_completion(struct completion *x);
extern bool completion_done(struct completion *x);
Index: linux-2.6/block/bio.c
===================================================================
--- linux-2.6.orig/block/bio.c 2024-04-17 19:41:14.000000000 +0200
+++ linux-2.6/block/bio.c 2024-04-17 19:41:14.000000000 +0200
@@ -1378,7 +1378,7 @@ int submit_bio_wait(struct bio *bio)
bio->bi_end_io = submit_bio_wait_endio;
bio->bi_opf |= REQ_SYNC;
submit_bio(bio);
- blk_wait_io(&done);
+ wait_for_completion_long_io(&done);
return blk_status_to_errno(bio->bi_status);
}
Index: linux-2.6/block/blk-mq.c
===================================================================
--- linux-2.6.orig/block/blk-mq.c 2024-04-17 19:41:14.000000000 +0200
+++ linux-2.6/block/blk-mq.c 2024-04-17 19:41:14.000000000 +0200
@@ -1407,7 +1407,7 @@ blk_status_t blk_execute_rq(struct reque
if (blk_rq_is_poll(rq))
blk_rq_poll_completion(rq, &wait.done);
else
- blk_wait_io(&wait.done);
+ wait_for_completion_long_io(&wait.done);
return wait.ret;
}
Index: linux-2.6/kernel/sched/completion.c
===================================================================
--- linux-2.6.orig/kernel/sched/completion.c 2024-04-17 19:41:14.000000000 +0200
+++ linux-2.6/kernel/sched/completion.c 2024-04-17 19:41:14.000000000 +0200
@@ -290,6 +290,26 @@ wait_for_completion_killable_timeout(str
EXPORT_SYMBOL(wait_for_completion_killable_timeout);
/**
+ * wait_for_completion_long_io - waits for completion of a task
+ * @x: holds the state of this particular completion
+ *
+ * This is like wait_for_completion_io, but it doesn't warn if the wait takes
+ * too long.
+ */
+void wait_for_completion_long_io(struct completion *x)
+{
+ /* Prevent hang_check timer from firing at us during very long I/O */
+ unsigned long timeout = sysctl_hung_task_timeout_secs * HZ / 2;
+
+ if (timeout)
+ while (!wait_for_completion_io_timeout(x, timeout))
+ ;
+ else
+ wait_for_completion_io(x);
+}
+EXPORT_SYMBOL(wait_for_completion_long_io);
+
+/**
* try_wait_for_completion - try to decrement a completion without blocking
* @x: completion structure
*
Powered by blists - more mailing lists