[PATCH v5 00/12] netfs, cifs: Delegate high-level I/O to netfslib

From: David Howells
Date: Mon Feb 05 2024 - 18:00:52 EST


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@xxxxxxxxxx/ [1]
Link: https://lore.kernel.org/r/20231013160423.2218093-1-dhowells@xxxxxxxxxx/ # v1
Link: https://lore.kernel.org/r/20231117211544.1740466-1-dhowells@xxxxxxxxxx/ # v2
Link: https://lore.kernel.org/r/20231207212206.1379128-1-dhowells@xxxxxxxxxx/ # v3
Link: https://lore.kernel.org/r/20231213154139.432922-1-dhowells@xxxxxxxxxx/ # 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(-)