Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp578475lqh; Thu, 28 Mar 2024 09:59:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUO7KO/3EeK5Vr6ytNBkq4QKTrrtZ6DFJhCy/fcf/DKWYp9zXknDYYyTve80tA8pRlnozpbzAA33xseT9+dwHejscSEGZl+ShHjpYEiOw== X-Google-Smtp-Source: AGHT+IF+IKdsKx5HFTYdJT/U1VYujB0T0NeXfZE4HM3zQ9GcqqUatkNLUcCm/hH603lqUFEkkU4i X-Received: by 2002:a17:907:940a:b0:a4e:196a:3457 with SMTP id dk10-20020a170907940a00b00a4e196a3457mr2371550ejc.10.1711645155458; Thu, 28 Mar 2024 09:59:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711645155; cv=pass; d=google.com; s=arc-20160816; b=MjTVAJ7iA2r/B3QD19sa3vG5HzcKPIrEXqNzY6gy2rEqV0/CIT9rG0AOsLkhwp4tNH k7Hs2OOR1DtUPpTSTXZMT3Ei9AqqWjKZydVsBiPh10WLeauyvF0cK+H8YDct70EVA5mU S57GKA871KLwEy79FdC7opvE+Lxr+bYf824J8DMJjIVaIppoS1cBiZg8R5CNqcJ8vl+S 3N5vVnus92WmdFzBN9WgJu9TQREYRyk6G28jt6uRGMLHmi7R7zgpPC7WXkoSaJnuTyWt j/1lY+aG3wjxv8ND7fBPpdGyhuD+FEmWfzgy59CePEj2ilpMp3aym/UZqwYgK3S+QBNB OoAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=jiVas1tSBjQdCIB/ofa+v43rtug1Sw6ETjtuvBUyvtU=; fh=s8gxidBpz+VtwKh3RxezB5XJC9lJlHpx4ZwCFt1twkk=; b=Oeh+PWVgxIXOHnUJuxbHE5yOeoY06Zk+MfXOHjFwOQUL+wHCiSpItq33Jfv4KxNkPD O8MWMz22qjQ9VxwwaHHURiU2Tb4vM8RdRxkojg2/fTKslXZx9ZB8jm04DVB1+j9wuisE 21poteqE5XvMyYjqueK6Z4htlM4r2yhc02aQpFWi2BJwR6Lqsap+ds4ks/cGmgGjNIJB CTxhZBxfEzRUTl71pN0KJiUqRhevfdWxe3Zktay6vFku2eCcQNkIMLOcSSmjqxApvA7N rK1dnTx7BHlLF5feDCW3KrdBRLUvDtaDgJIW+Pg90Q6Il2MquDewPIpAJamS5v0lXWd5 c6YA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ngl3Mzip; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123317-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v6-20020a1709060b4600b00a467368475fsi882711ejg.927.2024.03.28.09.59.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 09:59:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ngl3Mzip; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123317-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B940E1F2475E for ; Thu, 28 Mar 2024 16:59:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BC473C08E; Thu, 28 Mar 2024 16:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ngl3Mzip" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1C6C3BBF4 for ; Thu, 28 Mar 2024 16:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711645142; cv=none; b=jcGhnNAw2wwFLase5jbwweUT2s9MB2djrCFu3za30+gC38+C+6dF3xR9dKBvBkzyAAPZHnD/yeQQB8Hnyc05EeTvneUpPkaZvoMNOkGiP14FjkdLktcnpV71TEqTswk16ZEKk1kRtoOR4m1MBCCx1eEhp/z4vchkGhqPQ0Lax1Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711645142; c=relaxed/simple; bh=apCXXFZ6j3TcjCJV2Cam6vpg1nsRKdd8BKx/sY8Vqwc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pGUfsMcSE7LXoXaswNhU5ft9ndgx0d7MmAu/d9aP5DuL0FPjMyvgEu183WKikmpazJcWP/PJUdqILG6pXJ/5N4hkToolKY5G3bsmONJOJoEEedSzj3jZLs2+BdjYDT07vX/FTz8OPT8Z3HvDtUQ3SPO/sh/Rh8p78fsCXsQpBQA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ngl3Mzip; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711645139; 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=jiVas1tSBjQdCIB/ofa+v43rtug1Sw6ETjtuvBUyvtU=; b=Ngl3Mzipy6aoliCq44CyfJBn1iEbVCDpQIR3zaAXVW6PsTzXV20r/HHCJiXlyhdHEFmI6w Ngqyx2cFCqIC23vz0gZCeHT37lcRJbJKVObLmCbL7ONjzxm4duybQ6zvJ2zjhOwyWOkb5v 6CWwtCsi90REeSbz+URpv8GkZBzdmcw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-544-_lsKnMXBNLeQiQjtN82f-g-1; Thu, 28 Mar 2024 12:58:54 -0400 X-MC-Unique: _lsKnMXBNLeQiQjtN82f-g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 051F63C01C19; Thu, 28 Mar 2024 16:58:54 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id 622EDC4C7A1; Thu, 28 Mar 2024 16:58:52 +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 v6 00/15] netfs, cifs: Delegate high-level I/O to netfslib Date: Thu, 28 Mar 2024 16:57:51 +0000 Message-ID: <20240328165845.2782259-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Hi Steve, Here are patches to convert cifs to use the netfslib library. I've tested them with and without a cache. Unfortunately, if "-o fsc" is specified a leak of a tcon object shows up, particularly with the generic/013 xfstest that prevents further testing. I've investigated this and found that the tcon leak is actually present upstream, but just goes unnoticed unless it also pins an fscache volume cookie. The patches remove around 2000 lines from CIFS. 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 #6) - The netfslib write helpers got rewritten and, consequently, some changes were made here. - Rearranged the patch order a little to put the smaller changes first. - Use a different way to invalidate that doesn't use ->launder_folio(). - Attempt to open the handle on the server READ+WRITE, even if the user asks for O_WRONLY, if the mount was with "-o fsc" so that we can fill in the gaps in partial folio writes; if we can't fall back to WRITE-only and disable caching. - Fixed the cookie key to match the key used by iget5_locked() to avoid "Duplicate cookie" errors. - Made add_credits_and_wake_if() clear the number of returned credits, allowing it to be called multiple times in cleanup/error handling. - Made ->async_writev() not return an error directly, but always set it on the subreq. - Fixed error handling from writethrough writing. 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 Link: https://lore.kernel.org/r/20240205225726.3104808-1-dhowells@redhat.com/ # v5 David Howells (15): cifs: Replace cifs_readdata with a wrapper around netfs_io_subrequest 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: 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: Set zero_point in the copy_file_range() and remap_file_range() cifs: Add mempools for cifs_io_request and cifs_io_subrequest structs cifs: Make add_credits_and_wake_if() clear deducted credits cifs: Implement netfslib hooks cifs: When caching, try to open O_WRONLY file rdwr on server 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 | 6 + fs/netfs/io.c | 7 +- fs/smb/client/Kconfig | 1 + fs/smb/client/cifsfs.c | 124 +- fs/smb/client/cifsfs.h | 10 +- fs/smb/client/cifsglob.h | 65 +- fs/smb/client/cifsproto.h | 12 +- fs/smb/client/cifssmb.c | 120 +- fs/smb/client/dir.c | 15 + fs/smb/client/file.c | 2841 ++++++---------------------------- 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 | 186 ++- fs/smb/client/smb2proto.h | 5 +- fs/smb/client/trace.h | 144 +- fs/smb/client/transport.c | 17 +- include/linux/netfs.h | 1 + include/trace/events/netfs.h | 1 + 20 files changed, 946 insertions(+), 2801 deletions(-)