From patchwork Tue Mar 28 15:09:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 76143 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2314040vqo; Tue, 28 Mar 2023 08:41:00 -0700 (PDT) X-Google-Smtp-Source: AKy350Y03Rt2Dmy0Zyg7vTRei86uoviWGHF4sQOy5Vo2Je3g/z2+206h3xL4Zj2PM51CKJYxtVSD X-Received: by 2002:aa7:d50e:0:b0:502:1cd3:d0fb with SMTP id y14-20020aa7d50e000000b005021cd3d0fbmr15976058edq.20.1680018059870; Tue, 28 Mar 2023 08:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680018059; cv=none; d=google.com; s=arc-20160816; b=nG6GnbAeKVZU7mE7QqV4qp+8SpaIYMgLGcs0KGnKajfzdUKGzTZY6i5PAsp/L0c8V2 /vFQZwX3Z6LCMopFTFhWo0yPvSWrxeb2lJC1fyHGDTEMI71H6C0GItpHqkKMnKl0RFLt UimvCpsVS61hNLh7JPiigPaNJimhVUrnHSQ2zk9GdOQ1QqVpMZXUD0mq05NnP5Eo3Pdk ZLntbo2NMqy9dVnAaxzlOmwoiuilbUUl2MF3DcLKlvm1orc6uHQHofYH4S0Q5OTAPBiz SoVfz9DWxm02pl7MYX8rTz2DXJ1wJzTb7Nzc7lu1SzBABD+y94hNZovsxn5mxLG9Mmvr kc2g== 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=lzFlB5kGsJuuszceCewof5xYnczQcl6NgLt+NqBNBds=; b=GHG0c/xJ3GUl5XIISwAsc7NI6WGvH7BATXPPuVBTyLVrrQB8cUMyDwgjRgHBBZvpvx RVQhJigpLSylFPT+kRbbr9gQiUphv70/LRGKVgYcRGIGQRsvlsWKdiO64tPyczW/9iBo qWo71GRAvMkXsieXqYbYocfR8mS+0quyu103eOHsz0MM8QrLt6C9rGZFj0HPRr7MeYxC bzAuOQeKx17P6qyxdGCRvqFdBU/aHVd91a6VBlM+MaRE6Dau3+7+yiSUvjYYhy6NBc4A Uw3iVegm7Jn5KYr82dJu3WjwHhjXuBe2JYC/6nhwbyw4je91ERAkoR4KG+H7otwBzGE/ +e1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YQZV5Ywr; 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 y8-20020a50e608000000b004ad4c17aa75si30466916edm.425.2023.03.28.08.40.36; Tue, 28 Mar 2023 08:40:59 -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=YQZV5Ywr; 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 S233067AbjC1P2w (ORCPT + 99 others); Tue, 28 Mar 2023 11:28:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233023AbjC1P2X (ORCPT ); Tue, 28 Mar 2023 11:28:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90F08FF13 for ; Tue, 28 Mar 2023 08:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680017161; 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=lzFlB5kGsJuuszceCewof5xYnczQcl6NgLt+NqBNBds=; b=YQZV5YwrP3jnWgVjoG9LxDrarpwf0Im1ll8kmCbiG874bdo3ZnvCnWuvqfcSISvmcwrj41 LTPYlqqy34tvaPzo4JF/z1zcW28vnlrTeRGLPMvrFI7D2Z96haEULEBTTucUhWp3WKfjwi 2lHXaPZOE9oEXAgyiyk5Usng4Q8RWsE= 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-18-QzwG27TSP_qmvEwynYE1dQ-1; Tue, 28 Mar 2023 11:11:12 -0400 X-MC-Unique: QzwG27TSP_qmvEwynYE1dQ-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 0BF0E801206; Tue, 28 Mar 2023 15:11:09 +0000 (UTC) Received: from localhost (ovpn-8-20.pek2.redhat.com [10.72.8.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 190334020C82; Tue, 28 Mar 2023 15:11:01 +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 04/16] io_uring: support OP_READ/OP_WRITE for fused secondary request Date: Tue, 28 Mar 2023 23:09:46 +0800 Message-Id: <20230328150958.1253547-5-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761626617381504594?= X-GMAIL-MSGID: =?utf-8?q?1761626617381504594?= Start to allow fused secondary request to support OP_READ/OP_WRITE, and the buffer can be retrieved from the primary request. Once the secondary request is completed, the primary request buffer will be returned back. Signed-off-by: Ming Lei --- io_uring/opdef.c | 4 ++++ io_uring/rw.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/io_uring/opdef.c b/io_uring/opdef.c index 63b90e8e65f8..d81c9afd65ed 100644 --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -235,6 +235,8 @@ const struct io_issue_def io_issue_defs[] = { .ioprio = 1, .iopoll = 1, .iopoll_queue = 1, + .fused_secondary = 1, + .buf_dir = WRITE, .prep = io_prep_rw, .issue = io_read, }, @@ -248,6 +250,8 @@ const struct io_issue_def io_issue_defs[] = { .ioprio = 1, .iopoll = 1, .iopoll_queue = 1, + .fused_secondary = 1, + .buf_dir = READ, .prep = io_prep_rw, .issue = io_write, }, diff --git a/io_uring/rw.c b/io_uring/rw.c index 5431caf1e331..d25eeee67c65 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -19,6 +19,7 @@ #include "kbuf.h" #include "rsrc.h" #include "rw.h" +#include "fused_cmd.h" struct io_rw { /* NOTE: kiocb has the file as the first member, so don't do it here */ @@ -371,6 +372,18 @@ static struct iovec *__io_import_iovec(int ddir, struct io_kiocb *req, size_t sqe_len; ssize_t ret; + /* + * fused_secondary OP passes buffer offset from sqe->addr actually, since + * the fused cmd buf's mapped start address is zero. + */ + if (req->flags & REQ_F_FUSED_SECONDARY) { + ret = io_import_buf_for_secondary(rw->addr, rw->len, ddir, + iter, req); + if (ret) + return ERR_PTR(ret); + return NULL; + } + if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED) { ret = io_import_fixed(ddir, iter, req->imu, rw->addr, rw->len); if (ret) @@ -443,11 +456,19 @@ static inline loff_t *io_kiocb_ppos(struct kiocb *kiocb) */ static ssize_t loop_rw_iter(int ddir, struct io_rw *rw, struct iov_iter *iter) { + struct io_kiocb *req = cmd_to_io_kiocb(rw); struct kiocb *kiocb = &rw->kiocb; struct file *file = kiocb->ki_filp; ssize_t ret = 0; loff_t *ppos; + /* + * Fused secondary req hasn't user buffer, so ->read/->write can't + * be supported + */ + if (req->flags & REQ_F_FUSED_SECONDARY) + return -EOPNOTSUPP; + /* * Don't support polled IO through this interface, and we can't * support non-blocking either. For the latter, this just causes