From e54996d9354fe6276c2941f8cbe998e1a9d931d1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 13 Jun 2018 16:54:51 -0600 Subject: [PATCH] block: kill read-ahead if the submitting process is getting killed If we have tons of read-ahead coming in and the process is getting killed, then it can take forever to kill said process since each IO could take seconds on a loaded rotating drive. Signed-off-by: Jens Axboe --- block/blk-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index cf0ee764b908..839401541da3 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -35,6 +35,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -2530,6 +2531,13 @@ blk_qc_t submit_bio(struct bio *bio) if (bio_has_data(bio)) { unsigned int count; + if (unlikely((bio->bi_opf & REQ_RAHEAD) && + fatal_signal_pending(current))) { + bio->bi_status = BLK_STS_AGAIN; + bio_endio(bio); + return BLK_QC_T_NONE; + } + if (unlikely(bio_op(bio) == REQ_OP_WRITE_SAME)) count = queue_logical_block_size(bio->bi_disk->queue) >> 9; else -- 2.25.1