From patchwork Thu Mar 30 11:36:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 77118 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1059776vqo; Thu, 30 Mar 2023 04:41:24 -0700 (PDT) X-Google-Smtp-Source: AK7set9vG0ULqQV4GGK3Gi3kqQtU06/ylzzA6VeoScd2mJq5kLqw61fwg/elGt/wypfHbCIHnh+R X-Received: by 2002:a05:6a20:e1e:b0:d9:6650:ef14 with SMTP id ej30-20020a056a200e1e00b000d96650ef14mr19225461pzb.31.1680176484198; Thu, 30 Mar 2023 04:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680176484; cv=none; d=google.com; s=arc-20160816; b=YiIdrpk+swG4O7xzJrEtOT7werO85wcq7PqElKgPs6BZrWb/DLBEsTmkwznbRkbvuI JMnZatDx9SgdUUd+wmIsBNjE555S5MCUMnxj0F+kSWpu5Mrtem+l2U6ZMoVUP7lkJ7Yx hjuvUFRCdWjToYEBmlu0GjQzI4cByqreSBVgn9tpaTgoY5sYpUN/UKmyhOO4IdpTXW3v 5mjJZPLM3fDeEGnOhGiebeyRrHShwbdCs+OLw5wpZWnWGfnIHNvGtVXhUcQFpZwR1WAf 8W3eN/4B0iejZ6H/B9Z4MmNim3T50YOq0h5CyoOu0c2ScoFe2iYOUMlCSGpdWJD/iD1K 176A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2HaaAMVXBOU9npIKRCm63G2Jnf2K0Y8PRLMtIL+XBWM=; b=FFZ8IPi7qnJWLq/AWnLJ/P4C6px4z1mDkDdtwisTQIa0w3bTXQCa0wNCeNXLj8OjCU Ozr/7iAcZfMhow80SJA3npcALd4OWWqIz+NcITLHBEW5C/BFN07TVFRZYkb9kAx/dAG0 F4lLWVacKtwjJGW4iMJpyzCoW0PrHMYyt1jTVzoxD3jAEN2hPS9GX3K5XzdcHbPTLI2c BD6cNoiwU0+DxMoM8b1PP5CSPL2ivEpecsQnB7xeGbQ21R9pX9g1TQ/w+57h3fE/Smm/ fM43Vc8GPpilmOIpw6DItQ9tArzrtrgS7I1xMAAPRkpmj7h7MZwpyKMNUo2J4y6b/AO+ 0V7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VfHRud4v; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a63dc01000000b004fd10490f3dsi22577354pgg.251.2023.03.30.04.41.11; Thu, 30 Mar 2023 04:41:24 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VfHRud4v; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231708AbjC3Ljb (ORCPT + 99 others); Thu, 30 Mar 2023 07:39:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231699AbjC3LjF (ORCPT ); Thu, 30 Mar 2023 07:39:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 490F09EED for ; Thu, 30 Mar 2023 04:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680176237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2HaaAMVXBOU9npIKRCm63G2Jnf2K0Y8PRLMtIL+XBWM=; b=VfHRud4vELd/er8WxjV8lPowyh6/3jz3VruPh1SOC4snLi2AvXqlzAP0umk0D0wCHEzHcJ EB5G0qktYQ5ItdcusXiwQ17qu0UxQs3ZBSM4SYnFuI+DKDcinJb2XP656xlZsqesaJ0R4m Cu3thaZyQ9zFqSNuTq6tQ0U4Qdo7LxY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-281-Rhj8dw_eM82Bc3Cpkq4GXA-1; Thu, 30 Mar 2023 07:37:14 -0400 X-MC-Unique: Rhj8dw_eM82Bc3Cpkq4GXA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD54888B7A2; Thu, 30 Mar 2023 11:37:13 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4F83202701F; Thu, 30 Mar 2023 11:37:12 +0000 (UTC) From: Ming Lei To: Jens Axboe , io-uring@vger.kernel.org, linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Miklos Szeredi , ZiyangZhang , Xiaoguang Wang , Bernd Schubert , Pavel Begunkov , Stefan Hajnoczi , Dan Williams , Ming Lei Subject: [PATCH V6 07/17] block: ublk_drv: add common exit handling Date: Thu, 30 Mar 2023 19:36:20 +0800 Message-Id: <20230330113630.1388860-8-ming.lei@redhat.com> In-Reply-To: <20230330113630.1388860-1-ming.lei@redhat.com> References: <20230330113630.1388860-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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?1761792737196021687?= X-GMAIL-MSGID: =?utf-8?q?1761792737196021687?= Simplify exit handling a bit, and prepare for supporting fused command. Reviewed-by: Ziyang Zhang Signed-off-by: Ming Lei --- drivers/block/ublk_drv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index c73cc57ec547..bc46616710d4 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -655,14 +655,15 @@ static void ublk_complete_rq(struct request *req) struct ublk_queue *ubq = req->mq_hctx->driver_data; struct ublk_io *io = &ubq->ios[req->tag]; unsigned int unmapped_bytes; + blk_status_t res = BLK_STS_OK; /* failed read IO if nothing is read */ if (!io->res && req_op(req) == REQ_OP_READ) io->res = -EIO; if (io->res < 0) { - blk_mq_end_request(req, errno_to_blk_status(io->res)); - return; + res = errno_to_blk_status(io->res); + goto exit; } /* @@ -671,10 +672,8 @@ static void ublk_complete_rq(struct request *req) * * Both the two needn't unmap. */ - if (req_op(req) != REQ_OP_READ && req_op(req) != REQ_OP_WRITE) { - blk_mq_end_request(req, BLK_STS_OK); - return; - } + if (req_op(req) != REQ_OP_READ && req_op(req) != REQ_OP_WRITE) + goto exit; /* for READ request, writing data in iod->addr to rq buffers */ unmapped_bytes = ublk_unmap_io(ubq, req, io); @@ -691,6 +690,10 @@ static void ublk_complete_rq(struct request *req) blk_mq_requeue_request(req, true); else __blk_mq_end_request(req, BLK_STS_OK); + + return; +exit: + blk_mq_end_request(req, res); } /*