}
 
 static void
-bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_io_cq *bic)
+bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_data *bfqd,
+                     struct bfq_io_cq *bic, bool bfq_already_existing)
 {
+       unsigned int old_wr_coeff = bfqq->wr_coeff;
+       bool busy = bfq_already_existing && bfq_bfqq_busy(bfqq);
+
        if (bic->saved_idle_window)
                bfq_mark_bfqq_idle_window(bfqq);
        else
 
        /* make sure weight will be updated, however we got here */
        bfqq->entity.prio_changed = 1;
+
+       if (likely(!busy))
+               return;
+
+       if (old_wr_coeff == 1 && bfqq->wr_coeff > 1)
+               bfqd->wr_busy_queues++;
+       else if (old_wr_coeff > 1 && bfqq->wr_coeff == 1)
+               bfqd->wr_busy_queues--;
 }
 
 static int bfqq_process_refs(struct bfq_queue *bfqq)
        const int is_sync = rq_is_sync(rq);
        struct bfq_queue *bfqq;
        bool new_queue = false;
-       bool split = false;
+       bool bfqq_already_existing = false, split = false;
 
        if (!rq->elv.icq)
                return;
                                bfqq = bfq_get_bfqq_handle_split(bfqd, bic, bio,
                                                                 true, is_sync,
                                                                 NULL);
+                       else
+                               bfqq_already_existing = true;
                }
        }
 
                         * queue: restore the idle window and the
                         * possible weight raising period.
                         */
-                       bfq_bfqq_resume_state(bfqq, bic);
+                       bfq_bfqq_resume_state(bfqq, bfqd, bic,
+                                             bfqq_already_existing);
                }
        }