From patchwork Thu Feb 16 21:47:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13143998 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 7516CC636CC for ; Thu, 16 Feb 2023 21:48:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 168D96B007B; Thu, 16 Feb 2023 16:48:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1192F6B0087; Thu, 16 Feb 2023 16:48:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F23066B0088; Thu, 16 Feb 2023 16:48:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E332F6B007B for ; Thu, 16 Feb 2023 16:48:49 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C0F31A116A for ; Thu, 16 Feb 2023 21:48:49 +0000 (UTC) X-FDA: 80474495178.18.B7F874D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 1058540002 for ; Thu, 16 Feb 2023 21:48:47 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="UQ5q/TTO"; spf=pass (imf12.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=1676584128; 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=ZbR1ERx60swPmHLlvc4O0e0pHhwkZikBmUg0OVIfTvo=; b=O6WE/dZThSES9LMCy/IpxSHSwTHJZHjksqcesYyd5+R0n1ncl17AsFWfkChjpRJEUuQD4i DAza0wZ2p9vjsS/6B01GUvcMguTXnpVttQ7XTkrkaXVSMtUqZWAZFo9qGpzj9sbqP0ydAU QrLk8Yf5/Bh0lMkYRHYZuOoNSffApGk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="UQ5q/TTO"; spf=pass (imf12.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=1676584128; a=rsa-sha256; cv=none; b=P9ysOtLA8yYkokXM3FI4lHtAP7t7IwX3BORcHYMcxXHuEQyNrFpZtMqlF0SJK+QNSs+J8H d+lTAGkTPyYnD7oKOuVDIqzwoUeDDnK6HALeVGs6pslx3OloOvrcmngTsVb5nA6UzcC9OU WplitDZk5osJBwCh/qe1PWdsi3uc1ac= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676584127; 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=ZbR1ERx60swPmHLlvc4O0e0pHhwkZikBmUg0OVIfTvo=; b=UQ5q/TTO/xk7WWehvahW6vpMttAH2jFOy8p9ZwR8I1WTwvKxM4dFYpFvDVXriK3qJKN0p4 6oTZ6zlRmq8+v/U8JpQVzGPBa241oaqV1OwQZjjzWR3x+j6pTwrhRQAYVUz9DHlQQqzhjH xjG2kEDbZuVDmHhyd4q41kCul1wa1Us= 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-515-O-HRLX8QP9akrW_MwZnTmA-1; Thu, 16 Feb 2023 16:48:44 -0500 X-MC-Unique: O-HRLX8QP9akrW_MwZnTmA-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 6773985A5B1; Thu, 16 Feb 2023 21:48:43 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7979251FF; Thu, 16 Feb 2023 21:48:41 +0000 (UTC) From: David Howells To: Steve French Cc: David Howells , Jens Axboe , Al Viro , Shyam Prasad N , Rohith Surabattula , Tom Talpey , Stefan Metzmacher , Christoph Hellwig , Matthew Wilcox , Jeff Layton , linux-cifs@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Steve French Subject: [PATCH 13/17] cifs: Add a function to read into an iter from a socket Date: Thu, 16 Feb 2023 21:47:41 +0000 Message-Id: <20230216214745.3985496-14-dhowells@redhat.com> In-Reply-To: <20230216214745.3985496-1-dhowells@redhat.com> References: <20230216214745.3985496-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: rspam04 X-Rspamd-Queue-Id: 1058540002 X-Stat-Signature: cdix5qwzubom7iqx38q9ts5adhgx6zxc X-HE-Tag: 1676584127-351530 X-HE-Meta: U2FsdGVkX1/EttP2Y3gxS9g+Dyc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70AasruhSFV6MSswW2OJ2lQbRrmY+be846P88gm42nCXTn0ED4kM4BbJfVPoxNnDjtZmLnblL1hKxuFhj89lK3Cy3ktK/dkFCtgZcK8J0oApkdTXyzFsJ9X2T38Gt85sfyHvkFAl42gNYb55crXOnj0RqbkxdLVbobCDFNumN8lgc7Qpop43ylp99qkOKqTRz1vdkRBncXJEtnVdknQG6yRInznUrmy4o5bJBopph6jKXSIwNhYhHdk1P52QrqpJW5mi2vH2T2xEn46q8/hsKxXCGwwLSpZ0BvW/oHRdKYvK+5XooqDJozIIYoRA/espYeqZg9oKha4zUgPfLtYxDkRd8FqVppNsm1o/ksZyirUJ833NDPBDt90/rnVclsg1wuBtIFiM3ILWPuqSW4UqwW4JjxRQ== 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: Add a helper function to read data from a socket into the given iterator. Signed-off-by: David Howells cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jeff Layton cc: linux-cifs@vger.kernel.org Link: https://lore.kernel.org/r/164928617874.457102.10021662143234315566.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/165211419563.3154751.18431990381145195050.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/165348879662.2106726.16881134187242702351.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/165364826398.3334034.12541600783145647319.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/166126395495.708021.12328677373159554478.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/166697258876.61150.3530237818849429372.stgit@warthog.procyon.org.uk/ # rfc Link: https://lore.kernel.org/r/166732031039.3186319.10691316510079412635.stgit@warthog.procyon.org.uk/ # rfc --- fs/cifs/cifsproto.h | 3 +++ fs/cifs/connect.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 1207b39686fb..cb7a3fe89278 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -244,6 +244,9 @@ extern int cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page, unsigned int page_offset, unsigned int to_read); +int cifs_read_iter_from_socket(struct TCP_Server_Info *server, + struct iov_iter *iter, + unsigned int to_read); extern int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb); void cifs_mount_put_conns(struct cifs_mount_ctx *mnt_ctx); int cifs_mount_get_session(struct cifs_mount_ctx *mnt_ctx); diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index b2a04b4e89a5..152b457b849f 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -765,6 +765,20 @@ cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page, return cifs_readv_from_socket(server, &smb_msg); } +int +cifs_read_iter_from_socket(struct TCP_Server_Info *server, struct iov_iter *iter, + unsigned int to_read) +{ + struct msghdr smb_msg = { .msg_iter = *iter }; + int ret; + + iov_iter_truncate(&smb_msg.msg_iter, to_read); + ret = cifs_readv_from_socket(server, &smb_msg); + if (ret > 0) + iov_iter_advance(iter, ret); + return ret; +} + static bool is_smb_response(struct TCP_Server_Info *server, unsigned char type) {