From patchwork Fri Jun 23 22:55:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0619EB64D7 for ; Fri, 23 Jun 2023 22:56:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BD6B8D000F; Fri, 23 Jun 2023 18:56:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 71EDA8D0001; Fri, 23 Jun 2023 18:56:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54D218D000F; Fri, 23 Jun 2023 18:56:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 386CF8D0001 for ; Fri, 23 Jun 2023 18:56:01 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0AB1912036E for ; Fri, 23 Jun 2023 22:56:01 +0000 (UTC) X-FDA: 80935522122.18.E5E7CE3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 5892540016 for ; Fri, 23 Jun 2023 22:55:59 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Kh7J2tYb; spf=pass (imf07.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560959; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aZHrq272u78M4jQRc62xjzOjs56TE9G5qctmKlgdkdo=; b=2DHFomMC63ltBJtrU2uZsl+D7t2aLXXuQKXdz10RbRPBZfmkE1E3dZ4PwOejjRa2qd2NzO tpsaPGLnYx7aAVdcXarrwnO8lsexuWVqzAVHIFT/iuMmwmTPF74ogDxA9Mo/r2KNZA0cQ6 H/kKtpxzzqU5RDQmC4iwCaTfKapuzhM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560959; a=rsa-sha256; cv=none; b=Pz3OP06pQS2pHUySUKVwrpQP1rTkU/2Iv/PFwZX1lvYtjX/tjQoGaLiri+wLjh/Q4nWSar Mn/qLumvDWvT7tkcbDxnudOWVLhGIPz9bM0D3LSj10p0AqJiRF9CvOgru18+EcvPMVQPPK 8Lp4iOq6S3XwQP+9IEG6hD+GCoB4r+o= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Kh7J2tYb; spf=pass (imf07.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560958; 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=Kh7J2tYbxh4f9Lhj2mCsWXMV+WCv7BPl6/mAZZJ05tn9NTo2pDwYZ4PLmIbKTHedjWsYEr q3UEHFp8mrYJ0wOqlSpzycW2lV2iIUtGl34dHi4I5KE6aRGMGknP/f9QtW+z2qySxIFxEw +HCAS3Ak4ON6xLsZdqtG9lL/sm15Y5Y= 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: 5892540016 X-Rspam-User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Mb/8fuir4SgL635oN7DTsGt5UJ3clOmFe4p0TSroMP9LSpHxgGDrMYV+HWGdwbNDLSldnol5DPfnS6+fMgMCG+DbNij0/pGggKk0oDMKoBHfQXVWR2XBWi591zuG4+ZAJtun7Ec8sNUl2W4VcqDSmsqWzPikNX7izu+xpbQ2iWu6KaXr6aWsmJjU67MKtLaaLxlkGXRcaCY2sE0JhkwZwXL3+slJ2UZzMRQzDS4KHBdWVmeNZctZ42V2l/n+U7Dwid+i1iIh4FSU5G+Eoi23GyU1qMdHGkcM0j9mMKmYydXMR+3BCx1rYF/BNVYOTe5dt2at5KbovZvYBySGfnHQ9pxT//8PP3IGRO2hWGfErmHWl0cllEV49lW5R2EIhhVpQp1L/ePURH9zVEvKlVhl0/astJQJaqw9ar712K2eHmO7ZD3/QKlKTv6W7PIs+vQ9Gq15z5RRoZ1ETmQis6A6r5+XH470U9M5V2+hY5JrhE19gT1bVhwwQS/2ymq1LUHAR/4uEca1T4hLYo3Qo+dG8AriXvg9DVN7yz61e6vUdMPJud29cWS1Ur34LuTU+nxkJh4q1VvSIzV0mUwItpjg9DZfj3xxp5pNrdd+QykLhZMCe500qnVjOr7ua0Ahq/+8vHZJcqEygjgvC34xQD3gi/sKQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; }