summaryrefslogtreecommitdiff
path: root/block/blk.h
diff options
context:
space:
mode:
authorKeith Busch <kbusch@kernel.org>2024-02-23 07:59:09 -0800
committerJens Axboe <axboe@kernel.dk>2024-02-24 12:46:46 -0700
commit0eb4db4706603db09644ec3bc9bb0d63ea5d326c (patch)
tree4f26a8b78b34f487c7c45cd64d68ccf7e9adc971 /block/blk.h
parent76a27e1b53b94b5a23c221434146fda3e9d8d8e0 (diff)
block: io wait hang check helper
This is the same in two places, and another will be added soon. Create a helper for it. Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Link: https://lore.kernel.org/r/20240223155910.3622666-4-kbusch@meta.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk.h')
-rw-r--r--block/blk.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/block/blk.h b/block/blk.h
index 7c30e2ac8ebc..6c2749d122ab 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -4,6 +4,7 @@
#include <linux/blk-crypto.h>
#include <linux/memblock.h> /* for max_pfn/max_low_pfn */
+#include <linux/sched/sysctl.h>
#include <linux/timekeeping.h>
#include <xen/xen.h>
#include "blk-crypto-internal.h"
@@ -71,6 +72,18 @@ static inline int bio_queue_enter(struct bio *bio)
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);