mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
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>
This commit is contained in:
parent
76a27e1b53
commit
0eb4db4706
12
block/bio.c
12
block/bio.c
@ -16,7 +16,6 @@
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/cgroup.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/sched/sysctl.h>
|
||||
#include <linux/blk-crypto.h>
|
||||
#include <linux/xarray.h>
|
||||
|
||||
@ -1371,21 +1370,12 @@ int submit_bio_wait(struct bio *bio)
|
||||
{
|
||||
DECLARE_COMPLETION_ONSTACK_MAP(done,
|
||||
bio->bi_bdev->bd_disk->lockdep_map);
|
||||
unsigned long hang_check;
|
||||
|
||||
bio->bi_private = &done;
|
||||
bio->bi_end_io = submit_bio_wait_endio;
|
||||
bio->bi_opf |= REQ_SYNC;
|
||||
submit_bio(bio);
|
||||
|
||||
/* Prevent hang_check timer from firing at us during very long I/O */
|
||||
hang_check = sysctl_hung_task_timeout_secs;
|
||||
if (hang_check)
|
||||
while (!wait_for_completion_io_timeout(&done,
|
||||
hang_check * (HZ/2)))
|
||||
;
|
||||
else
|
||||
wait_for_completion_io(&done);
|
||||
blk_wait_io(&done);
|
||||
|
||||
return blk_status_to_errno(bio->bi_status);
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <linux/llist.h>
|
||||
#include <linux/cpu.h>
|
||||
#include <linux/cache.h>
|
||||
#include <linux/sched/sysctl.h>
|
||||
#include <linux/sched/topology.h>
|
||||
#include <linux/sched/signal.h>
|
||||
#include <linux/delay.h>
|
||||
@ -1409,22 +1408,10 @@ blk_status_t blk_execute_rq(struct request *rq, bool at_head)
|
||||
blk_mq_insert_request(rq, at_head ? BLK_MQ_INSERT_AT_HEAD : 0);
|
||||
blk_mq_run_hw_queue(hctx, false);
|
||||
|
||||
if (blk_rq_is_poll(rq)) {
|
||||
if (blk_rq_is_poll(rq))
|
||||
blk_rq_poll_completion(rq, &wait.done);
|
||||
} else {
|
||||
/*
|
||||
* Prevent hang_check timer from firing at us during very long
|
||||
* I/O
|
||||
*/
|
||||
unsigned long hang_check = sysctl_hung_task_timeout_secs;
|
||||
|
||||
if (hang_check)
|
||||
while (!wait_for_completion_io_timeout(&wait.done,
|
||||
hang_check * (HZ/2)))
|
||||
;
|
||||
else
|
||||
wait_for_completion_io(&wait.done);
|
||||
}
|
||||
else
|
||||
blk_wait_io(&wait.done);
|
||||
|
||||
return wait.ret;
|
||||
}
|
||||
|
13
block/blk.h
13
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);
|
||||
|
Loading…
Reference in New Issue
Block a user