From patchwork Tue May 30 14:16:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13260165 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 17E85C7EE23 for ; Tue, 30 May 2023 14:17:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A77E96B0075; Tue, 30 May 2023 10:17:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A27AD280002; Tue, 30 May 2023 10:17:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EF7D280001; Tue, 30 May 2023 10:17:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 816AD6B0075 for ; Tue, 30 May 2023 10:17:11 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 48A1B16025D for ; Tue, 30 May 2023 14:17:11 +0000 (UTC) X-FDA: 80847123462.30.A7D98F7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id A1F12160026 for ; Tue, 30 May 2023 14:17:07 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="FklVq/qR"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685456227; 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=SrEG3Id6KDn/gSf5yv4D68QElxexhX3bro3X0CJ6lE8=; b=S7pnXE+Zm1YwLVpCkj3P+6nhQA5ooP6mk3nIJRXR1lpKOySPBPPmIAa8EOS1efbbaM9RW+ bzqZ1Ud2sfelAemStH86dgrRd7XoVkV/ds71R/MOgUGWWohtwo9U1ZgGORrxJiZbOY1+TG l400OPuZXEanjCos/uQLSmXJQ9mAi9g= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="FklVq/qR"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685456227; a=rsa-sha256; cv=none; b=DZL6IA9S+U55WzYX1SZPMVVLYoVnp2Ld8Hf0tQ22DV8+cDguX94ot4BZTgwzw3HAonBdgu IlqxX+eHN35eBUC4BLnVKMvidldVUttYdFNtWVvSegOSDb+1uc5KizSo3RXnIqx3cl3KOB 0m3x7IztsaY7hBgq/M9yacUNKtNRIIw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685456226; 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=SrEG3Id6KDn/gSf5yv4D68QElxexhX3bro3X0CJ6lE8=; b=FklVq/qRiZBILKfoFLWSaUDVfwxNUgCwbbH6/O2Bfs+9+xxm6b9gx0a641IsGB/QkIZPee OitTjMAy4gE7lxVfKCf3oi4mRyq9t187ROtt0ktFJUNdXaeZmmK8rPENZ1GOoluhvrZ/rz t5+NhTC8tL1RVUW/tNEyndbceQgMFmo= 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-662-GYtZWPrcPFKGze4E1bwesg-1; Tue, 30 May 2023 10:17:04 -0400 X-MC-Unique: GYtZWPrcPFKGze4E1bwesg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BAE3B3C0ED43; Tue, 30 May 2023 14:17:02 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46E7917103; Tue, 30 May 2023 14:16:57 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jeff Layton , Steve French , Shyam Prasad N , Rohith Surabattula , linux-cachefs@redhat.com, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH net-next v2 01/10] Drop the netfs_ prefix from netfs_extract_iter_to_sg() Date: Tue, 30 May 2023 15:16:25 +0100 Message-ID: <20230530141635.136968-2-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: A1F12160026 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: qq3gdjwdcmod6wsaoatcbypdoxpopjog X-HE-Tag: 1685456227-536419 X-HE-Meta: U2FsdGVkX19PECkON//pJIgHgv+RyqsoNzzljd38HEBNAK3T7wghBal5+feBmQ1rZc5IqYnsHedrozVg5MSACK4dAoCgvDK+mHSh8TZmIN5buDR2IYF+3BFsoXtepmfNP7V4BN4u22gySPcSyMVjipzLmdyDoJHRJW+hKxQsbmKNEUrhcvSiMuoJFSh5DxfExOfP0K3jtbM9hLCYGjaU9X12DDixPbT8l8Mbc7Ow6H/2OLLX+5SHU+KwWIzf9JzsG0poVju8fX9vLs+4j8fr6gM1zg0s2f8cjRGsi6+0Sw5udO82l177rMvVQo9wmCdIiJZlAJ7oHZl7OZbOVNIdaZvoqyTquY3k1XQ9abi8n8zS/ECq6fHl3PMjnPMAVxNc1YsVmJTQE9GEfN+YqaueFTVKMSya9Jn5Z9oCfDDvfR8Aa+e7pF+uh/PlfE/nfvmT6cpEBjC7Yfh00G1kLVy+IevyO1eWU7o4pIZEIxjHMQR8FjYDF41YOxEGvH8KR9XXiLukWTYKMUdHseBveXcpdMSxNb7umTMbEpYwf6rfMGqufQeT4yh4XYLH8uEFpoHu8k35vesQtABI2TZCHtAC1pdcop6P09K6CG4KNw29eIoX1czfJdkSogCVsGVUidIVgvAaH7y3YQVMeM8OyMmNQdxQ0tUziFsDxUr3KM6ffBaVzoylK9as223rjaTwBhZmyN8PGaxA00sBfUuAmmOQkgK7etEDUI67sfckNg4ZEPVQthirfDDdrur+CP+UY23u4MIv6dVI0WvvK0ze0VsmSz9TNRthnpc62eQ4+VfA4OY8pyl7WQ8QCJh9wVWWf1BlwCdchpd4YR5Zo9C8jJOJc8EH0ake+/72riiHBM/f5snAYwkeeE0WODUYjuC9ZcT/3CemiQOltCoNZ4j4pudoU6cnRkilkhVoGarAxBzHApG8IL+yiTjxMM5/VSaoColnQvGKALOF//drrX/72co 3MqBpReK atXfaWu5Lsy/9oZugeBRUbXOlP8eHdzKcxPaVLB72SttMRIskeQ6LZ6eGVqdbUjosxp1t/RPPvwcHOdIShyt9VDM/6driQD0bt8CBBZvds4LK5YHubiqSMq4gdVnJ7k1uRy5zIFmFoagtZt2ZvE2WnEo5Kfx/eQCEpYsAu1P6CsAtyemWIbGUT5M3AsN24MGhGyskURf1QgQlCsMzQz19l4VjVUz5hEkdAzHtATTZnNoptFjs91/RQQOwUVEs8FG6emsnlZKFgwFw/P2KoSTp3j49oQn6ZQnRgZOCjNAi+zfg1dOOVhpeCZluddVwjpoTO7SVGGmcy9a0dl0dX+cWGH/GIDpq3uSKIwWqAHPB3Wyui9+v+LVM/VThEUh5G2PYopInp2c0h4O03AZbhwbtJdNlIC2HwFuZ+Tv9rnEG51ET8zGtAxmWW83ULfA8UZEUJzrfh5L0swU8sH2y+HLe2u1+PZC5q+8N0UM/hFXvmF5uOLQFLsSpAuPHD/xjhLmSY9AACzj6yX2PdWBRPr7bTz72LiC/Qy/gEyUKGMVfIqF+JCt/l67QRXGA+RmNw6/rGOl9xYbzzBM0XIoWr0DZ7tFs9fMC+Qr3l5Ms2BboUHUkeEia97j5HkOks1RvqFjtj30G 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: Rename netfs_extract_iter_to_sg() and its auxiliary functions to drop the netfs_ prefix. Signed-off-by: David Howells cc: Jeff Layton cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jens Axboe cc: Herbert Xu cc: "Matthew Wilcox (Oracle)" cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: linux-crypto@vger.kernel.org cc: linux-cachefs@redhat.com cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #2: - Put the "netfs_" prefix removal first to shorten lines and avoid checkpatch 80-char warnings. fs/cifs/smb2ops.c | 4 +-- fs/cifs/smbdirect.c | 2 +- fs/netfs/iterator.c | 66 +++++++++++++++++++++---------------------- include/linux/netfs.h | 6 ++-- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 5065398665f1..2a0e0a7f009c 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -4334,8 +4334,8 @@ static void *smb2_get_aead_req(struct crypto_aead *tfm, struct smb_rqst *rqst, } sgtable.orig_nents = sgtable.nents; - rc = netfs_extract_iter_to_sg(iter, count, &sgtable, - num_sgs - sgtable.nents, 0); + rc = extract_iter_to_sg(iter, count, &sgtable, + num_sgs - sgtable.nents, 0); iov_iter_revert(iter, rc); sgtable.orig_nents = sgtable.nents; } diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index 0362ebd4fa0f..223e17c16b60 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -2227,7 +2227,7 @@ static int smbd_iter_to_mr(struct smbd_connection *info, memset(sgt->sgl, 0, max_sg * sizeof(struct scatterlist)); - ret = netfs_extract_iter_to_sg(iter, iov_iter_count(iter), sgt, max_sg, 0); + ret = extract_iter_to_sg(iter, iov_iter_count(iter), sgt, max_sg, 0); WARN_ON(ret < 0); if (sgt->nents > 0) sg_mark_end(&sgt->sgl[sgt->nents - 1]); diff --git a/fs/netfs/iterator.c b/fs/netfs/iterator.c index 8a4c86687429..f8eba3de1a97 100644 --- a/fs/netfs/iterator.c +++ b/fs/netfs/iterator.c @@ -106,11 +106,11 @@ EXPORT_SYMBOL_GPL(netfs_extract_user_iter); * Extract and pin a list of up to sg_max pages from UBUF- or IOVEC-class * iterators, and add them to the scatterlist. */ -static ssize_t netfs_extract_user_to_sg(struct iov_iter *iter, - ssize_t maxsize, - struct sg_table *sgtable, - unsigned int sg_max, - iov_iter_extraction_t extraction_flags) +static ssize_t extract_user_to_sg(struct iov_iter *iter, + ssize_t maxsize, + struct sg_table *sgtable, + unsigned int sg_max, + iov_iter_extraction_t extraction_flags) { struct scatterlist *sg = sgtable->sgl + sgtable->nents; struct page **pages; @@ -159,11 +159,11 @@ static ssize_t netfs_extract_user_to_sg(struct iov_iter *iter, * Extract up to sg_max pages from a BVEC-type iterator and add them to the * scatterlist. The pages are not pinned. */ -static ssize_t netfs_extract_bvec_to_sg(struct iov_iter *iter, - ssize_t maxsize, - struct sg_table *sgtable, - unsigned int sg_max, - iov_iter_extraction_t extraction_flags) +static ssize_t extract_bvec_to_sg(struct iov_iter *iter, + ssize_t maxsize, + struct sg_table *sgtable, + unsigned int sg_max, + iov_iter_extraction_t extraction_flags) { const struct bio_vec *bv = iter->bvec; struct scatterlist *sg = sgtable->sgl + sgtable->nents; @@ -205,11 +205,11 @@ static ssize_t netfs_extract_bvec_to_sg(struct iov_iter *iter, * scatterlist. This can deal with vmalloc'd buffers as well as kmalloc'd or * static buffers. The pages are not pinned. */ -static ssize_t netfs_extract_kvec_to_sg(struct iov_iter *iter, - ssize_t maxsize, - struct sg_table *sgtable, - unsigned int sg_max, - iov_iter_extraction_t extraction_flags) +static ssize_t extract_kvec_to_sg(struct iov_iter *iter, + ssize_t maxsize, + struct sg_table *sgtable, + unsigned int sg_max, + iov_iter_extraction_t extraction_flags) { const struct kvec *kv = iter->kvec; struct scatterlist *sg = sgtable->sgl + sgtable->nents; @@ -266,11 +266,11 @@ static ssize_t netfs_extract_kvec_to_sg(struct iov_iter *iter, * Extract up to sg_max folios from an XARRAY-type iterator and add them to * the scatterlist. The pages are not pinned. */ -static ssize_t netfs_extract_xarray_to_sg(struct iov_iter *iter, - ssize_t maxsize, - struct sg_table *sgtable, - unsigned int sg_max, - iov_iter_extraction_t extraction_flags) +static ssize_t extract_xarray_to_sg(struct iov_iter *iter, + ssize_t maxsize, + struct sg_table *sgtable, + unsigned int sg_max, + iov_iter_extraction_t extraction_flags) { struct scatterlist *sg = sgtable->sgl + sgtable->nents; struct xarray *xa = iter->xarray; @@ -312,7 +312,7 @@ static ssize_t netfs_extract_xarray_to_sg(struct iov_iter *iter, } /** - * netfs_extract_iter_to_sg - Extract pages from an iterator and add ot an sglist + * extract_iter_to_sg - Extract pages from an iterator and add ot an sglist * @iter: The iterator to extract from * @maxsize: The amount of iterator to copy * @sgtable: The scatterlist table to fill in @@ -339,9 +339,9 @@ static ssize_t netfs_extract_xarray_to_sg(struct iov_iter *iter, * The iov_iter_extract_mode() function should be used to query how cleanup * should be performed. */ -ssize_t netfs_extract_iter_to_sg(struct iov_iter *iter, size_t maxsize, - struct sg_table *sgtable, unsigned int sg_max, - iov_iter_extraction_t extraction_flags) +ssize_t extract_iter_to_sg(struct iov_iter *iter, size_t maxsize, + struct sg_table *sgtable, unsigned int sg_max, + iov_iter_extraction_t extraction_flags) { if (maxsize == 0) return 0; @@ -349,21 +349,21 @@ ssize_t netfs_extract_iter_to_sg(struct iov_iter *iter, size_t maxsize, switch (iov_iter_type(iter)) { case ITER_UBUF: case ITER_IOVEC: - return netfs_extract_user_to_sg(iter, maxsize, sgtable, sg_max, - extraction_flags); + return extract_user_to_sg(iter, maxsize, sgtable, sg_max, + extraction_flags); case ITER_BVEC: - return netfs_extract_bvec_to_sg(iter, maxsize, sgtable, sg_max, - extraction_flags); + return extract_bvec_to_sg(iter, maxsize, sgtable, sg_max, + extraction_flags); case ITER_KVEC: - return netfs_extract_kvec_to_sg(iter, maxsize, sgtable, sg_max, - extraction_flags); + return extract_kvec_to_sg(iter, maxsize, sgtable, sg_max, + extraction_flags); case ITER_XARRAY: - return netfs_extract_xarray_to_sg(iter, maxsize, sgtable, sg_max, - extraction_flags); + return extract_xarray_to_sg(iter, maxsize, sgtable, sg_max, + extraction_flags); default: pr_err("%s(%u) unsupported\n", __func__, iov_iter_type(iter)); WARN_ON_ONCE(1); return -EIO; } } -EXPORT_SYMBOL_GPL(netfs_extract_iter_to_sg); +EXPORT_SYMBOL_GPL(extract_iter_to_sg); diff --git a/include/linux/netfs.h b/include/linux/netfs.h index a1f3522daa69..55e201c3a841 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -301,9 +301,9 @@ ssize_t netfs_extract_user_iter(struct iov_iter *orig, size_t orig_len, struct iov_iter *new, iov_iter_extraction_t extraction_flags); struct sg_table; -ssize_t netfs_extract_iter_to_sg(struct iov_iter *iter, size_t len, - struct sg_table *sgtable, unsigned int sg_max, - iov_iter_extraction_t extraction_flags); +ssize_t extract_iter_to_sg(struct iov_iter *iter, size_t len, + struct sg_table *sgtable, unsigned int sg_max, + iov_iter_extraction_t extraction_flags); /** * netfs_inode - Get the netfs inode context from the inode From patchwork Tue May 30 14:16:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13260166 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 B3D56C7EE23 for ; Tue, 30 May 2023 14:17:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F9BB280001; Tue, 30 May 2023 10:17:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A8E06B007B; Tue, 30 May 2023 10:17:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39881280001; Tue, 30 May 2023 10:17:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2CDCC6B0078 for ; Tue, 30 May 2023 10:17:18 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 00A15802EA for ; Tue, 30 May 2023 14:17:17 +0000 (UTC) X-FDA: 80847123756.07.F36EC0F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 85D9C80019 for ; Tue, 30 May 2023 14:17:13 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GEYxyAR+; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1685456233; 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=AZhuY8lo9alWA9NhmnnpTaWvKv5QvMPV1nDbwBiDKtM=; b=EQDQ26nInWY6HqlTj/yFL+/dQ7R3Qpu5wWvw+tOmpfDOErCx/NMBoIMyPGoTd5zs3Z55QK 4nWMp7UIlTKLn1Wjw6Zl5zYdR7bv6mCkoOhzVFrsCTwIeXac5W0AKcAUaSnJK1ozNAlnxn KKZ3mJ3JtqciJcLnu42VZXJNojQ1KbE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GEYxyAR+; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685456233; a=rsa-sha256; cv=none; b=JzHFbsTQHLsa6szf5ZrIpkgxAbcic7Msc43+5hOt58IHRRJixCq1AkRG5rVj4KnM0lukKD 4R6orO5j1U98PKNuL8HgVqQ8RoW/VyORcas5Nmoyll32HY8UA68gFH/HakEHCfhV4tq5wi 8FxRprSXmMh06Zq2ULDeFikJJGeRPn4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685456232; 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=AZhuY8lo9alWA9NhmnnpTaWvKv5QvMPV1nDbwBiDKtM=; b=GEYxyAR+ygzY+A2JljV9Kok+8mzRvo/H83geqqPbJ+EbyFcU7bhn/HwsLZEKlYGkF5AcZ7 Qi4Iz9XtW38nUBbRxmzLKp82vVxozdoYSb9nOfeGQ5Y0As1OIQ8eZpcKzXb60Ma+G71Q9e hlD+2/jKmzFSzpAoVaVPJ2CG3X7Hwro= 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-121-4s_DJpgzMaGbhp4TeKUhEQ-1; Tue, 30 May 2023 10:17:09 -0400 X-MC-Unique: 4s_DJpgzMaGbhp4TeKUhEQ-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 1C7E7858F18; Tue, 30 May 2023 14:17:08 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75F0E40CFD46; Tue, 30 May 2023 14:17:04 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Simon Horman , Jeff Layton , Steve French , Shyam Prasad N , Rohith Surabattula , linux-cachefs@redhat.com, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH net-next v2 02/10] Fix a couple of spelling mistakes Date: Tue, 30 May 2023 15:16:26 +0100 Message-ID: <20230530141635.136968-3-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: 85D9C80019 X-Rspam-User: X-Stat-Signature: qexgqaaz4ob8dwbwnhgroas1k33rdsbs X-Rspamd-Server: rspam01 X-HE-Tag: 1685456233-198562 X-HE-Meta: U2FsdGVkX18VLYQHYz+Fe3LbgEhMbZRqn7DhqfRHbVxVetc1soYfb4Dl1Gr6I5/NpnO7nEcXY/CyFdHeY/IlM9Z4RcUbxqAfgnOlevp9L+ND8MJ6QPthTjdPUUDjKkCOUGrORkQ9NXnvwOLvTtQVv4YvZ0bM8hIJdYC2poj7Ee8zZAQgNkRJNwpSEmLUJ3H6YHxyw4UDPeJ45WKTlGGUbyvwb+ooXXUawoLV7Gkbz7kehyCJZYJBz7phjM552FtZPpVobkTkI6YH876GuRlPBHGKVgzdP8aHatV73JirGy9RnS7sn+R0WCmJhSUrlypm20nuLtej1+NymI6VLYI/TSTMH+tloK/OKb8WMPjN48m+ymih9gbv8aRSlAZd4RHjI1/4XnTm1jwl5IXZVlkUF/hHdimK2Na3t6vN0cDKjfPbyPotjayGxzqih+/39NLc+SeWL8LBEVWk0v9ibmzx3nef0F+KRa+VSM7Un9b/5cEHB9nWB8Vo8KUAL8euwStk7VLAS1v5ONJ9Wmr6oqyuq1Tt93RvuZPZX0WxKBvKxAWqdUurqEbUHeamKmXBE3mK78APmxWaboV/arm+d4KTXvPoTuE/1ZAJ24UXb7dVG+RTYfN+0ucv/A+9bqVmDCVGbwkrIc/UhQfsFgSRPT/1cScSc6jq8oq9vbkM1ZxWXfcH3y1f0ooQiMcMz6J8eXMmnOPmlFIb0mMtCCyEI85o1+MFvuUz7uJKw6U01EvFaE0+cA+Jj3vrgFg6iHyeso87CKKS7mIMnMP5tKz/yJoRlOWSQRSnQEpFhbgXMwecbuGqoYLNsalB5tWCevjx0GJ6whiRRwoX1zxxtSCDsuiRZ5TP6O4UNEjeV3QNfylFeNMmjQm1difNG2B5bisua59hGjjVH2jBM6BKqHoL62qflmXpQsXUB2OwsAuAZ6RNQYV2BMNa1wZFD2Z2q/uSRr2f2+xzi2jLkvs5ReQQ4B6 oNIkq16C Z/auhNy7gcheVJAKoMY+6kfJH/6VNmQ0HeDjCRmPni++JCOz1WWjxGscFpo+mPy7sgdK83GiB1V9LQSzJXJU6oUyiUjnXz4gcAMZgVpcSfpmntoVbQ6bBjY31if/LgEY+VAyTsiZvx/IapwzNTa0fpgsejYyMcdbk4FGtLLotZTu5nBDtlemgIsod7/Da7JEJDJhgtjz/BqAkheLULjtCjA+1+S2Q7Rne+SMPcNm09ICalP3SIOv+eraYnPHWNb6cjDP9fjxMgj4usEv3HbVacR96A47clBjjb7G+AkY+VudisSIZIyJyo57FRSRtYgTE7PLeRMSMKbgxPYjP6iKf+QfCuvTzGWwmkVxcwuXJSgATjia5ojwIDHPmKY/2psFLy/DFnfhkJJJRMxEUArLltisfZ93zI15kVaIw9YCYGBHp/xKtkqjc2wZmufp7cYGZkNmn2sezTwgksULx5SXU76jM4Mh5xUmHw1A+Ndpx/nVi3ohIKKLtRI4ffRyvNC2ZYIkJs3nUf0Kjav8MsLpLsb4m4eSefO8Qsj1SNOdaQ22KmOzkaW3Un1UrAFEjm9nCFfuFma8qZ1SYu/nNm5FCKWgspE7mnCtw/q4g+nnmdyv3JIOH48ZPvGr1tsmOABJODHI554gJO8bD6MI= 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: Fix a couple of spelling mistakes in a comment. Suggested-by: Simon Horman Link: https://lore.kernel.org/r/ZHH2mSRqeL4Gs1ft@corigine.com/ Link: https://lore.kernel.org/r/ZHH1nqZWOGzxlidT@corigine.com/ Signed-off-by: David Howells cc: Jeff Layton cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jens Axboe cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: linux-cachefs@redhat.com cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: netdev@vger.kernel.org Reviewed-by: Simon Horman --- fs/netfs/iterator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/netfs/iterator.c b/fs/netfs/iterator.c index f8eba3de1a97..f41a37bca1e8 100644 --- a/fs/netfs/iterator.c +++ b/fs/netfs/iterator.c @@ -312,7 +312,7 @@ static ssize_t extract_xarray_to_sg(struct iov_iter *iter, } /** - * extract_iter_to_sg - Extract pages from an iterator and add ot an sglist + * extract_iter_to_sg - Extract pages from an iterator and add to an sglist * @iter: The iterator to extract from * @maxsize: The amount of iterator to copy * @sgtable: The scatterlist table to fill in @@ -332,7 +332,7 @@ static ssize_t extract_xarray_to_sg(struct iov_iter *iter, * @extraction_flags can have ITER_ALLOW_P2PDMA set to request peer-to-peer DMA * be allowed on the pages extracted. * - * If successul, @sgtable->nents is updated to include the number of elements + * If successful, @sgtable->nents is updated to include the number of elements * added and the number of bytes added is returned. @sgtable->orig_nents is * left unaltered. * From patchwork Tue May 30 14:16:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13260168 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 360ACC77B73 for ; Tue, 30 May 2023 14:17:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6228280003; Tue, 30 May 2023 10:17:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AEAB26B0078; Tue, 30 May 2023 10:17:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B32C280003; Tue, 30 May 2023 10:17:34 -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 8C55E6B0075 for ; Tue, 30 May 2023 10:17:34 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 49C5DADD24 for ; Tue, 30 May 2023 14:17:34 +0000 (UTC) X-FDA: 80847124428.19.F52E179 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 388D01C0021 for ; Tue, 30 May 2023 14:17:31 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZA+sRxr7; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685456252; a=rsa-sha256; cv=none; b=PlFnfhTinyrMvt+hU3tHJwoK76bAC5oakJFmjz2i62zX1+Htb509O7mPIlrSiyCGpppsZo xL5uTSkymxS9fPGun9Vf6qmK8vzSZI5nYYRYgFuDSP/JbYiR+LBWW5MB03hDpJv7uP1Jp3 y+oRka4IIJFEzg/ZM11atDcj1sj7ip4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZA+sRxr7; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685456252; 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=8XAsj4uxJsU5nzHkgzshZ8+UJL6y54h/fBUZHPzhfR8=; b=XgiIz7+NPnV43sdtlkXbIzhwMhz1EV2+Ge0Z/vbcxeinN1oLv0iIHvT00TQdI6oBmY572I KRe8mW3m8Q2X5USqlt/uGW8P5FquyUE2cg3VVZC81TG8ZLvhtcPyoWMhW936wi7NOdDtPI qB0BtVJO2EFWu41c/MHmrHkThA4hW+E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685456251; 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=8XAsj4uxJsU5nzHkgzshZ8+UJL6y54h/fBUZHPzhfR8=; b=ZA+sRxr7I2yo/KNRPTe2sG08dUBeZgRzlcge5I+xn2GNq7UUQPogxjpqxfCZq/oZv06ccY /LNAe73OGyi3zhtRsSGLzn6oI9RqlJ4N/N9LZT/g1F6oYEoKhe26fOZgVBNI4EhDMzXFeC aBAzNjH6r7pVFAMpfCUh55ev408B/U8= 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-444-uIi8tBz6PMukM1ed44bcvg-1; Tue, 30 May 2023 10:17:26 -0400 X-MC-Unique: uIi8tBz6PMukM1ed44bcvg-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 239E9803D78; Tue, 30 May 2023 14:17:13 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 230E640CFD46; Tue, 30 May 2023 14:17:08 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jeff Layton , Steve French , Shyam Prasad N , Rohith Surabattula , Simon Horman , linux-cachefs@redhat.com, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH net-next v2 03/10] Wrap lines at 80 Date: Tue, 30 May 2023 15:16:27 +0100 Message-ID: <20230530141635.136968-4-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 388D01C0021 X-Stat-Signature: rm71s51a96y5ebdnbcc7s1gwqn59yq9u X-HE-Tag: 1685456251-386327 X-HE-Meta: U2FsdGVkX1+DIbdGJ0WuWIxi38/SKzEEybOsPhrEsaX4nGn8wD2tiDBuaLcmTy6D3hZ3/4ghD1+IbmgxBcCCiVoz43LHg+3Rb9EHTRsjYU/+WGePLzjkqjaWzP79y8ScR+LfHX0bqAqO7RcADoosimhNJUk/Zjv7J4aeZ23wa8z5NqlK519fzR8C8Lj5buVz5X8B/JKULPibr5OYytw63+zP4L4IPVn/7peCzF9y9FGY6YHoajgDqDWNT5DAvNR9XUvylrzqYk9JhRM9g0hyQoM8lXRGbeaxqAs8/UiKsh1s10Umz2s7dWVMRHf1RXPcesVNuh4nHgnmskTEiM1boTkdRK06DLAPDhriYH3GpOPc3VhwkAUbq47MOhwbq/SEil/99NkZKIOLxIYfVywCTsj3gUvkM41QMvP7m7Xd7A0qeLAGhHnavu6fNHliES0PZ/LkkREf4b1kczl3dT8sCQubz5POKFiDCc9oGy/yxOMYfWSSn//Ww6xP+06znnsK93ShjYYzriv99uEEews1CWeKKyOZlZMJZmn4DQ3zong6HPWcgr2ay7Zsop4jLKh1JdGb0cmz3S7qu7qdyhBiQU7Q/UsIbIvI4HyjSxE2G1ulZAQ1TV5mR8QrsDS1VZOpPxUAlRbyW+vvB8q1VSKrbahm4vFdJkcLxutdVgm/bonMaAiInsiMB0wLVxmsHq7w/4827CS9eoNATyi7j5dEXeASRWakgVGcTXKNL23o+XTiKrX58pVJVjNdSg1D3J9FWRQh4ldb+sDnwnK1D/fH0dkBmfkpUiUQl62D6SNJcghIa9jxslHjwPvNvs1qQhM8xbYK2XkaY9gX8ORU+WAL17bIA5wZOQXHrzwqvabswg+De/Q+H+Z6kMUo7WIaNt2Pakjq9VIiuD4OCYYgWZnf0a1qLfxyGFOq704BA46OFBJvZoCf+JPi7nPEKzU+jBBkmf/NZ+1L2AKK8tBCs9i Dxt1fwQU VGMoOWVY3lAvB2r2/cQ8JYCJCUlmtApVych/yD5xn7Mdr3GOm9ly/AFkqsXjyZNb+Zfexnz5xNMgIDX5w9r2VGRKkkkCqH1is6/TujoFnN2Uvyiamb5D0AxPGxcus3gCuzZ9/bnRcEKl79sipdFZv1hniiRmJ/TxBux0S5kb2S+wl9P48Ee3BHTSzW111tP0s//DA0mh/gULKgLzUkGxqIcq2Zck7e9sZ/odYCm73SZVusKGwPsmikqxSMomcohyrtlGQ65ONGxnCbJdNfkzeC7m+y3xhNr3vWz74kK9FtYCd8ibLlsiIeWhL+CHYpm2Whsgwh17Yj7r1leaujYaFmiZ41G59pBmRlyPyUfux7BCnxF7qbarYhPxq2usRwf1EDXQC/d3NK/ZENymnr10QWUd2Z3eoTmxyLlrOuBfT7KJPjf94Y2knYK5Lbquujp8YbE6iKJ/Uk1eAaXLf5y/67CEARKSTjq7NPbpMvzhYH9JLShdlsYblJMJ0Bi5Z2EpXvEtve1X2oYB1PeNciHoqwxQ2C/TaQlKamwgvSQkzVcoHcjGd+kunkTuAv4ZsJ0JTHPF/cQ67cDOaTFl04tyA/h7Fq4Dlv+uYL80OvRE5VFXGhIWGeapz5TORBb9B27xTRkg6yEVyxjjDF8Q= 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: Wrap a line at 80 to stop checkpatch complaining. Signed-off-by: David Howells cc: Jeff Layton cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jens Axboe cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Matthew Wilcox cc: Simon Horman cc: linux-crypto@vger.kernel.org cc: linux-cachefs@redhat.com cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: netdev@vger.kernel.org --- fs/netfs/iterator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/netfs/iterator.c b/fs/netfs/iterator.c index f41a37bca1e8..9f09dc30ceb6 100644 --- a/fs/netfs/iterator.c +++ b/fs/netfs/iterator.c @@ -119,7 +119,8 @@ static ssize_t extract_user_to_sg(struct iov_iter *iter, size_t len, off; /* We decant the page list into the tail of the scatterlist */ - pages = (void *)sgtable->sgl + array_size(sg_max, sizeof(struct scatterlist)); + pages = (void *)sgtable->sgl + + array_size(sg_max, sizeof(struct scatterlist)); pages -= sg_max; do { From patchwork Tue May 30 14:16:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13260167 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 42B79C77B73 for ; Tue, 30 May 2023 14:17:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0F5D280002; Tue, 30 May 2023 10:17:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CBF1D6B0078; Tue, 30 May 2023 10:17:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B60CA280002; Tue, 30 May 2023 10:17:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A76E46B0075 for ; Tue, 30 May 2023 10:17:30 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 74FDD1C706B for ; Tue, 30 May 2023 14:17:30 +0000 (UTC) X-FDA: 80847124260.06.6C07A7D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 4165B180015 for ; Tue, 30 May 2023 14:17:28 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E00LRCrp; spf=pass (imf16.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=1685456248; 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=VjV1Ciimn6pzCandpdZtjXJYCOMjJSyNy1/qiT7b1Ng=; b=5Cys8KProv4U4CGE0l1n26VRpFwvwDXThTjvbMYeDegd910IE/oTreLaWuvUjc/BYDjgFD hI4jndfm1ioUCSD+9l60DcRaiNXe+Tc+6mEoo1FcPwoMVXAQ6vX2lNdsb3upBTipFBoc2p gIJFQgZ8NU3q5IOpYLhhn1f+kMcAyQY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685456248; a=rsa-sha256; cv=none; b=HSDSzX1Y7Jnj2yyzwSdS6LeZwV1Ya6hZSTMcuKBpVI05/zQOGgHEifRHU3wK/0v/hK+B/b P9u7d+NXmxIKjd0FQC4YrkqYDS9ceFdXMbt8WUaC+C2Vh6qBfyKhwXnmhYoyR03PT5JfbI fp2YDrr2PFaZtmlDooCp9nDpxrv9GK0= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E00LRCrp; spf=pass (imf16.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=1685456247; 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=VjV1Ciimn6pzCandpdZtjXJYCOMjJSyNy1/qiT7b1Ng=; b=E00LRCrpn+sHZtPA9ll5cQi3/MwP1t+zXNWyYC1jWnT6ZvWLYerIqgpksXA7crt5xWZmvd URV7WovcUc3u5WkY+DGGCRPlG/AFxJeeCbyfWrAsWc89BJOLdOiCPCewbNiiiqWGkYcTDC PH2gC9LuRtyNB+Hl4K9m1bQUqHQxgq0= 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-530-Ueeskx28ORyWEErMR7otWg-1; Tue, 30 May 2023 10:17:25 -0400 X-MC-Unique: Ueeskx28ORyWEErMR7otWg-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 E901F8030CF; Tue, 30 May 2023 14:17:21 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 517B640C6EC4; Tue, 30 May 2023 14:17:15 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jeff Layton , Steve French , Shyam Prasad N , Rohith Surabattula , linux-cachefs@redhat.com, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH net-next v2 04/10] Move netfs_extract_iter_to_sg() to lib/scatterlist.c Date: Tue, 30 May 2023 15:16:28 +0100 Message-ID: <20230530141635.136968-5-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: 4165B180015 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 64zj6ukhkbwcyzik7cm9ogdniz9xfdfy X-HE-Tag: 1685456248-598276 X-HE-Meta: U2FsdGVkX19eshS0RQQBEHhgiDMIMB9kmGgl7cyH/2KWW5U2h+iCIG5+9o8t6pC/ph0HVZOvinafJhvQx9k/Efzduo5FYh9RjivnpMu20jOHO9NX9Qe4K1dlv/CkjA/Xj5QbycgCCXoTIv7Hy9m274wEyUWu58fQy9HtI9IYaS3wcbomaUJZ/ovzoBRZTiEhPdiI35N7ywqHl/RdhHuAZy0nFOED7awdz0ig8hbpFl3rIU2pXKpQLv9FBfOKODXMeNgP1TVlCao9W7j1ybRtamn1T20U+jfI/hMeq2rgP+GrII4PGcu8+vK9BXqeoSSG57dSZD1RNpQrf0nu7JEfprXT3UHZl0AUC7EqAXhHqzbFsiW8EVqzQHrsxNUeVeD0BDb0oszprc/vorI3vxSUnFbgsO6SXao+VubGmrAdPXEhIz+Lbj0ZhNp+YAiFgML+W3VyVgVd1waM1o3i35w2SvmfUROvhIs8lh8LvG2fY6IePQY6O2PoLTP6iZY1fnL9voatOUhE4V9BFheqeCmRITfuJ/DD7dwpHE2RxFZRHd3PluWzOxQlrMgoU4DdDuYbVbzgEgpK8g1M1+jZotdw/43GQGe2B/934/vVzhX3dHWZ2QU7cawZeezu2Nm8xMtDB9gQ/AOKWPtoldfUYEL5Ac7PgIiliqhHZWFqI7IdO/AodfYHkx3Yxoz+dJ/OH/OHO0R3IIsD9y3nQzZJgbviGONJrpvrDFnvI7OwISH9YYIdwFmcUq+QOy2meXiXrVRPlS+chlIbS5QTYkavl44pr4zggcMm8m0yS8RldumvwX6hHNBtpAKsG9TKDWC+MJiIw6uAREg+Wvi3VqwxEX8Gdrb5mOHoK7uPds1LYAGtZ0zcRdjeWgGwr9qVTs3XAylmw+hjBiTdbVyhHT7bc69yS8mgAlTel3z65utSMREJZldfUhb8SojQ9Gr8aYQWppwSeeEMfEuyJY9vvHoLOHY bgHiTmej s3+mELipBnpNeH8oDWYF8rfCBz12uJ7owurWBarhNGDuE5qM6aruf6OkN9lMruWPg7Bm6XwYbl+lE392Uas7dfbPJqLl4a5DvCt++1bdahdcxHLEEX2DG+xxUbBMPrXjUL13P5iKE5WDotU4xBYwgczDu+6dm0qfwuhgUYT0rkho1gd6y5TyfKFPaeoetSqhsX6ytRulkgXMyZ6TAVyva9c+EDSuzOM2gFaGV2NMqhV09hNV+CNqkP7iZ+DCVTEdnQ3YX/PLk2Ay6puzlksnfJHzL50hbQNJH90d8MR0YDoblg/aSVvRtCsYCOR2R7Zd+1/7NowoEj31gt+nwVrB6ssDhlmqMtg0eiDKpIwUivcy6xqh+e1Vg4v2DDBop5o8bIbyxc2TAYLicwPDc/Vj9xbtUKjHSspj7I3fTc0ENC3VHL9X/9c8g4HtyhswhKlzwOarF4ePaAdx0ddFYAGDpgYFI5nzlG7x+GyOELY84PUgqhzcq0hHM3ifWwCmsBdvE2lIzdwOhIYyo5lIDSdY96WYsJ7iGcpxTW3UZ+F8EEY/DTn9fOM5n+10Kcnf4+HSqr2Njr4IIsZkPjRl25QJvEWaD9ybx+ArshkGsCvOVQQHeKyANfqOVZki5O2j9dJgE1vo3 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: Move netfs_extract_iter_to_sg() to lib/scatterlist.c as it's going to be used by more than just network filesystems (AF_ALG, for example). Signed-off-by: David Howells cc: Jeff Layton cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jens Axboe cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: linux-cachefs@redhat.com cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: netdev@vger.kernel.org --- fs/netfs/iterator.c | 267 ----------------------------------------- include/linux/netfs.h | 4 - include/linux/uio.h | 5 + lib/scatterlist.c | 269 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 274 insertions(+), 271 deletions(-) diff --git a/fs/netfs/iterator.c b/fs/netfs/iterator.c index 9f09dc30ceb6..2ff07ba655a0 100644 --- a/fs/netfs/iterator.c +++ b/fs/netfs/iterator.c @@ -101,270 +101,3 @@ ssize_t netfs_extract_user_iter(struct iov_iter *orig, size_t orig_len, return npages; } EXPORT_SYMBOL_GPL(netfs_extract_user_iter); - -/* - * Extract and pin a list of up to sg_max pages from UBUF- or IOVEC-class - * iterators, and add them to the scatterlist. - */ -static ssize_t extract_user_to_sg(struct iov_iter *iter, - ssize_t maxsize, - struct sg_table *sgtable, - unsigned int sg_max, - iov_iter_extraction_t extraction_flags) -{ - struct scatterlist *sg = sgtable->sgl + sgtable->nents; - struct page **pages; - unsigned int npages; - ssize_t ret = 0, res; - size_t len, off; - - /* We decant the page list into the tail of the scatterlist */ - pages = (void *)sgtable->sgl + - array_size(sg_max, sizeof(struct scatterlist)); - pages -= sg_max; - - do { - res = iov_iter_extract_pages(iter, &pages, maxsize, sg_max, - extraction_flags, &off); - if (res < 0) - goto failed; - - len = res; - maxsize -= len; - ret += len; - npages = DIV_ROUND_UP(off + len, PAGE_SIZE); - sg_max -= npages; - - for (; npages > 0; npages--) { - struct page *page = *pages; - size_t seg = min_t(size_t, PAGE_SIZE - off, len); - - *pages++ = NULL; - sg_set_page(sg, page, seg, off); - sgtable->nents++; - sg++; - len -= seg; - off = 0; - } - } while (maxsize > 0 && sg_max > 0); - - return ret; - -failed: - while (sgtable->nents > sgtable->orig_nents) - put_page(sg_page(&sgtable->sgl[--sgtable->nents])); - return res; -} - -/* - * Extract up to sg_max pages from a BVEC-type iterator and add them to the - * scatterlist. The pages are not pinned. - */ -static ssize_t extract_bvec_to_sg(struct iov_iter *iter, - ssize_t maxsize, - struct sg_table *sgtable, - unsigned int sg_max, - iov_iter_extraction_t extraction_flags) -{ - const struct bio_vec *bv = iter->bvec; - struct scatterlist *sg = sgtable->sgl + sgtable->nents; - unsigned long start = iter->iov_offset; - unsigned int i; - ssize_t ret = 0; - - for (i = 0; i < iter->nr_segs; i++) { - size_t off, len; - - len = bv[i].bv_len; - if (start >= len) { - start -= len; - continue; - } - - len = min_t(size_t, maxsize, len - start); - off = bv[i].bv_offset + start; - - sg_set_page(sg, bv[i].bv_page, len, off); - sgtable->nents++; - sg++; - sg_max--; - - ret += len; - maxsize -= len; - if (maxsize <= 0 || sg_max == 0) - break; - start = 0; - } - - if (ret > 0) - iov_iter_advance(iter, ret); - return ret; -} - -/* - * Extract up to sg_max pages from a KVEC-type iterator and add them to the - * scatterlist. This can deal with vmalloc'd buffers as well as kmalloc'd or - * static buffers. The pages are not pinned. - */ -static ssize_t extract_kvec_to_sg(struct iov_iter *iter, - ssize_t maxsize, - struct sg_table *sgtable, - unsigned int sg_max, - iov_iter_extraction_t extraction_flags) -{ - const struct kvec *kv = iter->kvec; - struct scatterlist *sg = sgtable->sgl + sgtable->nents; - unsigned long start = iter->iov_offset; - unsigned int i; - ssize_t ret = 0; - - for (i = 0; i < iter->nr_segs; i++) { - struct page *page; - unsigned long kaddr; - size_t off, len, seg; - - len = kv[i].iov_len; - if (start >= len) { - start -= len; - continue; - } - - kaddr = (unsigned long)kv[i].iov_base + start; - off = kaddr & ~PAGE_MASK; - len = min_t(size_t, maxsize, len - start); - kaddr &= PAGE_MASK; - - maxsize -= len; - ret += len; - do { - seg = min_t(size_t, len, PAGE_SIZE - off); - if (is_vmalloc_or_module_addr((void *)kaddr)) - page = vmalloc_to_page((void *)kaddr); - else - page = virt_to_page(kaddr); - - sg_set_page(sg, page, len, off); - sgtable->nents++; - sg++; - sg_max--; - - len -= seg; - kaddr += PAGE_SIZE; - off = 0; - } while (len > 0 && sg_max > 0); - - if (maxsize <= 0 || sg_max == 0) - break; - start = 0; - } - - if (ret > 0) - iov_iter_advance(iter, ret); - return ret; -} - -/* - * Extract up to sg_max folios from an XARRAY-type iterator and add them to - * the scatterlist. The pages are not pinned. - */ -static ssize_t extract_xarray_to_sg(struct iov_iter *iter, - ssize_t maxsize, - struct sg_table *sgtable, - unsigned int sg_max, - iov_iter_extraction_t extraction_flags) -{ - struct scatterlist *sg = sgtable->sgl + sgtable->nents; - struct xarray *xa = iter->xarray; - struct folio *folio; - loff_t start = iter->xarray_start + iter->iov_offset; - pgoff_t index = start / PAGE_SIZE; - ssize_t ret = 0; - size_t offset, len; - XA_STATE(xas, xa, index); - - rcu_read_lock(); - - xas_for_each(&xas, folio, ULONG_MAX) { - if (xas_retry(&xas, folio)) - continue; - if (WARN_ON(xa_is_value(folio))) - break; - if (WARN_ON(folio_test_hugetlb(folio))) - break; - - offset = offset_in_folio(folio, start); - len = min_t(size_t, maxsize, folio_size(folio) - offset); - - sg_set_page(sg, folio_page(folio, 0), len, offset); - sgtable->nents++; - sg++; - sg_max--; - - maxsize -= len; - ret += len; - if (maxsize <= 0 || sg_max == 0) - break; - } - - rcu_read_unlock(); - if (ret > 0) - iov_iter_advance(iter, ret); - return ret; -} - -/** - * extract_iter_to_sg - Extract pages from an iterator and add to an sglist - * @iter: The iterator to extract from - * @maxsize: The amount of iterator to copy - * @sgtable: The scatterlist table to fill in - * @sg_max: Maximum number of elements in @sgtable that may be filled - * @extraction_flags: Flags to qualify the request - * - * Extract the page fragments from the given amount of the source iterator and - * add them to a scatterlist that refers to all of those bits, to a maximum - * addition of @sg_max elements. - * - * The pages referred to by UBUF- and IOVEC-type iterators are extracted and - * pinned; BVEC-, KVEC- and XARRAY-type are extracted but aren't pinned; PIPE- - * and DISCARD-type are not supported. - * - * No end mark is placed on the scatterlist; that's left to the caller. - * - * @extraction_flags can have ITER_ALLOW_P2PDMA set to request peer-to-peer DMA - * be allowed on the pages extracted. - * - * If successful, @sgtable->nents is updated to include the number of elements - * added and the number of bytes added is returned. @sgtable->orig_nents is - * left unaltered. - * - * The iov_iter_extract_mode() function should be used to query how cleanup - * should be performed. - */ -ssize_t extract_iter_to_sg(struct iov_iter *iter, size_t maxsize, - struct sg_table *sgtable, unsigned int sg_max, - iov_iter_extraction_t extraction_flags) -{ - if (maxsize == 0) - return 0; - - switch (iov_iter_type(iter)) { - case ITER_UBUF: - case ITER_IOVEC: - return extract_user_to_sg(iter, maxsize, sgtable, sg_max, - extraction_flags); - case ITER_BVEC: - return extract_bvec_to_sg(iter, maxsize, sgtable, sg_max, - extraction_flags); - case ITER_KVEC: - return extract_kvec_to_sg(iter, maxsize, sgtable, sg_max, - extraction_flags); - case ITER_XARRAY: - return extract_xarray_to_sg(iter, maxsize, sgtable, sg_max, - extraction_flags); - default: - pr_err("%s(%u) unsupported\n", __func__, iov_iter_type(iter)); - WARN_ON_ONCE(1); - return -EIO; - } -} -EXPORT_SYMBOL_GPL(extract_iter_to_sg); diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 55e201c3a841..b11a84f6c32b 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -300,10 +300,6 @@ void netfs_stats_show(struct seq_file *); ssize_t netfs_extract_user_iter(struct iov_iter *orig, size_t orig_len, struct iov_iter *new, iov_iter_extraction_t extraction_flags); -struct sg_table; -ssize_t extract_iter_to_sg(struct iov_iter *iter, size_t len, - struct sg_table *sgtable, unsigned int sg_max, - iov_iter_extraction_t extraction_flags); /** * netfs_inode - Get the netfs inode context from the inode diff --git a/include/linux/uio.h b/include/linux/uio.h index 044c1d8c230c..0ccb983cf645 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -433,4 +433,9 @@ static inline bool iov_iter_extract_will_pin(const struct iov_iter *iter) return user_backed_iter(iter); } +struct sg_table; +ssize_t extract_iter_to_sg(struct iov_iter *iter, size_t len, + struct sg_table *sgtable, unsigned int sg_max, + iov_iter_extraction_t extraction_flags); + #endif diff --git a/lib/scatterlist.c b/lib/scatterlist.c index 8d7519a8f308..e97d7060329e 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include /** * sg_next - return the next scatterlist entry in a list @@ -1095,3 +1097,270 @@ size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents, return offset; } EXPORT_SYMBOL(sg_zero_buffer); + +/* + * Extract and pin a list of up to sg_max pages from UBUF- or IOVEC-class + * iterators, and add them to the scatterlist. + */ +static ssize_t extract_user_to_sg(struct iov_iter *iter, + ssize_t maxsize, + struct sg_table *sgtable, + unsigned int sg_max, + iov_iter_extraction_t extraction_flags) +{ + struct scatterlist *sg = sgtable->sgl + sgtable->nents; + struct page **pages; + unsigned int npages; + ssize_t ret = 0, res; + size_t len, off; + + /* We decant the page list into the tail of the scatterlist */ + pages = (void *)sgtable->sgl + + array_size(sg_max, sizeof(struct scatterlist)); + pages -= sg_max; + + do { + res = iov_iter_extract_pages(iter, &pages, maxsize, sg_max, + extraction_flags, &off); + if (res < 0) + goto failed; + + len = res; + maxsize -= len; + ret += len; + npages = DIV_ROUND_UP(off + len, PAGE_SIZE); + sg_max -= npages; + + for (; npages > 0; npages--) { + struct page *page = *pages; + size_t seg = min_t(size_t, PAGE_SIZE - off, len); + + *pages++ = NULL; + sg_set_page(sg, page, seg, off); + sgtable->nents++; + sg++; + len -= seg; + off = 0; + } + } while (maxsize > 0 && sg_max > 0); + + return ret; + +failed: + while (sgtable->nents > sgtable->orig_nents) + put_page(sg_page(&sgtable->sgl[--sgtable->nents])); + return res; +} + +/* + * Extract up to sg_max pages from a BVEC-type iterator and add them to the + * scatterlist. The pages are not pinned. + */ +static ssize_t extract_bvec_to_sg(struct iov_iter *iter, + ssize_t maxsize, + struct sg_table *sgtable, + unsigned int sg_max, + iov_iter_extraction_t extraction_flags) +{ + const struct bio_vec *bv = iter->bvec; + struct scatterlist *sg = sgtable->sgl + sgtable->nents; + unsigned long start = iter->iov_offset; + unsigned int i; + ssize_t ret = 0; + + for (i = 0; i < iter->nr_segs; i++) { + size_t off, len; + + len = bv[i].bv_len; + if (start >= len) { + start -= len; + continue; + } + + len = min_t(size_t, maxsize, len - start); + off = bv[i].bv_offset + start; + + sg_set_page(sg, bv[i].bv_page, len, off); + sgtable->nents++; + sg++; + sg_max--; + + ret += len; + maxsize -= len; + if (maxsize <= 0 || sg_max == 0) + break; + start = 0; + } + + if (ret > 0) + iov_iter_advance(iter, ret); + return ret; +} + +/* + * Extract up to sg_max pages from a KVEC-type iterator and add them to the + * scatterlist. This can deal with vmalloc'd buffers as well as kmalloc'd or + * static buffers. The pages are not pinned. + */ +static ssize_t extract_kvec_to_sg(struct iov_iter *iter, + ssize_t maxsize, + struct sg_table *sgtable, + unsigned int sg_max, + iov_iter_extraction_t extraction_flags) +{ + const struct kvec *kv = iter->kvec; + struct scatterlist *sg = sgtable->sgl + sgtable->nents; + unsigned long start = iter->iov_offset; + unsigned int i; + ssize_t ret = 0; + + for (i = 0; i < iter->nr_segs; i++) { + struct page *page; + unsigned long kaddr; + size_t off, len, seg; + + len = kv[i].iov_len; + if (start >= len) { + start -= len; + continue; + } + + kaddr = (unsigned long)kv[i].iov_base + start; + off = kaddr & ~PAGE_MASK; + len = min_t(size_t, maxsize, len - start); + kaddr &= PAGE_MASK; + + maxsize -= len; + ret += len; + do { + seg = min_t(size_t, len, PAGE_SIZE - off); + if (is_vmalloc_or_module_addr((void *)kaddr)) + page = vmalloc_to_page((void *)kaddr); + else + page = virt_to_page(kaddr); + + sg_set_page(sg, page, len, off); + sgtable->nents++; + sg++; + sg_max--; + + len -= seg; + kaddr += PAGE_SIZE; + off = 0; + } while (len > 0 && sg_max > 0); + + if (maxsize <= 0 || sg_max == 0) + break; + start = 0; + } + + if (ret > 0) + iov_iter_advance(iter, ret); + return ret; +} + +/* + * Extract up to sg_max folios from an XARRAY-type iterator and add them to + * the scatterlist. The pages are not pinned. + */ +static ssize_t extract_xarray_to_sg(struct iov_iter *iter, + ssize_t maxsize, + struct sg_table *sgtable, + unsigned int sg_max, + iov_iter_extraction_t extraction_flags) +{ + struct scatterlist *sg = sgtable->sgl + sgtable->nents; + struct xarray *xa = iter->xarray; + struct folio *folio; + loff_t start = iter->xarray_start + iter->iov_offset; + pgoff_t index = start / PAGE_SIZE; + ssize_t ret = 0; + size_t offset, len; + XA_STATE(xas, xa, index); + + rcu_read_lock(); + + xas_for_each(&xas, folio, ULONG_MAX) { + if (xas_retry(&xas, folio)) + continue; + if (WARN_ON(xa_is_value(folio))) + break; + if (WARN_ON(folio_test_hugetlb(folio))) + break; + + offset = offset_in_folio(folio, start); + len = min_t(size_t, maxsize, folio_size(folio) - offset); + + sg_set_page(sg, folio_page(folio, 0), len, offset); + sgtable->nents++; + sg++; + sg_max--; + + maxsize -= len; + ret += len; + if (maxsize <= 0 || sg_max == 0) + break; + } + + rcu_read_unlock(); + if (ret > 0) + iov_iter_advance(iter, ret); + return ret; +} + +/** + * extract_iter_to_sg - Extract pages from an iterator and add to an sglist + * @iter: The iterator to extract from + * @maxsize: The amount of iterator to copy + * @sgtable: The scatterlist table to fill in + * @sg_max: Maximum number of elements in @sgtable that may be filled + * @extraction_flags: Flags to qualify the request + * + * Extract the page fragments from the given amount of the source iterator and + * add them to a scatterlist that refers to all of those bits, to a maximum + * addition of @sg_max elements. + * + * The pages referred to by UBUF- and IOVEC-type iterators are extracted and + * pinned; BVEC-, KVEC- and XARRAY-type are extracted but aren't pinned; PIPE- + * and DISCARD-type are not supported. + * + * No end mark is placed on the scatterlist; that's left to the caller. + * + * @extraction_flags can have ITER_ALLOW_P2PDMA set to request peer-to-peer DMA + * be allowed on the pages extracted. + * + * If successful, @sgtable->nents is updated to include the number of elements + * added and the number of bytes added is returned. @sgtable->orig_nents is + * left unaltered. + * + * The iov_iter_extract_mode() function should be used to query how cleanup + * should be performed. + */ +ssize_t extract_iter_to_sg(struct iov_iter *iter, size_t maxsize, + struct sg_table *sgtable, unsigned int sg_max, + iov_iter_extraction_t extraction_flags) +{ + if (maxsize == 0) + return 0; + + switch (iov_iter_type(iter)) { + case ITER_UBUF: + case ITER_IOVEC: + return extract_user_to_sg(iter, maxsize, sgtable, sg_max, + extraction_flags); + case ITER_BVEC: + return extract_bvec_to_sg(iter, maxsize, sgtable, sg_max, + extraction_flags); + case ITER_KVEC: + return extract_kvec_to_sg(iter, maxsize, sgtable, sg_max, + extraction_flags); + case ITER_XARRAY: + return extract_xarray_to_sg(iter, maxsize, sgtable, sg_max, + extraction_flags); + default: + pr_err("%s(%u) unsupported\n", __func__, iov_iter_type(iter)); + WARN_ON_ONCE(1); + return -EIO; + } +} +EXPORT_SYMBOL_GPL(extract_iter_to_sg); From patchwork Tue May 30 14:16:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13260171 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 DD1DFC7EE2F for ; Tue, 30 May 2023 14:17:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 791826B007B; Tue, 30 May 2023 10:17:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74130280004; Tue, 30 May 2023 10:17:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60947280003; Tue, 30 May 2023 10:17:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 52BF06B007B for ; Tue, 30 May 2023 10:17:51 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D955F1C70D9 for ; Tue, 30 May 2023 14:17:50 +0000 (UTC) X-FDA: 80847125100.07.1A6708F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 0197F140006 for ; Tue, 30 May 2023 14:17:48 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LiwnWWok; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685456269; 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=jPGukvQXP4Tai7PUqcbnIswr++Y11hB7rT1QDpn/afo=; b=sOiF5EEN7jhDSoIYGFYrLoREvkPTSfoDjSs7jhY4z4x5xp+0qi2Z2IkJ11Iz07EtJtkY94 0O602YAVIGOTQM+FILt6+Xbp2vWJpg+ayuluFpivYbfAPlh/ORpf1XtY7K+hd004aCG0vm d3V6gOGaLICuUCy2AASx/b0DErPsXAs= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LiwnWWok; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685456269; a=rsa-sha256; cv=none; b=K3qp2s0PCrItenb3GiNPHTEgPHKVur5ojRp09tz1kh3md/3vMOvlUKJJjMtnDRcaZ2kT8+ V9zHsCx15BZA1hvWfgMWOZZxOeVYEtV5J4sLIA+xoieKAnWkC+/Q5Lvmn2op3Svt+yoXD8 R86NJUZ2O7IkPehRB7SgixK3OtFWSBY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685456268; 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=jPGukvQXP4Tai7PUqcbnIswr++Y11hB7rT1QDpn/afo=; b=LiwnWWoksiHsp7q/gmxwWad7MKo4uS+jGDCxwsjFAqi7zV4vLoEFdaDO9wJuSUwIwOswkx TkC7cslrxalPH7ReWDDaplqyI7ku8HTZq4fnQ/2frIff838ey9073oDSIVz+xvb72o2cJ+ XgGYxqNAxEZz96t7waWcLmoguhT0y9Q= 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-422-RSYDLXzDO6mBKtqBJIWETQ-1; Tue, 30 May 2023 10:17:43 -0400 X-MC-Unique: RSYDLXzDO6mBKtqBJIWETQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4404B280BC52; Tue, 30 May 2023 14:17:31 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10D55C154D3; Tue, 30 May 2023 14:17:28 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 05/10] crypto: af_alg: Pin pages rather than ref'ing if appropriate Date: Tue, 30 May 2023 15:16:29 +0100 Message-ID: <20230530141635.136968-6-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 0197F140006 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: wnxy8gyw4ckjn3wny3nms3mzypjudoi1 X-HE-Tag: 1685456268-969443 X-HE-Meta: U2FsdGVkX1/1zdJfitHr9qEike5HMEoQELOFX03p9sWgIS/n+tIwQabjipaWlzeUdgzwkKIhR5L8SxB8YBdKZdL4PqQ+DIV/HHQsXqeOR91KzG2DVU/Tom7yBGTN8hiEguDa4j+AGiXvEtCcrGKh0DqMKBUTdAM3eA03acKH7hmGVd3rOOfa4+4jQsQP13M4lCgO1a4FCDtKwakLGznaNqRa84vNQoWgqwyWEFD5mf79GTTEaMiQXRoECMCkt6t6ggcDPCpz+iIXONnnoLYJnVKDxzIFCfIOjcJAVE92MoYYfjAd9ZzSKAr26xYEq9r5olSikm/ZiS13YgpNQblOTpoeerxYAV4bGksN0ikKS8fDysWSaow4pmOwVkit85lz8gtcknyTT2gnsvxiXrnK+X3LfY0ojkpoI9xgdLVJZv9ahzSXmZ7hxWiGbM7yZzbngqSvLikUDUBILojNVAl1Z9VBQPer7oIAyQ074T8EH8iq9DaGK+zDqiRzBTLjU39jPrb0HcP8rNnBp4VBJR4qyNbuWqXZFrm9DrTRv+KG4YzIV++VhqEOQN2cAM28U4d0mxytSIPIKBXg/R1b0kloTgPOsQURJVG2LkNNfHT9GhRXRVQ+d1CW9NBvZhN31C6lDOh2LYmOc778HXSyhOD4QNy1W/EBKNPcZNKvJ4ahpHW4Pg2E0zXIxpkj/E/4wZ9wlaYlWy8plINvgmJ1EAx1l2Uv2Rfmd48SKeYNtY/VslDeujsQW2e/1bhr9yLtMe5m05KO1bc2BjRWDwr9sAYAYoesiXTcRJCrX+0Q3WvUNJguVoR2Jm2GjLDt3buDlZckNaDworl5vBPGsBfkN2zXgD4/hdAQ3W0D0zgbF5nSJ/pQ+g2shHOhSQyvz2ceoARZNdTu0S7ujs4GQpzOM3pMH7fO3YTw6eV51hhz8djC5dUtaP5WhqAT+GNYw72sPMEuoFkAAxAG5E6laYgIYeM R3ea58mC deLeGVx8YD4Q9ZwzW4cJ/1A7H90WOASpxT57veWvyUQ8VaPVJu4S21F+NYqPjtOOopaAC3hsOEIKz97uUjOGy39zeU2obWPriFZCoPMZmR9bFtAvUS2pMKd8m43FuuqveekCApC1+CaVS304h3HASFFCOaROa9MapvpKcevIU1tf6kTzj0quqCMYgZVo/tTqSuv48pl3Vc4VJlMkt3OM2XxxpXRdYG+20490F8GwDRSg4vJIxkc8q+zWOmVVmC4bPQbavFGO2YakYZla5dzETCSFAWrywU7qu+wzgiP88d9qyUbiDvaEOp2iRHi1pba9ayk9zrWe5JZP6snhz0pHvWJqq+3sknaYG5waliPmAJPhJFZ3bDlp99E/gnCIKtQ2zVIfS9bHOBvkc/KawLeq8UNnDKzR/Equ5bUhHwmfkhLGSzjcwmp6Yw6Oyq3MkpEmpjz4kSjgnY3dzRKCiL9xB1JNOXmDlgm9uDNHwk1QMxeHDy90i3UY75oJU1oX0A4KA2+5wWW4RqmOmzQrsFGeAxqa6aLyc2Dcd55RmBKyWDq65SGw= 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: Convert AF_ALG to use iov_iter_extract_pages() instead of iov_iter_get_pages(). This will pin pages or leave them unaltered rather than getting a ref on them as appropriate to the iterator. The pages need to be pinned for DIO-read rather than having refs taken on them to prevent VM copy-on-write from malfunctioning during a concurrent fork() (the result of the I/O would otherwise end up only visible to the child process and not the parent). Signed-off-by: David Howells cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org --- crypto/af_alg.c | 10 +++++++--- include/crypto/if_alg.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 5f7252a5b7b4..7caff10df643 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -533,14 +533,17 @@ static const struct net_proto_family alg_family = { int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len) { + struct page **pages = sgl->pages; size_t off; ssize_t n; int npages, i; - n = iov_iter_get_pages2(iter, sgl->pages, len, ALG_MAX_PAGES, &off); + n = iov_iter_extract_pages(iter, &pages, len, ALG_MAX_PAGES, 0, &off); if (n < 0) return n; + sgl->need_unpin = iov_iter_extract_will_pin(iter); + npages = DIV_ROUND_UP(off + n, PAGE_SIZE); if (WARN_ON(npages == 0)) return -EINVAL; @@ -573,8 +576,9 @@ void af_alg_free_sg(struct af_alg_sgl *sgl) { int i; - for (i = 0; i < sgl->npages; i++) - put_page(sgl->pages[i]); + if (sgl->need_unpin) + for (i = 0; i < sgl->npages; i++) + unpin_user_page(sgl->pages[i]); } EXPORT_SYMBOL_GPL(af_alg_free_sg); diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h index 7e76623f9ec3..46494b33f5bc 100644 --- a/include/crypto/if_alg.h +++ b/include/crypto/if_alg.h @@ -59,6 +59,7 @@ struct af_alg_sgl { struct scatterlist sg[ALG_MAX_PAGES + 1]; struct page *pages[ALG_MAX_PAGES]; unsigned int npages; + bool need_unpin; }; /* TX SGL entry */ From patchwork Tue May 30 14:16:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13260169 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 7CD32C7EE2C for ; Tue, 30 May 2023 14:17:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C4BE6B0075; Tue, 30 May 2023 10:17:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1756A280005; Tue, 30 May 2023 10:17:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03CFF280004; Tue, 30 May 2023 10:17:43 -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 EA9576B0075 for ; Tue, 30 May 2023 10:17:42 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BF2AEADB24 for ; Tue, 30 May 2023 14:17:42 +0000 (UTC) X-FDA: 80847124764.08.18558A6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 9B5EB18001E for ; Tue, 30 May 2023 14:17:40 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TRxXAVfy; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685456260; a=rsa-sha256; cv=none; b=aQHPwveZdr6tj8hEF25B+btNZM9HicIJzp3d282ihw7rDMlZ0X8iiq9SNdkFoEgyGXM1ns UBeW0k9quLl5Gzg/MY+X8AVx4vgE2lRcIOJfZvK7khrdAJ+CeE0/FJ7CVgHUE2eEnSvxJx lycKpHDC+if1GbcVTPxGuKRyOYd1ZQk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TRxXAVfy; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685456260; 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=S6Cj3Wp9DlUBqB3ssDU9rjwPMpP7CzOqqIN8IX2Zg2c=; b=39v6dJzNAMqsMTZuGGKIQTDNf9mJze9dY9Dhaz45iVjU1175DhK325+wwLUf7Yp1TlKIAa dvlJ5DqiuxMK5d/cKgCCPAPn3vGjCT9+jJh3iqYetslJ2B0SJtmAs9JHGhY0T57tS2EMJN cvDczxEJCcyILkgIFSrHtZWZqIg+Geo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685456259; 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=S6Cj3Wp9DlUBqB3ssDU9rjwPMpP7CzOqqIN8IX2Zg2c=; b=TRxXAVfy3jURQZsZgJgN5WXsgDL8F9PCzwZm/CkSxIs+jmQcryJxon6Y8xIRUcBE36fw03 Fa80+WsG0E/pUcm4HmdD7RGnes3h+yovdzjEQycpV2MDXVHrhDnkKG4wH9drTec529JtmI JuU1AgVh3zygYLOjp2ZKBHF7hmG2GwM= 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-498-cs3AdqQuO9qpdCoxRFGrbA-1; Tue, 30 May 2023 10:17:36 -0400 X-MC-Unique: cs3AdqQuO9qpdCoxRFGrbA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B0582811E88; Tue, 30 May 2023 14:17:34 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24263C154D1; Tue, 30 May 2023 14:17:32 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 06/10] crypto: af_alg: Use extract_iter_to_sg() to create scatterlists Date: Tue, 30 May 2023 15:16:30 +0100 Message-ID: <20230530141635.136968-7-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9B5EB18001E X-Stat-Signature: bytbqpo83mbwsduxfjhn3xkxqrcj99sc X-HE-Tag: 1685456260-509786 X-HE-Meta: U2FsdGVkX19pPxkm8I1SwKQVcFMHibM2BixngqN9hhniIAepAEXxdq/LA/8UqFspjk6pZwy/Bb5hdbNKKo2dNyNETmDgbmDLcbnSNqhhc7ySUt7Rjax2Kls1XugZ4Px0d4dgAmf+JKgg0SIdYkgTgZ6R8ebcf3cRNxePKbKswRhsRZp6MCz94CupRSGwpZ8nk+VaQ+VqN0aFw8NjlYkE48sMOoEDBWOJWX81b3X0SQb0kkLICrA2cDMYAYqA4EKvTkUnkStpQ4W/UH1nOxWAiFv7SNiyCk9GtqwkkrUxuwjZyu20wuNaHkfdMu4pOVWNBbVItOQ12lsJ2KdngmnfLFiD/bLqqUDLulZDttNiGo0uGFptvme70DP0baJFbMb/kgGZv419oaxDcMo/lXDk7Qf3K/BjLuGmGtPN8QzvPb0FQ3TA685RglHIPe9DiL9bATyhph38W2/WoKrT360JSTBrqLytKwP1rkYL4hr8oC9HLEd5uyYz6NvP+xOpJZVnFHpL315+dKWzt9GvCSil8zZXtbUOyp2P7mk964P1zDgpm76Fjqtzynjr2gZxEMp6hLndMmRN8mXDlFVKucH4G3y1tUGiTQCQ0dHSLhVSPH549wQUUUHORnWgFxuLqicl7NST2vgAC/ELMZabzKT79/sFaui55LqTxYQWUTUKDz0+l6xBMPtBoXWnOS3knoicYmbrNMDpef3pgK6gxMw9RaeZcFksedso+OPukPWPD8+mZz4hZognz8uajJ7gGDCwsbKqJ2ogiy6pH+ecJO1+pSur42xpYc89yP02ZH+GfiGghKSb/IXVRJDsURTuHP8Zzvr24hPRAnvs/qyX9kf9LwXnFeXLIbFl0pI9BvfNa4pgzzK1iB47isDeoYuGtnm011IB2htRTvpw202NJ4aEnFYolkbOmSjka42LkD39zybiUvsYNErzNeiReVsGtYfDnjG7/sbqHVqSaaNqOe6 K/VW5Re8 jJrGs1u5hi+a7DPrgWzHSNNwxv2IzUWDwSIaCZyVx04/JzgDp2CayX1DLm1hs6ysCjZ4RB8xku/SQzRyEmvfO8ozXpInd6tUK3+nBl/smq/mPNwc1TMbGbvYsduPq03szNKEjKX5fttch/y1X9U62RV87tejc9TIvaIW0g1Tl+zh7uC857p51lb74gWRDSK1rCVZN3wCEViRHVU5pNG6Bwq87pdIZFPYztVoYDFALpHqViRGGxoL14EacG6b4m6mt6gEXiombTHLhzT2ZlqoAOmXzcGzdUCPJ7yaptdVjTJr0mJvsZ04sdHo/odB+MqHB2xtITnNYI3BhwoQkfze0qAsckL42rqfl4aLnJkmCUk8uRIxt3YFxFtTa1zprfZA3RJzZj1NJ048JHqIO0kvr14ogEUNlS2gJrptTVIULyLWX0M6c0j1nvTIr2kNLJfPUG4nn6G/sEZ1L45ws1Pqvb9tmYCK3PXfGXAxeCq9LfeL1nIP2vg97NNaet/bmBpoUxDfS4t17PaNqoeMxDes5KfajvfKxWungeHPYc4wjl4C9q+0= 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 extract_iter_to_sg() to decant the destination iterator into a scatterlist in af_alg_get_rsgl(). af_alg_make_sg() can then be removed. Signed-off-by: David Howells cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #2) - Fix some checkpatch warnings. crypto/af_alg.c | 57 +++++++++++------------------------------ crypto/algif_aead.c | 16 +++++++----- crypto/algif_hash.c | 18 +++++++++---- crypto/algif_skcipher.c | 2 +- include/crypto/if_alg.h | 6 ++--- 5 files changed, 40 insertions(+), 59 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 7caff10df643..b8bf6d8525ba 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -531,45 +531,11 @@ static const struct net_proto_family alg_family = { .owner = THIS_MODULE, }; -int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len) -{ - struct page **pages = sgl->pages; - size_t off; - ssize_t n; - int npages, i; - - n = iov_iter_extract_pages(iter, &pages, len, ALG_MAX_PAGES, 0, &off); - if (n < 0) - return n; - - sgl->need_unpin = iov_iter_extract_will_pin(iter); - - npages = DIV_ROUND_UP(off + n, PAGE_SIZE); - if (WARN_ON(npages == 0)) - return -EINVAL; - /* Add one extra for linking */ - sg_init_table(sgl->sg, npages + 1); - - for (i = 0, len = n; i < npages; i++) { - int plen = min_t(int, len, PAGE_SIZE - off); - - sg_set_page(sgl->sg + i, sgl->pages[i], plen, off); - - off = 0; - len -= plen; - } - sg_mark_end(sgl->sg + npages - 1); - sgl->npages = npages; - - return n; -} -EXPORT_SYMBOL_GPL(af_alg_make_sg); - static void af_alg_link_sg(struct af_alg_sgl *sgl_prev, struct af_alg_sgl *sgl_new) { - sg_unmark_end(sgl_prev->sg + sgl_prev->npages - 1); - sg_chain(sgl_prev->sg, sgl_prev->npages + 1, sgl_new->sg); + sg_unmark_end(sgl_prev->sgt.sgl + sgl_prev->sgt.nents - 1); + sg_chain(sgl_prev->sgt.sgl, sgl_prev->sgt.nents + 1, sgl_new->sgt.sgl); } void af_alg_free_sg(struct af_alg_sgl *sgl) @@ -577,8 +543,8 @@ void af_alg_free_sg(struct af_alg_sgl *sgl) int i; if (sgl->need_unpin) - for (i = 0; i < sgl->npages; i++) - unpin_user_page(sgl->pages[i]); + for (i = 0; i < sgl->sgt.nents; i++) + unpin_user_page(sg_page(&sgl->sgt.sgl[i])); } EXPORT_SYMBOL_GPL(af_alg_free_sg); @@ -1292,8 +1258,8 @@ int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags, while (maxsize > len && msg_data_left(msg)) { struct af_alg_rsgl *rsgl; + ssize_t err; size_t seglen; - int err; /* limit the amount of readable buffers */ if (!af_alg_readable(sk)) @@ -1310,16 +1276,23 @@ int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags, return -ENOMEM; } - rsgl->sgl.npages = 0; + rsgl->sgl.sgt.sgl = rsgl->sgl.sgl; + rsgl->sgl.sgt.nents = 0; + rsgl->sgl.sgt.orig_nents = 0; list_add_tail(&rsgl->list, &areq->rsgl_list); - /* make one iovec available as scatterlist */ - err = af_alg_make_sg(&rsgl->sgl, &msg->msg_iter, seglen); + sg_init_table(rsgl->sgl.sgt.sgl, ALG_MAX_PAGES); + err = extract_iter_to_sg(&msg->msg_iter, seglen, &rsgl->sgl.sgt, + ALG_MAX_PAGES, 0); if (err < 0) { rsgl->sg_num_bytes = 0; return err; } + sg_mark_end(rsgl->sgl.sgt.sgl + rsgl->sgl.sgt.nents - 1); + rsgl->sgl.need_unpin = + iov_iter_extract_will_pin(&msg->msg_iter); + /* chain the new scatterlist with previous one */ if (areq->last_rsgl) af_alg_link_sg(&areq->last_rsgl->sgl, &rsgl->sgl); diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c index 42493b4d8ce4..829878025dba 100644 --- a/crypto/algif_aead.c +++ b/crypto/algif_aead.c @@ -210,7 +210,7 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg, */ /* Use the RX SGL as source (and destination) for crypto op. */ - rsgl_src = areq->first_rsgl.sgl.sg; + rsgl_src = areq->first_rsgl.sgl.sgt.sgl; if (ctx->enc) { /* @@ -224,7 +224,8 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg, * RX SGL: AAD || PT || Tag */ err = crypto_aead_copy_sgl(null_tfm, tsgl_src, - areq->first_rsgl.sgl.sg, processed); + areq->first_rsgl.sgl.sgt.sgl, + processed); if (err) goto free; af_alg_pull_tsgl(sk, processed, NULL, 0); @@ -242,7 +243,8 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg, /* Copy AAD || CT to RX SGL buffer for in-place operation. */ err = crypto_aead_copy_sgl(null_tfm, tsgl_src, - areq->first_rsgl.sgl.sg, outlen); + areq->first_rsgl.sgl.sgt.sgl, + outlen); if (err) goto free; @@ -267,10 +269,10 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg, if (usedpages) { /* RX SGL present */ struct af_alg_sgl *sgl_prev = &areq->last_rsgl->sgl; + struct scatterlist *sg = sgl_prev->sgt.sgl; - sg_unmark_end(sgl_prev->sg + sgl_prev->npages - 1); - sg_chain(sgl_prev->sg, sgl_prev->npages + 1, - areq->tsgl); + sg_unmark_end(sg + sgl_prev->sgt.nents - 1); + sg_chain(sg, sgl_prev->sgt.nents + 1, areq->tsgl); } else /* no RX SGL present (e.g. authentication only) */ rsgl_src = areq->tsgl; @@ -278,7 +280,7 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg, /* Initialize the crypto operation */ aead_request_set_crypt(&areq->cra_u.aead_req, rsgl_src, - areq->first_rsgl.sgl.sg, used, ctx->iv); + areq->first_rsgl.sgl.sgt.sgl, used, ctx->iv); aead_request_set_ad(&areq->cra_u.aead_req, ctx->aead_assoclen); aead_request_set_tfm(&areq->cra_u.aead_req, tfm); diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index 63af72e19fa8..16c69c4b9c62 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c @@ -91,13 +91,21 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg, if (len > limit) len = limit; - len = af_alg_make_sg(&ctx->sgl, &msg->msg_iter, len); + ctx->sgl.sgt.sgl = ctx->sgl.sgl; + ctx->sgl.sgt.nents = 0; + ctx->sgl.sgt.orig_nents = 0; + + len = extract_iter_to_sg(&msg->msg_iter, len, &ctx->sgl.sgt, + ALG_MAX_PAGES, 0); if (len < 0) { err = copied ? 0 : len; goto unlock; } + sg_mark_end(ctx->sgl.sgt.sgl + ctx->sgl.sgt.nents); + + ctx->sgl.need_unpin = iov_iter_extract_will_pin(&msg->msg_iter); - ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, NULL, len); + ahash_request_set_crypt(&ctx->req, ctx->sgl.sgt.sgl, NULL, len); err = crypto_wait_req(crypto_ahash_update(&ctx->req), &ctx->wait); @@ -141,8 +149,8 @@ static ssize_t hash_sendpage(struct socket *sock, struct page *page, flags |= MSG_MORE; lock_sock(sk); - sg_init_table(ctx->sgl.sg, 1); - sg_set_page(ctx->sgl.sg, page, size, offset); + sg_init_table(ctx->sgl.sgl, 1); + sg_set_page(ctx->sgl.sgl, page, size, offset); if (!(flags & MSG_MORE)) { err = hash_alloc_result(sk, ctx); @@ -151,7 +159,7 @@ static ssize_t hash_sendpage(struct socket *sock, struct page *page, } else if (!ctx->more) hash_free_result(sk, ctx); - ahash_request_set_crypt(&ctx->req, ctx->sgl.sg, ctx->result, size); + ahash_request_set_crypt(&ctx->req, ctx->sgl.sgl, ctx->result, size); if (!(flags & MSG_MORE)) { if (ctx->more) diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index ee8890ee8f33..a251cd6bd5b9 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -105,7 +105,7 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg, /* Initialize the crypto operation */ skcipher_request_set_tfm(&areq->cra_u.skcipher_req, tfm); skcipher_request_set_crypt(&areq->cra_u.skcipher_req, areq->tsgl, - areq->first_rsgl.sgl.sg, len, ctx->iv); + areq->first_rsgl.sgl.sgt.sgl, len, ctx->iv); if (msg->msg_iocb && !is_sync_kiocb(msg->msg_iocb)) { /* AIO operation */ diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h index 46494b33f5bc..34224e77f5a2 100644 --- a/include/crypto/if_alg.h +++ b/include/crypto/if_alg.h @@ -56,9 +56,8 @@ struct af_alg_type { }; struct af_alg_sgl { - struct scatterlist sg[ALG_MAX_PAGES + 1]; - struct page *pages[ALG_MAX_PAGES]; - unsigned int npages; + struct sg_table sgt; + struct scatterlist sgl[ALG_MAX_PAGES + 1]; bool need_unpin; }; @@ -164,7 +163,6 @@ int af_alg_release(struct socket *sock); void af_alg_release_parent(struct sock *sk); int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern); -int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len); void af_alg_free_sg(struct af_alg_sgl *sgl); static inline struct alg_sock *alg_sk(struct sock *sk) From patchwork Tue May 30 14:16:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13260170 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 F0D84C77B73 for ; Tue, 30 May 2023 14:17:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8CA006B0078; Tue, 30 May 2023 10:17:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 87954280005; Tue, 30 May 2023 10:17:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 71B36280004; Tue, 30 May 2023 10:17:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 650876B0078 for ; Tue, 30 May 2023 10:17:46 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7EE55160305 for ; Tue, 30 May 2023 14:17:44 +0000 (UTC) X-FDA: 80847124848.21.FFFA71B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id B7B074000C for ; Tue, 30 May 2023 14:17:42 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CRUr25O+; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685456262; 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=jD4W/W7iXB9ATeRl2QuO5GnCDoE2m4ZXOMCYUAgCXGY=; b=SzH2PtWJFKNkvT8z6OraQOPKvrggPONNu6qr9jm7X3UJ5WjRCOtuEav15P/roN0uZIXQdK qDgkWd0cw8lEOIFxr2rTL5PFfBF5VPWVryNszglidTSTihZlPs3th8c168PvWMclLVD/7x IwdU/ePyQOPw5szOBIz1Aw8llD9NAHw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CRUr25O+; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685456262; a=rsa-sha256; cv=none; b=DvlP5iC+SXY4kBQAPCEGz8FWLaAHbHF7RvXW4MNl+qEyFUhcVP9X41FA/RGgFs6/QearLF 9HCOvIBKg8YvCSXq2wm4+QqT+Pyvl8xiJF9VOjMF80EI7tSRxPVoEE/vlC2HwMzvpwl3c3 UxvnjM8A8D1IPo+y8MVOE+yYfpNpmd8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685456262; 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=jD4W/W7iXB9ATeRl2QuO5GnCDoE2m4ZXOMCYUAgCXGY=; b=CRUr25O+VIQorY2X3X6Y2X8zeHPZgPlvzwEoDCDtczyDq7FFqT7GxSYHQF3ptVlufXfFGh +PBn8pF8zP5Ow/SSBYjmllc5ov2FWhsoMxRiHrHup53hKWoZtzNGrupm+J6NCuea6C012e 9MVwCue2jO8ePd9RnoEzuFGZz4jDTdQ= 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-210-n8AGTfiBPVSP1SnUgycr9w-1; Tue, 30 May 2023 10:17:38 -0400 X-MC-Unique: n8AGTfiBPVSP1SnUgycr9w-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 EF71E38154EB; Tue, 30 May 2023 14:17:37 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id A08D1140E955; Tue, 30 May 2023 14:17:35 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 07/10] crypto: af_alg: Indent the loop in af_alg_sendmsg() Date: Tue, 30 May 2023 15:16:31 +0100 Message-ID: <20230530141635.136968-8-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Queue-Id: B7B074000C X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: chibu3o4br38hcwf7uz9rrn8fz31cdxs X-HE-Tag: 1685456262-508373 X-HE-Meta: U2FsdGVkX1+jwLv8+ZD5YbWWJt89wEXUOeTcbWWmBkrC6xiAyOLa1mo+gEoFJEMvCNaPRMTmRwoSgIgFiKR7yX2EXeZRY73D33uuR2rQ2ZjhPXWXIOU0g+Wn46pM0apDeS6Am/454EVDBIdaqI+BwOFc6yRmgY27nkFLJhCjW7DyBFeER+de2UjqopF0ukUAmvxUmCYtt3VTJohNPm55YbA/ZSlJr9sq7yNZKb6MyIPcrifOx/Ow57qlT6KV62x3ePh7f1ZPUx+OekeZhVW7eQ8jFDfbTdl+qflFqkCWkdAXTTREsa1i5FK+iMW7OHH+QdWfWTIYwQ2yHleOckSFVrbOuGLYxjeT6StQLPWA06v4YJDL8yOE7SwXmkS+OqgESUfyCrYM5A+MO8FqVHcCa2G8dFXbNvLSx/JmRSOKazKXBM5ibA0aDRUz3dWcDOfy4zminbfnfoIFqDvsFmuwZlNLbS3KzHAz4R8XvWiBomOnE6yFdsm60GUj6ownGLZPJD+wOvdRCJzNh+LUfaOyhbm3dsg5aiS+mNV7WjGyeWSFd6AcEvFwwumjk2ufFBOA0y3f4f9M9nZlBcUyCkvLlA2CiLpI1uGaQi9CznxJEOW7Ns3YMQZ2sLyQMnIrFtqyMfXhfpC6dDO/+ttnuvMUQ/wgRlZNcPtd/MFEPCy1QUa5NiCITJnrpnkKfXsw32DFds3s6FLG6J2PJLlSBTvB5DYEancpcSIKyuWyzkZyFClCwjOZBIcn41pInGN8VG4pO31QHYI/DyjwQ98yx/F1gx7eJobM2cQilzWlXPkVrI1lv4FQfAozPEOlHSwfnF5OCb8Pvm9asOTQihwxcFghx3nxL5Jk75hahW0xuX0O/pu+PRRXo0ru/sn1+wg2jQ04vkwHwEbCx7AovAV4e/2JsxpRy17vtDSzSE+Z14lnNpOCBpp5iph+AtAZulNMSt+NfmID3oW4ju0W5RcD1r8 CRwsivne qawJa5dP/TvPe0g/JBBeoQRjfDgYLKrE2+ovCS5woGSHI+7BkF/Ik7N2KSjroXTK4AglDTSGoUSYQOyVopXfx66O+eA1Rc/lhopT7SmGsf62HS/zsyHDAGIjCM53K5eBaxEJvkDo0cQkvLVW1x4O8zGNsPmqzxQjjB0nDbF+b92pL6hCziz23Peb2vLeXfGDTuRvqnIRqfTtlWlU9WVn79rxzttlMYhsk4Rj1jC+NvKktQO7MdSBDDn9ZgbB9rhKVMRQOb4JtCL1/hS+sa0Hkb/jsgLojsxUEAUTy+N3ggBe5GtZ4Np1stKCcPSHhmTWYjD99cOA4vYF379sb+BY2Tl06Vi3I37eVnLP0mwojbDnoxxrPiQo3jOnWqverufFpMd9P6rOCiIc4SDK8bOcWQi1CrzAjDyhl5XE3H76Vsm5NRqVbU+pcxMvOhFIGQiiuWepj/Bcj/sPAYQwX+W2tf3Jg3/V4l9y4m4+bS9c3/TakWcOaoZKohxFsqfG/rfXr6EK9ZP3GWvNnvDcCwtCvL8s0AL6QM4sP9Daf7b4XIWZ5hUU= 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: Put the loop in af_alg_sendmsg() into an if-statement to indent it to make the next patch easier to review as that will add another branch to handle MSG_SPLICE_PAGES to the if-statement. Signed-off-by: David Howells cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #2) - Fix a checkpatch warning. crypto/af_alg.c | 51 ++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index b8bf6d8525ba..fd56ccff6fed 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -1030,35 +1030,38 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, if (sgl->cur) sg_unmark_end(sg + sgl->cur - 1); - do { - struct page *pg; - unsigned int i = sgl->cur; + if (1 /* TODO check MSG_SPLICE_PAGES */) { + do { + struct page *pg; + unsigned int i = sgl->cur; - plen = min_t(size_t, len, PAGE_SIZE); + plen = min_t(size_t, len, PAGE_SIZE); - pg = alloc_page(GFP_KERNEL); - if (!pg) { - err = -ENOMEM; - goto unlock; - } + pg = alloc_page(GFP_KERNEL); + if (!pg) { + err = -ENOMEM; + goto unlock; + } - sg_assign_page(sg + i, pg); + sg_assign_page(sg + i, pg); - err = memcpy_from_msg(page_address(sg_page(sg + i)), - msg, plen); - if (err) { - __free_page(sg_page(sg + i)); - sg_assign_page(sg + i, NULL); - goto unlock; - } + err = memcpy_from_msg( + page_address(sg_page(sg + i)), + msg, plen); + if (err) { + __free_page(sg_page(sg + i)); + sg_assign_page(sg + i, NULL); + goto unlock; + } - sg[i].length = plen; - len -= plen; - ctx->used += plen; - copied += plen; - size -= plen; - sgl->cur++; - } while (len && sgl->cur < MAX_SGL_ENTS); + sg[i].length = plen; + len -= plen; + ctx->used += plen; + copied += plen; + size -= plen; + sgl->cur++; + } while (len && sgl->cur < MAX_SGL_ENTS); + } if (!size) sg_mark_end(sg + sgl->cur - 1); From patchwork Tue May 30 14:16:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13260172 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 E65FCC77B73 for ; Tue, 30 May 2023 14:17:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7921A280003; Tue, 30 May 2023 10:17:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 71C0E6B007E; Tue, 30 May 2023 10:17:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39AB9280003; Tue, 30 May 2023 10:17:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 233246B007D for ; Tue, 30 May 2023 10:17:52 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C50ADADFC0 for ; Tue, 30 May 2023 14:17:51 +0000 (UTC) X-FDA: 80847125142.26.BA18FF7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id CDC994000F for ; Tue, 30 May 2023 14:17:49 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Sqm7x5sx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685456269; 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=PCkracVZHXcjf1udYjohuqRBAaoXTMR0EtKaMQxdAMM=; b=QFuxgN7MYynGPk4ypMByCx9Dl7BhAOEeZNWNZ+GOqs2maI4RJZNFOsJIoXGhzzMgcVssmM 70zO5A/ihINkmpdb2GsabUXS2nn0HHXxig89xC1Glf+ydtDLXHes+T5PysQApMSaqCVT81 Q3XTI1W69a2WA2xMaxzMUELgIXIyiLw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Sqm7x5sx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685456269; a=rsa-sha256; cv=none; b=C8FbFlW2D31OGoq5uSim1lzIc+ukO0iGKRQ3btuvOi8GKUyt1WOoYjDKeoaz/S0ZW0plzP RVDvKiC8LEP6B+QGqlzQjozOKBfd2AwEWYUhtLeTOrD4eqYxW3iXJtMirhbwhx7IA4HAJm +xLqDsVhkGv3k8QDbexdTOFP50YjBKk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685456268; 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=PCkracVZHXcjf1udYjohuqRBAaoXTMR0EtKaMQxdAMM=; b=Sqm7x5sx7s6aweWML6z7J4m7zXoS9cjbLDD68nHrxuPforFhMtpXCLyH0Y2FRCo9C+sKFU xaBSbrwvGaTBN7iJvB4PgNbpj3grcQwq95uqTiUtUAmG7/didXgvDFiQu27vvMIskkY9ZM rtkCEJR/edus9iqa14KyaOuY/FIU114= 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-557-ULW1DDxcMK6oR9kRngPuvA-1; Tue, 30 May 2023 10:17:43 -0400 X-MC-Unique: ULW1DDxcMK6oR9kRngPuvA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4E0FC858F0F; Tue, 30 May 2023 14:17:42 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id A549CC15612; Tue, 30 May 2023 14:17:39 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 08/10] crypto: af_alg: Support MSG_SPLICE_PAGES Date: Tue, 30 May 2023 15:16:32 +0100 Message-ID: <20230530141635.136968-9-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CDC994000F X-Stat-Signature: s38y6rfbi9c8z6t5xup3fgqq1e8nfd19 X-HE-Tag: 1685456269-752632 X-HE-Meta: U2FsdGVkX1/zNeypaOEh8QNXfnXmTeqMuEvc5rcC6OyLp5s885gB6ZSS/IS6sLaEvi6KqL4gDwYgrKkGUdTPFSW61a5rSeKO4ZzGXWbuY7A12JVbgvz/4WBBnCVsbnJ3XmbZG0F8xaiTfSg6pnCPPmJ+FhRSuEC2+Xojv5MOh+FupfrnI/WBHzP9IMRurv1eCw9pmNy1iNJ9VSFe1ah8Vt0dHPe53yr3fP7PFtH7OV/HgIQcjWwCHxhFfYhZ1pXnGY27zO25VRxjQCQORp5QzgOjHCI2lehzfYB/XSX0Py7pmsTSlkmoCnmdaxETdbVyXNPc3kKUGrHSZ3DKO5VYR9HSpcKddCQrkGrTYXyhH9Wk1N4v593fr4vcTUf7mVIOF4sTdZAQ3hCO4FNwsUt4Xbj2Eml/vJ9YRayK3mU0Cf7ZFpl8Vl0HbKnjc/bsWv0aL8IBcjwzVtQ+Olytz2ZR14LsBR0x9NFCsYsDh1IuE3L79Awe3dttdPx4KVwv35Lvkqw/74GxjwiW5Cn4uRYNEx8k5k7q9aH21an8RuruV9K1epDud55twujM4a4KQElyDRLK3tkXZtT2h9/Uumyy0mUk6mdQZK9lvAi06IW3FXzPw7UxNz+R26KS922w+A4i3CtZv6K9GMSe+AHkJV8hS3WTjF9ZEoHciYM1KXwT/RotrRIsorvc03LQrhtAq7cpPcBeUK3R0F7OzC7ILzr0Ae5fDgbJHD4A6KZKtl+3LD0wLKBpNyeeC9xMhIXWzr22+EC1kFCpXZlLmKEBThgMuFOVc9tNocwCzWBtQDFGINaJIDR5VDytB2tkplyIPL6ixFW1NuXsHNU1IjNaqrks32p5DfoB/p3GsILanRKNvq9V3MvVLq9sNdex+fKzvTdWKo1/SCgR4uA+dAH9o6UfrMA0DfVrkZHHFsEU4Ye+FHiAM24aTd2ShIDHP/46z8GbXs6LGFenCF/o8wycAsO XYWYi44O aGmVo4PDGC/iCzdayjWysmaQfkOfNfodC5PV9C21BazDBVBO+02P+p/kcL10PL+OshzvkEYKA83hEaDie4ImM+7LB2+9gRJ7uXq+4RdkW4PHUMchxQxvtSdVGrHOxy/7cGYAXAGPlAgmN8PTFlrDrhlmhKEOKer1O4OB+r+IATKIln46LbDFIiaPPKJxH9PcneLQS+8QkR+0VsazZkCu7He6MXKjNjUvmBOXEkT/dn3ksdauKP8a0qTKG96dm3n1YwFDbitgZ70BC7eT7op9mGtDgHC1wGztUHgO8ACF4eAxC3osWw7zGtzb00yYrjwUyZqwXso6BlRI6gB1l6njxuncyeTgE2WMooxmvOskUUfm48ic8UZOOxdw2tzwawX5VbuxrzQ4b6oRceI8g19cY3lnJirEcbQiZ8tihwEfvyWYNp/EtHWj3fSnPOma6UQR4mQaRNb535xk5SsAn1zvm61+KjJhVAmI9VveiaoQpY1haI+b/LWDuao45WaKN9HeQ1zsmBBDemI/5kWfqsMj4sZYBQ6GYadRkjJKq2ozRAolfB2k= 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: Make AF_ALG sendmsg() support MSG_SPLICE_PAGES. This causes pages to be spliced from the source iterator. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org --- crypto/af_alg.c | 28 ++++++++++++++++++++++++++-- crypto/algif_aead.c | 22 +++++++++++----------- crypto/algif_skcipher.c | 8 ++++---- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index fd56ccff6fed..62f4205d42e3 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -940,6 +940,10 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, bool init = false; int err = 0; + if ((msg->msg_flags & MSG_SPLICE_PAGES) && + !iov_iter_is_bvec(&msg->msg_iter)) + return -EINVAL; + if (msg->msg_controllen) { err = af_alg_cmsg_send(msg, &con); if (err) @@ -985,7 +989,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, while (size) { struct scatterlist *sg; size_t len = size; - size_t plen; + ssize_t plen; /* use the existing memory in an allocated page */ if (ctx->merge) { @@ -1030,7 +1034,27 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, if (sgl->cur) sg_unmark_end(sg + sgl->cur - 1); - if (1 /* TODO check MSG_SPLICE_PAGES */) { + if (msg->msg_flags & MSG_SPLICE_PAGES) { + struct sg_table sgtable = { + .sgl = sg, + .nents = sgl->cur, + .orig_nents = sgl->cur, + }; + + plen = extract_iter_to_sg(&msg->msg_iter, len, &sgtable, + MAX_SGL_ENTS, 0); + if (plen < 0) { + err = plen; + goto unlock; + } + + for (; sgl->cur < sgtable.nents; sgl->cur++) + get_page(sg_page(&sg[sgl->cur])); + len -= plen; + ctx->used += plen; + copied += plen; + size -= plen; + } else { do { struct page *pg; unsigned int i = sgl->cur; diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c index 829878025dba..35bfa283748d 100644 --- a/crypto/algif_aead.c +++ b/crypto/algif_aead.c @@ -9,8 +9,8 @@ * The following concept of the memory management is used: * * The kernel maintains two SGLs, the TX SGL and the RX SGL. The TX SGL is - * filled by user space with the data submitted via sendpage/sendmsg. Filling - * up the TX SGL does not cause a crypto operation -- the data will only be + * filled by user space with the data submitted via sendpage. Filling up + * the TX SGL does not cause a crypto operation -- the data will only be * tracked by the kernel. Upon receipt of one recvmsg call, the caller must * provide a buffer which is tracked with the RX SGL. * @@ -113,19 +113,19 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg, } /* - * Data length provided by caller via sendmsg/sendpage that has not - * yet been processed. + * Data length provided by caller via sendmsg that has not yet been + * processed. */ used = ctx->used; /* - * Make sure sufficient data is present -- note, the same check is - * also present in sendmsg/sendpage. The checks in sendpage/sendmsg - * shall provide an information to the data sender that something is - * wrong, but they are irrelevant to maintain the kernel integrity. - * We need this check here too in case user space decides to not honor - * the error message in sendmsg/sendpage and still call recvmsg. This - * check here protects the kernel integrity. + * Make sure sufficient data is present -- note, the same check is also + * present in sendmsg. The checks in sendmsg shall provide an + * information to the data sender that something is wrong, but they are + * irrelevant to maintain the kernel integrity. We need this check + * here too in case user space decides to not honor the error message + * in sendmsg and still call recvmsg. This check here protects the + * kernel integrity. */ if (!aead_sufficient_data(sk)) return -EINVAL; diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index a251cd6bd5b9..b1f321b9f846 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -9,10 +9,10 @@ * The following concept of the memory management is used: * * The kernel maintains two SGLs, the TX SGL and the RX SGL. The TX SGL is - * filled by user space with the data submitted via sendpage/sendmsg. Filling - * up the TX SGL does not cause a crypto operation -- the data will only be - * tracked by the kernel. Upon receipt of one recvmsg call, the caller must - * provide a buffer which is tracked with the RX SGL. + * filled by user space with the data submitted via sendmsg. Filling up the TX + * SGL does not cause a crypto operation -- the data will only be tracked by + * the kernel. Upon receipt of one recvmsg call, the caller must provide a + * buffer which is tracked with the RX SGL. * * During the processing of the recvmsg operation, the cipher request is * allocated and prepared. As part of the recvmsg operation, the processed From patchwork Tue May 30 14:16:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13260173 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 C1EAAC7EE2C for ; Tue, 30 May 2023 14:17:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C5256B007D; Tue, 30 May 2023 10:17:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 128C1280004; Tue, 30 May 2023 10:17:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5C496B0080; Tue, 30 May 2023 10:17:53 -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 C20896B007D for ; Tue, 30 May 2023 10:17:53 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7F6361A0224 for ; Tue, 30 May 2023 14:17:53 +0000 (UTC) X-FDA: 80847125226.02.D3BE17B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id AD77F4001D for ; Tue, 30 May 2023 14:17:51 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="MnXe2/o8"; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685456271; a=rsa-sha256; cv=none; b=eZ5SlJtZZQMxfTdmyARIXXXLHz8qkwuyJWZS9rzJpVcN9MTxXprcpy3ft8LmeQLaA7Wikh B6c6YUqiToPX68P1crVP9ajxDv6XI2POeo1eNlEaEjiaMgc4VIH66/vO0MWtBrIAJrRw1S pzbfL2Cw/dzdSXijfvWThJM7felramg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="MnXe2/o8"; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1685456271; 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=MjSSqX/syLjzwTkjbRl9f0Ha+hyqgimWwPgJCeougMc=; b=0XNf5uasf90S7cgIfdwRqPC2FEX4/kjULn9y/v2odPwNRQa1Cw1qRnT5/w67uHy7eZ3xsT NdyHf3Tv5GlaMafyEbTq2K9Y/iLoW2m73bfi1Xa3euVW7vbKRlKF8MKtmZj8gsRrv6K+91 VIi+DIit3NURlYEKQLYJ2U18ybXjvjg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685456270; 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=MjSSqX/syLjzwTkjbRl9f0Ha+hyqgimWwPgJCeougMc=; b=MnXe2/o86glsA54L7vCadvYqG9V5k5CeDbOEqMmRzg87M0eVXvvL/g2cfnOOYUvnsHY29Y O7EUHRRtCnj9p+6wnluvF0QeRCa/tH4UN3JRIYRzact/HP7XO1cPLqnmOvuzjyEqWI4Kfg hWpoT+f9FSz0fNnGWr4O/vjXndW3tZQ= 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-591-tTDWSCdgPwaguFY00P7trQ-1; Tue, 30 May 2023 10:17:47 -0400 X-MC-Unique: tTDWSCdgPwaguFY00P7trQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8744D280BC43; Tue, 30 May 2023 14:17:46 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 576C8112132C; Tue, 30 May 2023 14:17:43 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 09/10] crypto: af_alg: Convert af_alg_sendpage() to use MSG_SPLICE_PAGES Date: Tue, 30 May 2023 15:16:33 +0100 Message-ID: <20230530141635.136968-10-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: AD77F4001D X-Stat-Signature: gxchim4b4p1j9kk4ety7f9etkfpezef5 X-Rspam-User: X-HE-Tag: 1685456271-589693 X-HE-Meta: U2FsdGVkX1+OrXAPJxK2yngDY5dLfhA5AhNEaeMXkPKz6MhLz9tkGBvO5i0W+yyUDuT7ImtJKpwzYL5TTI9RmjeWvZwtrTtpuV/tv4hpD/KONW+fiA4UZ32uFFtZ3yu1U9IdHAsYSWDh4bxym45qbmexJz4XjPSdyq+7jdD45IgUS2YPfeyeqNjen1l45evZ2EoskO4XfSJxQ69F5goYqyZqLkZECAJujiRAZIvF/lxPjLAuvgqiKsjVdSJ80lK8DgI4vImFuwi0m8IzG8fuWR0EEv7dLkiKX97eutUQtb963IXvBM/Q130mGEwq416AafNY+Lji7a51PUDsvNmmMa1kMzWVpf/cheqOgqWJ+pRZRTQtLhuowSR7YP2vEnary5wLyjwiGznP4U2rYvmnORRzlLng1046uGSAKJ/x+FqKixkrcOizxMHGyvd9VJOH2mOUx81y3YEhsOzIAxvnBNLsbD8nuEpu5Cv/QQ0IjmSXfNdZBnxpG1zweplJc18J8LV8fVluXmfNttX3gJqAvE0Z3WVIF43JTWF17o3EX7ryLHimXDfXDkt1jENyVzmq9UK4Ga58RhojMxLsxJC61k5zWkPUA/B0QTnUw9pnI0Kk8MlDR8nTuj4bldWNvtbi5P9V7F0EpYvPX28jhKvJbaF/1FFC9Zfjq7J7TbIrpok94qbwptrF8mtqzhsj4Dm4rUaXl98BWQvZ8mbx5Ow+OWN3d1F+7K47LnMy2h0eb1Fxe+pRl2l7igRUV9Nx4j63FEvX3xhjCJ4pqICcej5Q9I6jKnkNpOfz1VZiV9ywHCVWRisQnQCCCKI6tM+Mcw6bXJAlJ+JgV4uMYmKbdIDEXPPJmUNQ+I8ZXQ0AOG1mfrvAHmy9syq3S119us/scfCEqeSvnahfEIl1alRmXOBKu7vRYgZrCVrRTq7sAOvftPPzMBpdPpwNjsDhemkls8LUii7UvQvPHbW7SkorAyR XZBwK0Oj 2CYfYopKQ9/6U+QJW682e58+L7OM211qI2RH4wEZb50pH16KItRQp0hSa1IyIXBFhuHEqnwbL/qLFC2vXWDjnvZfF3Pc/BBpQgkye/xAIftNNStY2n65mRI0QVNNNteV/6g016SNjEJFn4y7/SM4aeaHbq877BQ+Z/Ysq4oNNJgWyQz1zY/VvzAPDqqqTOZE8SRWugK73RkzIZwbyCr0N3O1IwlfVTh5nZeHZlLOyguOmZv7Twhm5iAUZTWM80EzyXH+cb+11Tgv37Be52hzp42aV2OfRUleGcueu0B3hbk+LMwBpxjKneNhbuEKsGMRZvu/GHSmioQp2xJHHXFuxKQqQJ0MeYRJYckOlLt5cRQ7rFVoI9esw8ieWYLKb2+f8Qcl6E0gzBPVo2x0lQMd9sq1i9f3MAsevsTegNV9rZeETtUDLpkca6fW3GUWM84bPnqpVqTHPaTSv4KsR+EAL0sfl+g1KhmDEpML9STGIp+VB5fsYbG0/GSLJxxYE9245e5X0Bp+ZKm1frf1+ZweunZQgqexEHjKyFDhQahuJHTGjPpo= 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: Convert af_alg_sendpage() to use sendmsg() with MSG_SPLICE_PAGES rather than directly splicing in the pages itself. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org --- crypto/af_alg.c | 52 ++++++++----------------------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 62f4205d42e3..e2fc9051ba39 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -1118,53 +1118,17 @@ EXPORT_SYMBOL_GPL(af_alg_sendmsg); ssize_t af_alg_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags) { - struct sock *sk = sock->sk; - struct alg_sock *ask = alg_sk(sk); - struct af_alg_ctx *ctx = ask->private; - struct af_alg_tsgl *sgl; - int err = -EINVAL; + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = flags | MSG_SPLICE_PAGES, + }; if (flags & MSG_SENDPAGE_NOTLAST) - flags |= MSG_MORE; - - lock_sock(sk); - if (!ctx->more && ctx->used) - goto unlock; - - if (!size) - goto done; - - if (!af_alg_writable(sk)) { - err = af_alg_wait_for_wmem(sk, flags); - if (err) - goto unlock; - } - - err = af_alg_alloc_tsgl(sk); - if (err) - goto unlock; - - ctx->merge = 0; - sgl = list_entry(ctx->tsgl_list.prev, struct af_alg_tsgl, list); - - if (sgl->cur) - sg_unmark_end(sgl->sg + sgl->cur - 1); - - sg_mark_end(sgl->sg + sgl->cur); - - get_page(page); - sg_set_page(sgl->sg + sgl->cur, page, size, offset); - sgl->cur++; - ctx->used += size; - -done: - ctx->more = flags & MSG_MORE; - -unlock: - af_alg_data_wakeup(sk); - release_sock(sk); + msg.msg_flags |= MSG_MORE; - return err ?: size; + bvec_set_page(&bvec, page, size, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size); + return sock_sendmsg(sock, &msg); } EXPORT_SYMBOL_GPL(af_alg_sendpage); From patchwork Tue May 30 14:16:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13260174 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 1B9BEC7EE33 for ; Tue, 30 May 2023 14:18:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AED45280004; Tue, 30 May 2023 10:17:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A75CF900002; Tue, 30 May 2023 10:17:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EF98280004; Tue, 30 May 2023 10:17:59 -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 7B1E6900002 for ; Tue, 30 May 2023 10:17:59 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2D147160276 for ; Tue, 30 May 2023 14:17:59 +0000 (UTC) X-FDA: 80847125478.28.C7352D4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id F09B04000A for ; Tue, 30 May 2023 14:17:55 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JAHUKqZx; spf=pass (imf04.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=1685456277; 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=NBXOPllhnShhjBRylpaDepFHduJQFj0kF52MtSgNo3M=; b=1j3QmSIk7a7yXHIWjRnkwOxoyc4f/JRD+FMtURFVWIiWKPM5vUfCaxKHRjQI8z+M6XMTqE l/Ce2y8TWDU+9by5ikhQqeK/ra7UpBloSxm6m8Z71JdsUA112gwYaXn6OD44EMgDY86FQS c0pfHVInHitOdo847kESq/mj9CAbboM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685456277; a=rsa-sha256; cv=none; b=sh4jGxPLnzVFLJ8VukMN0X0p9folPK4FzKVNuB44A59CzFoolCZKePCJsnj49tczPgRSTA tdFyTkC0l/CtvdXtZ9psiDT5sN4MxK8tDuD/mozdR1bw1VE9B6LaQa4eRRJJwuKQsotX/n ZYnaixwi0usClpqdcr3wqh3CkK4k9Y8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JAHUKqZx; spf=pass (imf04.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=1685456275; 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=NBXOPllhnShhjBRylpaDepFHduJQFj0kF52MtSgNo3M=; b=JAHUKqZxMU8QaseBE2858xlGKKwovvDC1jWfByjj4SxgsTFrMxP0PmwhKzCMBb/8QaN6Vk sNN8QLDowo37DxS/ISML16BSUkhvcFfTXhPMLxOtiofFAFkkDtP0SLAc6eyFyph2lLzcmS Z6hE2m1tU+uffwEQ93bR0NUnXTH1nRQ= 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-454-lYgHP-yeNMaEfEacsos-nA-1; Tue, 30 May 2023 10:17:52 -0400 X-MC-Unique: lYgHP-yeNMaEfEacsos-nA-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 D6652185A797; Tue, 30 May 2023 14:17:49 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DB6E140E956; Tue, 30 May 2023 14:17:47 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 10/10] crypto: af_alg/hash: Support MSG_SPLICE_PAGES Date: Tue, 30 May 2023 15:16:34 +0100 Message-ID: <20230530141635.136968-11-dhowells@redhat.com> In-Reply-To: <20230530141635.136968-1-dhowells@redhat.com> References: <20230530141635.136968-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Queue-Id: F09B04000A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: es1ic5r1gfbpfmt5rykk7gx8cmpwh53u X-HE-Tag: 1685456275-240246 X-HE-Meta: U2FsdGVkX1/wtd9gy+n8zljVNE76HEmneMuHFNS1uJO6WbIph6c4OP/oorZ5rLJ1+i1em4O5mTGOz2eqp7aErv7XokQNETYtm/YpoNEVYbgyg+MlDkhQFC25uq5hHOQIIbzlDA+Xeec+ucC+PGsCvK8gH6MKaJSdsYV4YEKE98JoRdBbf5MKy8BybgYu7J6NbbskjOQxjehhb96HBveHetHzZNViQ5PKaorrYxK38l8M03AiB6PxzfIOUby7S1Mfxg+3DRc/atLZo+m4IV4EPlCWWivZq0obimho0daLuM+788YDow72YFZVva7iFq3J2Q+kM8dsJ3xHFkmegWYy2c255ZniLkLjWlH4oWhpg243FBNX6jjn9df04CfAXhZOMWyNTV1I6nCtXOL758rAwfybA1iBh22xYH09ztXp0zCWtWS0JAszNKLOO+dsA49J5onD3/JM5LwAmCtyqDxa3CFikBcPOYfEgT73PViso77rUEbnPDTeqVJDS6+6pYynD1L8zQEPqVb+fO8oFppjHNPySrJT6AUHZ9TtCSvt3COVBC+L11+ExCk9On+3bvacp2iZ4EXSVwYZlshHe/nqd1LrvdLuQYz1RmX4OEx2qH6QrcNLCa7XmUtHhiMsC+3LxYUBpvsuq0gIqZr0E2bnP22ooOYHmzPNOPRkJyTkX2rknvPyLSiJ445lb84OypBFCiHyTVCZ+X5yvxBPy7VbuTSXuASuLyWRXwZ9xdBKh4uYhShlYTaAnXl8fpoj+Zsg3xMrC1NwLfO3JERg+kBgmmYSLCySYk2OOgKO6MbY5FrUzS0C+mL+8cGGHbWxDb+89oxN8PrOl65HSqjJEiXiAiyZHNNJIeXP9ZNPDhpPQIFTef1wV7rjdeOeHsMghRgGZJdYGrElid0K3L3ADQT0QbLkbVR9oQEpH19ddrj73o/JqxMd74JX2yMvkLEY8B9JgWBUpNREfwN8FsJRBqE zOjACqWZ +ZldsY8ljSyF/WcgtvOXXcZiIuNEj1gaIIPdjsgwPaiQq8F4lWF85bGiBKrfqJ3mPe6ZmzQ973b2bkU84lY0Ptx7y+TbT2ktEZ3F12cHLNHqzTzt3rCczxLNrOfCvttxdmyKE9gmPwAb2QEBt1YKXzW37DgKAtlSJUDDfvf6yAfLZVJrIXOinabprJ3y3rt0q7Qfb4luk3k1QxwBQ58DwQfFYrzanXvo0Vi2dvgUFFPuWjx+5NdM8MXRsD1T5vYPdVPtlIA+VtaUuqdsbpP+YYg5GdMw8X3u2HLXbhEOfLOdyz+Co2HXbEoEciCZCDP6G71ibjN5tcPvRozQ1/++/JqSchgikTYbjY7125oaP3rncQnqmqc9K9m2zOPbIcocrKxx+XAtsj/y01XJkAz8rAGMlFHKJ1i+Yi4mOS8EsoUE9p1zCY/uxNut74dKbqFrNFVNhWi6ztiVzyRoN8OM5oeh9y6tUcLGyFuRhnucEqy0u3G7JPkhGkaCLBG5OuEroToYwSUFHLMUtBMVfcc7/WPhfjITC+T8jmS7uzy9y7SN+jS0= 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: Make AF_ALG sendmsg() support MSG_SPLICE_PAGES in the hashing code. This causes pages to be spliced from the source iterator if possible. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #2) - Fixed some checkpatch warnings. crypto/af_alg.c | 11 +++-- crypto/algif_hash.c | 104 ++++++++++++++++++++++++++++---------------- 2 files changed, 74 insertions(+), 41 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index e2fc9051ba39..b78a399d0e19 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -542,9 +542,14 @@ void af_alg_free_sg(struct af_alg_sgl *sgl) { int i; - if (sgl->need_unpin) - for (i = 0; i < sgl->sgt.nents; i++) - unpin_user_page(sg_page(&sgl->sgt.sgl[i])); + if (sgl->sgt.sgl) { + if (sgl->need_unpin) + for (i = 0; i < sgl->sgt.nents; i++) + unpin_user_page(sg_page(&sgl->sgt.sgl[i])); + if (sgl->sgt.sgl != sgl->sgl) + kvfree(sgl->sgt.sgl); + sgl->sgt.sgl = NULL; + } } EXPORT_SYMBOL_GPL(af_alg_free_sg); diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index 16c69c4b9c62..2f7a98b0eae3 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c @@ -63,78 +63,106 @@ static void hash_free_result(struct sock *sk, struct hash_ctx *ctx) static int hash_sendmsg(struct socket *sock, struct msghdr *msg, size_t ignored) { - int limit = ALG_MAX_PAGES * PAGE_SIZE; struct sock *sk = sock->sk; struct alg_sock *ask = alg_sk(sk); struct hash_ctx *ctx = ask->private; - long copied = 0; + ssize_t copied = 0; + size_t len, max_pages = ALG_MAX_PAGES, npages; + bool continuing = ctx->more, need_init = false; int err; - if (limit > sk->sk_sndbuf) - limit = sk->sk_sndbuf; + /* Don't limit to ALG_MAX_PAGES if the pages are all already pinned. */ + if (!user_backed_iter(&msg->msg_iter)) + max_pages = INT_MAX; + else + max_pages = min_t(size_t, max_pages, + DIV_ROUND_UP(sk->sk_sndbuf, PAGE_SIZE)); lock_sock(sk); - if (!ctx->more) { + if (!continuing) { if ((msg->msg_flags & MSG_MORE)) hash_free_result(sk, ctx); - - err = crypto_wait_req(crypto_ahash_init(&ctx->req), &ctx->wait); - if (err) - goto unlock; + need_init = true; } ctx->more = false; while (msg_data_left(msg)) { - int len = msg_data_left(msg); - - if (len > limit) - len = limit; - ctx->sgl.sgt.sgl = ctx->sgl.sgl; ctx->sgl.sgt.nents = 0; ctx->sgl.sgt.orig_nents = 0; - len = extract_iter_to_sg(&msg->msg_iter, len, &ctx->sgl.sgt, - ALG_MAX_PAGES, 0); - if (len < 0) { - err = copied ? 0 : len; - goto unlock; + err = -EIO; + npages = iov_iter_npages(&msg->msg_iter, max_pages); + if (npages == 0) + goto unlock_free; + + if (npages > ARRAY_SIZE(ctx->sgl.sgl)) { + err = -ENOMEM; + ctx->sgl.sgt.sgl = + kvmalloc(array_size(npages, + sizeof(*ctx->sgl.sgt.sgl)), + GFP_KERNEL); + if (!ctx->sgl.sgt.sgl) + goto unlock_free; } - sg_mark_end(ctx->sgl.sgt.sgl + ctx->sgl.sgt.nents); + sg_init_table(ctx->sgl.sgl, npages); ctx->sgl.need_unpin = iov_iter_extract_will_pin(&msg->msg_iter); - ahash_request_set_crypt(&ctx->req, ctx->sgl.sgt.sgl, NULL, len); + err = extract_iter_to_sg(&msg->msg_iter, LONG_MAX, + &ctx->sgl.sgt, npages, 0); + if (err < 0) + goto unlock_free; + len = err; + sg_mark_end(ctx->sgl.sgt.sgl + ctx->sgl.sgt.nents - 1); - err = crypto_wait_req(crypto_ahash_update(&ctx->req), - &ctx->wait); - af_alg_free_sg(&ctx->sgl); - if (err) { - iov_iter_revert(&msg->msg_iter, len); - goto unlock; + if (!msg_data_left(msg)) { + err = hash_alloc_result(sk, ctx); + if (err) + goto unlock_free; } - copied += len; - } + ahash_request_set_crypt(&ctx->req, ctx->sgl.sgt.sgl, + ctx->result, len); - err = 0; + if (!msg_data_left(msg) && !continuing && + !(msg->msg_flags & MSG_MORE)) { + err = crypto_ahash_digest(&ctx->req); + } else { + if (need_init) { + err = crypto_wait_req( + crypto_ahash_init(&ctx->req), + &ctx->wait); + if (err) + goto unlock_free; + need_init = false; + } + + if (msg_data_left(msg) || (msg->msg_flags & MSG_MORE)) + err = crypto_ahash_update(&ctx->req); + else + err = crypto_ahash_finup(&ctx->req); + continuing = true; + } - ctx->more = msg->msg_flags & MSG_MORE; - if (!ctx->more) { - err = hash_alloc_result(sk, ctx); + err = crypto_wait_req(err, &ctx->wait); if (err) - goto unlock; + goto unlock_free; - ahash_request_set_crypt(&ctx->req, NULL, ctx->result, 0); - err = crypto_wait_req(crypto_ahash_final(&ctx->req), - &ctx->wait); + copied += len; + af_alg_free_sg(&ctx->sgl); } + ctx->more = msg->msg_flags & MSG_MORE; + err = 0; unlock: release_sock(sk); + return copied ?: err; - return err ?: copied; +unlock_free: + af_alg_free_sg(&ctx->sgl); + goto unlock; } static ssize_t hash_sendpage(struct socket *sock, struct page *page,