aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/blk-settings.c7
-rw-r--r--block/blk-sysfs.c11
2 files changed, 12 insertions, 6 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 291cf9df7fc2..86ff375c00ce 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -824,10 +824,13 @@ EXPORT_SYMBOL(blk_set_queue_depth);
*/
void blk_queue_write_cache(struct request_queue *q, bool wc, bool fua)
{
- if (wc)
+ if (wc) {
+ blk_queue_flag_set(QUEUE_FLAG_HW_WC, q);
blk_queue_flag_set(QUEUE_FLAG_WC, q);
- else
+ } else {
+ blk_queue_flag_clear(QUEUE_FLAG_HW_WC, q);
blk_queue_flag_clear(QUEUE_FLAG_WC, q);
+ }
if (fua)
blk_queue_flag_set(QUEUE_FLAG_FUA, q);
else
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 4f34525bafac..a582ea0da74f 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -528,13 +528,16 @@ static ssize_t queue_wc_show(struct request_queue *q, char *page)
static ssize_t queue_wc_store(struct request_queue *q, const char *page,
size_t count)
{
- if (!strncmp(page, "write back", 10))
+ if (!strncmp(page, "write back", 10)) {
+ if (!test_bit(QUEUE_FLAG_HW_WC, &q->queue_flags))
+ return -EINVAL;
blk_queue_flag_set(QUEUE_FLAG_WC, q);
- else if (!strncmp(page, "write through", 13) ||
- !strncmp(page, "none", 4))
+ } else if (!strncmp(page, "write through", 13) ||
+ !strncmp(page, "none", 4)) {
blk_queue_flag_clear(QUEUE_FLAG_WC, q);
- else
+ } else {
return -EINVAL;
+ }
return count;
}