An error occurred fetching the project authors.
  1. 20 Sep, 2024 3 commits
    • NeilBrown's avatar
      nfsd: move error choice for incorrect object types to version-specific code. · 438f81e0
      NeilBrown authored
      If an NFS operation expects a particular sort of object (file, dir, link,
      etc) but gets a file handle for a different sort of object, it must
      return an error.  The actual error varies among NFS versions in non-trivial
      ways.
      
      For v2 and v3 there are ISDIR and NOTDIR errors and, for NFSv4 only,
      INVAL is suitable.
      
      For v4.0 there is also NFS4ERR_SYMLINK which should be used if a SYMLINK
      was found when not expected.  This take precedence over NOTDIR.
      
      For v4.1+ there is also NFS4ERR_WRONG_TYPE which should be used in
      preference to EINVAL when none of the specific error codes apply.
      
      When nfsd_mode_check() finds a symlink where it expected a directory it
      needs to return an error code that can be converted to NOTDIR for v2 or
      v3 but will be SYMLINK for v4.  It must be different from the error
      code returns when it finds a symlink but expects a regular file - that
      must be converted to EINVAL or SYMLINK.
      
      So we introduce an internal error code nfserr_symlink_not_dir which each
      version converts as appropriate.
      
      nfsd_check_obj_isreg() is similar to nfsd_mode_check() except that it is
      only used by NFSv4 and only for OPEN.  NFSERR_INVAL is never a suitable
      error if the object is the wrong time.  For v4.0 we use nfserr_symlink
      for non-dirs even if not a symlink.  For v4.1 we have nfserr_wrong_type.
      We handle this difference in-place in nfsd_check_obj_isreg() as there is
      nothing to be gained by delaying the choice to nfsd4_map_status().
      
      As a result of these changes, nfsd_mode_check() doesn't need an rqstp
      arg any more.
      
      Note that NFSv4 operations are actually performed in the xdr code(!!!)
      so to the only place that we can map the status code successfully is in
      nfsd4_encode_operation().
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      438f81e0
    • NeilBrown's avatar
      nfsd: Don't pass all of rqst into rqst_exp_find() · c55aeef7
      NeilBrown authored
      Rather than passing the whole rqst, pass the pieces that are actually
      needed.  This makes the inputs to rqst_exp_find() more obvious.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      c55aeef7
    • Sagi Grimberg's avatar
      nfsd: don't assume copy notify when preprocessing the stateid · 11673b2a
      Sagi Grimberg authored
      Move the stateid handling to nfsd4_copy_notify.
      If nfs4_preprocess_stateid_op did not produce an output stateid, error out.
      
      Copy notify specifically does not permit the use of special stateids,
      so enforce that outside generic stateid pre-processing.
      Signed-off-by: default avatarSagi Grimberg <sagi@grimberg.me>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Reviewed-by: default avatarOlga Kornievskaia <aglo@umich.edu>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      11673b2a
  2. 08 Jul, 2024 1 commit
    • Chuck Lever's avatar
      NFSD: Support write delegations in LAYOUTGET · abc02e56
      Chuck Lever authored
      I noticed LAYOUTGET(LAYOUTIOMODE4_RW) returning NFS4ERR_ACCESS
      unexpectedly. The NFS client had created a file with mode 0444, and
      the server had returned a write delegation on the OPEN(CREATE). The
      client was requesting a RW layout using the write delegation stateid
      so that it could flush file modifications.
      
      Creating a read-only file does not seem to be problematic for
      NFSv4.1 without pNFS, so I began looking at NFSD's implementation of
      LAYOUTGET.
      
      The failure was because fh_verify() was doing a permission check as
      part of verifying the FH presented during the LAYOUTGET. It uses the
      loga_iomode value to specify the @accmode argument to fh_verify().
      fh_verify(MAY_WRITE) on a file whose mode is 0444 fails with -EACCES.
      
      To permit LAYOUT* operations in this case, add OWNER_OVERRIDE when
      checking the access permission of the incoming file handle for
      LAYOUTGET and LAYOUTCOMMIT.
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: stable@vger.kernel.org # v6.6+
      Message-Id: 4E9C0D74-A06D-4DC3-A48A-73034DC40395@oracle.com
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      abc02e56
  3. 09 May, 2024 1 commit
    • Chuck Lever's avatar
      NFSD: Force all NFSv4.2 COPY requests to be synchronous · 8d915bbf
      Chuck Lever authored
      We've discovered that delivering a CB_OFFLOAD operation can be
      unreliable in some pretty unremarkable situations. Examples
      include:
      
       - The server dropped the connection because it lost a forechannel
         NFSv4 request and wishes to force the client to retransmit
       - The GSS sequence number window under-flowed
       - A network partition occurred
      
      When that happens, all pending callback operations, including
      CB_OFFLOAD, are lost. NFSD does not retransmit them.
      
      Moreover, the Linux NFS client does not yet support sending an
      OFFLOAD_STATUS operation to probe whether an asynchronous COPY
      operation has finished. Thus, on Linux NFS clients, when a
      CB_OFFLOAD is lost, asynchronous COPY can hang until manually
      interrupted.
      
      I've tried a couple of remedies, but so far the side-effects are
      worse than the disease and they have had to be reverted. So
      temporarily force COPY operations to be synchronous so that the use
      of CB_OFFLOAD is avoided entirely. This is a fix that can easily be
      backported to LTS kernels. I am working on client patches that
      introduce an implementation of OFFLOAD_STATUS.
      
      Note that NFSD arbitrarily limits the size of a copy_file_range
      to 4MB to avoid indefinitely blocking an nfsd thread. A short
      COPY result is returned in that case, and the client can present
      a fresh COPY request for the remainder.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      8d915bbf
  4. 06 May, 2024 3 commits
    • Chuck Lever's avatar
      NFSD: Add COPY status code to OFFLOAD_STATUS response · cc63c216
      Chuck Lever authored
      Clients that send an OFFLOAD_STATUS might want to distinguish
      between an async COPY operation that is still running, has
      completed successfully, or that has failed.
      
      The intention of this patch is to make NFSD behave like this:
      
       * Copy still running:
      	OFFLOAD_STATUS returns NFS4_OK, the number of bytes copied
      	so far, and an empty osr_status array
       * Copy completed successfully:
      	OFFLOAD_STATUS returns NFS4_OK, the number of bytes copied,
      	and an osr_status of NFS4_OK
       * Copy failed:
      	OFFLOAD_STATUS returns NFS4_OK, the number of bytes copied,
      	and an osr_status other than NFS4_OK
       * Copy operation lost, canceled, or otherwise unrecognized:
      	OFFLOAD_STATUS returns NFS4ERR_BAD_STATEID
      
      NB: Though RFC 7862 Section 11.2 lists a small set of NFS status
      codes that are valid for OFFLOAD_STATUS, there do not seem to be any
      explicit spec limits on the status codes that may be returned in the
      osr_status field.
      
      At this time we have no unit tests for COPY and its brethren, as
      pynfs does not yet implement support for NFSv4.2.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      cc63c216
    • Chuck Lever's avatar
      NFSD: Record status of async copy operation in struct nfsd4_copy · a8483b9a
      Chuck Lever authored
      After a client has started an asynchronous COPY operation, a
      subsequent OFFLOAD_STATUS operation will need to report the status
      code once that COPY operation has completed. The recorded status
      record will be used by a subsequent patch.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      a8483b9a
    • Jeff Layton's avatar
      nfsd: trivial GET_DIR_DELEGATION support · 33a1e6ea
      Jeff Layton authored
      This adds basic infrastructure for handing GET_DIR_DELEGATION calls from
      clients, including the decoders and encoders. For now, it always just
      returns NFS4_OK + GDD4_UNAVAIL.
      
      Eventually clients may start sending this operation, and it's better if
      we can return GDD4_UNAVAIL instead of having to abort the whole compound.
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      33a1e6ea
  5. 01 Mar, 2024 3 commits
  6. 07 Jan, 2024 1 commit
  7. 18 Oct, 2023 1 commit
  8. 16 Oct, 2023 6 commits
  9. 09 Sep, 2023 1 commit
  10. 29 Aug, 2023 4 commits
    • NeilBrown's avatar
      nfsd: don't allow nfsd threads to be signalled. · 39039024
      NeilBrown authored
      The original implementation of nfsd used signals to stop threads during
      shutdown.
      In Linux 2.3.46pre5 nfsd gained the ability to shutdown threads
      internally it if was asked to run "0" threads.  After this user-space
      transitioned to using "rpc.nfsd 0" to stop nfsd and sending signals to
      threads was no longer an important part of the API.
      
      In commit 3ebdbe52 ("SUNRPC: discard svo_setup and rename
      svc_set_num_threads_sync()") (v5.17-rc1~75^2~41) we finally removed the
      use of signals for stopping threads, using kthread_stop() instead.
      
      This patch makes the "obvious" next step and removes the ability to
      signal nfsd threads - or any svc threads.  nfsd stops allowing signals
      and we don't check for their delivery any more.
      
      This will allow for some simplification in later patches.
      
      A change worth noting is in nfsd4_ssc_setup_dul().  There was previously
      a signal_pending() check which would only succeed when the thread was
      being shut down.  It should really have tested kthread_should_stop() as
      well.  Now it just does the latter, not the former.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      39039024
    • Jeff Layton's avatar
      nfsd: set missing after_change as before_change + 1 · f2b7019d
      Jeff Layton authored
      In the event that we can't fetch post_op_attr attributes, we still need
      to set a value for the after_change. The operation has already happened,
      so we're not able to return an error at that point, but we do want to
      ensure that the client knows that its cache should be invalidated.
      
      If we weren't able to fetch post-op attrs, then just set the
      after_change to before_change + 1. The atomic flag should already be
      clear in this case.
      Suggested-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      f2b7019d
    • Jeff Layton's avatar
      nfsd: remove unsafe BUG_ON from set_change_info · 97662607
      Jeff Layton authored
      At one time, nfsd would scrape inode information directly out of struct
      inode in order to populate the change_info4. At that time, the BUG_ON in
      set_change_info made some sense, since having it unset meant a coding
      error.
      
      More recently, it calls vfs_getattr to get this information, which can
      fail. If that fails, fh_pre_saved can end up not being set. While this
      situation is unfortunate, we don't need to crash the box.
      
      Move set_change_info to nfs4proc.c since all of the callers are there.
      Revise the condition for setting "atomic" to also check for
      fh_pre_saved. Drop the BUG_ON and just have it zero out both
      change_attr4s when this occurs.
      Reported-by: default avatarBoyang Xue <bxue@redhat.com>
      Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2223560Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      97662607
    • Jeff Layton's avatar
      nfsd: handle failure to collect pre/post-op attrs more sanely · a332018a
      Jeff Layton authored
      Collecting pre_op_attrs can fail, in which case it's probably best to
      fail the whole operation.
      
      Change fh_fill_pre_attrs and fh_fill_both_attrs to return __be32, and
      have the callers check the return code and abort the operation if it's
      not nfs_ok.
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      a332018a
  11. 20 Feb, 2023 7 commits
    • Dai Ngo's avatar
      NFSD: fix problems with cleanup on errors in nfsd4_copy · 81e72297
      Dai Ngo authored
      When nfsd4_copy fails to allocate memory for async_copy->cp_src, or
      nfs4_init_copy_state fails, it calls cleanup_async_copy to do the
      cleanup for the async_copy which causes page fault since async_copy
      is not yet initialized.
      
      This patche rearranges the order of initializing the fields in
      async_copy and adds checks in cleanup_async_copy to skip un-initialized
      fields.
      
      Fixes: ce0887ac ("NFSD add nfs4 inter ssc to nfsd4_copy")
      Fixes: 87689df6 ("NFSD: Shrink size of struct nfsd4_copy")
      Signed-off-by: default avatarDai Ngo <dai.ngo@oracle.com>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      81e72297
    • Dai Ngo's avatar
      NFSD: fix leaked reference count of nfsd4_ssc_umount_item · 34e8f9ec
      Dai Ngo authored
      The reference count of nfsd4_ssc_umount_item is not decremented
      on error conditions. This prevents the laundromat from unmounting
      the vfsmount of the source file.
      
      This patch decrements the reference count of nfsd4_ssc_umount_item
      on error.
      
      Fixes: f4e44b39 ("NFSD: delay unmount source's export after inter-server copy completed.")
      Signed-off-by: default avatarDai Ngo <dai.ngo@oracle.com>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      34e8f9ec
    • Jeff Layton's avatar
      nfsd: clean up potential nfsd_file refcount leaks in COPY codepath · 6ba434cb
      Jeff Layton authored
      There are two different flavors of the nfsd4_copy struct. One is
      embedded in the compound and is used directly in synchronous copies. The
      other is dynamically allocated, refcounted and tracked in the client
      struture. For the embedded one, the cleanup just involves releasing any
      nfsd_files held on its behalf. For the async one, the cleanup is a bit
      more involved, and we need to dequeue it from lists, unhash it, etc.
      
      There is at least one potential refcount leak in this code now. If the
      kthread_create call fails, then both the src and dst nfsd_files in the
      original nfsd4_copy object are leaked.
      
      The cleanup in this codepath is also sort of weird. In the async copy
      case, we'll have up to four nfsd_file references (src and dst for both
      flavors of copy structure). They are both put at the end of
      nfsd4_do_async_copy, even though the ones held on behalf of the embedded
      one outlive that structure.
      
      Change it so that we always clean up the nfsd_file refs held by the
      embedded copy structure before nfsd4_copy returns. Rework
      cleanup_async_copy to handle both inter and intra copies. Eliminate
      nfsd4_cleanup_intra_ssc since it now becomes a no-op.
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      6ba434cb
    • Jeff Layton's avatar
      nfsd: zero out pointers after putting nfsd_files on COPY setup error · 1f0001d4
      Jeff Layton authored
      At first, I thought this might be a source of nfsd_file overputs, but
      the current callers seem to avoid an extra put when nfsd4_verify_copy
      returns an error.
      
      Still, it's "bad form" to leave the pointers filled out when we don't
      have a reference to them anymore, and that might lead to bugs later.
      Zero them out as a defensive coding measure.
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      1f0001d4
    • Jeff Layton's avatar
      nfsd: don't take nfsd4_copy ref for OP_OFFLOAD_STATUS · fcb53097
      Jeff Layton authored
      We're not doing any blocking operations for OP_OFFLOAD_STATUS, so taking
      and putting a reference is a waste of effort. Take the client lock,
      search for the copy and fetch the wr_bytes_written field and return.
      
      Also, make find_async_copy a static function.
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Reviewed-by: default avatarOlga Kornievskaia <kolga@netapp.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      fcb53097
    • Chuck Lever's avatar
      SUNRPC: Use per-CPU counters to tally server RPC counts · 65ba3d24
      Chuck Lever authored
       - Improves counting accuracy
       - Reduces cross-CPU memory traffic
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      65ba3d24
    • Dai Ngo's avatar
      NFSD: enhance inter-server copy cleanup · df24ac7a
      Dai Ngo authored
      Currently nfsd4_setup_inter_ssc returns the vfsmount of the source
      server's export when the mount completes. After the copy is done
      nfsd4_cleanup_inter_ssc is called with the vfsmount of the source
      server and it searches nfsd_ssc_mount_list for a matching entry
      to do the clean up.
      
      The problems with this approach are (1) the need to search the
      nfsd_ssc_mount_list and (2) the code has to handle the case where
      the matching entry is not found which looks ugly.
      
      The enhancement is instead of nfsd4_setup_inter_ssc returning the
      vfsmount, it returns the nfsd4_ssc_umount_item which has the
      vfsmount embedded in it. When nfsd4_cleanup_inter_ssc is called
      it's passed with the nfsd4_ssc_umount_item directly to do the
      clean up so no searching is needed and there is no need to handle
      the 'not found' case.
      Signed-off-by: default avatarDai Ngo <dai.ngo@oracle.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      [ cel: adjusted whitespace and variable/function names ]
      Reviewed-by: default avatarOlga Kornievskaia <kolga@netapp.com>
      df24ac7a
  12. 12 Jan, 2023 1 commit
  13. 06 Jan, 2023 1 commit
  14. 14 Dec, 2022 1 commit
  15. 10 Dec, 2022 2 commits
  16. 28 Nov, 2022 2 commits
  17. 26 Sep, 2022 2 commits
    • Chuck Lever's avatar
      NFSD: Cap rsize_bop result based on send buffer size · 76ce4dce
      Chuck Lever authored
      Since before the git era, NFSD has conserved the number of pages
      held by each nfsd thread by combining the RPC receive and send
      buffers into a single array of pages. This works because there are
      no cases where an operation needs a large RPC Call message and a
      large RPC Reply at the same time.
      
      Once an RPC Call has been received, svc_process() updates
      svc_rqst::rq_res to describe the part of rq_pages that can be
      used for constructing the Reply. This means that the send buffer
      (rq_res) shrinks when the received RPC record containing the RPC
      Call is large.
      
      Add an NFSv4 helper that computes the size of the send buffer. It
      replaces svc_max_payload() in spots where svc_max_payload() returns
      a value that might be larger than the remaining send buffer space.
      Callers who need to know the transport's actual maximum payload size
      will continue to use svc_max_payload().
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      76ce4dce
    • Chuck Lever's avatar
      NFSD: Rename the fields in copy_stateid_t · 781fde1a
      Chuck Lever authored
      Code maintenance: The name of the copy_stateid_t::sc_count field
      collides with the sc_count field in struct nfs4_stid, making the
      latter difficult to grep for when auditing stateid reference
      counting.
      
      No behavior change expected.
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      781fde1a