diff options
author | Jens Axboe <axboe@fb.com> | 2016-04-12 17:46:35 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-04-12 17:46:35 -0400 |
commit | 2f9a0b33ac6c4a2accaf787456080af35f1cab0b (patch) | |
tree | f9fff8867f90c42f1ec70e0ba86cf7529f881ef7 /block | |
parent | e8f1e1630b0a98685d1a3521e8aba0dc7e68082c (diff) | |
parent | 93e9d8e836cb1a9a58b33eb6643bf061c6119ef2 (diff) |
Merge branch 'for-4.7/core' into for-4.7/drivers
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-settings.c | 26 | ||||
-rw-r--r-- | block/blk-sysfs.c | 39 |
2 files changed, 65 insertions, 0 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c index 331e4eee0dda..c903bee43cf8 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c | |||
@@ -846,6 +846,32 @@ void blk_queue_flush_queueable(struct request_queue *q, bool queueable) | |||
846 | } | 846 | } |
847 | EXPORT_SYMBOL_GPL(blk_queue_flush_queueable); | 847 | EXPORT_SYMBOL_GPL(blk_queue_flush_queueable); |
848 | 848 | ||
849 | /** | ||
850 | * blk_queue_write_cache - configure queue's write cache | ||
851 | * @q: the request queue for the device | ||
852 | * @wc: write back cache on or off | ||
853 | * @fua: device supports FUA writes, if true | ||
854 | * | ||
855 | * Tell the block layer about the write cache of @q. | ||
856 | */ | ||
857 | void blk_queue_write_cache(struct request_queue *q, bool wc, bool fua) | ||
858 | { | ||
859 | spin_lock_irq(q->queue_lock); | ||
860 | if (wc) { | ||
861 | queue_flag_set(QUEUE_FLAG_WC, q); | ||
862 | q->flush_flags = REQ_FLUSH; | ||
863 | } else | ||
864 | queue_flag_clear(QUEUE_FLAG_WC, q); | ||
865 | if (fua) { | ||
866 | if (wc) | ||
867 | q->flush_flags |= REQ_FUA; | ||
868 | queue_flag_set(QUEUE_FLAG_FUA, q); | ||
869 | } else | ||
870 | queue_flag_clear(QUEUE_FLAG_FUA, q); | ||
871 | spin_unlock_irq(q->queue_lock); | ||
872 | } | ||
873 | EXPORT_SYMBOL_GPL(blk_queue_write_cache); | ||
874 | |||
849 | static int __init blk_settings_init(void) | 875 | static int __init blk_settings_init(void) |
850 | { | 876 | { |
851 | blk_max_low_pfn = max_low_pfn - 1; | 877 | blk_max_low_pfn = max_low_pfn - 1; |
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 | ||
350 | static 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 | |||
358 | static 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 | |||
350 | static struct queue_sysfs_entry queue_requests_entry = { | 382 | static 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 | ||
513 | static 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 | |||
481 | static struct attribute *default_attrs[] = { | 519 | static 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 | ||