You need to sign in or sign up before continuing.
  1. 25 Jul, 2022 2 commits
  2. 23 Jul, 2022 1 commit
  3. 07 Jun, 2022 1 commit
    • Scott Mayhew's avatar
      sunrpc: set cl_max_connect when cloning an rpc_clnt · 30479125
      Scott Mayhew authored
      
      If the initial attempt at trunking detection using the krb5i auth flavor
      fails with -EACCES, -NFS4ERR_CLID_INUSE, or -NFS4ERR_WRONGSEC, then the
      NFS client tries again using auth_sys, cloning the rpc_clnt in the
      process.  If this second attempt at trunking detection succeeds, then
      the resulting nfs_client->cl_rpcclient winds up having cl_max_connect=0
      and subsequent attempts to add additional transport connections to the
      rpc_clnt will fail with a message similar to the following being logged:
      
      [502044.312640] SUNRPC: reached max allowed number (0) did not add
      transport to server: 192.168.122.3
      Signed-off-by: default avatarScott Mayhew <smayhew@redhat.com>
      Fixes: dc48e0ab
      
       ("SUNRPC enforce creation of no more than max_connect xprts")
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      30479125
  4. 07 May, 2022 2 commits
  5. 29 Apr, 2022 1 commit
  6. 22 Apr, 2022 1 commit
  7. 07 Apr, 2022 3 commits
  8. 30 Mar, 2022 1 commit
    • NeilBrown's avatar
      SUNRPC: handle malloc failure in ->request_prepare · eb07d5a4
      NeilBrown authored
      
      If ->request_prepare() detects an error, it sets ->rq_task->tk_status.
      This is easy for callers to ignore.
      The only caller is xprt_request_enqueue_receive() and it does ignore the
      error, as does call_encode() which calls it.  This can result in a
      request being queued to receive a reply without an allocated receive buffer.
      
      So instead of setting rq_task->tk_status, return an error, and store in
      ->tk_status only in call_encode();
      
      The call to xprt_request_enqueue_receive() is now earlier in
      call_encode(), where the error can still be handled.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      eb07d5a4
  9. 24 Mar, 2022 1 commit
  10. 13 Mar, 2022 3 commits
    • NeilBrown's avatar
      NFSv4: keep state manager thread active if swap is enabled · 4dc73c67
      NeilBrown authored
      
      If we are swapping over NFSv4, we may not be able to allocate memory to
      start the state-manager thread at the time when we need it.
      So keep it always running when swap is enabled, and just signal it to
      start.
      
      This requires updating and testing the cl_swapper count on the root
      rpc_clnt after following all ->cl_parent links.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      4dc73c67
    • NeilBrown's avatar
      SUNRPC: improve 'swap' handling: scheduling and PF_MEMALLOC · 8db55a03
      NeilBrown authored
      
      rpc tasks can be marked as RPC_TASK_SWAPPER.  This causes GFP_MEMALLOC
      to be used for some allocations.  This is needed in some cases, but not
      in all where it is currently provided, and in some where it isn't
      provided.
      
      Currently *all* tasks associated with a rpc_client on which swap is
      enabled get the flag and hence some GFP_MEMALLOC support.
      
      GFP_MEMALLOC is provided for ->buf_alloc() but only swap-writes need it.
      However xdr_alloc_bvec does not get GFP_MEMALLOC - though it often does
      need it.
      
      xdr_alloc_bvec is called while the XPRT_LOCK is held.  If this blocks,
      then it blocks all other queued tasks.  So this allocation needs
      GFP_MEMALLOC for *all* requests, not just writes, when the xprt is used
      for any swap writes.
      
      Similarly, if the transport is not connected, that will block all
      requests including swap writes, so memory allocations should get
      GFP_MEMALLOC if swap writes are possible.
      
      So with this patch:
       1/ we ONLY set RPC_TASK_SWAPPER for swap writes.
       2/ __rpc_execute() sets PF_MEMALLOC while handling any task
          with RPC_TASK_SWAPPER set, or when handling any task that
          holds the XPRT_LOCKED lock on an xprt used for swap.
          This removes the need for the RPC_IS_SWAPPER() test
          in ->buf_alloc handlers.
       3/ xprt_prepare_transmit() sets PF_MEMALLOC after locking
          any task to a swapper xprt.  __rpc_execute() will clear it.
       3/ PF_MEMALLOC is set for all the connect workers.
      
      Reviewed-by: Chuck Lever <chuck.lever@oracle.com> (for xprtrdma parts)
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      8db55a03
    • NeilBrown's avatar
      SUNRPC/auth: async tasks mustn't block waiting for memory · a41b05ed
      NeilBrown authored
      
      When memory is short, new worker threads cannot be created and we depend
      on the minimum one rpciod thread to be able to handle everything.  So it
      must not block waiting for memory.
      
      mempools are particularly a problem as memory can only be released back
      to the mempool by an async rpc task running.  If all available workqueue
      threads are waiting on the mempool, no thread is available to return
      anything.
      
      lookup_cred() can block on a mempool or kmalloc - and this can cause
      deadlocks.  So add a new RPCAUTH_LOOKUP flag for async lookups and don't
      block on memory.  If the -ENOMEM gets back to call_refreshresult(), wait
      a short while and try again.  HZ>>4 is chosen as it is used elsewhere
      for -ENOMEM retries.
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      a41b05ed
  11. 25 Feb, 2022 1 commit
  12. 13 Jan, 2022 1 commit
  13. 20 Oct, 2021 1 commit
  14. 27 Aug, 2021 2 commits
  15. 09 Aug, 2021 3 commits
  16. 08 Jul, 2021 4 commits
  17. 20 May, 2021 1 commit
    • NeilBrown's avatar
      SUNRPC in case of backlog, hand free slots directly to waiting task · e877a88d
      NeilBrown authored
      If sunrpc.tcp_max_slot_table_entries is small and there are tasks
      on the backlog queue, then when a request completes it is freed and the
      first task on the queue is woken.  The expectation is that it will wake
      and claim that request.  However if it was a sync task and the waiting
      process was killed at just that moment, it will wake and NOT claim the
      request.
      
      As long as TASK_CONGESTED remains set, requests can only be claimed by
      tasks woken from the backlog, and they are woken only as requests are
      freed, so when a task doesn't claim a request, no other task can ever
      get that request until TASK_CONGESTED is cleared.  Each time this
      happens the number of available requests is decreased by one.
      
      With a sufficiently high workload and sufficiently low setting of
      max_slot (16 in the case where this was seen), TASK_CONGESTED can remain
      set for an extended period, and the above scenario (of a process being
      killed just as its task was woken) can repeat until no requests can be
      allocated.  Then traffic stops.
      
      This patch addresses the problem by introducing a positive handover of a
      request from a completing task to a backlog task - the request is never
      freed when there is a backlog.
      
      When a task is woken it might not already have a request attached in
      which case it is *not* freed (as with current code) but is initialised
      (if needed) and used.  If it isn't used it will eventually be freed by
      rpc_exit_task().  xprt_release() is enhanced to be able to correctly
      release an uninitialised request.
      
      Fixes: ba60eb25
      
       ("SUNRPC: Fix a livelock problem in the xprt->backlog queue")
      Signed-off-by: default avatarNeilBrown <neilb@suse.de>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      e877a88d
  18. 01 May, 2021 1 commit
    • Baptiste Lepers's avatar
      sunrpc: Fix misplaced barrier in call_decode · f8f7e0fb
      Baptiste Lepers authored
      Fix a misplaced barrier in call_decode. The struct rpc_rqst is modified
      as follows by xprt_complete_rqst:
      
      req->rq_private_buf.len = copied;
      /* Ensure all writes are done before we update */
      /* req->rq_reply_bytes_recvd */
      smp_wmb();
      req->rq_reply_bytes_recvd = copied;
      
      And currently read as follows by call_decode:
      
      smp_rmb(); // misplaced
      if (!req->rq_reply_bytes_recvd)
         goto out;
      req->rq_rcv_buf.len = req->rq_private_buf.len;
      
      This patch places the smp_rmb after the if to ensure that
      rq_reply_bytes_recvd and rq_private_buf.len are read in order.
      
      Fixes: 9ba82886
      
       ("SUNRPC: Don't try to parse incomplete RPC messages")
      Signed-off-by: default avatarBaptiste Lepers <baptiste.lepers@gmail.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      f8f7e0fb
  19. 14 Apr, 2021 1 commit
    • Chuck Lever's avatar
      SUNRPC: Move fault injection call sites · 7638e0bf
      Chuck Lever authored
      I've hit some crashes that occur in the xprt_rdma_inject_disconnect
      path. It appears that, for some provides, rdma_disconnect() can
      take so long that the transport can disconnect and release its
      hardware resources while rdma_disconnect() is still running,
      resulting in a UAF in the provider.
      
      The transport's fault injection method may depend on the stability
      of transport data structures. That means it needs to be invoked
      only from contexts that hold the transport write lock.
      
      Fixes: 4a068258
      
       ("SUNRPC: Transport fault injection")
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      7638e0bf
  20. 02 Dec, 2020 1 commit
    • Trond Myklebust's avatar
      SUNRPC: Clean up the handling of page padding in rpc_prepare_reply_pages() · 9ed5af26
      Trond Myklebust authored
      rpc_prepare_reply_pages() currently expects the 'hdrsize' argument to
      contain the length of the data that we expect to want placed in the head
      kvec plus a count of 1 word of padding that is placed after the page data.
      This is very confusing when trying to read the code, and sometimes leads
      to callers adding an arbitrary value of '1' just in order to satisfy the
      requirement (whether or not the page data actually needs such padding).
      
      This patch aims to clarify the code by changing the 'hdrsize' argument
      to remove that 1 word of padding. This means we need to subtract the
      padding from all the existing callers.
      
      Fixes: 02ef04e4
      
       ("NFS: Account for XDR pad of buf->pages")
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      9ed5af26
  21. 21 Sep, 2020 8 commits