Skip to content

smb3: Use iov_iters down to the network transport and fix DIO page pinning

David Howells linux-cifs linux-crypto linux-fsdevel linux-rdma lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11netfs: Add a function to extract a UBUF or IOVEC into a BVEC iteratorfs/netfs/Makefile fs/netfs/iterator.c include/linux/netfs.h+108 -00 replies
2/11netfs: Add a function to extract an iterator into a scatterlistfs/netfs/iterator.c include/linux/netfs.h mm/vmalloc.c+274 -00 replies
3/11cifs: Add a function to build an RDMA SGE list from an iteratorfs/cifs/smbdirect.c+214 -00 replies
4/11cifs: Add a function to Hash the contents of an iteratorfs/cifs/cifsencrypt.c+144 -00 replies
5/11cifs: Add some helper functionsfs/cifs/cifsfs.h fs/cifs/file.c+96 -00 replies
6/11cifs: Add a function to read into an iter from a socketfs/cifs/cifsproto.h fs/cifs/connect.c+17 -00 replies
7/11cifs: Change the I/O paths to use an iterator rather than a page listfs/cifs/Kconfig fs/cifs/cifsencrypt.c fs/cifs/cifsglob.h +11 more+1122 -10820 replies
8/11cifs: Build the RDMA SGE list directly from an iteratorfs/cifs/smbdirect.c fs/cifs/smbdirect.h+63 -930 replies
9/11cifs: Remove unused codefs/cifs/file.c+0 -6060 replies
10/11cifs: DIO to/from KVEC-type iterators should now workfs/cifs/file.c+0 -200 replies
11/11cifs: Fix problem with encrypted RDMA data readfs/cifs/smb2ops.c+3 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/11] smb3: Use iov_iters down to the network transport and fix DIO page pinning

Hi Steve,

Here's an updated version of my patchset to make the cifs/smb3 driver pass iov_iters down to the lowest layers where they can be passed directly to the network transport rather than passing lists of pages around.

I've dropped the patch Stefan Metzmacher objected to and the splice patch and rebased on top of a merge of part of my iov-extract branch onto your for-next branch. The merge is so that the same commits are used as are in the linux-block tree. At the iov-extract-base tag point my branch makes the following changes:

(1) Change how file read-splices are done, using ITER_BVEC (DIO read) or page cache extraction (buffered read). ITER_PIPE is then removed.

(2) Add a function to replace iov_iter_get_pages*() that uses FOLL_PIN on user pages (IOVEC, UBUF) and doesn't pin kernel pages (BVEC, KVEC, XARRAY).

The series also deals with some other issues:

(*) By pinning pages, it fixes the race between concurrent DIO read and
fork, whereby the pages containing the DIO read buffer may end up belonging to the child process and not the parent - with the result that the parent might not see the retrieved data.

(*) cifs shouldn't take refs on pages extracted from non-user-backed
iterators (eg. KVEC). With these changes, cifs will apply the appropriate cleanup. Note that there is the possibility the network transport might, but that's beyond the scope of this patchset.

(*) Making it easier to transition to using folios in cifs rather than
pages by dealing with them through BVEC and XARRAY iterators.

The series starts with a couple of patches that add stuff to netfslib that I want to use there as well as in cifs:

(1) Add a netfslib function to extract and pin pages from an ITER_IOBUF or ITER_UBUF iterator into an ITER_BVEC iterator.

(2) Add a netfslib function to extract pages from an iterator that's of type ITER_UBUF/IOVEC/BVEC/KVEC/XARRAY and add them to a scatterlist. The cleanup will need to be done as for iov_iter_extract_pages().

BVEC, KVEC and XARRAY iterators can be rendered into elements that span multiple pages.

Then a fix:

(3) Fix oops due to uncleared server->smbd_conn in reconnect

Then there are some cifs helpers that work with iterators:

(4) 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).

(5) Add a function to walk through an ITER_BVEC/KVEC/XARRAY iterator and pass the contents into a shash function.

(6) 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.

(7) 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:

(8) 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.

(9) 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.

(10) Remove a chunk of now-unused code.

(11) Allow DIO to/from KVEC-type iterators.

I've pushed the patches here also:

https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=iov-cifs

David

David Howells (11):
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: 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
cifs: DIO to/from KVEC-type iterators should now work
cifs: Fix problem with encrypted RDMA data read

 fs/cifs/Kconfig       |    1 +
 fs/cifs/cifsencrypt.c |  172 +++-
 fs/cifs/cifsfs.h      |    3 +
 fs/cifs/cifsglob.h    |   66 +-
 fs/cifs/cifsproto.h   |   11 +-
 fs/cifs/cifssmb.c     |   15 +-
 fs/cifs/connect.c     |   14 +
 fs/cifs/file.c        | 1750 ++++++++++++++++++-----------------------
 fs/cifs/fscache.c     |   22 +-
 fs/cifs/fscache.h     |   10 +-
 fs/cifs/misc.c        |  128 +--
 fs/cifs/smb2ops.c     |  365 ++++-----
 fs/cifs/smb2pdu.c     |   53 +-
 fs/cifs/smbdirect.c   |  535 ++++++++-----
 fs/cifs/smbdirect.h   |    7 +-
 fs/cifs/transport.c   |   54 +-
 fs/netfs/Makefile     |    1 +
 fs/netfs/iterator.c   |  372 +++++++++
 include/linux/netfs.h |    8 +
 mm/vmalloc.c          |    1 +
 20 files changed, 1914 insertions(+), 1674 deletions(-)
 create mode 100644 fs/netfs/iterator.c