diff options
Diffstat (limited to 'block/blk-sysfs.c')
-rw-r--r-- | block/blk-sysfs.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 306759bbdf1b..58b53c354c2c 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c | |||
@@ -250,6 +250,27 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count) | |||
250 | return ret; | 250 | return ret; |
251 | } | 251 | } |
252 | 252 | ||
253 | static ssize_t queue_random_show(struct request_queue *q, char *page) | ||
254 | { | ||
255 | return queue_var_show(blk_queue_add_random(q), page); | ||
256 | } | ||
257 | |||
258 | static ssize_t queue_random_store(struct request_queue *q, const char *page, | ||
259 | size_t count) | ||
260 | { | ||
261 | unsigned long val; | ||
262 | ssize_t ret = queue_var_store(&val, page, count); | ||
263 | |||
264 | spin_lock_irq(q->queue_lock); | ||
265 | if (val) | ||
266 | queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q); | ||
267 | else | ||
268 | queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q); | ||
269 | spin_unlock_irq(q->queue_lock); | ||
270 | |||
271 | return ret; | ||
272 | } | ||
273 | |||
253 | static ssize_t queue_iostats_show(struct request_queue *q, char *page) | 274 | static ssize_t queue_iostats_show(struct request_queue *q, char *page) |
254 | { | 275 | { |
255 | return queue_var_show(blk_queue_io_stat(q), page); | 276 | return queue_var_show(blk_queue_io_stat(q), page); |
@@ -374,6 +395,12 @@ static struct queue_sysfs_entry queue_iostats_entry = { | |||
374 | .store = queue_iostats_store, | 395 | .store = queue_iostats_store, |
375 | }; | 396 | }; |
376 | 397 | ||
398 | static struct queue_sysfs_entry queue_random_entry = { | ||
399 | .attr = {.name = "add_random", .mode = S_IRUGO | S_IWUSR }, | ||
400 | .show = queue_random_show, | ||
401 | .store = queue_random_store, | ||
402 | }; | ||
403 | |||
377 | static struct attribute *default_attrs[] = { | 404 | static struct attribute *default_attrs[] = { |
378 | &queue_requests_entry.attr, | 405 | &queue_requests_entry.attr, |
379 | &queue_ra_entry.attr, | 406 | &queue_ra_entry.attr, |
@@ -394,6 +421,7 @@ static struct attribute *default_attrs[] = { | |||
394 | &queue_nomerges_entry.attr, | 421 | &queue_nomerges_entry.attr, |
395 | &queue_rq_affinity_entry.attr, | 422 | &queue_rq_affinity_entry.attr, |
396 | &queue_iostats_entry.attr, | 423 | &queue_iostats_entry.attr, |
424 | &queue_random_entry.attr, | ||
397 | NULL, | 425 | NULL, |
398 | }; | 426 | }; |
399 | 427 | ||