From patchwork Wed Apr 3 20:11:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10884421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7307517E0 for ; Wed, 3 Apr 2019 20:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5839522B26 for ; Wed, 3 Apr 2019 20:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4927328449; Wed, 3 Apr 2019 20:11:36 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 D3D7D22B26 for ; Wed, 3 Apr 2019 20:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726144AbfDCULf (ORCPT ); Wed, 3 Apr 2019 16:11:35 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36387 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbfDCULe (ORCPT ); Wed, 3 Apr 2019 16:11:34 -0400 Received: by mail-pl1-f193.google.com with SMTP id ck15so7382168plb.3; Wed, 03 Apr 2019 13:11:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fbFb30DuL1WyFK9RqYkg9Uo0R4Ri3L7ljBbLZ+QBvKI=; b=UuUFFT+XMZbxtZu28RwTwYyWelr+Pbo8hpfiF+RNJYkbz6/1DHOL5aO4adeMbaHFaR VXv1J2atym1H/ZSjfYXdz7TG3EIPfXWK470kkUcGuws2v0BYWXt6gqozPw0OJOZyso8q ZL1rgAMnjULM26zM39O/gtrUq7HAUtvWyMm7ljvf99J3Vo0fhXdq40kvTlFYf4i3b8Iq CCD/xZWb8SpKrjy1JlBaU9yiXVBH30IL7SI2r70Id2FKegWy2DTGlvjrJ4Mtt8hcoOi+ SlZUwC4SC/tbH779tPShH+AnnnB4J2kuUFnbhN9q2faqGj6sYhfyBqzTKorTydGZjBlb 6biw== X-Gm-Message-State: APjAAAVfSsFhppIhiKR0C5HQ4Ub5fxs0uxDCqfTrUuiPJLZGnvTyDw/5 qDwvmJT6tgGImjmuv1O/tZE= X-Google-Smtp-Source: APXvYqxO0cnQBHdHUuUMr6OSL4WA8oaIsH6uno/4gC9oSJ3EqTjRvxll/aOT4LuHX/7+8Bwv677Z/Q== X-Received: by 2002:a17:902:2b87:: with SMTP id l7mr2065115plb.38.1554322293871; Wed, 03 Apr 2019 13:11:33 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id p7sm22707724pfp.70.2019.04.03.13.11.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 13:11:32 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Christoph Hellwig , Hannes Reinecke , James Smart , Ming Lei , Jianchao Wang , Keith Busch , Dongli Zhang , Laurence Oberman , stable@vger.kernel.org Subject: [PATCH] block: Fix blk_mq_try_issue_directly() Date: Wed, 3 Apr 2019 13:11:26 -0700 Message-Id: <20190403201126.22819-1-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT 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 If blk_mq_try_issue_directly() returns BLK_STS*_RESOURCE that means that the request has not been queued and that the caller should retry to submit the request. Both blk_mq_request_bypass_insert() and blk_mq_sched_insert_request() guarantee that a request will be processed. Hence return BLK_STS_OK if one of these functions is called. This patch avoids that blk_mq_dispatch_rq_list() crashes when using dm-mpath. Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: James Smart Cc: Ming Lei Cc: Jianchao Wang Cc: Keith Busch Cc: Dongli Zhang Cc: Laurence Oberman Tested-by: Laurence Oberman Reviewed-by: Laurence Oberman Reported-by: Laurence Oberman Fixes: 7f556a44e61d ("blk-mq: refactor the code of issue request directly") # v5.0. Cc: Signed-off-by: Bart Van Assche Reported-by: Laurence Oberman Signed-off-by: Bart Van Assche Tested-by: Laurence Oberman --- block/blk-mq.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 652d0c6d5945..b2c20dce8a30 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1859,16 +1859,11 @@ blk_status_t blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, case BLK_STS_RESOURCE: if (force) { blk_mq_request_bypass_insert(rq, run_queue); - /* - * We have to return BLK_STS_OK for the DM - * to avoid livelock. Otherwise, we return - * the real result to indicate whether the - * request is direct-issued successfully. - */ - ret = bypass ? BLK_STS_OK : ret; + ret = BLK_STS_OK; } else if (!bypass) { blk_mq_sched_insert_request(rq, false, run_queue, false); + ret = BLK_STS_OK; } break; default: