From mboxrd@z Thu Jan 1 00:00:00 1970 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 52803C433FE for ; Tue, 1 Nov 2022 16:59:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE8846B0071; Tue, 1 Nov 2022 12:59:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D71958E0001; Tue, 1 Nov 2022 12:59:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC38E6B0074; Tue, 1 Nov 2022 12:59:58 -0400 (EDT) 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 A64C06B0071 for ; Tue, 1 Nov 2022 12:59:58 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 71B50161039 for ; Tue, 1 Nov 2022 16:59:58 +0000 (UTC) X-FDA: 80085485676.25.1E6E28B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 8A3F2180044 for ; Tue, 1 Nov 2022 16:59:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667321996; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-to: resent-from:resent-message-id; bh=11t7t2M5S9FVtreaeqc7IEi/JpUAAyL70GwctMIr/Uo=; b=A1klIP2dD0aGEh9sxm5AxQ08sVzhdCJ6HwviBfAW1T8elk1E507SgOJEBOK+r988M9CqgN tbzH8MXmaGiQ01QWH7A+dBnLu7AuApVI/3EOCbUQHCUY/TDrCCsE/8OvUgZJjpqXJlSXYF 8FDMmQC/simPwS2U42+ftjU8JI5Tx6Y= 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-83-aOp2EZeXPu6tRuJ6Nq8VQg-1; Tue, 01 Nov 2022 12:59:55 -0400 X-MC-Unique: aOp2EZeXPu6tRuJ6Nq8VQg-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 8EEDB101A54E for ; Tue, 1 Nov 2022 16:59:55 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40B6DC2C8C8 for ; Tue, 1 Nov 2022 16:59:55 +0000 (UTC) X-Mailbox-Line: From dhowells Tue Nov 1 16: 30:58 2022 Received: from imap.gmail.com [2a00:1450:400c:c00::6d] by warthog.procyon.org.uk with IMAP (fetchmail-7.0.0-alpha9) for (single-drop); Tue, 01 Nov 2022 16:30:58 +0000 (GMT) Received: by 2002:ac0:c78e:0:0:0:0:0 with SMTP id j14csp1842765imk; Tue, 1 Nov 2022 09:30:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6seLqObpaZiVaxtTAeb1Z1H3EJbSgCqWHA4ctla4T0T9crv93W1DjkxT4yStAdHTeqaQkt X-Received: by 2002:a17:907:7f16:b0:7ad:bf79:f9b6 with SMTP id qf22-20020a1709077f1600b007adbf79f9b6mr14791067ejc.61.1667320247697; Tue, 01 Nov 2022 09:30:47 -0700 (PDT) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com. [205.139.110.61]) by mx.google.com with ESMTPS id nc42-20020a1709071c2a00b007ad96737de4si12697990ejc.624.2022.11.01.09.30.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Nov 2022 09:30:47 -0700 (PDT) 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-528-PI8tfpbbMnukRwlmZrjVzw-1; Tue, 01 Nov 2022 12:30:45 -0400 X-MC-Unique: PI8tfpbbMnukRwlmZrjVzw-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 EE164185A78F for ; Tue, 1 Nov 2022 16:30:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EAFDF4EA5F; Tue, 1 Nov 2022 16:30:44 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD9AC4EA49; Tue, 1 Nov 2022 16:30:42 +0000 (UTC) Subject: [RFC PATCH 00/12] smb3: Add iter helpers and use iov_iters down to the network transport From: David Howells To: Steve French , Al Viro Cc: linux-cachefs@redhat.com, John Hubbard , linux-cifs@vger.kernel.org, linux-rdma@vger.kernel.org, Jeff Layton , linux-mm@vger.kernel.org, linux-fsdevel@vger.kernel.org, Matthew Wilcox , Steve French , Shyam Prasad N , linux-crypto@vger.kernel.org, Rohith Surabattula , Christoph Hellwig , dhowells@redhat.com, Shyam Prasad N , Rohith Surabattula , Tom Talpey , Christoph Hellwig , Matthew Wilcox , Jeff Layton , linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 01 Nov 2022 16:30:41 +0000 Message-ID: <166732024173.3186319.18204305072070871546.stgit@warthog.procyon.org.uk> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667321997; a=rsa-sha256; cv=none; b=jCAHJ+ng3c6/UQC52wbgcozR2UW52ljz5XxF8qCYbO6h3xNIikqk3T2U0lAd3s4VrHrU8k FAGDLPApTgKXAty7ZkysjZjFAr+4ism7EsjGMSCB4t5AXm5B9EoQwh4R/DHtHX0vrSJF+G ubia/wHR82Omn8f2pmwxQesZNYU/Ad0= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A1klIP2d; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.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=1667321997; 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-type: content-transfer-encoding:content-transfer-encoding:resent-to: resent-from:resent-message-id:in-reply-to:references:dkim-signature; bh=11t7t2M5S9FVtreaeqc7IEi/JpUAAyL70GwctMIr/Uo=; b=mWh3A83EKGfIwVr010GHuFB/+gejOhQTA3pWAyhE7ZiMhrWu91IK02LrYTf0xdnU1eUJ62 OJlaUsV82qGL8O2vAh/RJEH6UShHC99MmAFfabAiSauV4gOLdFHAEEI5FKeIwYRLNfAUTV tdkzjozFo78++mKWRHIZvLAB+bPZXHE= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 8A3F2180044 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A1klIP2d; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com X-Stat-Signature: jqj5z87im8aywhefxb5pq9qodropr8tk X-HE-Tag: 1667321997-526319 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: Hi Steve, Al, Christoph, Here's an updated version of a subset of my branch to make the cifs/smb3 driver pass iov_iters down to the lowest layers where they can be passed to the network transport. The first couple of patches provide iov_iter general stuff: (1) Move the FOLL_* flags to linux/mm_types.h so that linux/uio.h can make use of them. (2) Add a function to extract/get/pin pages from an iterator as a future replacement for iov_iter_get_pages*(). It also adds a function by which the caller can determine which of "extract/get/pin" the extraction function will actually do to aid in cleaning up. Then there are a couple of patches that add stuff to netfslib that I want to use there as well as in cifs: (3) Add a netfslib function to use (2) to extract pages from an ITER_IOBUF or ITER_UBUF iterator into an ITER_BVEC iterator. (4) Add a netfslib function to use (2) to extract pages from an iterator that's of type ITER_UBUF/IOVEC/BVEC/KVEC/XARRAY and add them to a scatterlist. The function in (2) is used for a UBUF and IOVEC iterators, so those need cleaning up afterwards; BVEC and XARRAY iterators can be rendered into elements that span multiple pages. Then there are some cifs helpers that work with iterators: (5) Implement cifs_splice_read() to use an ITER_BVEC rather than an ITER_PIPE, bulk-allocating the pages, attaching them to the bvec, doing the I/O and then pushing the pages into the pipe. This avoids the problem with cifs wanting to split the pipe iterator in a later patch. (6) Add a function to walk through an ITER_BVEC/KVEC/XARRAY iterator and add elements to an RDMA SGE list. Only the DMA addresses are stored, and an element may span multiple pages (say if an xarray contains a multipage folio). (7) Add a function to walk through an ITER_BVEC/KVEC/XARRAY iterator and pass the contents into a shash function. (8) Add functions to walk through an ITER_XARRAY iterator and perform various sorts of cleanup on the folios held therein, to be used on I/o completion. (9) Add a function to read from the transport TCP socket directly into an iterator. Then come the patches that actually do the work of iteratorising cifs: (10) The main patch. Replace page lists with iterators. It extracts the pages from ITER_UBUF and ITER_IOVEC iterators to an ITER_BVEC iterator, pinning or getting refs on them, before passing them down as the I/O may be done from a worker thread. The iterator is extracted into a scatterlist in order to talk to the crypto interface or to do RDMA. (11) In the cifs RDMA code, extract the iterator into an RDMA SGE[] list, removing the scatterlist intermediate - at least for smbd_send(). There appear to be other ways for cifs to talk to the RDMA layer that don't go through that that I haven't managed to work out. (12) Remove a chunk of now-unused code. Note also that I haven't managed to test all the combinations of transport. Samba doesn't support RDMA and ksmbd doesn't support encryption. I can test them separately, but not together. That said, rdma, sign, seal and sign+seal seem to work. I've pushed the patches here also: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=cifs-for-viro Note that this is based on a merge of Al's work.iov_iter branch with v6.1-rc2. David Link: https://lore.kernel.org/r/166697254399.61150.1256557652599252121.stgit@warthog.procyon.org.uk/ --- David Howells (12): mm: Move FOLL_* defs to mm_types.h iov_iter: Add a function to extract a page list from an iterator netfs: Add a function to extract a UBUF or IOVEC into a BVEC iterator netfs: Add a function to extract an iterator into a scatterlist cifs: Implement splice_read to pass down ITER_BVEC not ITER_PIPE cifs: Add a function to build an RDMA SGE list from an iterator cifs: Add a function to Hash the contents of an iterator cifs: Add some helper functions cifs: Add a function to read into an iter from a socket cifs: Change the I/O paths to use an iterator rather than a page list cifs: Build the RDMA SGE list directly from an iterator cifs: Remove unused code fs/cifs/Kconfig | 1 + fs/cifs/cifsencrypt.c | 172 +++- fs/cifs/cifsfs.c | 12 +- fs/cifs/cifsfs.h | 6 + fs/cifs/cifsglob.h | 31 +- fs/cifs/cifsproto.h | 11 +- fs/cifs/cifssmb.c | 13 +- fs/cifs/connect.c | 16 + fs/cifs/file.c | 1793 ++++++++++++++++++-------------------- fs/cifs/fscache.c | 22 +- fs/cifs/fscache.h | 10 +- fs/cifs/misc.c | 127 +-- fs/cifs/smb2ops.c | 378 ++++---- fs/cifs/smb2pdu.c | 45 +- fs/cifs/smbdirect.c | 503 +++++++---- fs/cifs/smbdirect.h | 4 +- fs/cifs/transport.c | 57 +- fs/netfs/Makefile | 1 + fs/netfs/iterator.c | 346 ++++++++ include/linux/mm.h | 74 -- include/linux/mm_types.h | 73 ++ include/linux/netfs.h | 5 + include/linux/uio.h | 29 + lib/iov_iter.c | 333 +++++++ 24 files changed, 2390 insertions(+), 1672 deletions(-) create mode 100644 fs/netfs/iterator.c