1. 20 2月, 2023 15 次提交
  2. 07 1月, 2023 1 次提交
  3. 26 12月, 2022 1 次提交
    • S
      treewide: Convert del_timer*() to timer_shutdown*() · 292a089d
      Steven Rostedt (Google) 提交于
      Due to several bugs caused by timers being re-armed after they are
      shutdown and just before they are freed, a new state of timers was added
      called "shutdown".  After a timer is set to this state, then it can no
      longer be re-armed.
      
      The following script was run to find all the trivial locations where
      del_timer() or del_timer_sync() is called in the same function that the
      object holding the timer is freed.  It also ignores any locations where
      the timer->function is modified between the del_timer*() and the free(),
      as that is not considered a "trivial" case.
      
      This was created by using a coccinelle script and the following
      commands:
      
          $ cat timer.cocci
          @@
          expression ptr, slab;
          identifier timer, rfield;
          @@
          (
          -       del_timer(&ptr->timer);
          +       timer_shutdown(&ptr->timer);
          |
          -       del_timer_sync(&ptr->timer);
          +       timer_shutdown_sync(&ptr->timer);
          )
            ... when strict
                when != ptr->timer
          (
                  kfree_rcu(ptr, rfield);
          |
                  kmem_cache_free(slab, ptr);
          |
                  kfree(ptr);
          )
      
          $ spatch timer.cocci . > /tmp/t.patch
          $ patch -p1 < /tmp/t.patch
      
      Link: https://lore.kernel.org/lkml/20221123201306.823305113@linutronix.de/Signed-off-by: NSteven Rostedt (Google) <rostedt@goodmis.org>
      Acked-by: Pavel Machek <pavel@ucw.cz> [ LED ]
      Acked-by: Kalle Valo <kvalo@kernel.org> [ wireless ]
      Acked-by: Paolo Abeni <pabeni@redhat.com> [ networking ]
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      292a089d
  4. 11 12月, 2022 1 次提交
  5. 29 11月, 2022 1 次提交
  6. 27 9月, 2022 3 次提交
  7. 23 5月, 2022 1 次提交
  8. 20 5月, 2022 1 次提交
  9. 28 2月, 2022 5 次提交
  10. 14 12月, 2021 7 次提交
    • N
      lockd: use svc_set_num_threads() for thread start and stop · 6b044fba
      NeilBrown 提交于
      svc_set_num_threads() does everything that lockd_start_svc() does, except
      set sv_maxconn.  It also (when passed 0) finds the threads and
      stops them with kthread_stop().
      
      So move the setting for sv_maxconn, and use svc_set_num_thread()
      
      We now don't need nlmsvc_task.
      
      Now that we use svc_set_num_threads() it makes sense to set svo_module.
      This request that the thread exists with module_put_and_exit().
      Also fix the documentation for svo_module to make this explicit.
      
      svc_prepare_thread is now only used where it is defined, so it can be
      made static.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      6b044fba
    • N
      SUNRPC: always treat sv_nrpools==1 as "not pooled" · 93aa619e
      NeilBrown 提交于
      Currently 'pooled' services hold a reference on the pool_map, and
      'unpooled' services do not.
      svc_destroy() uses the presence of ->svo_function (via
      svc_serv_is_pooled()) to determine if the reference should be dropped.
      There is no direct correlation between being pooled and the use of
      svo_function, though in practice, lockd is the only non-pooled service,
      and the only one not to use svo_function.
      
      This is untidy and would cause problems if we changed lockd to use
      svc_set_num_threads(), which requires the use of ->svo_function.
      
      So change the test for "is the service pooled" to "is sv_nrpools > 1".
      
      This means that when svc_pool_map_get() returns 1, it must NOT take a
      reference to the pool.
      
      We discard svc_serv_is_pooled(), and test sv_nrpools directly.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      93aa619e
    • N
      SUNRPC: move the pool_map definitions (back) into svc.c · cf0e124e
      NeilBrown 提交于
      These definitions are not used outside of svc.c, and there is no
      evidence that they ever have been.  So move them into svc.c
      and make the declarations 'static'.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      cf0e124e
    • N
      SUNRPC: discard svo_setup and rename svc_set_num_threads_sync() · 3ebdbe52
      NeilBrown 提交于
      The ->svo_setup callback serves no purpose.  It is always called from
      within the same module that chooses which callback is needed.  So
      discard it and call the relevant function directly.
      
      Now that svc_set_num_threads() is no longer used remove it and rename
      svc_set_num_threads_sync() to remove the "_sync" suffix.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      3ebdbe52
    • N
      SUNRPC: use sv_lock to protect updates to sv_nrthreads. · 2a36395f
      NeilBrown 提交于
      Using sv_lock means we don't need to hold the service mutex over these
      updates.
      
      In particular,  svc_exit_thread() no longer requires synchronisation, so
      threads can exit asynchronously.
      
      Note that we could use an atomic_t, but as there are many more read
      sites than writes, that would add unnecessary noise to the code.
      Some reads are already racy, and there is no need for them to not be.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      2a36395f
    • N
      SUNRPC: stop using ->sv_nrthreads as a refcount · ec52361d
      NeilBrown 提交于
      The use of sv_nrthreads as a general refcount results in clumsy code, as
      is seen by various comments needed to explain the situation.
      
      This patch introduces a 'struct kref' and uses that for reference
      counting, leaving sv_nrthreads to be a pure count of threads.  The kref
      is managed particularly in svc_get() and svc_put(), and also nfsd_put();
      
      svc_destroy() now takes a pointer to the embedded kref, rather than to
      the serv.
      
      nfsd allows the svc_serv to exist with ->sv_nrhtreads being zero.  This
      happens when a transport is created before the first thread is started.
      To support this, a 'keep_active' flag is introduced which holds a ref on
      the svc_serv.  This is set when any listening socket is successfully
      added (unless there are running threads), and cleared when the number of
      threads is set.  So when the last thread exits, the nfs_serv will be
      destroyed.
      The use of 'keep_active' replaces previous code which checked if there
      were any permanent sockets.
      
      We no longer clear ->rq_server when nfsd() exits.  This was done
      to prevent svc_exit_thread() from calling svc_destroy().
      Instead we take an extra reference to the svc_serv to prevent
      svc_destroy() from being called.
      Signed-off-by: NNeilBrown <neilb@suse.de>
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      ec52361d
    • N
      SUNRPC/NFSD: clean up get/put functions. · 8c62d127
      NeilBrown 提交于
      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: NNeilBrown <neilb@suse.de>
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      8c62d127
  11. 12 10月, 2021 2 次提交
  12. 03 10月, 2021 1 次提交
  13. 21 8月, 2021 1 次提交
    • C
      SUNRPC: Server-side disconnect injection · 3a126180
      Chuck Lever 提交于
      Disconnect injection stress-tests the ability for both client and
      server implementations to behave resiliently in the face of network
      instability.
      
      A file called /sys/kernel/debug/fail_sunrpc/ignore-server-disconnect
      enables administrators to turn off server-side disconnect injection
      while allowing other types of sunrpc errors to be injected. The
      default setting is that server-side disconnect injection is enabled
      (ignore=false).
      Signed-off-by: NChuck Lever <chuck.lever@oracle.com>
      3a126180