nvme-multipath: support io stats on the mpath device
[linux-2.6-microblaze.git] / block / blk-wbt.c
index 2464679..68a774d 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "blk-wbt.h"
 #include "blk-rq-qos.h"
+#include "elevator.h"
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/wbt.h>
@@ -422,6 +423,14 @@ static void wbt_update_limits(struct rq_wb *rwb)
        rwb_wake_all(rwb);
 }
 
+bool wbt_disabled(struct request_queue *q)
+{
+       struct rq_qos *rqos = wbt_rq_qos(q);
+
+       return !rqos || RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT ||
+              RQWB(rqos)->enable_state == WBT_STATE_OFF_MANUAL;
+}
+
 u64 wbt_get_min_lat(struct request_queue *q)
 {
        struct rq_qos *rqos = wbt_rq_qos(q);
@@ -435,8 +444,13 @@ void wbt_set_min_lat(struct request_queue *q, u64 val)
        struct rq_qos *rqos = wbt_rq_qos(q);
        if (!rqos)
                return;
+
        RQWB(rqos)->min_lat_nsec = val;
-       RQWB(rqos)->enable_state = WBT_STATE_ON_MANUAL;
+       if (val)
+               RQWB(rqos)->enable_state = WBT_STATE_ON_MANUAL;
+       else
+               RQWB(rqos)->enable_state = WBT_STATE_OFF_MANUAL;
+
        wbt_update_limits(RQWB(rqos));
 }
 
@@ -638,11 +652,15 @@ void wbt_set_write_cache(struct request_queue *q, bool write_cache_on)
  */
 void wbt_enable_default(struct request_queue *q)
 {
-       struct rq_qos *rqos = wbt_rq_qos(q);
+       struct rq_qos *rqos;
+       bool disable_flag = q->elevator &&
+                   test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags);
 
        /* Throttling already enabled? */
+       rqos = wbt_rq_qos(q);
        if (rqos) {
-               if (RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT)
+               if (!disable_flag &&
+                   RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT)
                        RQWB(rqos)->enable_state = WBT_STATE_ON_DEFAULT;
                return;
        }
@@ -651,7 +669,7 @@ void wbt_enable_default(struct request_queue *q)
        if (!blk_queue_registered(q))
                return;
 
-       if (queue_is_mq(q) && IS_ENABLED(CONFIG_BLK_WBT_MQ))
+       if (queue_is_mq(q) && !disable_flag)
                wbt_init(q);
 }
 EXPORT_SYMBOL_GPL(wbt_enable_default);
@@ -841,12 +859,11 @@ int wbt_init(struct request_queue *q)
        rwb->last_comp = rwb->last_issue = jiffies;
        rwb->win_nsec = RWB_WINDOW_NSEC;
        rwb->enable_state = WBT_STATE_ON_DEFAULT;
-       rwb->wc = 1;
+       rwb->wc = test_bit(QUEUE_FLAG_WC, &q->queue_flags);
        rwb->rq_depth.default_depth = RWB_DEF_DEPTH;
        rwb->min_lat_nsec = wbt_default_latency_nsec(q);
 
        wbt_queue_depth_changed(&rwb->rqos);
-       wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags));
 
        /*
         * Assign rwb and add the stats callback.