Merge branch 'core-rcu-2021.07.04' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / block / blk-wbt.c
index 42aed01..3ed71b8 100644 (file)
@@ -77,7 +77,8 @@ enum {
 
 static inline bool rwb_enabled(struct rq_wb *rwb)
 {
-       return rwb && rwb->wb_normal != 0;
+       return rwb && rwb->enable_state != WBT_STATE_OFF_DEFAULT &&
+                     rwb->wb_normal != 0;
 }
 
 static void wb_timestamp(struct rq_wb *rwb, unsigned long *var)
@@ -563,7 +564,6 @@ static void wbt_cleanup(struct rq_qos *rqos, struct bio *bio)
 }
 
 /*
- * Returns true if the IO request should be accounted, false if not.
  * May sleep, if we have exceeded the writeback limits. Caller can pass
  * in an irq held spinlock, if it holds one when calling this function.
  * If we do sleep, we'll release and re-grab it.
@@ -636,9 +636,13 @@ 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);
+
        /* Throttling already enabled? */
-       if (rqos)
+       if (rqos) {
+               if (RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT)
+                       RQWB(rqos)->enable_state = WBT_STATE_ON_DEFAULT;
                return;
+       }
 
        /* Queue not registered? Maybe shutting down... */
        if (!blk_queue_registered(q))
@@ -702,7 +706,7 @@ void wbt_disable_default(struct request_queue *q)
        rwb = RQWB(rqos);
        if (rwb->enable_state == WBT_STATE_ON_DEFAULT) {
                blk_stat_deactivate(rwb->cb);
-               rwb->wb_normal = 0;
+               rwb->enable_state = WBT_STATE_OFF_DEFAULT;
        }
 }
 EXPORT_SYMBOL_GPL(wbt_disable_default);