From patchwork Mon Feb 5 22:57:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13546378 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 38904C4828D for ; Mon, 5 Feb 2024 22:57:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FF626B0092; Mon, 5 Feb 2024 17:57:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 485636B0093; Mon, 5 Feb 2024 17:57:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2627D6B0095; Mon, 5 Feb 2024 17:57:47 -0500 (EST) 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 12F056B0092 for ; Mon, 5 Feb 2024 17:57:47 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CC22580AF7 for ; Mon, 5 Feb 2024 22:57:46 +0000 (UTC) X-FDA: 81759264132.02.4261A7B 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 3A5BA8000E for ; Mon, 5 Feb 2024 22:57:45 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Rx8Ggumj; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.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=1707173865; 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:references:dkim-signature; bh=m84d7QF2RHzKEpc2iYUiWaNTbg9vVp06SyHcrHDZtG0=; b=TSgynSzM7R//S+yflk8pdtrMz89B204OLG9r7ASD63KCSZ614OsPfEzZ/ztGVptZUv85k5 NDfBfWnP+LWPo2qnyk4cp1KZatQy47H/MQLLwhURF36gaPhJBunkTYKshaB/SItglNXUoy pQEwYGnOGz0HwEYYmgCfMoGApbf+ob8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Rx8Ggumj; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.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=1707173865; a=rsa-sha256; cv=none; b=eef8D3zdqFOxZ5TMpw88kPFlbVQEIAyos0HziX/Av0zSHVDSe+EKBPRw66DC9HtQMYbEGy MGdkSuaSf2qdLiV2UG3hbGdRJb2Gjlamg3g9ir7skCSeFtjNe1EEhYOiomzNp3WlacTeAN +E0ZmOZDT1eNNNFNT1QD5Ih1bLnLIAQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707173864; 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; bh=m84d7QF2RHzKEpc2iYUiWaNTbg9vVp06SyHcrHDZtG0=; b=Rx8GgumjqB1DxBAuwgITMl9m6azUkROz0knCpYVN1qofCZoVPQS8FJcyRJ8WKkwJXyzTpN H3ZGZ9fP5X1fUj0zF1PPKTAfKK/Nj/C8vygNUnkzrRaSzl8OT6kiTsihA80y6waeIAmd+5 UtiWbAFUAVYSWWtKXALolEl8rUs3XSk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-287-kn07yk8aMjSd8XV0XktC_Q-1; Mon, 05 Feb 2024 17:57:31 -0500 X-MC-Unique: kn07yk8aMjSd8XV0XktC_Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 35A77845DC0; Mon, 5 Feb 2024 22:57:31 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19C7B1121312; Mon, 5 Feb 2024 22:57:29 +0000 (UTC) From: David Howells To: Steve French Cc: David Howells , Jeff Layton , Matthew Wilcox , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Christian Brauner , netfs@lists.linux.dev, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 00/12] netfs, cifs: Delegate high-level I/O to netfslib Date: Mon, 5 Feb 2024 22:57:12 +0000 Message-ID: <20240205225726.3104808-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Rspamd-Queue-Id: 3A5BA8000E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 4aq6kzey5fowy8htbnhj9odhj9q77zia X-HE-Tag: 1707173865-840500 X-HE-Meta: U2FsdGVkX19JDpBwov7nukppJ3lnay6LsxLq4yvvkx5wEfjeCqLNDBYY7EdEC4S75w/dXz7Hsx+PfBr8QKJnv/L/buM/r1FcA84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VcUxBM/mXxZ2Cix/rrfqsZo5cwAoBIdjH+h524Zo5b24tttL6+lik= 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: List-Subscribe: List-Unsubscribe: Hi Steve, Here are patches to convert cifs to use the netfslib library. With this I can run a certain amount of xfstests on CIFS, though not all the tests work correctly because of fallocate issues. The patches remove around 2000 lines from CIFS To do: (*) Implement write-retry. Currently, netfslib errors out on a failed DIO write and relies on the VM to drive writepages again on a failed buffered write. This needs some retry logic adding into fs/netfs/output.c. I'm not sure what the best way to handle this is. One way is to resend each failing subreq as it fails, offloading this to a kernel thread that re-splits the subreq, calling out to a rreq->op to do the splitting, thereby allowing cifs to renegotiate credits. If a subreq is split, the two parts need to be adjacent in the rreq->subrequests list. An alternative way might be to try and combine failing tests and then split them. Yet a third way might be to try each failing subreq a smaller bit at a time and keep track of what has been sent in wdata->subreq.transferred. Whichever way is chosen, NETFS_SREQ_RETRYING should be set in wdata->subreq.flags instead of setting wdata->replay. Notes: (1) CIFS is made to use unbuffered I/O for unbuffered caching modes and write-through caching for cache=strict. (2) Various cifs fallocate() function implementations have issues that aren't easily fixed without enhanced protocol support. (3) It should be possible to turn on multipage folio support in CIFS now. (4) The then-unused CIFS code is removed in three patches, not one, to avoid the git patch generator from producing confusing patches in which it thinks code is being moved around rather than just being removed. The patches can be found here also: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=cifs-netfs Changes ======= ver #5) - Rebased to -rc3 plus SteveF's for-next branch as netfslib is now upstream, as are a couple of patches from this series. - Replace the ->replay bool Shyam added with a flag on the netfs subrequest. This is tested by the code, but not currently set (see above). ver #4) - Slimmed down the branch: - Split the cifs-related patches off to a separate branch (cifs-netfs) - Deferred the content-encryption to the in-progress ceph changes. - Deferred the use-PG_writeback rather than PG_fscache patch - Rebased on a later linux-next with afs-rotation patches. ver #3) - Moved the fscache module into netfslib to avoid export cycles. - Fixed a bunch of bugs. - Got CIFS to pass as much of xfstests as possible. - Added a patch to make 9P use all the helpers. - Added a patch to stop using PG_fscache, but rather dirty pages on reading and have writepages write to the cache. ver #2) - Folded the addition of NETFS_RREQ_NONBLOCK/BLOCKED into first patch that uses them. - Folded addition of rsize member into first user. - Don't set rsize in ceph (yet) and set it in kafs to 256KiB. cifs sets it dynamically. - Moved direct_bv next to direct_bv_count in struct netfs_io_request and labelled it with a __counted_by(). - Passed flags into netfs_xa_store_and_mark() rather than two bools. - Removed netfs_set_up_buffer() as it wasn't used. David Link: https://lore.kernel.org/r/20231213152350.431591-1-dhowells@redhat.com/ [1] Link: https://lore.kernel.org/r/20231013160423.2218093-1-dhowells@redhat.com/ # v1 Link: https://lore.kernel.org/r/20231117211544.1740466-1-dhowells@redhat.com/ # v2 Link: https://lore.kernel.org/r/20231207212206.1379128-1-dhowells@redhat.com/ # v3 Link: https://lore.kernel.org/r/20231213154139.432922-1-dhowells@redhat.com/ # v4 David Howells (12): cifs: Replace cifs_readdata with a wrapper around netfs_io_subrequest cifs: Set zero_point in the copy_file_range() and remap_file_range() cifs: Replace cifs_writedata with a wrapper around netfs_io_subrequest cifs: Use more fields from netfs_io_subrequest cifs: Make wait_mtu_credits take size_t args cifs: Implement netfslib hooks cifs: Replace the writedata replay bool with a netfs sreq flag cifs: Move cifs_loose_read_iter() and cifs_file_write_iter() to file.c cifs: Cut over to using netfslib cifs: Remove some code that's no longer used, part 1 cifs: Remove some code that's no longer used, part 2 cifs: Remove some code that's no longer used, part 3 fs/netfs/buffered_write.c | 3 + fs/netfs/io.c | 7 +- fs/smb/client/Kconfig | 1 + fs/smb/client/cifsfs.c | 69 +- fs/smb/client/cifsfs.h | 10 +- fs/smb/client/cifsglob.h | 59 +- fs/smb/client/cifsproto.h | 14 +- fs/smb/client/cifssmb.c | 111 +- fs/smb/client/file.c | 2911 ++++++---------------------------- fs/smb/client/fscache.c | 109 -- fs/smb/client/fscache.h | 54 - fs/smb/client/inode.c | 19 +- fs/smb/client/smb2ops.c | 10 +- fs/smb/client/smb2pdu.c | 169 +- fs/smb/client/smb2proto.h | 5 +- fs/smb/client/trace.h | 144 +- fs/smb/client/transport.c | 17 +- include/linux/netfs.h | 2 + include/trace/events/netfs.h | 1 + 19 files changed, 852 insertions(+), 2863 deletions(-)