Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4587298rwl; Tue, 28 Mar 2023 08:44:17 -0700 (PDT) X-Google-Smtp-Source: AK7set8bj9mS0QfmvWnp9ApCGUq4kvxuew2yBda+FqG7jOlYDmvdtjGzQR1PHDv4P01/MlgAx0R1 X-Received: by 2002:a05:6a20:718a:b0:d9:a792:8e3d with SMTP id s10-20020a056a20718a00b000d9a7928e3dmr14275468pzb.30.1680018257136; Tue, 28 Mar 2023 08:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680018257; cv=none; d=google.com; s=arc-20160816; b=KtgwxwhJ2MhGPmh4Acku3fTopjAiDezTgLyweTESa8LbGtMbpQJYERZDLpW6d/JYHp xTX9/UjSnppR37/8WgKa0UC0pbfIZDmuF/a2Oi5ZRqVg9o+Jo6BQZWZE/xZEquLtlg6a emnUr9zEa62g4JVW6DTo96FUtKEog51TZQmE6xlFLEsf5AvjlpMQ28B3P6mx85/uARXo qQN1S78ZusjSrB59oYa56uKtOWS4LfUSZLjvw/qwPxHhTTIZBqTP78+KxlTELjdha4d6 CTSUSJ2KynuWNX3cUE8z5t6FZoZmXHKz0IseIN8YO1oCV1LcNNM+hbhrpfrr7WsfhCOY gj1w== 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=a+LP/eGObxESjSZtnTg8CVLgYRu7HZvCpWjJZDO48e4=; b=Z/2PWDSZNrfTa7RaQacrqS1KALECda9WvXptZXa6a3g3CeOfl1KECC0i5wllr6MKZE g2mt8TOtKqSqwPAuPzKbq8GzkDDMJVV505oMObmIRt4NGv7X1SjVeqPowgK8NbN0GfhU yPD9cNWsS5PjWGoFaoKOX9Va49VBJ7bcvOwiPKKcE70CTSWYmnM9b8Iopz1ODXVoakOX m2iO3/kG4hX4XrKFU6D2mB3ShNJ/XTd+aMXGWwqNLxDkMSjymdDnFMcBQCUN/cK7kUbB gzGsYXt72tEP/jMv3FzxbVYcDDYjsEo6PpYJ+QxLeXMOvrfRlKPYAPPPTOHd2gFfXZDB CIiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OfQcZ+jX; 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 fa16-20020a056a002d1000b005b9a30ee5a4si30174022pfb.116.2023.03.28.08.44.05; Tue, 28 Mar 2023 08:44:17 -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=OfQcZ+jX; 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 S234071AbjC1PjC (ORCPT + 99 others); Tue, 28 Mar 2023 11:39:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234070AbjC1PiT (ORCPT ); Tue, 28 Mar 2023 11:38:19 -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 86D4740CA for ; Tue, 28 Mar 2023 08:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680017787; 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=a+LP/eGObxESjSZtnTg8CVLgYRu7HZvCpWjJZDO48e4=; b=OfQcZ+jXTrBUWoX9WqQe+qCsLP40HO1WUNzMBzUzOJ9YRGpaM9TGDzpZsqiQGGlk7nUkYp +skjykt9OwsqbWMntTp4ZQt0nIuP/KzTInfO5c9QyJtyX98dWnTFlxm0fslUXcfuzgqE/+ 8JkIyWD0k7VvuvdpEyek/HpmEdpQ32M= 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-495-MWpvJGt3PZ2YlU4lp9woSA-1; Tue, 28 Mar 2023 11:11:58 -0400 X-MC-Unique: MWpvJGt3PZ2YlU4lp9woSA-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 6D7218028B2; Tue, 28 Mar 2023 15:11:57 +0000 (UTC) Received: from localhost (ovpn-8-20.pek2.redhat.com [10.72.8.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6355314171BD; Tue, 28 Mar 2023 15:11:56 +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 15/16] block: ublk_drv: don't check buffer in case of zero copy Date: Tue, 28 Mar 2023 23:09:57 +0800 Message-Id: <20230328150958.1253547-16-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.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 In case of zero copy, ublk server needn't to pre-allocate IO buffer and provide it to driver more. Meantime not set the buffer in case of zero copy any more, and the userspace can use pread()/pwrite() to read from/write to the io request buffer, which is easier & simpler from userspace viewpoint. Signed-off-by: Ming Lei --- drivers/block/ublk_drv.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index 03ad33686808..a49b4de5ae1e 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -1410,25 +1410,30 @@ static int ublk_ch_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) if (io->flags & UBLK_IO_FLAG_OWNED_BY_SRV) goto out; /* FETCH_RQ has to provide IO buffer if NEED GET DATA is not enabled */ - if (!ub_cmd->addr && !ublk_need_get_data(ubq)) - goto out; + if (!ublk_support_zc(ubq)) { + if (!ub_cmd->addr && !ublk_need_get_data(ubq)) + goto out; + io->addr = ub_cmd->addr; + } io->cmd = cmd; io->flags |= UBLK_IO_FLAG_ACTIVE; - io->addr = ub_cmd->addr; - ublk_mark_io_ready(ub, ubq); break; case UBLK_IO_COMMIT_AND_FETCH_REQ: req = blk_mq_tag_to_rq(ub->tag_set.tags[ub_cmd->q_id], tag); + + if (!(io->flags & UBLK_IO_FLAG_OWNED_BY_SRV)) + goto out; /* * COMMIT_AND_FETCH_REQ has to provide IO buffer if NEED GET DATA is * not enabled or it is Read IO. */ - if (!ub_cmd->addr && (!ublk_need_get_data(ubq) || req_op(req) == REQ_OP_READ)) - goto out; - if (!(io->flags & UBLK_IO_FLAG_OWNED_BY_SRV)) - goto out; - io->addr = ub_cmd->addr; + if (!ublk_support_zc(ubq)) { + if (!ub_cmd->addr && (!ublk_need_get_data(ubq) || + req_op(req) == REQ_OP_READ)) + goto out; + io->addr = ub_cmd->addr; + } io->flags |= UBLK_IO_FLAG_ACTIVE; io->cmd = cmd; ublk_commit_completion(ub, ub_cmd); -- 2.39.2