From patchwork Mon Apr 24 16:22:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Loehle X-Patchwork-Id: 87110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2867565vqo; Mon, 24 Apr 2023 09:32:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6/Efd3nN2wDAnrbCMhE9cy/n6IOxNXydD7m4qYZQ8oeLdl746bgXvOvgnBxI3pFU0iRvLJ X-Received: by 2002:a17:902:8d8a:b0:1a9:826c:8f2f with SMTP id v10-20020a1709028d8a00b001a9826c8f2fmr1425078plo.16.1682353973443; Mon, 24 Apr 2023 09:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682353973; cv=none; d=google.com; s=arc-20160816; b=GRKf4w2lF9f+MtOSQ8MEQsTfG5rPk1ebIg5L2boqYUqqLF/ygyyOpw+t+9fzzPy7eS 4Il7ndqESiEImAtxyy1gDxz5ZJ0oWdZ7fxMNoxialhXGDS40+veQcQVHwB1m8M3FRhiO 0cMlw0ZjBBgc4J6EA+igpTJ84N8p/rWsReIDjvTeWzn9y6+cPdemRc9i7ToZBJOZ+ExH WRKPOETBmHUFti8PD5qyP2biauFOsgbPYU3wkBfmKoyF1D33kFwRO9ZN23tTaVLec7NB VmK2GobyVkrmOP0M4A4nQP6Q2bEPZlWKlcbYMrnJz7pG2fJjblZxv+DvdT4kGdYoN7d8 fWjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=iNN10lwBq7Y8POEKIPm/87muh3zzLaCqzQZsg0mKon0=; b=ptEPqiePw1jJTzOzfkKhkM9LNcIs/zIY7HPMdVwtLJNUhvGD5k8LGyGepzXYXABZew 7krB2bjOoyVpCJ67Io0C6prfCGF6E90WmQa/FVBqaNQ9nmZtuWhAPYWb5OJKPOpzL1Wf 4B9eyBWU1VNZITTpaHEK96DARCNW4boDIoCtN8+llCj2yVjBbwrAFDFFbzobW9WjMOlA meOFoPmQV97NLIp0/4naeDdc7YJJIdeqmx8wuIkzhkS+j8zz2yegPrxV5jRVbaSZSV82 xqFQGtUS0CapCyuYOnHeWQ8uLfBAa3AZGWpRg64fn9Q1NDLUSD0DCF/Zi2HzZoIir1w6 62uA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hyperstone.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020a170902cccb00b001a506617ab4si11168057ple.27.2023.04.24.09.32.39; Mon, 24 Apr 2023 09:32:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hyperstone.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231908AbjDXQWL convert rfc822-to-8bit (ORCPT + 99 others); Mon, 24 Apr 2023 12:22:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230355AbjDXQWK (ORCPT ); Mon, 24 Apr 2023 12:22:10 -0400 Received: from mail6.swissbit.com (mail5.swissbit.com [148.251.244.252]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C62F7682; Mon, 24 Apr 2023 09:22:08 -0700 (PDT) Received: from mail6.swissbit.com (localhost [127.0.0.1]) by DDEI (Postfix) with ESMTP id 87AF7222951; Mon, 24 Apr 2023 18:22:06 +0200 (CEST) Received: from mail6.swissbit.com (localhost [127.0.0.1]) by DDEI (Postfix) with ESMTP id 7355C2225AC; Mon, 24 Apr 2023 18:22:06 +0200 (CEST) X-TM-AS-ERS: 10.181.10.102-127.5.254.253 X-TM-AS-SMTP: 1.0 bXgyLmRtei5zd2lzc2JpdC5jb20= Y2xvZWhsZUBoeXBlcnN0b25lLmNvb Q== X-DDEI-TLS-USAGE: Used Received: from mx2.dmz.swissbit.com (mx2.dmz.swissbit.com [10.181.10.102]) by mail6.swissbit.com (Postfix) with ESMTPS; Mon, 24 Apr 2023 18:22:06 +0200 (CEST) From: Christian Loehle To: ulf hansson , linux-mmc , "linux-kernel@vger.kernel.org" CC: Avri Altman , Adrian Hunter , Christoph Hellwig Subject: [PATCH] mmc: queue: ensure error propagation for non-blk Thread-Topic: [PATCH] mmc: queue: ensure error propagation for non-blk Thread-Index: Adl2xsdYtFja5ytvTvyF17/lcuh7dQ== Date: Mon, 24 Apr 2023 16:22:05 +0000 Message-ID: <1d8ce997934c4395bb5dd235525bf7a2@hyperstone.com> Accept-Language: en-US, de-DE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: MIME-Version: 1.0 X-TMASE-Version: DDEI-5.1-9.0.1002-27586.000 X-TMASE-Result: 10--1.863700-10.000000 X-TMASE-MatchedRID: GegCmeQgyY5A+YmEQEhsujz6L+U/pejx1QQ6Jx/ffla4n9bqPhfH20mo bOLhIyMmZX2hfwUP7YpvtPtMpliQxdAy2LXTI7g3EXjPIvKd74BMkOX0UoduuSxMw0FMkBlZnvu lBJY7sZvi8zVgXoAltu339GNyKR8aC24oEZ6SpSkj80Za3RRg8KiVP4VLL8ChQv8bOiTBfk31he RrqmEGW4uV9Sql14RLrP2oEAEBXfg= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-TMASE-INERTIA: 0-0;;;; X-TMASE-XGENCLOUD: 188d4078-3282-414d-923f-36a7f32a4dfa-0-0-200-0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764076000066439802?= X-GMAIL-MSGID: =?utf-8?q?1764076000066439802?= Requests to the mmc layer usually come through a block device. The exceptions are the RPMB chardev and debugfs, which issue their own blk_mq requests through blk_execute_rq and do not query the BLK_STS error but the mmc-internal drv_op_result. This patch ensures that drv_op_result is set as error whenever a BLK_STS error is set. The behavior leads to a bug where the request never sees the error, e.g. by directly erroring out at mmc_blk_mq_issue_rq if mmc_blk_part_switch fails. The ioctl caller of the rpmb chardev then can never see the error and thus may assume that their call executed successfully when it did not. While always checking the blk_execute_rq return value would be advised, let's eliminate the error completely by always setting drv_op_result in case of a BLK_STS error. Signed-off-by: Christian Loehle --- drivers/mmc/core/queue.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index b396e3900717..8240962e28f3 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -334,6 +334,9 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx, WRITE_ONCE(mq->busy, false); } + /* Ensure request error propagates to non-blk callers, too. */ + if (!req_to_mmc_queue_req(req)->drv_op_result && ret) + req_to_mmc_queue_req(req)->drv_op_result = ret; return ret; }