From patchwork Thu Mar 16 15:26:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13177815 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 74041C6FD1F for ; Thu, 16 Mar 2023 15:27:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63323940011; Thu, 16 Mar 2023 11:27:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E19B94000A; Thu, 16 Mar 2023 11:27:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FBDB940011; Thu, 16 Mar 2023 11:27:11 -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 1AEAE94000A for ; Thu, 16 Mar 2023 11:27:11 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id F0B131A0601 for ; Thu, 16 Mar 2023 15:27:10 +0000 (UTC) X-FDA: 80575139820.25.335582A 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 2E0F34001F for ; Thu, 16 Mar 2023 15:27:09 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dewr0Sha; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.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=1678980429; 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=Fl0FVU0Ldf/kGpij9uVxFzVxVMUJY5FbZMiRTa3smnM=; b=4EGiV/dJRcGUJDRuF0paiComOufov9UB2kjOzKu6CFKqkiJBsJDX6B29OKJ2Rp6dIFvheE lIUnlsY/SDBMfFplQgGEiFZ8wGUBZoBXusssy+xeK5wskVO7oRM8EiVPB6ay+JyRaeqh5R mVgEttIuWdmnFk6BvdCx28c70m2nLv4= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dewr0Sha; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.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=1678980429; a=rsa-sha256; cv=none; b=UFQHNUP3DRcHgxuZw0hPDGADm2hPi22GgO2W7cwFjp+0PP//dkeVo1yY3x/uUELD4fqcQP ygBB1TvlebCBPkt/QYinH4ZVBwE7UBobeMsj0JMyxVibZn5iOFgpOBRLJpcIAFHPeBou9C Pf2iBxa5ynkLLbgQLk1W7oHMK7//WkM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678980427; 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=Fl0FVU0Ldf/kGpij9uVxFzVxVMUJY5FbZMiRTa3smnM=; b=dewr0ShahuoRosngOMtTCAP1LLI7V0r0a86ZQvdcBNMHsF2/2yN3IjDGL8Pfzd8PvbDuSs QfESLIzEyLT5SE+QvaTF2heQ906ljLGejIxgOs3i547l04BpBM0PNgGzI8nfl1X/oj4LwY 95K4gNbGjRXD43Ykk6qjkL+fTfFZle4= 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-216-khorhuokMxiDfSWLdIPQyg-1; Thu, 16 Mar 2023 11:27:00 -0400 X-MC-Unique: khorhuokMxiDfSWLdIPQyg-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 6213F96DC83; Thu, 16 Mar 2023 15:26:57 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64DEF35453; Thu, 16 Mar 2023 15:26:55 +0000 (UTC) From: David Howells To: Matthew Wilcox , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: David Howells , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Linus Torvalds , netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Herbert Xu , linux-crypto@vger.kernel.org Subject: [RFC PATCH 13/28] crypto: af_alg: Indent the loop in af_alg_sendmsg() Date: Thu, 16 Mar 2023 15:26:03 +0000 Message-Id: <20230316152618.711970-14-dhowells@redhat.com> In-Reply-To: <20230316152618.711970-1-dhowells@redhat.com> References: <20230316152618.711970-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2E0F34001F X-Stat-Signature: w4uja4nmxrduo1hm9crnty7rzkox6pjp X-HE-Tag: 1678980429-89704 X-HE-Meta: U2FsdGVkX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Bi7SmNGcsffnSNTuproHE0E9Af1b+yOiU2ABobPU9Zz/3MI09u0hw/rbgB56Oi+FYbKu1Tlfs+WOu9PhtFv4dIc/XTPbOfaR7w/eCZxZV1hP7fuzi0opMx7HrSCt10axfcIVqJercvY/4Hy82n6OlXqUodkqbbsZEYT1lPTbS/ULczkGoXiU+OESuE8x1GeReKVi4zFO6Dw8W+c/uXnF/sh/qJekAOOp62ys2dG1Y9St5xOpPERpD0Jky6kDX0NQeJhInyYXqdl2/uzPxWSQtRVeksh8nCP1OL3dd0yDaUJn35fAe54nebRsqAvKOAW6g6eUR2UMQFsRA+XL5eB7Km60Mt8zsmOKH+e7cJRwLOms7Yx3vEPxVzj2+m3cw== 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 --- crypto/af_alg.c | 50 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 5f7252a5b7b4..feb989b32606 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -1060,35 +1060,37 @@ 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);