From patchwork Thu Jun 20 17:31:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13705982 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 98874C27C79 for ; Thu, 20 Jun 2024 17:32:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17C316B02C6; Thu, 20 Jun 2024 13:32:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12CB66B02C7; Thu, 20 Jun 2024 13:32:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F36538D00AF; Thu, 20 Jun 2024 13:32:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D34C66B02C6 for ; Thu, 20 Jun 2024 13:32:01 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7C4A0A1E15 for ; Thu, 20 Jun 2024 17:32:01 +0000 (UTC) X-FDA: 82251960042.18.BC67CEB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id BE96E40016 for ; Thu, 20 Jun 2024 17:31:59 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A5cg7K1m; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.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=1718904709; 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=A6sdkxC5Rf5cszZ1f7tlsrLiiyuGvZyUxkFS40A7f1I=; b=y5CmulllFUGiTyC47TohgjCQVvKdJfoy4hLijmyDwDy8H8Zif9+mpyBWubYzqukQHeX5+G oOreiNeq8PdRwDO/T7MebMBnj+AbJk9gO9q/PuW2dhBAaHLGva1u6P9XPY/mqmYe6k3Mpr TsvCJ10IrTxEvliTdUR6a06MeKoLux4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718904709; a=rsa-sha256; cv=none; b=L9BaX8vvu7MxkUyVh1QXeiwZaJmLEtjMXMKyrZg3APBTa3y9gX2PxGE0fY37PIpVfezAcv DRV4Z8TyOvbgYV66GZnlQdveBzyF2priG2qozOMUmcBJNsUq7ys37sOIPWxsXbhLu58Ps/ WWnCbi4C3t/R4N4BK5k1AFEmDnYzzxY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=A5cg7K1m; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718904719; 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=A6sdkxC5Rf5cszZ1f7tlsrLiiyuGvZyUxkFS40A7f1I=; b=A5cg7K1msGGShLIq/ZowUoALdg8LPLgvcNFeYfakrDl61Xh/0QCi+RovQ4LS1YySOXRNuQ 2V1/nOARRlhl7X22ngsRkzr9aghJoLkigcyClJnovBY9TVe8V1vQHj0cSA5VR61+5e1bzX uRVcOQsk1mUq4cEs7NVYuhQtBQh9Ya0= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-OVbXt0VRPAe5lPnpjTGv9A-1; Thu, 20 Jun 2024 13:31:53 -0400 X-MC-Unique: OVbXt0VRPAe5lPnpjTGv9A-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 25C6D19560AD; Thu, 20 Jun 2024 17:31:49 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.39.195.156]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 807EA300022B; Thu, 20 Jun 2024 17:31:41 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 00/17] netfs, cifs: Miscellaneous fixes and read/write improvements Date: Thu, 20 Jun 2024 18:31:18 +0100 Message-ID: <20240620173137.610345-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: BE96E40016 X-Stat-Signature: oreg74qr9gjj58szjgxfezgkz3b37zuj X-Rspam-User: X-HE-Tag: 1718904719-502186 X-HE-Meta: U2FsdGVkX18ygLM6mhHkkrojWr7UpGvoQkSh7V05lvDbfQR0rAd1uFTIy3CKjrnyv3X5V4zv9SWKdP7PiUsG0n0eZsgYCRqF9kt6VpeV4/6gC7ACd79j41ViKQjkgNs4YAw2VvAZEWw1jxn29cPA2KhNJg9lgo4H83bcXg54LzxqoEQH17CRfNyS07YW1FZyjephJNX6ZwBfKw/LE3EmoCWqhABxiFFNatXB0CFvoGUIs0dop7zF9kgGnc0HA0FDruVW8Jt48xr+jzuvE+gTjLsvVUgQVgd/+Sj2hTklAUJMvQhtUx5GLnUCB8IVfeLm1GzhcbUgnxzTbNQIIrnzCF1HXbw8pdrytp+SBlkj8uAXcxSsR1LntT4V9cu0iiE+S042UpndW6Vi5h94vTwvqCxh9dcWEigIKwhiaZLzy9316TfcLbehSjqhRO60guLRxlUKKacXADMVUerAFfushM69Cy9u+t+qMFYt6SggXeGtMN63e8Gob9L1CsR+t00B5LB4hkW98854pYEXsOurAATR21JDWTrNkx3l2IfbQbW0//IHVUWKvjvymvKjpStWzV1gC0IRFwRptjQI63xZSD9HkGdmsnyQIazVBYMnQvc/Xllfdkur6peek3VRN5vpbrPr4oBMPEL83zTTUaA39iAm4dSUnLNDYqEd7mRQg38/7hRrpjRbZPolQn/JxkSgT50ICOyS0vRYK1BY6khdN5nTeOLybyp57QoTx2xwrYG14CsbzygsY3k+jTQPZ86cU+c+JceQuPk2KeBgKcwbT8Y0bTrP9QOqdGpfa9p97foLfUG2nwbyEhQANfmLR8Czywt9PzGnGvRcqtHm3uIrPO4L6qK+wsH69hP/czNUvDwYse2RMu1YkSo1ccByDda/9OxjZaCIkQGI+czcHqMpbY4IP5AaafwniSINHKQza4jx//KZBAmh4Y0vwpNKXJG4OkirNgZHmMOCj1MdgDI tp0FU7uW Fteh4KDq7d3gmfoIZoiA1ywJpPUhfA35TkZwrKbqqRAv+2T3xQPo0uJh89w18qY6/f78f5I9AwrmHtgxvc0LHLRDLjRsHnpMH/I5T1u8xw2aWwWG0XuHOf6tVUO5qoOvul+c6W6s1THxxP2ytnegqkbDB6HWRjC7QuWwFEE8L3WcWV7aJgVfbKL1isYMuYBUo3d1BWAn32/YYjt7oP3NjOvnhTq04qq3Wd2885Kxb+0z0Y3uqCCpm2pEOTv6XTdfXRuBauxuyFfTbnNLPE2M/3jlX7A== 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 Christian, Steve, Willy, [!] NOTE: THE LAST PATCH IS INCOMPLETE AND ONLY PARTIALLY WORKS. [!] Willy: Could you look at the sheaf-adding patch? This set of patches includes some netfs and cifs fixes: (1) Make sure we set the request length when doing an unbuffered/direct write. This was in v2 of the io_uring fix writethrough patch, but v1 got merged instead. (2) Move CIFS_INO_MODIFIED_ATTR to netfs_inode::flags to avoid jumping through a function pointer just for that. (3) Fix a premature issuing of write ops on a partially dirty page where the dirty part is at the end of the page and thus may be contiguous with the next page. A couple of adjustments to the /proc/fs/netfs/stats file: (4) All the netfs stats lines begin 'Netfs:'. Change this to something a bit more useful. (5) Add a couple of stats counters to track the numbers of skips and waits on the per-inode writeback serialisation lock to make it easier to check for this as a source of performance loss. Some miscellaneous bits: (6) Enable multipage folios in 9P. (7) Reduce the number of conditional branches in netfs_perform_write(). (8) Delete some unused netfslib functions for dealing with xarrays. (9) In cifs, defer read completion. (10) In cifs, only pick a channel once per read request (as per v6.9) rather than per-subrequest. (11) In cifs, move the 'pid' from the subrequest to the request as it's the same for all. (12) Move the max_len/max_nr_segs members from netfs_io_subrequest to netfs_io_request as they're only needed for one subreq at a time. Then there's the main performance enhancing changes: (13) Define a structure, struct sheaf, and a new iterator type, ITER_SHEAF, to hold a buffer as a replacement for ITER_XARRAY. See that patch for questions about naming and form. (14) Use sheaves in the write-side helpers instead of xarrays. (15) Simplify the write-side helpers to use sheaves to skip gaps rather than trying to work out where gaps are. (16) In afs, make the read subrequests asynchronous, putting them into work items to allow the next patch to do progressive unlocking/reading. (17) Overhaul the read-side helpers to improve performance. [!] NOTE: THIS IS INCOMPLETE! It works for buffered read to a large extent, but not DIO and may not cache correctly. David David Howells (17): netfs: Fix io_uring based write-through netfs, cifs: Move CIFS_INO_MODIFIED_ATTR to netfs_inode netfs: Fix early issue of write op on partial write to folio tail netfs: Adjust labels in /proc/fs/netfs/stats netfs: Record contention stats for writeback lock 9p: Enable multipage folios netfs: Reduce number of conditional branches in netfs_perform_write() netfs: Delete some xarray-wangling functions that aren't used cifs: Defer read completion cifs: Only pick a channel once per read request cifs: Move the 'pid' from the subreq to the req netfs: Move max_len/max_nr_segs from netfs_io_subrequest to netfs_io_stream mm: Define struct sheaf and ITER_SHEAF to handle a sequence of folios netfs: Use new sheaf data type and iterator instead of xarray iter netfs: Simplify the writeback code afs: Make read subreqs async netfs: Speed up buffered reading fs/9p/vfs_addr.c | 13 +- fs/9p/vfs_inode.c | 1 + fs/afs/file.c | 21 +- fs/afs/fsclient.c | 9 +- fs/afs/write.c | 4 +- fs/afs/yfsclient.c | 9 +- fs/cachefiles/io.c | 5 +- fs/ceph/addr.c | 72 ++--- fs/netfs/Makefile | 2 +- fs/netfs/buffered_read.c | 510 +++++++++++++++++++++------------ fs/netfs/buffered_write.c | 308 ++++++++++---------- fs/netfs/direct_read.c | 99 ++++++- fs/netfs/direct_write.c | 3 +- fs/netfs/internal.h | 26 +- fs/netfs/io.c | 528 +---------------------------------- fs/netfs/iterator.c | 50 ++++ fs/netfs/main.c | 7 +- fs/netfs/misc.c | 115 ++++---- fs/netfs/objects.c | 2 +- fs/netfs/read_collect.c | 450 +++++++++++++++++++++++++++++ fs/netfs/stats.c | 23 +- fs/netfs/write_collect.c | 242 +++++----------- fs/netfs/write_issue.c | 68 ++--- fs/nfs/fscache.c | 31 +- fs/nfs/fscache.h | 7 +- fs/smb/client/cifsglob.h | 4 +- fs/smb/client/cifssmb.c | 14 +- fs/smb/client/file.c | 109 +++----- fs/smb/client/smb2pdu.c | 21 +- include/linux/iov_iter.h | 57 ++++ include/linux/netfs.h | 29 +- include/linux/sheaf.h | 83 ++++++ include/linux/uio.h | 11 + include/trace/events/netfs.h | 124 +++++--- lib/iov_iter.c | 222 ++++++++++++++- lib/kunit_iov_iter.c | 259 +++++++++++++++++ lib/scatterlist.c | 69 ++++- 37 files changed, 2251 insertions(+), 1356 deletions(-) create mode 100644 fs/netfs/read_collect.c create mode 100644 include/linux/sheaf.h