1. 30 6月, 2020 1 次提交
  2. 02 6月, 2020 1 次提交
    • J
      nfsd4: make drc_slab global, not per-net · 027690c7
      J. Bruce Fields 提交于
      I made every global per-network-namespace instead.  But perhaps doing
      that to this slab was a step too far.
      
      The kmem_cache_create call in our net init method also seems to be
      responsible for this lockdep warning:
      
      [   45.163710] Unable to find swap-space signature
      [   45.375718] trinity-c1 (855): attempted to duplicate a private mapping with mremap.  This is not supported.
      [   46.055744] futex_wake_op: trinity-c1 tries to shift op by -209; fix this program
      [   51.011723]
      [   51.013378] ======================================================
      [   51.013875] WARNING: possible circular locking dependency detected
      [   51.014378] 5.2.0-rc2 #1 Not tainted
      [   51.014672] ------------------------------------------------------
      [   51.015182] trinity-c2/886 is trying to acquire lock:
      [   51.015593] 000000005405f099 (slab_mutex){+.+.}, at: slab_attr_store+0xa2/0x130
      [   51.016190]
      [   51.016190] but task is already holding lock:
      [   51.016652] 00000000ac662005 (kn->count#43){++++}, at: kernfs_fop_write+0x286/0x500
      [   51.017266]
      [   51.017266] which lock already depends on the new lock.
      [   51.017266]
      [   51.017909]
      [   51.017909] the existing dependency chain (in reverse order) is:
      [   51.018497]
      [   51.018497] -> #1 (kn->count#43){++++}:
      [   51.018956]        __lock_acquire+0x7cf/0x1a20
      [   51.019317]        lock_acquire+0x17d/0x390
      [   51.019658]        __kernfs_remove+0x892/0xae0
      [   51.020020]        kernfs_remove_by_name_ns+0x78/0x110
      [   51.020435]        sysfs_remove_link+0x55/0xb0
      [   51.020832]        sysfs_slab_add+0xc1/0x3e0
      [   51.021332]        __kmem_cache_create+0x155/0x200
      [   51.021720]        create_cache+0xf5/0x320
      [   51.022054]        kmem_cache_create_usercopy+0x179/0x320
      [   51.022486]        kmem_cache_create+0x1a/0x30
      [   51.022867]        nfsd_reply_cache_init+0x278/0x560
      [   51.023266]        nfsd_init_net+0x20f/0x5e0
      [   51.023623]        ops_init+0xcb/0x4b0
      [   51.023928]        setup_net+0x2fe/0x670
      [   51.024315]        copy_net_ns+0x30a/0x3f0
      [   51.024653]        create_new_namespaces+0x3c5/0x820
      [   51.025257]        unshare_nsproxy_namespaces+0xd1/0x240
      [   51.025881]        ksys_unshare+0x506/0x9c0
      [   51.026381]        __x64_sys_unshare+0x3a/0x50
      [   51.026937]        do_syscall_64+0x110/0x10b0
      [   51.027509]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      [   51.028175]
      [   51.028175] -> #0 (slab_mutex){+.+.}:
      [   51.028817]        validate_chain+0x1c51/0x2cc0
      [   51.029422]        __lock_acquire+0x7cf/0x1a20
      [   51.029947]        lock_acquire+0x17d/0x390
      [   51.030438]        __mutex_lock+0x100/0xfa0
      [   51.030995]        mutex_lock_nested+0x27/0x30
      [   51.031516]        slab_attr_store+0xa2/0x130
      [   51.032020]        sysfs_kf_write+0x11d/0x180
      [   51.032529]        kernfs_fop_write+0x32a/0x500
      [   51.033056]        do_loop_readv_writev+0x21d/0x310
      [   51.033627]        do_iter_write+0x2e5/0x380
      [   51.034148]        vfs_writev+0x170/0x310
      [   51.034616]        do_pwritev+0x13e/0x160
      [   51.035100]        __x64_sys_pwritev+0xa3/0x110
      [   51.035633]        do_syscall_64+0x110/0x10b0
      [   51.036200]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      [   51.036924]
      [   51.036924] other info that might help us debug this:
      [   51.036924]
      [   51.037876]  Possible unsafe locking scenario:
      [   51.037876]
      [   51.038556]        CPU0                    CPU1
      [   51.039130]        ----                    ----
      [   51.039676]   lock(kn->count#43);
      [   51.040084]                                lock(slab_mutex);
      [   51.040597]                                lock(kn->count#43);
      [   51.041062]   lock(slab_mutex);
      [   51.041320]
      [   51.041320]  *** DEADLOCK ***
      [   51.041320]
      [   51.041793] 3 locks held by trinity-c2/886:
      [   51.042128]  #0: 000000001f55e152 (sb_writers#5){.+.+}, at: vfs_writev+0x2b9/0x310
      [   51.042739]  #1: 00000000c7d6c034 (&of->mutex){+.+.}, at: kernfs_fop_write+0x25b/0x500
      [   51.043400]  #2: 00000000ac662005 (kn->count#43){++++}, at: kernfs_fop_write+0x286/0x500
      Reported-by: Nkernel test robot <lkp@intel.com>
      Fixes: 3ba75830 "drc containerization"
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      027690c7
  3. 21 5月, 2020 1 次提交
    • C
      NFSD: Fix improperly-formatted Doxygen comments · f2453978
      Chuck Lever 提交于
      fs/nfsd/nfsctl.c:256: warning: Function parameter or member 'file' not described in 'write_unlock_ip'
      fs/nfsd/nfsctl.c:256: warning: Function parameter or member 'buf' not described in 'write_unlock_ip'
      fs/nfsd/nfsctl.c:256: warning: Function parameter or member 'size' not described in 'write_unlock_ip'
      fs/nfsd/nfsctl.c:295: warning: Function parameter or member 'file' not described in 'write_unlock_fs'
      fs/nfsd/nfsctl.c:295: warning: Function parameter or member 'buf' not described in 'write_unlock_fs'
      fs/nfsd/nfsctl.c:295: warning: Function parameter or member 'size' not described in 'write_unlock_fs'
      fs/nfsd/nfsctl.c:352: warning: Function parameter or member 'file' not described in 'write_filehandle'
      fs/nfsd/nfsctl.c:352: warning: Function parameter or member 'buf' not described in 'write_filehandle'
      fs/nfsd/nfsctl.c:352: warning: Function parameter or member 'size' not described in 'write_filehandle'
      fs/nfsd/nfsctl.c:434: warning: Function parameter or member 'file' not described in 'write_threads'
      fs/nfsd/nfsctl.c:434: warning: Function parameter or member 'buf' not described in 'write_threads'
      fs/nfsd/nfsctl.c:434: warning: Function parameter or member 'size' not described in 'write_threads'
      fs/nfsd/nfsctl.c:478: warning: Function parameter or member 'file' not described in 'write_pool_threads'
      fs/nfsd/nfsctl.c:478: warning: Function parameter or member 'buf' not described in 'write_pool_threads'
      fs/nfsd/nfsctl.c:478: warning: Function parameter or member 'size' not described in 'write_pool_threads'
      fs/nfsd/nfsctl.c:697: warning: Function parameter or member 'file' not described in 'write_versions'
      fs/nfsd/nfsctl.c:697: warning: Function parameter or member 'buf' not described in 'write_versions'
      fs/nfsd/nfsctl.c:697: warning: Function parameter or member 'size' not described in 'write_versions'
      fs/nfsd/nfsctl.c:858: warning: Function parameter or member 'file' not described in 'write_ports'
      fs/nfsd/nfsctl.c:858: warning: Function parameter or member 'buf' not described in 'write_ports'
      fs/nfsd/nfsctl.c:858: warning: Function parameter or member 'size' not described in 'write_ports'
      fs/nfsd/nfsctl.c:892: warning: Function parameter or member 'file' not described in 'write_maxblksize'
      fs/nfsd/nfsctl.c:892: warning: Function parameter or member 'buf' not described in 'write_maxblksize'
      fs/nfsd/nfsctl.c:892: warning: Function parameter or member 'size' not described in 'write_maxblksize'
      fs/nfsd/nfsctl.c:941: warning: Function parameter or member 'file' not described in 'write_maxconn'
      fs/nfsd/nfsctl.c:941: warning: Function parameter or member 'buf' not described in 'write_maxconn'
      fs/nfsd/nfsctl.c:941: warning: Function parameter or member 'size' not described in 'write_maxconn'
      fs/nfsd/nfsctl.c:1023: warning: Function parameter or member 'file' not described in 'write_leasetime'
      fs/nfsd/nfsctl.c:1023: warning: Function parameter or member 'buf' not described in 'write_leasetime'
      fs/nfsd/nfsctl.c:1023: warning: Function parameter or member 'size' not described in 'write_leasetime'
      fs/nfsd/nfsctl.c:1039: warning: Function parameter or member 'file' not described in 'write_gracetime'
      fs/nfsd/nfsctl.c:1039: warning: Function parameter or member 'buf' not described in 'write_gracetime'
      fs/nfsd/nfsctl.c:1039: warning: Function parameter or member 'size' not described in 'write_gracetime'
      fs/nfsd/nfsctl.c:1094: warning: Function parameter or member 'file' not described in 'write_recoverydir'
      fs/nfsd/nfsctl.c:1094: warning: Function parameter or member 'buf' not described in 'write_recoverydir'
      fs/nfsd/nfsctl.c:1094: warning: Function parameter or member 'size' not described in 'write_recoverydir'
      fs/nfsd/nfsctl.c:1125: warning: Function parameter or member 'file' not described in 'write_v4_end_grace'
      fs/nfsd/nfsctl.c:1125: warning: Function parameter or member 'buf' not described in 'write_v4_end_grace'
      fs/nfsd/nfsctl.c:1125: warning: Function parameter or member 'size' not described in 'write_v4_end_grace'
      
      fs/nfsd/nfs4proc.c:1164: warning: Function parameter or member 'nss' not described in 'nfsd4_interssc_connect'
      fs/nfsd/nfs4proc.c:1164: warning: Function parameter or member 'rqstp' not described in 'nfsd4_interssc_connect'
      fs/nfsd/nfs4proc.c:1164: warning: Function parameter or member 'mount' not described in 'nfsd4_interssc_connect'
      fs/nfsd/nfs4proc.c:1262: warning: Function parameter or member 'rqstp' not described in 'nfsd4_setup_inter_ssc'
      fs/nfsd/nfs4proc.c:1262: warning: Function parameter or member 'cstate' not described in 'nfsd4_setup_inter_ssc'
      fs/nfsd/nfs4proc.c:1262: warning: Function parameter or member 'copy' not described in 'nfsd4_setup_inter_ssc'
      fs/nfsd/nfs4proc.c:1262: warning: Function parameter or member 'mount' not described in 'nfsd4_setup_inter_ssc'
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      f2453978
  4. 19 3月, 2020 1 次提交
  5. 04 2月, 2020 1 次提交
  6. 20 12月, 2019 1 次提交
    • A
      nfsd: use boottime for lease expiry calculation · 20b7d86f
      Arnd Bergmann 提交于
      A couple of time_t variables are only used to track the state of the
      lease time and its expiration. The code correctly uses the 'time_after()'
      macro to make this work on 32-bit architectures even beyond year 2038,
      but the get_seconds() function and the time_t type itself are deprecated
      as they behave inconsistently between 32-bit and 64-bit architectures
      and often lead to code that is not y2038 safe.
      
      As a minor issue, using get_seconds() leads to problems with concurrent
      settimeofday() or clock_settime() calls, in the worst case timeout never
      triggering after the time has been set backwards.
      
      Change nfsd to use time64_t and ktime_get_boottime_seconds() here. This
      is clearly excessive, as boottime by itself means we never go beyond 32
      bits, but it does mean we handle this correctly and consistently without
      having to worry about corner cases and should be no more expensive than
      the previous implementation on 64-bit architectures.
      
      The max_cb_time() function gets changed in order to avoid an expensive
      64-bit division operation, but as the lease time is at most one hour,
      there is no change in behavior.
      
      Also do the same for server-to-server copy expiration time.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      [bfields@redhat.com: fix up copy expiration]
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      20b7d86f
  7. 10 9月, 2019 1 次提交
  8. 06 9月, 2019 1 次提交
  9. 16 8月, 2019 3 次提交
  10. 10 7月, 2019 1 次提交
  11. 04 7月, 2019 5 次提交
  12. 03 7月, 2019 1 次提交
  13. 26 5月, 2019 1 次提交
    • D
      vfs: Convert nfsctl to use the new mount API · 96a374a3
      David Howells 提交于
      Convert the nfsctl filesystem to the new internal mount API as the old
      one will be obsoleted and removed.  This allows greater flexibility in
      communication of mount parameters between userspace, the VFS and the
      filesystem.
      
      See Documentation/filesystems/mount_api.txt for more information.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: "J. Bruce Fields" <bfields@fieldses.org>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: linux-nfs@vger.kernel.org
      96a374a3
  14. 21 5月, 2019 1 次提交
  15. 24 4月, 2019 3 次提交
  16. 06 3月, 2019 1 次提交
  17. 15 2月, 2019 1 次提交
    • J
      Revert "nfsd4: return default lease period" · 3bf6b57e
      J. Bruce Fields 提交于
      This reverts commit d6ebf508.
      
      I forgot that the kernel's default lease period should never be
      decreased!
      
      After a kernel upgrade, the kernel has no way of knowing on its own what
      the previous lease time was.  Unless userspace tells it otherwise, it
      will assume the previous lease period was the same.
      
      So if we decrease this value in a kernel upgrade, we end up enforcing a
      grace period that's too short, and clients will fail to reclaim state in
      time.  Symptoms may include EIO and log messages like "NFS:
      nfs4_reclaim_open_state: Lock reclaim failed!"
      
      There was no real justification for the lease period decrease anyway.
      Reported-by: NDonald Buczek <buczek@molgen.mpg.de>
      Fixes: d6ebf508 "nfsd4: return default lease period"
      Cc: stable@vger.kernel.org
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      3bf6b57e
  18. 29 11月, 2018 1 次提交
  19. 26 9月, 2018 1 次提交
    • O
      NFSD introduce async copy feature · e0639dc5
      Olga Kornievskaia 提交于
      Upon receiving a request for async copy, create a new kthread.  If we
      get asynchronous request, make sure to copy the needed arguments/state
      from the stack before starting the copy. Then start the thread and reply
      back to the client indicating copy is asynchronous.
      
      nfsd_copy_file_range() will copy in a loop over the total number of
      bytes is needed to copy. In case a failure happens in the middle, we
      ignore the error and return how much we copied so far. Once done
      creating a workitem for the callback workqueue and send CB_OFFLOAD with
      the results.
      
      The lifetime of the copy stateid is bound to the vfs copy. This way we
      don't need to keep the nfsd_net structure for the callback.  We could
      keep it around longer so that an OFFLOAD_STATUS that came late would
      still get results, but clients should be able to deal without that.
      
      We handle OFFLOAD_CANCEL by sending a signal to the copy thread and
      calling kthread_stop.
      
      A client should cancel any ongoing copies before calling DESTROY_CLIENT;
      if not, we return a CLIENT_BUSY error.
      
      If the client is destroyed for some other reason (lease expiration, or
      server shutdown), we must clean up any ongoing copies ourselves.
      Signed-off-by: NOlga Kornievskaia <kolga@netapp.com>
      [colin.king@canonical.com: fix leak in error case]
      [bfields@fieldses.org: remove signalling, merge patches]
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      e0639dc5
  20. 10 8月, 2018 1 次提交
  21. 17 6月, 2018 2 次提交
  22. 28 3月, 2018 2 次提交
  23. 28 11月, 2017 1 次提交
  24. 27 4月, 2017 1 次提交
  25. 11 3月, 2017 1 次提交
    • N
      NFSD: further refinement of content of /proc/fs/nfsd/versions · abcb4dac
      NeilBrown 提交于
      Prior to
        e35659f1 ("NFSD: correctly range-check v4.x minor version when setting versions.")
      
      v4.0 could not be disabled without disabling all NFSv4 protocols.
      So the 'versions' file contained ±4 ±4.1 ±4.2.
      Writing "-4" would disable all v4 completely.  Writing +4 would enabled those
      minor versions that are currently enabled, either by default or otherwise.
      
      After that commit, it was possible to disable v4.0 independently.  To
      maximize backward compatibility with use cases which never disabled
      v4.0, the "versions" file would never contain "+4.0" - that was implied
      by "+4", unless explicitly negated by "-4.0".
      
      This introduced an inconsistency in that it was possible to disable all
      minor versions, but still have the major version advertised.
      e.g. "-4.0 -4.1 -4.2 +4" would result in NFSv4 support being advertised,
      but all attempts to use it rejected.
      
      Commit
        d3635ff0 ("nfsd: fix configuration of supported minor versions")
      
      and following removed this inconsistency. If all minor version were disabled,
      the major would be disabled too.  If any minor was enabled, the major would be
      disabled.
      This patch also treated "+4" as equivalent to "+4.0" and "-4" as "-4.0".
      A consequence of this is that writing "-4" would only disable 4.0.
      This is a regression against the earlier behaviour, in a use case that rpc.nfsd
      actually uses.
      The command "rpc.nfsd -N 4" will write "+2 +3 -4" to the versions files.
      Previously, that would disable v4 completely.  Now it will only disable v4.0.
      
      Also "4.0" never appears in the "versions" file when read.
      So if only v4.1 is available, the previous kernel would have reported
      "+4 -4.0 +4.1 -4.2"  the current kernel reports "-4 +4.1 -4.2" which
      could easily confuse.
      
      This patch restores the implication that "+4" and "-4" apply more
      globals and do not imply "4.0".
      Specifically:
       writing "-4" will disable all 4.x minor versions.
       writing "+4" will enable all 4.1 minor version if none are currently enabled.
          rpc.nfsd will list minor versions before major versions, so
            rpc.nfsd -V 4.2 -N 4.1
          will write "-4.1 +4.2 +2 +3 +4"
          so it would be a regression for "+4" to enable always all versions.
       reading "-4" implies that no v4.x are enabled
       reading "+4" implies that some v4.x are enabled, and that v4.0 is enabled unless
       "-4.0" is also present.  All other minor versions will explicitly be listed.
      Signed-off-by: NNeilBrown <neilb@suse.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      abcb4dac
  26. 28 2月, 2017 2 次提交
  27. 01 2月, 2017 1 次提交
    • N
      NFSD: correctly range-check v4.x minor version when setting versions. · e35659f1
      NeilBrown 提交于
      Writing to /proc/fs/nfsd/versions allows individual major versions
      and NFSv4 minor versions to be enabled or disabled.
      
      However NFSv4.0 cannot currently be disabled, thought there is no good reason.
      Also the minor number is parsed as a 'long' but used as an 'int'
      so '4294967297' will be incorrectly treated as '1'.
      
      This patch removes the test on 'minor == 0' and switches to kstrtouint()
      to get correct range checking.
      
      When reading from /proc/fs/nfsd/versions, 4.0 is current not reported.
      To allow the disabling for v4.0 to be visible, while maintaining
      backward compatibility, change code to report "-4.0" if appropriate, but
      not "+4.0".
      Signed-off-by: NNeilBrown <neilb@suse.com>
      Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
      e35659f1
  28. 18 11月, 2016 1 次提交
    • A
      netns: make struct pernet_operations::id unsigned int · c7d03a00
      Alexey Dobriyan 提交于
      Make struct pernet_operations::id unsigned.
      
      There are 2 reasons to do so:
      
      1)
      This field is really an index into an zero based array and
      thus is unsigned entity. Using negative value is out-of-bound
      access by definition.
      
      2)
      On x86_64 unsigned 32-bit data which are mixed with pointers
      via array indexing or offsets added or subtracted to pointers
      are preffered to signed 32-bit data.
      
      "int" being used as an array index needs to be sign-extended
      to 64-bit before being used.
      
      	void f(long *p, int i)
      	{
      		g(p[i]);
      	}
      
        roughly translates to
      
      	movsx	rsi, esi
      	mov	rdi, [rsi+...]
      	call 	g
      
      MOVSX is 3 byte instruction which isn't necessary if the variable is
      unsigned because x86_64 is zero extending by default.
      
      Now, there is net_generic() function which, you guessed it right, uses
      "int" as an array index:
      
      	static inline void *net_generic(const struct net *net, int id)
      	{
      		...
      		ptr = ng->ptr[id - 1];
      		...
      	}
      
      And this function is used a lot, so those sign extensions add up.
      
      Patch snipes ~1730 bytes on allyesconfig kernel (without all junk
      messing with code generation):
      
      	add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)
      
      Unfortunately some functions actually grow bigger.
      This is a semmingly random artefact of code generation with register
      allocator being used differently. gcc decides that some variable
      needs to live in new r8+ registers and every access now requires REX
      prefix. Or it is shifted into r12, so [r12+0] addressing mode has to be
      used which is longer than [r8]
      
      However, overall balance is in negative direction:
      
      	add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)
      	function                                     old     new   delta
      	nfsd4_lock                                  3886    3959     +73
      	tipc_link_build_proto_msg                   1096    1140     +44
      	mac80211_hwsim_new_radio                    2776    2808     +32
      	tipc_mon_rcv                                1032    1058     +26
      	svcauth_gss_legacy_init                     1413    1429     +16
      	tipc_bcbase_select_primary                   379     392     +13
      	nfsd4_exchange_id                           1247    1260     +13
      	nfsd4_setclientid_confirm                    782     793     +11
      		...
      	put_client_renew_locked                      494     480     -14
      	ip_set_sockfn_get                            730     716     -14
      	geneve_sock_add                              829     813     -16
      	nfsd4_sequence_done                          721     703     -18
      	nlmclnt_lookup_host                          708     686     -22
      	nfsd4_lockt                                 1085    1063     -22
      	nfs_get_client                              1077    1050     -27
      	tcf_bpf_init                                1106    1076     -30
      	nfsd4_encode_fattr                          5997    5930     -67
      	Total: Before=154856051, After=154854321, chg -0.00%
      Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c7d03a00
  29. 15 11月, 2016 1 次提交