From patchwork Thu Jan 10 03:19:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauricio Faria de Oliveira X-Patchwork-Id: 1022688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43Zrq21W4Nz9sNs; Thu, 10 Jan 2019 14:20:30 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1ghQtM-0000Av-Lw; Thu, 10 Jan 2019 03:20:24 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1ghQtG-00006X-II for kernel-team@lists.ubuntu.com; Thu, 10 Jan 2019 03:20:18 +0000 Received: from mail-qt1-f199.google.com ([209.85.160.199]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1ghQtG-00013V-8e for kernel-team@lists.ubuntu.com; Thu, 10 Jan 2019 03:20:18 +0000 Received: by mail-qt1-f199.google.com with SMTP id 42so8726992qtr.7 for ; Wed, 09 Jan 2019 19:20:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=yVrOaRdyfIx6+SFJGEiz4rbdr+3NFdle6wgM0x4luJE=; b=QkyhA/2D4Q0oKD6Q6IYRuxF4mLvI+fYBWGaD+6/qSGLRvM3jays81O9hFyyjo7n3by Jc0BfYIvwVdvq1kNL16y+GwYT8n+65sibBwpiPh58DgL+TlLHqZSNXLUcAVliTvrY9mc H8QxORPeEB49l5NYE7FqukD9G5ht9t7dsjTT70S8hyze2FIITLJioMGvLgQflqdIlFVu /JzRjFKMRq1wFvqo/FKuJYj2dipDMgeJKR8Z6K26xXBxjKbZ3SUHHfjoVZdLOemIGuRI NfspBHZedYwRB2bnPNrMjIg0YqPLAA6MkHTq4VwjwPdr/6u+lfqv/fFp9cQHnRokukH9 uHQQ== X-Gm-Message-State: AJcUukeB4umrNUy2daCTpMoYCr2P7Cos7SiDNwObSHUXXa9j59t6ErGI 03zOupmR+CEshsBYsIT2GZfRb/hAhvnDC2CE844hsvAc6S6YIR8Ldh2LawJrDjD9Sh3BwqQgVCe d7LGJyCkfLoKkcFixHMG8ofx3vov+wBuR3IPbN5bPnw== X-Received: by 2002:aed:3425:: with SMTP id w34mr7939023qtd.358.1547090417364; Wed, 09 Jan 2019 19:20:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN4t82Pmt7jgUyfO7oQRVo4c1RWNDDmlwd4VfwB55c4WBJc3FZBOGkbglKaTEtR4eg/sjL7w1Q== X-Received: by 2002:aed:3425:: with SMTP id w34mr7939013qtd.358.1547090417216; Wed, 09 Jan 2019 19:20:17 -0800 (PST) Received: from localhost.localdomain ([177.181.227.0]) by smtp.gmail.com with ESMTPSA id e129sm32371961qkf.85.2019.01.09.19.20.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 19:20:16 -0800 (PST) From: Mauricio Faria de Oliveira To: kernel-team@lists.ubuntu.com Subject: [SRU C][PATCH 3/8] blk-wbt: move disable check into get_limit() Date: Thu, 10 Jan 2019 01:19:23 -0200 Message-Id: <20190110031928.30981-4-mfo@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110031928.30981-1-mfo@canonical.com> References: <20190110031928.30981-1-mfo@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jens Axboe BugLink: https://bugs.launchpad.net/bugs/1810998 Check it in one place, instead of in multiple places. Tested-by: Anchal Agarwal Signed-off-by: Jens Axboe (cherry picked from commit ffa358dcaae1f2f00926484e712e06daa8953cb4) Signed-off-by: Mauricio Faria de Oliveira --- block/blk-wbt.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/block/blk-wbt.c b/block/blk-wbt.c index e817970202a6..70075f21482f 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -449,6 +449,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; + if ((rw & REQ_OP_MASK) == REQ_OP_DISCARD) return rwb->wb_background; @@ -486,16 +493,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) && rq_wait_inc_below(rqw, get_limit(rwb, rw))) return; @@ -504,11 +501,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 (rq_wait_inc_below(rqw, get_limit(rwb, rw))) break;