summaryrefslogtreecommitdiffstats
path: root/block/blk-sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/blk-sysfs.c')
-rw-r--r--block/blk-sysfs.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 995b58d46ed1..99205965f559 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -347,6 +347,38 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,
347 return ret; 347 return ret;
348} 348}
349 349
350static ssize_t queue_wc_show(struct request_queue *q, char *page)
351{
352 if (test_bit(QUEUE_FLAG_WC, &q->queue_flags))
353 return sprintf(page, "write back\n");
354
355 return sprintf(page, "write through\n");
356}
357
358static ssize_t queue_wc_store(struct request_queue *q, const char *page,
359 size_t count)
360{
361 int set = -1;
362
363 if (!strncmp(page, "write back", 10))
364 set = 1;
365 else if (!strncmp(page, "write through", 13) ||
366 !strncmp(page, "none", 4))
367 set = 0;
368
369 if (set == -1)
370 return -EINVAL;
371
372 spin_lock_irq(q->queue_lock);
373 if (set)
374 queue_flag_set(QUEUE_FLAG_WC, q);
375 else
376 queue_flag_clear(QUEUE_FLAG_WC, q);
377 spin_unlock_irq(q->queue_lock);
378
379 return count;
380}
381
350static struct queue_sysfs_entry queue_requests_entry = { 382static struct queue_sysfs_entry queue_requests_entry = {
351 .attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR }, 383 .attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR },
352 .show = queue_requests_show, 384 .show = queue_requests_show,
@@ -478,6 +510,12 @@ static struct queue_sysfs_entry queue_poll_entry = {
478 .store = queue_poll_store, 510 .store = queue_poll_store,
479}; 511};
480 512
513static struct queue_sysfs_entry queue_wc_entry = {
514 .attr = {.name = "write_cache", .mode = S_IRUGO | S_IWUSR },
515 .show = queue_wc_show,
516 .store = queue_wc_store,
517};
518
481static struct attribute *default_attrs[] = { 519static struct attribute *default_attrs[] = {
482 &queue_requests_entry.attr, 520 &queue_requests_entry.attr,
483 &queue_ra_entry.attr, 521 &queue_ra_entry.attr,
@@ -503,6 +541,7 @@ static struct attribute *default_attrs[] = {
503 &queue_iostats_entry.attr, 541 &queue_iostats_entry.attr,
504 &queue_random_entry.attr, 542 &queue_random_entry.attr,
505 &queue_poll_entry.attr, 543 &queue_poll_entry.attr,
544 &queue_wc_entry.attr,
506 NULL, 545 NULL,
507}; 546};
508 547