An error occurred fetching the project authors.
  1. 13 May, 2024 1 commit
  2. 01 May, 2024 5 commits
    • David Howells's avatar
      cifs: Cut over to using netfslib · 3ee1a1fc
      David Howells authored
      Make the cifs filesystem use netfslib to handle reading and writing on
      behalf of cifs.  The changes include:
      
       (1) Various read_iter/write_iter type functions are turned into wrappers
           around netfslib API functions or are pointed directly at those
           functions:
      
      	cifs_file_direct{,_nobrl}_ops switch to use
      	netfs_unbuffered_read_iter and netfs_unbuffered_write_iter.
      
      Large pieces of code that will be removed are #if'd out and will be removed
      in subsequent patches.
      
      [?] Why does cifs mark the page dirty in the destination buffer of a DIO
          read?  Should that happen automatically?  Does netfs need to do that?
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Steve French <sfrench@samba.org>
      cc: Shyam Prasad N <nspmangalore@gmail.com>
      cc: Rohith Surabattula <rohiths.msft@gmail.com>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: linux-cifs@vger.kernel.org
      cc: netfs@lists.linux.dev
      cc: linux-fsdevel@vger.kernel.org
      cc: linux-mm@kvack.org
      3ee1a1fc
    • David Howells's avatar
      cifs: Implement netfslib hooks · 69c3c023
      David Howells authored
      Provide implementation of the netfslib hooks that will be used by netfslib
      to ask cifs to set up and perform operations.  Of particular note are
      
       (*) cifs_clamp_length() - This is used to negotiate the size of the next
           subrequest in a read request, taking into account the credit available
           and the rsize.  The credits are attached to the subrequest.
      
       (*) cifs_req_issue_read() - This is used to issue a subrequest that has
           been set up and clamped.
      
       (*) cifs_prepare_write() - This prepares to fill a subrequest by picking a
           channel, reopening the file and requesting credits so that we can set
           the maximum size of the subrequest and also sets the maximum number of
           segments if we're doing RDMA.
      
       (*) cifs_issue_write() - This releases any unneeded credits and issues an
           asynchronous data write for the contiguous slice of file covered by
           the subrequest.  This should possibly be folded in to all
           ->async_writev() ops and that called directly.
      
       (*) cifs_begin_writeback() - This gets the cached writable handle through
           which we do writeback (this does not affect writethrough, unbuffered
           or direct writes).
      
      At this point, cifs is not wired up to actually *use* netfslib; that will
      be done in a subsequent patch.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Steve French <sfrench@samba.org>
      cc: Shyam Prasad N <nspmangalore@gmail.com>
      cc: Rohith Surabattula <rohiths.msft@gmail.com>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: linux-cifs@vger.kernel.org
      cc: netfs@lists.linux.dev
      cc: linux-fsdevel@vger.kernel.org
      cc: linux-mm@kvack.org
      69c3c023
    • David Howells's avatar
      cifs: Add mempools for cifs_io_request and cifs_io_subrequest structs · edea94a6
      David Howells authored
      Add mempools for the allocation of cifs_io_request and cifs_io_subrequest
      structs for netfslib to use so that it can guarantee eventual allocation in
      writeback.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Steve French <sfrench@samba.org>
      cc: Shyam Prasad N <nspmangalore@gmail.com>
      cc: Rohith Surabattula <rohiths.msft@gmail.com>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: linux-cifs@vger.kernel.org
      cc: netfs@lists.linux.dev
      cc: linux-fsdevel@vger.kernel.org
      cc: linux-mm@kvack.org
      edea94a6
    • David Howells's avatar
      cifs: Set zero_point in the copy_file_range() and remap_file_range() · 3758c485
      David Howells authored
      Set zero_point in the copy_file_range() and remap_file_range()
      implementations so that we don't skip reading data modified on a
      server-side copy.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Steve French <sfrench@samba.org>
      cc: Shyam Prasad N <nspmangalore@gmail.com>
      cc: Rohith Surabattula <rohiths.msft@gmail.com>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: linux-cifs@vger.kernel.org
      cc: netfs@lists.linux.dev
      cc: linux-fsdevel@vger.kernel.org
      cc: linux-mm@kvack.org
      3758c485
    • David Howells's avatar
      cifs: Move cifs_loose_read_iter() and cifs_file_write_iter() to file.c · 1a5b4edd
      David Howells authored
      Move cifs_loose_read_iter() and cifs_file_write_iter() to file.c so that
      they are colocated with similar functions rather than being split with
      cifsfs.c.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Steve French <sfrench@samba.org>
      cc: Shyam Prasad N <nspmangalore@gmail.com>
      cc: Rohith Surabattula <rohiths.msft@gmail.com>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: linux-cifs@vger.kernel.org
      cc: netfs@lists.linux.dev
      cc: linux-fsdevel@vger.kernel.org
      cc: linux-mm@kvack.org
      1a5b4edd
  3. 19 Apr, 2024 2 commits
    • Paulo Alcantara's avatar
      smb: client: fix rename(2) regression against samba · 18d86965
      Paulo Alcantara authored
      After commit 2c7d399e ("smb: client: reuse file lease key in
      compound operations") the client started reusing lease keys for
      rename, unlink and set path size operations to prevent it from
      breaking its own leases and thus causing unnecessary lease breaks to
      same connection.
      
      The implementation relies on positive dentries and
      cifsInodeInfo::lease_granted to decide whether reusing lease keys for
      the compound requests.  cifsInodeInfo::lease_granted was introduced by
      commit 0ab95c25 ("Defer close only when lease is enabled.") to
      indicate whether lease caching is granted for a specific file, but
      that can only happen until file is open, so
      cifsInodeInfo::lease_granted was left uninitialised in ->alloc_inode
      and then client started sending random lease keys for files that
      hadn't any leases.
      
      This fixes the following test case against samba:
      
      mount.cifs //srv/share /mnt/1 -o ...,nosharesock
      mount.cifs //srv/share /mnt/2 -o ...,nosharesock
      touch /mnt/1/foo; tail -f /mnt/1/foo & pid=$!
      mv /mnt/2/foo /mnt/2/bar # fails with -EIO
      kill $pid
      
      Fixes: 0ab95c25 ("Defer close only when lease is enabled.")
      Signed-off-by: default avatarPaulo Alcantara (Red Hat) <pc@manguebit.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      18d86965
    • David Howells's avatar
      cifs: Add tracing for the cifs_tcon struct refcounting · afc23feb
      David Howells authored
      Add tracing for the refcounting/lifecycle of the cifs_tcon struct, marking
      different events with different labels and giving each tcon its own debug
      ID so that the tracelines corresponding to individual tcons can be
      distinguished.  This can be enabled with:
      
      	echo 1 >/sys/kernel/debug/tracing/events/cifs/smb3_tcon_ref/enable
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarPaulo Alcantara (Red Hat) <pc@manguebit.com>
      cc: Shyam Prasad N <nspmangalore@gmail.com>
      cc: linux-cifs@vger.kernel.org
      cc: linux-fsdevel@vger.kernel.org
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      afc23feb
  4. 03 Apr, 2024 1 commit
  5. 20 Mar, 2024 1 commit
  6. 13 Mar, 2024 1 commit
  7. 11 Mar, 2024 2 commits
  8. 25 Feb, 2024 1 commit
  9. 06 Feb, 2024 1 commit
  10. 05 Feb, 2024 1 commit
  11. 24 Jan, 2024 1 commit
  12. 19 Jan, 2024 1 commit
  13. 28 Dec, 2023 1 commit
    • David Howells's avatar
      netfs: Optimise away reads above the point at which there can be no data · 100ccd18
      David Howells authored
      Track the file position above which the server is not expected to have any
      data (the "zero point") and preemptively assume that we can satisfy
      requests by filling them with zeroes locally rather than attempting to
      download them if they're over that line - even if we've written data back
      to the server.  Assume that any data that was written back above that
      position is held in the local cache.  Note that we have to split requests
      that straddle the line.
      
      Make use of this to optimise away some reads from the server.  We need to
      set the zero point in the following circumstances:
      
       (1) When we see an extant remote inode and have no cache for it, we set
           the zero_point to i_size.
      
       (2) On local inode creation, we set zero_point to 0.
      
       (3) On local truncation down, we reduce zero_point to the new i_size if
           the new i_size is lower.
      
       (4) On local truncation up, we don't change zero_point.
      
       (5) On local modification, we don't change zero_point.
      
       (6) On remote invalidation, we set zero_point to the new i_size.
      
       (7) If stored data is discarded from the pagecache or culled from fscache,
           we must set zero_point above that if the data also got written to the
           server.
      
       (8) If dirty data is written back to the server, but not fscache, we must
           set zero_point above that.
      
       (9) If a direct I/O write is made, set zero_point above that.
      
      Assuming the above, any read from the server at or above the zero_point
      position will return all zeroes.
      
      The zero_point value can be stored in the cache, provided the above rules
      are applied to it by any code that culls part of the local cache.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: linux-cachefs@redhat.com
      cc: linux-fsdevel@vger.kernel.org
      cc: linux-mm@kvack.org
      100ccd18
  14. 24 Dec, 2023 1 commit
    • David Howells's avatar
      netfs: Move pinning-for-writeback from fscache to netfs · c9c4ff12
      David Howells authored
      Move the resource pinning-for-writeback from fscache code to netfslib code.
      This is used to keep a cache backing object pinned whilst we have dirty
      pages on the netfs inode in the pagecache such that VM writeback will be
      able to reach it.
      
      Whilst we're at it, switch the parameters of netfs_unpin_writeback() to
      match ->write_inode() so that it can be used for that directly.
      
      Note that this mechanism could be more generically useful than that for
      network filesystems.  Quite often they have to keep around other resources
      (e.g. authentication tokens or network connections) until the writeback is
      complete.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      cc: linux-cachefs@redhat.com
      cc: linux-fsdevel@vger.kernel.org
      cc: linux-mm@kvack.org
      c9c4ff12
  15. 12 Dec, 2023 1 commit
  16. 06 Dec, 2023 1 commit
  17. 04 Dec, 2023 2 commits
    • David Howells's avatar
      cifs: Fix flushing, invalidation and file size with FICLONE · c54fc3a4
      David Howells authored
      Fix a number of issues in the cifs filesystem implementation of the FICLONE
      ioctl in cifs_remap_file_range().  This is analogous to the previously
      fixed bug in cifs_file_copychunk_range() and can share the helper
      functions.
      
      Firstly, the invalidation of the destination range is handled incorrectly:
      We shouldn't just invalidate the whole file as dirty data in the file may
      get lost and we can't just call truncate_inode_pages_range() to invalidate
      the destination range as that will erase parts of a partial folio at each
      end whilst invalidating and discarding all the folios in the middle.  We
      need to force all the folios covering the range to be reloaded, but we
      mustn't lose dirty data in them that's not in the destination range.
      
      Further, we shouldn't simply round out the range to PAGE_SIZE at each end
      as cifs should move to support multipage folios.
      
      Secondly, there's an issue whereby a write may have extended the file
      locally, but not have been written back yet.  This can leaves the local
      idea of the EOF at a later point than the server's EOF.  If a clone request
      is issued, this will fail on the server with STATUS_INVALID_VIEW_SIZE
      (which gets translated to -EIO locally) if the clone source extends past
      the server's EOF.
      
      Fix this by:
      
       (0) Flush the source region (already done).  The flush does nothing and
           the EOF isn't moved if the source region has no dirty data.
      
       (1) Move the EOF to the end of the source region if it isn't already at
           least at this point.  If we can't do this, for instance if the server
           doesn't support it, just flush the entire source file.
      
       (2) Find the folio (if present) at each end of the range, flushing it and
           increasing the region-to-be-invalidated to cover those in their
           entirety.
      
       (3) Fully discard all the folios covering the range as we want them to be
           reloaded.
      
       (4) Then perform the extent duplication.
      
      Thirdly, set i_size after doing the duplicate_extents operation as this
      value may be used by various things internally.  stat() hides the issue
      because setting ->time to 0 causes cifs_getatr() to revalidate the
      attributes.
      
      These were causing the cifs/001 xfstest to fail.
      
      Fixes: 04b38d60 ("vfs: pull btrfs clone API to vfs layer")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Cc: stable@vger.kernel.org
      cc: Christoph Hellwig <hch@lst.de>
      cc: Paulo Alcantara <pc@manguebit.com>
      cc: Shyam Prasad N <nspmangalore@gmail.com>
      cc: Rohith Surabattula <rohiths.msft@gmail.com>
      cc: Matthew Wilcox <willy@infradead.org>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: linux-cifs@vger.kernel.org
      cc: linux-mm@kvack.org
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      c54fc3a4
    • David Howells's avatar
      cifs: Fix flushing, invalidation and file size with copy_file_range() · 7b2404a8
      David Howells authored
      Fix a number of issues in the cifs filesystem implementation of the
      copy_file_range() syscall in cifs_file_copychunk_range().
      
      Firstly, the invalidation of the destination range is handled incorrectly:
      We shouldn't just invalidate the whole file as dirty data in the file may
      get lost and we can't just call truncate_inode_pages_range() to invalidate
      the destination range as that will erase parts of a partial folio at each
      end whilst invalidating and discarding all the folios in the middle.  We
      need to force all the folios covering the range to be reloaded, but we
      mustn't lose dirty data in them that's not in the destination range.
      
      Further, we shouldn't simply round out the range to PAGE_SIZE at each end
      as cifs should move to support multipage folios.
      
      Secondly, there's an issue whereby a write may have extended the file
      locally, but not have been written back yet.  This can leaves the local
      idea of the EOF at a later point than the server's EOF.  If a copy request
      is issued, this will fail on the server with STATUS_INVALID_VIEW_SIZE
      (which gets translated to -EIO locally) if the copy source extends past the
      server's EOF.
      
      Fix this by:
      
       (0) Flush the source region (already done).  The flush does nothing and
           the EOF isn't moved if the source region has no dirty data.
      
       (1) Move the EOF to the end of the source region if it isn't already at
           least at this point.  If we can't do this, for instance if the server
           doesn't support it, just flush the entire source file.
      
       (2) Find the folio (if present) at each end of the range, flushing it and
           increasing the region-to-be-invalidated to cover those in their
           entirety.
      
       (3) Fully discard all the folios covering the range as we want them to be
           reloaded.
      
       (4) Then perform the copy.
      
      Thirdly, set i_size after doing the copychunk_range operation as this value
      may be used by various things internally.  stat() hides the issue because
      setting ->time to 0 causes cifs_getatr() to revalidate the attributes.
      
      These were causing the generic/075 xfstest to fail.
      
      Fixes: 620d8745 ("Introduce cifs_copy_file_range()")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Paulo Alcantara <pc@manguebit.com>
      cc: Shyam Prasad N <nspmangalore@gmail.com>
      cc: Rohith Surabattula <rohiths.msft@gmail.com>
      cc: Matthew Wilcox <willy@infradead.org>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: linux-cifs@vger.kernel.org
      cc: linux-mm@kvack.org
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      7b2404a8
  18. 23 Oct, 2023 1 commit
  19. 07 Sep, 2023 1 commit
  20. 31 Aug, 2023 1 commit
  21. 20 Aug, 2023 1 commit
  22. 10 Jul, 2023 1 commit
    • Luca Vizzarro's avatar
      fs: Pass argument to fcntl_setlease as int · ed5f17f6
      Luca Vizzarro authored
      The interface for fcntl expects the argument passed for the command
      F_SETLEASE to be of type int. The current code wrongly treats it as
      a long. In order to avoid access to undefined bits, we should explicitly
      cast the argument to int.
      
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Chuck Lever <chuck.lever@oracle.com>
      Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
      Cc: Anna Schumaker <anna@kernel.org>
      Cc: Kevin Brodsky <Kevin.Brodsky@arm.com>
      Cc: Vincenzo Frascino <Vincenzo.Frascino@arm.com>
      Cc: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: David Laight <David.Laight@ACULAB.com>
      Cc: Mark Rutland <Mark.Rutland@arm.com>
      Cc: linux-fsdevel@vger.kernel.org
      Cc: linux-cifs@vger.kernel.org
      Cc: linux-nfs@vger.kernel.org
      Cc: linux-morello@op-lists.linaro.org
      Signed-off-by: default avatarLuca Vizzarro <Luca.Vizzarro@arm.com>
      Message-Id: <20230414152459.816046-3-Luca.Vizzarro@arm.com>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      ed5f17f6
  23. 21 Jun, 2023 1 commit
  24. 19 Jun, 2023 1 commit
  25. 24 May, 2023 3 commits
  26. 10 May, 2023 1 commit
  27. 09 May, 2023 2 commits
    • Steve French's avatar
      SMB3: force unmount was failing to close deferred close files · 2cb6f968
      Steve French authored
      In investigating a failure with xfstest generic/392 it
      was noticed that mounts were reusing a superblock that should
      already have been freed. This turned out to be related to
      deferred close files keeping a reference count until the
      closetimeo expired.
      
      Currently the only way an fs knows that mount is beginning is
      when force unmount is called, but when this, ie umount_begin(),
      is called all deferred close files on the share (tree
      connection) should be closed immediately (unless shared by
      another mount) to avoid using excess resources on the server
      and to avoid reusing a superblock which should already be freed.
      
      In umount_begin, close all deferred close handles for that
      share if this is the last mount using that share on this
      client (ie send the SMB3 close request over the wire for those
      that have been already closed by the app but that we have
      kept a handle lease open for and have not sent closes to the
      server for yet).
      Reported-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarBharath SM <bharathsm@microsoft.com>
      Cc: <stable@vger.kernel.org>
      Fixes: 78c09634 ("Cifs: Fix kernel oops caused by deferred close for files.")
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      2cb6f968
    • Steve French's avatar
      smb3: improve parallel reads of large files · ba8c2b75
      Steve French authored
      rasize (ra_pages) should be set higher than read size by default
      to allow parallel reads when reading large files in order to
      improve performance (otherwise there is much dead time on the
      network when doing readahead of large files).  Default rasize
      to twice readsize.
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      ba8c2b75
  28. 02 May, 2023 1 commit
  29. 24 Mar, 2023 1 commit
    • Steve French's avatar
      smb3: fix unusable share after force unmount failure · 491eafce
      Steve French authored
      If user does forced unmount ("umount -f") while files are still open
      on the share (as was seen in a Kubernetes example running on SMB3.1.1
      mount) then we were marking the share as "TID_EXITING" in umount_begin()
      which caused all subsequent operations (except write) to fail ... but
      unfortunately when umount_begin() is called we do not know yet that
      there are open files or active references on the share that would prevent
      unmount from succeeding.  Kubernetes had example when they were doing
      umount -f when files were open which caused the share to become
      unusable until the files were closed (and the umount retried).
      
      Fix this so that TID_EXITING is not set until we are about to send
      the tree disconnect (not at the beginning of forced umounts in
      umount_begin) so that if "umount -f" fails (due to open files or
      references) the mount is still usable.
      
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarShyam Prasad N <sprasad@microsoft.com>
      Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      491eafce
  30. 20 Feb, 2023 1 commit
    • David Howells's avatar
      cifs: Implement splice_read to pass down ITER_BVEC not ITER_PIPE · 4e260a8f
      David Howells authored
      Provide cifs_splice_read() to use a bvec rather than an pipe iterator as
      the latter cannot so easily be split and advanced, which is necessary to
      pass an iterator down to the bottom levels.  Upstream cifs gets around this
      problem by using iov_iter_get_pages() to prefill the pipe and then passing
      the list of pages down.
      
      This is done by:
      
       (1) Bulk-allocate a bunch of pages to carry as much of the requested
           amount of data as possible, but without overrunning the available
           slots in the pipe and add them to an ITER_BVEC.
      
       (2) Synchronously call ->read_iter() to read into the buffer.
      
       (3) Discard any unused pages.
      
       (4) Load the remaining pages into the pipe in order and advance the head
           pointer.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Steve French <sfrench@samba.org>
      cc: Shyam Prasad N <nspmangalore@gmail.com>
      cc: Rohith Surabattula <rohiths.msft@gmail.com>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: Al Viro <viro@zeniv.linux.org.uk>
      cc: linux-cifs@vger.kernel.org
      
      Link: https://lore.kernel.org/r/166732028113.3186319.1793644937097301358.stgit@warthog.procyon.org.uk/ # rfc
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      4e260a8f