Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fail_make_request: cleanup should_fail_request

This changes should_fail_request() to more usable wrapper function of
should_fail(). It can avoid putting #ifdef CONFIG_FAIL_MAKE_REQUEST in
the middle of a function.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Akinobu Mita and committed by
Linus Torvalds
b2c9cd37 b2588c4b

+12 -14
+12 -14
block/blk-core.c
··· 1361 1361 } 1362 1362 __setup("fail_make_request=", setup_fail_make_request); 1363 1363 1364 - static int should_fail_request(struct bio *bio) 1364 + static bool should_fail_request(struct hd_struct *part, unsigned int bytes) 1365 1365 { 1366 - struct hd_struct *part = bio->bi_bdev->bd_part; 1367 - 1368 - if (part_to_disk(part)->part0.make_it_fail || part->make_it_fail) 1369 - return should_fail(&fail_make_request, bio->bi_size); 1370 - 1371 - return 0; 1366 + return part->make_it_fail && should_fail(&fail_make_request, bytes); 1372 1367 } 1373 1368 1374 1369 static int __init fail_make_request_debugfs(void) ··· 1376 1381 1377 1382 #else /* CONFIG_FAIL_MAKE_REQUEST */ 1378 1383 1379 - static inline int should_fail_request(struct bio *bio) 1384 + static inline bool should_fail_request(struct hd_struct *part, 1385 + unsigned int bytes) 1380 1386 { 1381 - return 0; 1387 + return false; 1382 1388 } 1383 1389 1384 1390 #endif /* CONFIG_FAIL_MAKE_REQUEST */ ··· 1462 1466 old_dev = 0; 1463 1467 do { 1464 1468 char b[BDEVNAME_SIZE]; 1469 + struct hd_struct *part; 1465 1470 1466 1471 q = bdev_get_queue(bio->bi_bdev); 1467 1472 if (unlikely(!q)) { ··· 1486 1489 if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) 1487 1490 goto end_io; 1488 1491 1489 - if (should_fail_request(bio)) 1492 + part = bio->bi_bdev->bd_part; 1493 + if (should_fail_request(part, bio->bi_size) || 1494 + should_fail_request(&part_to_disk(part)->part0, 1495 + bio->bi_size)) 1490 1496 goto end_io; 1491 1497 1492 1498 /* ··· 1704 1704 if (blk_rq_check_limits(q, rq)) 1705 1705 return -EIO; 1706 1706 1707 - #ifdef CONFIG_FAIL_MAKE_REQUEST 1708 - if (rq->rq_disk && rq->rq_disk->part0.make_it_fail && 1709 - should_fail(&fail_make_request, blk_rq_bytes(rq))) 1707 + if (rq->rq_disk && 1708 + should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq))) 1710 1709 return -EIO; 1711 - #endif 1712 1710 1713 1711 spin_lock_irqsave(q->queue_lock, flags); 1714 1712