diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2011-07-26 19:09:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-26 19:49:46 -0400 |
commit | b2c9cd3793e5878e301ec2219785a7b8ca402ef1 (patch) | |
tree | e0a8a447ea8c6d59c20a1e190e2c397bfcd46a49 | |
parent | b2588c4b4c3c075e9b45d61065d86c60de2b6441 (diff) |
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>
-rw-r--r-- | block/blk-core.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index f9255815a5bb..b850bedad229 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -1361,14 +1361,9 @@ static int __init setup_fail_make_request(char *str) | |||
1361 | } | 1361 | } |
1362 | __setup("fail_make_request=", setup_fail_make_request); | 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; | 1366 | return part->make_it_fail && should_fail(&fail_make_request, bytes); |
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; | ||
1372 | } | 1367 | } |
1373 | 1368 | ||
1374 | static int __init fail_make_request_debugfs(void) | 1369 | static int __init fail_make_request_debugfs(void) |
@@ -1381,9 +1376,10 @@ late_initcall(fail_make_request_debugfs); | |||
1381 | 1376 | ||
1382 | #else /* CONFIG_FAIL_MAKE_REQUEST */ | 1377 | #else /* CONFIG_FAIL_MAKE_REQUEST */ |
1383 | 1378 | ||
1384 | static inline int should_fail_request(struct bio *bio) | 1379 | static inline bool should_fail_request(struct hd_struct *part, |
1380 | unsigned int bytes) | ||
1385 | { | 1381 | { |
1386 | return 0; | 1382 | return false; |
1387 | } | 1383 | } |
1388 | 1384 | ||
1389 | #endif /* CONFIG_FAIL_MAKE_REQUEST */ | 1385 | #endif /* CONFIG_FAIL_MAKE_REQUEST */ |
@@ -1466,6 +1462,7 @@ static inline void __generic_make_request(struct bio *bio) | |||
1466 | old_dev = 0; | 1462 | old_dev = 0; |
1467 | do { | 1463 | do { |
1468 | char b[BDEVNAME_SIZE]; | 1464 | char b[BDEVNAME_SIZE]; |
1465 | struct hd_struct *part; | ||
1469 | 1466 | ||
1470 | q = bdev_get_queue(bio->bi_bdev); | 1467 | q = bdev_get_queue(bio->bi_bdev); |
1471 | if (unlikely(!q)) { | 1468 | if (unlikely(!q)) { |
@@ -1489,7 +1486,10 @@ static inline void __generic_make_request(struct bio *bio) | |||
1489 | if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) | 1486 | if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) |
1490 | goto end_io; | 1487 | goto end_io; |
1491 | 1488 | ||
1492 | if (should_fail_request(bio)) | 1489 | part = bio->bi_bdev->bd_part; |
1490 | if (should_fail_request(part, bio->bi_size) || | ||
1491 | should_fail_request(&part_to_disk(part)->part0, | ||
1492 | bio->bi_size)) | ||
1493 | goto end_io; | 1493 | goto end_io; |
1494 | 1494 | ||
1495 | /* | 1495 | /* |
@@ -1704,11 +1704,9 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq) | |||
1704 | if (blk_rq_check_limits(q, rq)) | 1704 | if (blk_rq_check_limits(q, rq)) |
1705 | return -EIO; | 1705 | return -EIO; |
1706 | 1706 | ||
1707 | #ifdef CONFIG_FAIL_MAKE_REQUEST | 1707 | if (rq->rq_disk && |
1708 | if (rq->rq_disk && rq->rq_disk->part0.make_it_fail && | 1708 | should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq))) |
1709 | should_fail(&fail_make_request, blk_rq_bytes(rq))) | ||
1710 | return -EIO; | 1709 | return -EIO; |
1711 | #endif | ||
1712 | 1710 | ||
1713 | spin_lock_irqsave(q->queue_lock, flags); | 1711 | spin_lock_irqsave(q->queue_lock, flags); |
1714 | 1712 | ||