block: kill read-ahead if the submitting process is getting killed readpages-ahead-args
authorJens Axboe <axboe@kernel.dk>
Wed, 13 Jun 2018 22:54:51 +0000 (16:54 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 21 Jun 2018 01:01:09 +0000 (19:01 -0600)
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 <axboe@kernel.dk>
block/blk-core.c

index cf0ee764b908b384f69be9efbb9d7a1352eb7a52..839401541da34950ba20df6d0a1fbe625d938fdf 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/blk-cgroup.h>
 #include <linux/debugfs.h>
 #include <linux/bpf.h>
+#include <linux/sched/signal.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/block.h>
@@ -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