From patchwork Fri Jun 23 22:55:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291449 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 37243EB64D7 for ; Fri, 23 Jun 2023 22:55:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AC1F8D000C; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6378B8D0001; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 439398D000C; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 28C568D0001 for ; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D461C140350 for ; Fri, 23 Jun 2023 22:55:54 +0000 (UTC) X-FDA: 80935521828.25.5D7371F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 3D06E100003 for ; Fri, 23 Jun 2023 22:55:53 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WXgHJBr8; spf=pass (imf14.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=1687560953; 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=3eD9cwJhfzpjqArgDx6+FQer5AVxYbVfQjKZhNYJ+UE=; b=WLnszgopBn0AGaBxxpVOqrjq2QEXsKaQFNt5PKPsltHPri/OevJGPPTtYcHsm7BRhX/5OF BXt2faq8f2rRlGKou+ZolWACpqv8OT/RstGSEmymRASA1lVoDa7ffJvOeiJaRUQhWhKzhK WC1cg+ufXuopaFDPTwCv0q8lyD/qAvo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560953; a=rsa-sha256; cv=none; b=aIhbVQ3RLmRPzsaH0LsW6AEllPpVPJiDgjZRWTRFSq2qrKd/4atbbQTivtDt+XWlNkmTyT pVVPc8Uepiac9gWBz/E3IXHEGcXbV62OmRAKURwGABdNp4NkDS/h71rMUcrxM/DLHZU/35 JXuzb6MFbH8A63eGDAz1y4tVj9b+74s= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WXgHJBr8; spf=pass (imf14.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=1687560952; 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=3eD9cwJhfzpjqArgDx6+FQer5AVxYbVfQjKZhNYJ+UE=; b=WXgHJBr8ZTgmwztLr9R18HkFzWlrphe4gtwMCq9LhcX7o0uW8yPXJKynruzAjtnHMC9Nuz XFaRbLRyUkykxPg5nGNmUM0SPP6LnwKIl1Ig0+k+rQLkQVvXrrPFiYHvejWs8nRbU9XjWn PtoyoQwjGtbj9xMxNfWCGX4IqEf0Wic= 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-632-PTJ_wQD9ObaVu43jKmpMaw-1; Fri, 23 Jun 2023 18:55:49 -0400 X-MC-Unique: PTJ_wQD9ObaVu43jKmpMaw-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 17CAE3C0BE35; Fri, 23 Jun 2023 22:55:48 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id CEDA91400C35; Fri, 23 Jun 2023 22:55:45 +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 , Lee Duncan , Chris Leech , "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 11/16] scsi: iscsi_tcp: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 23 Jun 2023 23:55:08 +0100 Message-ID: <20230623225513.2732256-12-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.7 X-Rspamd-Queue-Id: 3D06E100003 X-Rspam-User: X-Rspamd-Server: r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GjlI+vzEkirW9zIXqClUr8BYJl9zJpI+RItnEb+M0z/A/dqcPIY+Dkqa5f2FOEz4V6aNKi/sH2QSxlgIA5BbAtALHKJLZalr20BBOLA/wH+CeI9PS5HChYEebED5F4rC7+bIZXe+gpryPHumW73qIdfXfMEm3yCvtmTBb2TLfeN5aTZYx3W5ZTbLycmwSq/PPbruHEkf4c9vngRzJm84EKo3xLt3uQlF40MkBz4EksVMk1rhJW8HeHi2HIj3mUWwaGjrYgQQntMj8LkfDytzCuv8V0yLy4EtyNnWNgTJavO33dLFlnP2DHHbylHoioULTZnByfsjznu01ZfzxDzVjlBna3S+l+pTLglgMl81EYqLJMNo+JQaYMRKHnPfv2Re8Q5imfYYqDeirDkNEyrh6QmXKftbKGXiJcB8dxVv9FUolERMw0eZDdnI5JdDmeOlw4VbBJXvs6EUYMN7Px2gJagCMoUKTamxc/BmErqRGiTl8z8MH9nKNVXb28UyifKp3Ffn9JtTkRV2xSkbnipCfzZnYdzgcF6+JEF0dwtd21H5exI26KY2kQvX7dnTXL0NwL5soZqSbXb8VjmnKnhKW+dcGHlxlK78cUocZbfFQp4uiIqZK92sMI+BJf1jQycqak2r6sAJdgTqG9QYkXCk8ATE5YrkHzsSsUIf0XFEZyPMOTjS3k+20PxztOQRTugSnHuj1ovHOAZBtjXx2hxpZOTQ== 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. Signed-off-by: David Howells Reviewed-by: Mike Christie cc: Lee Duncan cc: Chris Leech 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 Reviewed-by: Chris Leech --- Notes: ver #5) - Split iscsi changes into client and target patches drivers/scsi/iscsi_tcp.c | 26 ++++++++++---------------- drivers/scsi/iscsi_tcp.h | 2 -- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 9637d4bc2bc9..9ab8555180a3 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -301,35 +301,32 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn, while (!iscsi_tcp_segment_done(tcp_conn, segment, 0, r)) { struct scatterlist *sg; + struct msghdr msg = {}; + struct bio_vec bv; unsigned int offset, copy; - int flags = 0; r = 0; offset = segment->copied; copy = segment->size - offset; if (segment->total_copied + segment->size < segment->total_size) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; if (tcp_sw_conn->queue_recv) - flags |= MSG_DONTWAIT; + msg.msg_flags |= MSG_DONTWAIT; - /* Use sendpage if we can; else fall back to sendmsg */ if (!segment->data) { + if (!tcp_conn->iscsi_conn->datadgst_en) + msg.msg_flags |= MSG_SPLICE_PAGES; sg = segment->sg; offset += segment->sg_offset + sg->offset; - r = tcp_sw_conn->sendpage(sk, sg_page(sg), offset, - copy, flags); + bvec_set_page(&bv, sg_page(sg), copy, offset); } else { - struct msghdr msg = { .msg_flags = flags }; - struct kvec iov = { - .iov_base = segment->data + offset, - .iov_len = copy - }; - - r = kernel_sendmsg(sk, &msg, &iov, 1, copy); + bvec_set_virt(&bv, segment->data + offset, copy); } + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bv, 1, copy); + r = sock_sendmsg(sk, &msg); if (r < 0) { iscsi_tcp_segment_unmap(segment); return r; @@ -746,7 +743,6 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session, sock_no_linger(sk); iscsi_sw_tcp_conn_set_callbacks(conn); - tcp_sw_conn->sendpage = tcp_sw_conn->sock->ops->sendpage; /* * set receive state machine into initial state */ @@ -777,8 +773,6 @@ static int iscsi_sw_tcp_conn_set_param(struct iscsi_cls_conn *cls_conn, return -ENOTCONN; } iscsi_set_param(cls_conn, param, buf, buflen); - tcp_sw_conn->sendpage = conn->datadgst_en ? - sock_no_sendpage : tcp_sw_conn->sock->ops->sendpage; mutex_unlock(&tcp_sw_conn->sock_lock); break; case ISCSI_PARAM_MAX_R2T: diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h index 68e14a344904..89a6fc552f0b 100644 --- a/drivers/scsi/iscsi_tcp.h +++ b/drivers/scsi/iscsi_tcp.h @@ -47,8 +47,6 @@ struct iscsi_sw_tcp_conn { /* MIB custom statistics */ uint32_t sendpage_failures_cnt; uint32_t discontiguous_hdr_cnt; - - ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int); }; struct iscsi_sw_tcp_host {