Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13126440rwd; Fri, 23 Jun 2023 16:24:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zvVk5mkD1YsvgvvwWQHiXVtC8jNsAr9kCRl1tD40gC+d4y8bpZSE56oATImjRX3oTrkXx X-Received: by 2002:a05:6a20:918e:b0:11d:1b15:4d28 with SMTP id v14-20020a056a20918e00b0011d1b154d28mr31862746pzd.4.1687562694543; Fri, 23 Jun 2023 16:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687562694; cv=none; d=google.com; s=arc-20160816; b=VjFgc9XqHtvNeqvBTk2EWlLOtEe2tmWFi3y3ypyMZLUyuHz15yAZAknw6hogsF60cg BgEE/ts0OtKcIZbWQJdJaBscvMHtgyoL0p9DupPcYp4N7ypv2H7UZ0PwcJpxjC5sgx+f 19HIH/e1PSnaxdz5pYqnQjVnWfk+Ne8PDdy6FxSuC8FB05W1Gwgvv+XK0hSLdma1Qtu9 j1GJthLzHLZe7xm5/hSnKyUDDbgUV0GckoTTd6zjc9XeVnduFg9Abc9CxAffbSK+bzMA og9wE6FLp+v7IRc2IGINPBdtpCGb7Zni/x6aOLoS3xzAGdSG0wIuqZPptfNl/P6FWPjz roQQ== 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=aZHrq272u78M4jQRc62xjzOjs56TE9G5qctmKlgdkdo=; fh=XUChReT89AZKXR03O6N6VkxruTzZ2h/XkDMXq6NaZQc=; b=e+nSTTmf8OxFHA53w2ZjB6LBB0m2/5fNs7ooQP+JkOf7lZMWTYdISyhqSTWb5zx++O GuYYIHHV9FGPnTRRX2Dy39sb79g7u72vRf3V6PDmRBim+i6oNWNf3iFWazLJlPemKV8W Ha2svntnES12gPjKn2Oto+/ifAjE34A8QzZ2wxPGs1JEpcNBOOwCPSW2VSGMPoeTnM5o 3iFUo78uu7p8Cd22IDVc19uUVYPAbFU4goruncKWs8pYblwY7wmnE8gCIcZanxFFCtr6 9OtKPRM5zBbtpyz1U68/wc2QcZ2dQTZBXn2fwvcBMsUQBBeQt+O7dNK8JirVhTN0brjG R7cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VX7jgF8D; 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 w26-20020a63475a000000b0055117ae3878si425257pgk.324.2023.06.23.16.24.42; Fri, 23 Jun 2023 16:24:54 -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=VX7jgF8D; 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 S232638AbjFWW5f (ORCPT + 99 others); Fri, 23 Jun 2023 18:57:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232588AbjFWW5Q (ORCPT ); Fri, 23 Jun 2023 18:57:16 -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 22191294D for ; Fri, 23 Jun 2023 15:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560955; 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=aZHrq272u78M4jQRc62xjzOjs56TE9G5qctmKlgdkdo=; b=VX7jgF8DuIsW845vzo3g87Z9nxrIUL6ik2KQptJCxtFXGhKpVWC5kvIXTNS0muFZNQhJoY 9J7knIeGaBAz/irAO0ZJehhNojq2fsJJp4TMBHTQDMJTmNObbUa3pW0HVPCVJmUgHVgzbP ngthUl8w1M3pqV9iiwWAX+Shj9aBQtY= 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-90-ADNZXf0mNHmnFJ3WbtgVaQ-1; Fri, 23 Jun 2023 18:55:52 -0400 X-MC-Unique: ADNZXf0mNHmnFJ3WbtgVaQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA1AE2A2AD56; Fri, 23 Jun 2023 22:55:50 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6FB340C2063; Fri, 23 Jun 2023 22:55:48 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Christie , Maurizio Lombardi , "James E.J. Bottomley" , "Martin K. Petersen" , Al Viro , open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH net-next v5 12/16] scsi: target: iscsi: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 23 Jun 2023 23:55:09 +0100 Message-ID: <20230623225513.2732256-13-dhowells@redhat.com> In-Reply-To: <20230623225513.2732256-1-dhowells@redhat.com> References: <20230623225513.2732256-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Use sendmsg() with MSG_SPLICE_PAGES rather than sendpage. This allows multiple pages and multipage folios to be passed through. TODO: iscsit_fe_sendpage_sg() should perhaps set up a bio_vec array for the entire set of pages it's going to transfer plus two for the header and trailer and page fragments to hold the header and trailer - and then call sendmsg once for the entire message. Signed-off-by: David Howells cc: Mike Christie cc: Maurizio Lombardi cc: "James E.J. Bottomley" cc: "Martin K. Petersen" cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: Al Viro cc: open-iscsi@googlegroups.com cc: linux-scsi@vger.kernel.org cc: target-devel@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #5) - Split iscsi changes into client and target patches ver #2) - Wrap lines at 80. drivers/target/iscsi/iscsi_target_util.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index b14835fcb033..6231fa4ef5c6 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -1129,6 +1129,8 @@ int iscsit_fe_sendpage_sg( struct iscsit_conn *conn) { struct scatterlist *sg = cmd->first_data_sg; + struct bio_vec bvec; + struct msghdr msghdr = { .msg_flags = MSG_SPLICE_PAGES, }; struct kvec iov; u32 tx_hdr_size, data_len; u32 offset = cmd->first_data_sg_off; @@ -1172,17 +1174,18 @@ int iscsit_fe_sendpage_sg( u32 space = (sg->length - offset); u32 sub_len = min_t(u32, data_len, space); send_pg: - tx_sent = conn->sock->ops->sendpage(conn->sock, - sg_page(sg), sg->offset + offset, sub_len, 0); + bvec_set_page(&bvec, sg_page(sg), sub_len, sg->offset + offset); + iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, sub_len); + + tx_sent = conn->sock->ops->sendmsg(conn->sock, &msghdr, + sub_len); if (tx_sent != sub_len) { if (tx_sent == -EAGAIN) { - pr_err("tcp_sendpage() returned" - " -EAGAIN\n"); + pr_err("sendmsg/splice returned -EAGAIN\n"); goto send_pg; } - pr_err("tcp_sendpage() failure: %d\n", - tx_sent); + pr_err("sendmsg/splice failure: %d\n", tx_sent); return -1; }