@@ -35,6 +35,17 @@ static sector_t bio_discard_limit(struct block_device *bdev, sector_t sector)
return round_down(UINT_MAX, discard_granularity) >> SECTOR_SHIFT;
}
+static void abort_bio_endio(struct bio *bio)
+{
+ bio_put(bio);
+}
+
+static void abort_bio(struct bio *bio)
+{
+ bio->bi_end_io = abort_bio_endio;
+ bio_endio(bio);
+}
+
int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
sector_t nr_sects, gfp_t gfp_mask, struct bio **biop)
{
@@ -77,6 +88,10 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
* is disabled.
*/
cond_resched();
+ if (fatal_signal_pending(current)) {
+ abort_bio(bio);
+ return -EINTR;
+ }
}
*biop = bio;
@@ -146,6 +161,10 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
nr_sects = 0;
}
cond_resched();
+ if (fatal_signal_pending(current)) {
+ abort_bio(bio);
+ return -EINTR;
+ }
}
*biop = bio;
@@ -190,6 +209,10 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
break;
}
cond_resched();
+ if (fatal_signal_pending(current)) {
+ abort_bio(bio);
+ return -EINTR;
+ }
}
*biop = bio;
@@ -337,6 +360,11 @@ int blkdev_issue_secure_erase(struct block_device *bdev, sector_t sector,
break;
}
cond_resched();
+ if (fatal_signal_pending(current)) {
+ abort_bio(bio);
+ ret = -EINTR;
+ bio = NULL;
+ }
}
blk_finish_plug(&plug);