Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1154314rwl; Fri, 24 Mar 2023 07:02:32 -0700 (PDT) X-Google-Smtp-Source: AKy350Zh8x/55muorBf6uIuJ/htfgQJQ1Dn/2tKK/r2O8haO9RLH9Yoj8EbzUd5M4FxSOqNJvtPR X-Received: by 2002:a17:906:298c:b0:933:37f4:2fe0 with SMTP id x12-20020a170906298c00b0093337f42fe0mr2776981eje.46.1679666552439; Fri, 24 Mar 2023 07:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679666552; cv=none; d=google.com; s=arc-20160816; b=LUlek/EoZMx8mWmpyTX3Ctx1FB252zoICP83EiJAdV3sqiknY41o5HYmLEDj53FRwl g12qLcDcmwuqAwZEUA+9H2EH0TsOl76MI5jnEdEfe7/DB0fc1Ev7dzqGBL6/x0P7hx75 6Mud6c6SwbC/xstkOiN+7IrK/Z5jLALSnUFTwb4aQ8rv1PGeMuKXhW+k6vNqbeYmLvJJ IntpTXeycIEHnMlxb+VWuaKj5rUoMeULKt9UQPWfyxTvUg7JcfBTXzR3rQfq/5TXWIKc 0vAd9ikRgFqbs4yTIJGP0iuzS8K5pLFfqPaKM+bWCdStK+3IVgczrzmyEshEn4U3p9MF S0YQ== 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=/5kegSRJea5mlNcvhsJOGDqb0HH/kL74VNa9/pI4EIA=; b=PMQxj8cHHwULAnDMOWZOifAvHH5sF3aVF/Mvmqu70nNXdLtLr9crqaWUYMnCprfUgV yUpFRfqBh33cJfxruWgGaQEaByBIcQG6EpyU9X6LAnBl9l4gVb5oD8CjA/WHxE2HyVOh QT1zhwpaI26OkkmAHMJiqBFnyi4D0DEkFTAIrHiRhHmIqzuhpovWqxtPEy1bMFrBuuP2 IG6Z5QJXgSqltuHlDkOnSAFhcYQRHeDKWDwpzXT898EjoU9Mqr/8i+QVv9TBUYQR6fH8 WOxbPVAt1VC2bdsv3Sp6pFjkxc5SvMUod+jaPc4V45KuI0nUF/u/oesATsHCB7qw8x6Z aYSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dMowBNlo; 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 hs40-20020a1709073ea800b008b3b05ca5ebsi26027677ejc.40.2023.03.24.07.02.05; Fri, 24 Mar 2023 07:02:32 -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=dMowBNlo; 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 S232119AbjCXOA2 (ORCPT + 99 others); Fri, 24 Mar 2023 10:00:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbjCXOAI (ORCPT ); Fri, 24 Mar 2023 10:00:08 -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 5251C1B2FB for ; Fri, 24 Mar 2023 06:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679666334; 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=/5kegSRJea5mlNcvhsJOGDqb0HH/kL74VNa9/pI4EIA=; b=dMowBNloT/lA6CggcVCePoHmYk6/hfDcweCsGo7Mzf/ogn4IO4U2V63Diqm3iKsSdPI1+J 200CHSVa1j9fuSO+CeEhxBAXm99zU06CfMvZLUQVisYLHpRKLEfbaM4YWTwC/Ck7ME413E u1uK37sMrNgGCXpM05K0IQbOuUiirCU= 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-153-aTjkxU65Pruc-MjMCMrXxw-1; Fri, 24 Mar 2023 09:58:47 -0400 X-MC-Unique: aTjkxU65Pruc-MjMCMrXxw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B1E19185A790; Fri, 24 Mar 2023 13:58:45 +0000 (UTC) Received: from localhost (ovpn-8-20.pek2.redhat.com [10.72.8.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2C69140EBF4; Fri, 24 Mar 2023 13:58:44 +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 , Ming Lei Subject: [PATCH V4 07/17] block: ublk_drv: add common exit handling Date: Fri, 24 Mar 2023 21:57:58 +0800 Message-Id: <20230324135808.855245-8-ming.lei@redhat.com> In-Reply-To: <20230324135808.855245-1-ming.lei@redhat.com> References: <20230324135808.855245-1-ming.lei@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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 fb5a557afde8..b8998ed87a0f 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