diff options
author | Yufen Yu <yuyufen@huawei.com> | 2019-03-18 10:44:41 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-03-20 16:02:07 -0400 |
commit | 29ece8b4354f8c5eaee798a3d8a1b356efee426f (patch) | |
tree | 953360a0c9964a71527205e3f427269c80d0f10f | |
parent | 9496c015ed39ddfce971d63a1442e6d258504a7d (diff) |
block: add BLK_MQ_POLL_CLASSIC for hybrid poll and return EINVAL for unexpected value
For q->poll_nsec == -1, means doing classic poll, not hybrid poll.
We introduce a new flag BLK_MQ_POLL_CLASSIC to replace -1, which
may make code much easier to read.
Additionally, since val is an int obtained with kstrtoint(), val can be
a negative value other than -1, so return -EINVAL for that case.
Thanks to Damien Le Moal for some good suggestion.
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/blk-mq.c | 4 | ||||
-rw-r--r-- | block/blk-sysfs.c | 12 | ||||
-rw-r--r-- | include/linux/blkdev.h | 3 |
3 files changed, 12 insertions, 7 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index ea01c23b58a3..76a3f78c566a 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -2856,7 +2856,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, | |||
2856 | /* | 2856 | /* |
2857 | * Default to classic polling | 2857 | * Default to classic polling |
2858 | */ | 2858 | */ |
2859 | q->poll_nsec = -1; | 2859 | q->poll_nsec = BLK_MQ_POLL_CLASSIC; |
2860 | 2860 | ||
2861 | blk_mq_init_cpu_queues(q, set->nr_hw_queues); | 2861 | blk_mq_init_cpu_queues(q, set->nr_hw_queues); |
2862 | blk_mq_add_queue_tag_set(set, q); | 2862 | blk_mq_add_queue_tag_set(set, q); |
@@ -3391,7 +3391,7 @@ static bool blk_mq_poll_hybrid(struct request_queue *q, | |||
3391 | { | 3391 | { |
3392 | struct request *rq; | 3392 | struct request *rq; |
3393 | 3393 | ||
3394 | if (q->poll_nsec == -1) | 3394 | if (q->poll_nsec == BLK_MQ_POLL_CLASSIC) |
3395 | return false; | 3395 | return false; |
3396 | 3396 | ||
3397 | if (!blk_qc_t_is_internal(cookie)) | 3397 | if (!blk_qc_t_is_internal(cookie)) |
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 59685918167e..422327089e0f 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c | |||
@@ -360,8 +360,8 @@ static ssize_t queue_poll_delay_show(struct request_queue *q, char *page) | |||
360 | { | 360 | { |
361 | int val; | 361 | int val; |
362 | 362 | ||
363 | if (q->poll_nsec == -1) | 363 | if (q->poll_nsec == BLK_MQ_POLL_CLASSIC) |
364 | val = -1; | 364 | val = BLK_MQ_POLL_CLASSIC; |
365 | else | 365 | else |
366 | val = q->poll_nsec / 1000; | 366 | val = q->poll_nsec / 1000; |
367 | 367 | ||
@@ -380,10 +380,12 @@ static ssize_t queue_poll_delay_store(struct request_queue *q, const char *page, | |||
380 | if (err < 0) | 380 | if (err < 0) |
381 | return err; | 381 | return err; |
382 | 382 | ||
383 | if (val == -1) | 383 | if (val == BLK_MQ_POLL_CLASSIC) |
384 | q->poll_nsec = -1; | 384 | q->poll_nsec = BLK_MQ_POLL_CLASSIC; |
385 | else | 385 | else if (val >= 0) |
386 | q->poll_nsec = val * 1000; | 386 | q->poll_nsec = val * 1000; |
387 | else | ||
388 | return -EINVAL; | ||
387 | 389 | ||
388 | return count; | 390 | return count; |
389 | } | 391 | } |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 0de92b29f589..5c58a3b2bf00 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -50,6 +50,9 @@ struct blk_stat_callback; | |||
50 | /* Must be consistent with blk_mq_poll_stats_bkt() */ | 50 | /* Must be consistent with blk_mq_poll_stats_bkt() */ |
51 | #define BLK_MQ_POLL_STATS_BKTS 16 | 51 | #define BLK_MQ_POLL_STATS_BKTS 16 |
52 | 52 | ||
53 | /* Doing classic polling */ | ||
54 | #define BLK_MQ_POLL_CLASSIC -1 | ||
55 | |||
53 | /* | 56 | /* |
54 | * Maximum number of blkcg policies allowed to be registered concurrently. | 57 | * Maximum number of blkcg policies allowed to be registered concurrently. |
55 | * Defined here to simplify include dependency. | 58 | * Defined here to simplify include dependency. |