Skip to content
Snippets Groups Projects
  1. Dec 15, 2023
  2. Oct 16, 2023
  3. Aug 29, 2023
    • NeilBrown's avatar
      nfsd: separate nfsd_last_thread() from nfsd_put() · 9f28a971
      NeilBrown authored
      
      Now that the last nfsd thread is stopped by an explicit act of calling
      svc_set_num_threads() with a count of zero, we only have a limited
      number of places that can happen, and don't need to call
      nfsd_last_thread() in nfsd_put()
      
      So separate that out and call it at the two places where the number of
      threads is set to zero.
      
      Move the clearing of ->nfsd_serv and the call to svc_xprt_destroy_all()
      into nfsd_last_thread(), as they are really part of the same action.
      
      nfsd_put() is now a thin wrapper around svc_put(), so make it a static
      inline.
      
      nfsd_put() cannot be called after nfsd_last_thread(), so in a couple of
      places we have to use svc_put() instead.
      
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      9f28a971
  4. Feb 20, 2023
    • Chuck Lever's avatar
      SUNRPC: Refactor RPC server dispatch method · cee4db19
      Chuck Lever authored
      
      Currently, svcauth_gss_accept() pre-reserves response buffer space
      for the RPC payload length and GSS sequence number before returning
      to the dispatcher, which then adds the header's accept_stat field.
      
      The problem is the accept_stat field is supposed to go before the
      length and seq_num fields. So svcauth_gss_release() has to relocate
      the accept_stat value (see svcauth_gss_prepare_to_wrap()).
      
      To enable these fields to be added to the response buffer in the
      correct (final) order, the pointer to the accept_stat has to be made
      available to svcauth_gss_accept() so that it can set it before
      reserving space for the length and seq_num fields.
      
      As a first step, move the pointer to the location of the accept_stat
      field into struct svc_rqst.
      
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      cee4db19
  5. Jan 12, 2023
  6. Nov 28, 2022
    • Jeff Layton's avatar
      nfsd: allow disabling NFSv2 at compile time · 2f3a4b2a
      Jeff Layton authored
      
      rpc.nfsd stopped supporting NFSv2 a year ago. Take the next logical
      step toward deprecating it and allow NFSv2 support to be compiled out.
      
      Add a new CONFIG_NFSD_V2 option that can be turned off and rework the
      CONFIG_NFSD_V?_ACL option dependencies. Add a description that
      discourages enabling it.
      
      Also, change the description of CONFIG_NFSD to state that the always-on
      version is now 3 instead of 2.
      
      Finally, add an #ifdef around "case 2:" in __write_versions. When NFSv2
      is disabled at compile time, this should make the kernel ignore attempts
      to disable it at runtime, but still error out when trying to enable it.
      
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Reviewed-by: default avatarTom Talpey <tom@talpey.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      2f3a4b2a
  7. Sep 26, 2022
  8. Jul 30, 2022
    • Dai Ngo's avatar
      NFSD: limit the number of v4 clients to 1024 per 1GB of system memory · 4271c2c0
      Dai Ngo authored
      
      Currently there is no limit on how many v4 clients are supported
      by the system. This can be a problem in systems with small memory
      configuration to function properly when a very large number of
      clients exist that creates memory shortage conditions.
      
      This patch enforces a limit of 1024 NFSv4 clients, including courtesy
      clients, per 1GB of system memory.  When the number of the clients
      reaches the limit, requests that create new clients are returned
      with NFS4ERR_DELAY and the laundromat is kicked start to trim old
      clients. Due to the overhead of the upcall to remove the client
      record, the maximun number of clients the laundromat removes on
      each run is limited to 128. This is done to ensure the laundromat
      can still process the other tasks in a timely manner.
      
      Since there is now a limit of the number of clients, the 24-hr
      idle time limit of courtesy client is no longer needed and was
      removed.
      
      Signed-off-by: default avatarDai Ngo <dai.ngo@oracle.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      4271c2c0
    • Dai Ngo's avatar
      NFSD: refactoring v4 specific code to a helper in nfs4state.c · 6867137e
      Dai Ngo authored
      
      This patch moves the v4 specific code from nfsd_init_net() to
      nfsd4_init_leases_net() helper in nfs4state.c
      
      Signed-off-by: default avatarDai Ngo <dai.ngo@oracle.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      6867137e
  9. Jul 11, 2022
    • Chuck Lever's avatar
      NFSD: Decode NFSv4 birth time attribute · 5b2f3e07
      Chuck Lever authored
      
      NFSD has advertised support for the NFSv4 time_create attribute
      since commit e377a3e6 ("nfsd: Add support for the birth time
      attribute").
      
      Igor Mammedov reports that Mac OS clients attempt to set the NFSv4
      birth time attribute via OPEN(CREATE) and SETATTR if the server
      indicates that it supports it, but since the above commit was
      merged, those attempts now fail.
      
      Table 5 in RFC 8881 lists the time_create attribute as one that can
      be both set and retrieved, but the above commit did not add server
      support for clients to provide a time_create attribute. IMO that's
      a bug in our implementation of the NFSv4 protocol, which this commit
      addresses.
      
      Whether NFSD silently ignores the new birth time or actually sets it
      is another matter. I haven't found another filesystem service in the
      Linux kernel that enables users or clients to modify a file's birth
      time attribute.
      
      This commit reflects my (perhaps incorrect) understanding of whether
      Linux users can set a file's birth time. NFSD will now recognize a
      time_create attribute but it ignores its value. It clears the
      time_create bit in the returned attribute bitmask to indicate that
      the value was not used.
      
      Reported-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Fixes: e377a3e6 ("nfsd: Add support for the birth time attribute")
      Tested-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      5b2f3e07
  10. May 19, 2022
  11. Feb 28, 2022
  12. Dec 13, 2021
    • NeilBrown's avatar
      SUNRPC/NFSD: clean up get/put functions. · 8c62d127
      NeilBrown authored
      
      svc_destroy() is poorly named - it doesn't necessarily destroy the svc,
      it might just reduce the ref count.
      nfsd_destroy() is poorly named for the same reason.
      
      This patch:
       - removes the refcount functionality from svc_destroy(), moving it to
         a new svc_put().  Almost all previous callers of svc_destroy() now
         call svc_put().
       - renames nfsd_destroy() to nfsd_put() and improves the code, using
         the new svc_destroy() rather than svc_put()
       - removes a few comments that explain the important for balanced
         get/put calls.  This should be obvious.
      
      The only non-trivial part of this is that svc_destroy() would call
      svc_sock_update() on a non-final decrement.  It can no longer do that,
      and svc_put() isn't really a good place of it.  This call is now made
      from svc_exit_thread() which seems like a good place.  This makes the
      call *before* sv_nrthreads is decremented rather than after.  This
      is not particularly important as the call just sets a flag which
      causes sv_nrthreads set be checked later.  A subsequent patch will
      improve the ordering.
      
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      8c62d127
  13. Oct 13, 2021
  14. May 25, 2021
    • Dai Ngo's avatar
      NFSD: delay unmount source's export after inter-server copy completed. · f4e44b39
      Dai Ngo authored
      
      Currently the source's export is mounted and unmounted on every
      inter-server copy operation. This patch is an enhancement to delay
      the unmount of the source export for a certain period of time to
      eliminate the mount and unmount overhead on subsequent copy operations.
      
      After a copy operation completes, a work entry is added to the
      delayed unmount list with an expiration time. This list is serviced
      by the laundromat thread to unmount the export of the expired entries.
      Each time the export is being used again, its expiration time is
      extended and the entry is re-inserted to the tail of the list.
      
      The unmount task and the mount operation of the copy request are
      synced to make sure the export is not unmounted while it's being
      used.
      
      Signed-off-by: default avatarDai Ngo <dai.ngo@oracle.com>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      f4e44b39
  15. Mar 22, 2021
    • NeilBrown's avatar
      nfsd: report client confirmation status in "info" file · 472d155a
      NeilBrown authored
      
      mountd can now monitor clients appearing and disappearing in
      /proc/fs/nfsd/clients, and will log these events, in liu of the logging
      of mount/unmount events for NFSv3.
      
      Currently it cannot distinguish between unconfirmed clients (which might
      be transient and totally uninteresting) and confirmed clients.
      
      So add a "status: " line which reports either "confirmed" or
      "unconfirmed", and use fsnotify to report that the info file
      has been modified.
      
      This requires a bit of infrastructure to keep the dentry for the "info"
      file.  There is no need to take a counted reference as the dentry must
      remain around until the client is removed.
      
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      472d155a
    • Trond Myklebust's avatar
      nfsd: Ensure knfsd shuts down when the "nfsd" pseudofs is unmounted · c6c7f2a8
      Trond Myklebust authored
      
      In order to ensure that knfsd threads don't linger once the nfsd
      pseudofs is unmounted (e.g. when the container is killed) we let
      nfsd_umount() shut down those threads and wait for them to exit.
      
      This also should ensure that we don't need to do a kernel mount of
      the pseudofs, since the thread lifetime is now limited by the
      lifetime of the filesystem.
      
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      c6c7f2a8
  16. Jan 25, 2021
    • Amir Goldstein's avatar
      nfsd: report per-export stats · 20ad856e
      Amir Goldstein authored
      
      Collect some nfsd stats per export in addition to the global stats.
      
      A new nfsdfs export_stats file is created.  It uses the same ops as the
      exports file to iterate the export entries and we use the file's name to
      determine the reported info per export.  For example:
      
       $ cat /proc/fs/nfsd/export_stats
       # Version 1.1
       # Path Client Start-time
       #	Stats
       /test	localhost	92
      	fh_stale: 0
      	io_read: 9
      	io_write: 1
      
      Every export entry reports the start time when stats collection
      started, so stats collecting scripts can know if stats where reset
      between samples.
      
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      20ad856e
  17. Dec 09, 2020
    • J. Bruce Fields's avatar
      Revert "nfsd4: support change_attr_type attribute" · 1631087b
      J. Bruce Fields authored
      
      This reverts commit a8585763.
      
      We're still factoring ctime into our change attribute even in the
      IS_I_VERSION case.  If someone sets the system time backwards, a client
      could see the change attribute go backwards.  Maybe we can just say
      "well, don't do that", but there's some question whether that's good
      enough, or whether we need a better guarantee.
      
      Also, the client still isn't actually using the attribute.
      
      While we're still figuring this out, let's just stop returning this
      attribute.
      
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      1631087b
  18. Nov 30, 2020
  19. Jul 13, 2020
  20. Jun 29, 2020
  21. May 09, 2020
    • J. Bruce Fields's avatar
      nfsd: clients don't need to break their own delegations · 28df3d15
      J. Bruce Fields authored
      
      We currently revoke read delegations on any write open or any operation
      that modifies file data or metadata (including rename, link, and
      unlink).  But if the delegation in question is the only read delegation
      and is held by the client performing the operation, that's not really
      necessary.
      
      It's not always possible to prevent this in the NFSv4.0 case, because
      there's not always a way to determine which client an NFSv4.0 delegation
      came from.  (In theory we could try to guess this from the transport
      layer, e.g., by assuming all traffic on a given TCP connection comes
      from the same client.  But that's not really correct.)
      
      In the NFSv4.1 case the session layer always tells us the client.
      
      This patch should remove such self-conflicts in all cases where we can
      reliably determine the client from the compound.
      
      To do that we need to track "who" is performing a given (possibly
      lease-breaking) file operation.  We're doing that by storing the
      information in the svc_rqst and using kthread_data() to map the current
      task back to a svc_rqst.
      
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      28df3d15
  22. Dec 20, 2019
  23. Dec 09, 2019
  24. Nov 30, 2019
    • NeilBrown's avatar
      nfsd: check for EBUSY from vfs_rmdir/vfs_unink. · 466e16f0
      NeilBrown authored
      
      vfs_rmdir and vfs_unlink can return -EBUSY if the
      target is a mountpoint.  This currently gets passed to
      nfserrno() by nfsd_unlink(), and that results in a WARNing,
      which is not user-friendly.
      
      Possibly the best NFSv4 error is NFS4ERR_FILE_OPEN, because
      there is a sense in which the object is currently in use
      by some other task.  The Linux NFSv4 client will map this
      back to EBUSY, which is an added benefit.
      
      For NFSv3, the best we can do is probably NFS3ERR_ACCES, which isn't
      true, but is not less true than the other options.
      
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      466e16f0
  25. Jul 03, 2019
  26. Apr 24, 2019
  27. Jun 17, 2018
  28. Nov 02, 2017
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      
      Reviewed-by: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  29. Jul 13, 2017
Loading