]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
blk-wbt: move disable check into get_limit()
authorJens Axboe <axboe@kernel.dk>
Fri, 11 Jan 2019 11:07:00 +0000 (12:07 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 14 Jan 2019 09:28:55 +0000 (09:28 +0000)
BugLink: https://bugs.launchpad.net/bugs/1810998
Check it in one place, instead of in multiple places.

Tested-by: Anchal Agarwal <anchalag@amazon.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(backported from commit ffa358dcaae1f2f00926484e712e06daa8953cb4)
[mfo: backport:
 - blk-wbt.c:
   - hunk 1: refresh lower context lines due to lack of commit
     782f569774d7 ("blk-wbt: throttle discards like background
     writes"), not required / introduces a new thing/behavior.]
   - hunk 2: s/rq_wait_inc_below(rqw/atomic_inc_below(&rqw->inflight/
   - hunk 3: s/rq_wait_inc_below(rqw/atomic_inc_below(&rqw->inflight/
Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
block/blk-wbt.c

index 145f192a80072ae26b8530a4818ca6c91b286623..0d3c01cfe30c94f0a9b218261807af6907b9d59b 100644 (file)
@@ -483,6 +483,13 @@ static inline unsigned int get_limit(struct rq_wb *rwb, unsigned long rw)
 {
        unsigned int limit;
 
+       /*
+        * If we got disabled, just return UINT_MAX. This ensures that
+        * we'll properly inc a new IO, and dec+wakeup at the end.
+        */
+       if (!rwb_enabled(rwb))
+               return UINT_MAX;
+
        /*
         * At this point we know it's a buffered write. If this is
         * kswapd trying to free memory, or REQ_SYNC is set, then
@@ -517,16 +524,6 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
        struct rq_wait *rqw = get_rq_wait(rwb, wb_acct);
        DECLARE_WAITQUEUE(wait, current);
 
-       /*
-       * inc it here even if disabled, since we'll dec it at completion.
-       * this only happens if the task was sleeping in __wbt_wait(),
-       * and someone turned it off at the same time.
-       */
-       if (!rwb_enabled(rwb)) {
-               atomic_inc(&rqw->inflight);
-               return;
-       }
-
        if (!waitqueue_active(&rqw->wait)
                && atomic_inc_below(&rqw->inflight, get_limit(rwb, rw)))
                return;
@@ -535,11 +532,6 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
        do {
                set_current_state(TASK_UNINTERRUPTIBLE);
 
-               if (!rwb_enabled(rwb)) {
-                       atomic_inc(&rqw->inflight);
-                       break;
-               }
-
                if (atomic_inc_below(&rqw->inflight, get_limit(rwb, rw)))
                        break;