From patchwork Fri Mar 24 17:39:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9643449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2806602C9 for ; Fri, 24 Mar 2017 17:39:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5CF7203B9 for ; Fri, 24 Mar 2017 17:39:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C99DD21E5A; Fri, 24 Mar 2017 17:39:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44C71203B9 for ; Fri, 24 Mar 2017 17:39:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752933AbdCXRjP (ORCPT ); Fri, 24 Mar 2017 13:39:15 -0400 Received: from mail-it0-f43.google.com ([209.85.214.43]:35524 "EHLO mail-it0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752399AbdCXRjO (ORCPT ); Fri, 24 Mar 2017 13:39:14 -0400 Received: by mail-it0-f43.google.com with SMTP id y18so15890503itc.0 for ; Fri, 24 Mar 2017 10:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=mHTl0RUzri5vMpP6fSBYi1sjZk1S9QvoWulT0LZh8o8=; b=akRPduJQSCRppYleelah/0Nh/U48ymLHxtnCV0+lKe7vSAUo+uu4++4L/Rqd2tUsY5 Ozhboqq0+6Y64Umzd3taFkrG+jVr4ESi36J8Ei5NBdbxLAW0nSiTTAguF/kX0e8HOSqH 4wC8UwWw7cEdQ0EaR4Qk9XdH0YwqewX4o1Fxrm70sTw/yhTX+ubE2z/brgRrthxLyZ6G RkRq5/4iKC7YVxdjLS+DAXuH6gFhPHE85vpDDf6lv5iO5CdkKi90lRGIJ5IW7K60ze8O 7H96viSos4B7JDXsaDUsrRs4m1Y89DI7HT+zd3jJhjP+L9KBX6sqblQe4+RG+t/VDf2O Wfxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=mHTl0RUzri5vMpP6fSBYi1sjZk1S9QvoWulT0LZh8o8=; b=m9n1u7wczsYq4qPSY2nMq8I2T0tXt0NYjAJqj9iNENSDrUaPeQgN/pVOreI9PCKtGJ lLXwRoesf4srMQeA6ATPeYpxGygIppYOxeJHOyGZgr3oNiBjMYMVsfjZHapDQ5nyPazB MINh7UJ3JEXMpib7cbjLJxlp214oZqo+HmYgn2J9k732JaBOrqnhg/0l2p4sw6M1aB7O 4rtmh/CGTMr1+1HO7LwOYbZuR2sR7vzWecNFC9czhlN0iNdS61AU/j3y6z0U37nB05Fb gCMomDWOFa6+B1chN5c5RiMA9Mob4g25wrja0e27/vsClsC11P+oODHsQ435UC2Jmnm5 3cJg== X-Gm-Message-State: AFeK/H2Ch68MigE0DBAae8rGyAPnzpQMdW7a+SKIeptgdb5UEsgytbwBLH7xL1zEeUcN4w== X-Received: by 10.36.172.65 with SMTP id m1mr4195868iti.33.1490377153182; Fri, 24 Mar 2017 10:39:13 -0700 (PDT) Received: from [192.168.1.154] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id x64sm1270532ita.1.2017.03.24.10.39.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Mar 2017 10:39:12 -0700 (PDT) To: "linux-block@vger.kernel.org" From: Jens Axboe Subject: [PATCH] blk-mq: include errors in did_work calculation Message-ID: Date: Fri, 24 Mar 2017 11:39:10 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently we return true in blk_mq_dispatch_rq_list() if we queued IO successfully, but we really want to return whether or not the we made progress. Progress includes if we got an error return. If we don't, this can lead to a hang in blk_mq_sched_dispatch_requests() when a driver is draining IO by returning BLK_MQ_QUEUE_ERROR instead of manually ending the IO in error and return BLK_MQ_QUEUE_OK. Signed-off-by: Jens Axboe Tested-by: Josef Bacik Reviewed-by: Bart Van Assche Reviewed-by: Omar Sandoval diff --git a/block/blk-mq.c b/block/blk-mq.c index a4546f060e80..e3b09abf9d5b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -978,7 +978,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list) struct request *rq; LIST_HEAD(driver_list); struct list_head *dptr; - int queued, ret = BLK_MQ_RQ_QUEUE_OK; + int errors, queued, ret = BLK_MQ_RQ_QUEUE_OK; /* * Start off with dptr being NULL, so we start the first request @@ -989,7 +989,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list) /* * Now process all the entries, sending them to the driver. */ - queued = 0; + errors = queued = 0; while (!list_empty(list)) { struct blk_mq_queue_data bd; @@ -1046,6 +1046,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list) default: pr_err("blk-mq: bad return on queue: %d\n", ret); case BLK_MQ_RQ_QUEUE_ERROR: + errors++; rq->errors = -EIO; blk_mq_end_request(rq, rq->errors); break; @@ -1097,7 +1098,7 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list) blk_mq_run_hw_queue(hctx, true); } - return queued != 0; + return (queued + errors) != 0; } static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)