Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4560896rwl; Tue, 28 Mar 2023 08:24:42 -0700 (PDT) X-Google-Smtp-Source: AKy350Y3eCGX0ieVbT1ZAXtO7gOgZMbrCm4hgKkjqCdsBIUDVKBOsc/5ndPZ6hJEPTp+TalSMvk+ X-Received: by 2002:a17:906:1685:b0:930:660d:8f92 with SMTP id s5-20020a170906168500b00930660d8f92mr17235221ejd.52.1680017081922; Tue, 28 Mar 2023 08:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680017081; cv=none; d=google.com; s=arc-20160816; b=Im/JqNyS5+3WBehzrjYCwiLoIXyVeAXVGtwaTdCpLjcfIogfV3P93EO4X8neD8Jqj+ E7zZutav6uSJ/mpYTS+myZOHzDvSWNzwVztT4k3IfGqEhli5yoxMv5ng+h2vpCuj75QC j3WScnlDj6tce78lWWSmCu11KXEyZP2SllkxGkUPe/ORK3xywC5O4MoQ53/i4n3w85TU yUirchU0YimJ5PCFmykeizTDk0w3QxIinq6fvqoC/aH2cUMrZmRNKn9IiKisfKyqbjm/ 3WQRSasePEw9Lq3QaiUDgfI7aobFDyaLzfW9blTTtTBAWmiNdl8+YsdIOgrv/kBAJwDB senw== 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=UmnfDkTw7ovYJXB+g6IpB9SV6YU2Mth9Crg/LUE0D4LBPytTt3RbCCz6o0rMk1gqzE ijZKRgtfKfhQZm4npRmgCTwpjuY9uVP/1lPq+/mtPVYXkio38O88RTAkD5T48DoY1Tv2 tiHrBZ4JxsId8i7PuHyF8dLSB5gbOWoR7PwwiYSVrrDidhhKAPyy3wWCWGsZT9zcQdaR pV19h1hGbUO9NzaVo8Ist/B3WDj7cQjUlCylViQeAAQlkXoYe3jqI+oplwv4hj+2QJ0k WjG5SUfuN5gyPH83mWMz0Entu3m64WOGEotui8hk7/l7EA1hQaRUEbrzuNpMsUEGvnpK QC6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a013+mhG; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pv7-20020a170907208700b009314f2c4e80si26107362ejb.873.2023.03.28.08.24.16; Tue, 28 Mar 2023 08:24:41 -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=a013+mhG; 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 S233386AbjC1PSD (ORCPT + 99 others); Tue, 28 Mar 2023 11:18:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233010AbjC1PRc (ORCPT ); Tue, 28 Mar 2023 11:17:32 -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 CDFDF10423 for ; Tue, 28 Mar 2023 08:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680016500; 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=a013+mhGXq/5KosL/zRRFwMQ7pByfNEnJbMlP3imWYCzL130N1Sfz3dOUg0ibEIsgbAwDF 72FhrjRoxywQc/5y1b9KGakppX5KMPfzupJg+ZDC7Ga4FhzA9wAbiBp9A+VCHH4y5u9t60 vDqn1sQ4chfYt7FDrv0SbtmS6oV+Ars= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-380-EKSnFKTlNW2-26zE5_Z4xw-1; Tue, 28 Mar 2023 11:11:23 -0400 X-MC-Unique: EKSnFKTlNW2-26zE5_Z4xw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D375E38149CC; Tue, 28 Mar 2023 15:11:21 +0000 (UTC) Received: from localhost (ovpn-8-20.pek2.redhat.com [10.72.8.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E684D4020C83; Tue, 28 Mar 2023 15:11:15 +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 V5 06/16] block: ublk_drv: add common exit handling Date: Tue, 28 Mar 2023 23:09:48 +0800 Message-Id: <20230328150958.1253547-7-ming.lei@redhat.com> In-Reply-To: <20230328150958.1253547-1-ming.lei@redhat.com> References: <20230328150958.1253547-1-ming.lei@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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 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); } /* -- 2.39.2