1. 21 6月, 2013 6 次提交
  2. 29 5月, 2013 1 次提交
  3. 28 2月, 2013 2 次提交
    • S
      hlist: drop the node parameter from iterators · b67bfe0d
      Sasha Levin 提交于
      I'm not sure why, but the hlist for each entry iterators were conceived
      
              list_for_each_entry(pos, head, member)
      
      The hlist ones were greedy and wanted an extra parameter:
      
              hlist_for_each_entry(tpos, pos, head, member)
      
      Why did they need an extra pos parameter? I'm not quite sure. Not only
      they don't really need it, it also prevents the iterator from looking
      exactly like the list iterator, which is unfortunate.
      
      Besides the semantic patch, there was some manual work required:
      
       - Fix up the actual hlist iterators in linux/list.h
       - Fix up the declaration of other iterators based on the hlist ones.
       - A very small amount of places were using the 'node' parameter, this
       was modified to use 'obj->member' instead.
       - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
       properly, so those had to be fixed up manually.
      
      The semantic patch which is mostly the work of Peter Senna Tschudin is here:
      
      @@
      iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
      
      type T;
      expression a,c,d,e;
      identifier b;
      statement S;
      @@
      
      -T b;
          <+... when != b
      (
      hlist_for_each_entry(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_continue(a,
      - b,
      c) S
      |
      hlist_for_each_entry_from(a,
      - b,
      c) S
      |
      hlist_for_each_entry_rcu(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_rcu_bh(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_continue_rcu_bh(a,
      - b,
      c) S
      |
      for_each_busy_worker(a, c,
      - b,
      d) S
      |
      ax25_uid_for_each(a,
      - b,
      c) S
      |
      ax25_for_each(a,
      - b,
      c) S
      |
      inet_bind_bucket_for_each(a,
      - b,
      c) S
      |
      sctp_for_each_hentry(a,
      - b,
      c) S
      |
      sk_for_each(a,
      - b,
      c) S
      |
      sk_for_each_rcu(a,
      - b,
      c) S
      |
      sk_for_each_from
      -(a, b)
      +(a)
      S
      + sk_for_each_from(a) S
      |
      sk_for_each_safe(a,
      - b,
      c, d) S
      |
      sk_for_each_bound(a,
      - b,
      c) S
      |
      hlist_for_each_entry_safe(a,
      - b,
      c, d, e) S
      |
      hlist_for_each_entry_continue_rcu(a,
      - b,
      c) S
      |
      nr_neigh_for_each(a,
      - b,
      c) S
      |
      nr_neigh_for_each_safe(a,
      - b,
      c, d) S
      |
      nr_node_for_each(a,
      - b,
      c) S
      |
      nr_node_for_each_safe(a,
      - b,
      c, d) S
      |
      - for_each_gfn_sp(a, c, d, b) S
      + for_each_gfn_sp(a, c, d) S
      |
      - for_each_gfn_indirect_valid_sp(a, c, d, b) S
      + for_each_gfn_indirect_valid_sp(a, c, d) S
      |
      for_each_host(a,
      - b,
      c) S
      |
      for_each_host_safe(a,
      - b,
      c, d) S
      |
      for_each_mesh_entry(a,
      - b,
      c, d) S
      )
          ...+>
      
      [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
      [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
      [akpm@linux-foundation.org: checkpatch fixes]
      [akpm@linux-foundation.org: fix warnings]
      [akpm@linux-foudnation.org: redo intrusive kvm changes]
      Tested-by: NPeter Senna Tschudin <peter.senna@gmail.com>
      Acked-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: NSasha Levin <sasha.levin@oracle.com>
      Cc: Wu Fengguang <fengguang.wu@intel.com>
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Cc: Gleb Natapov <gleb@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b67bfe0d
    • T
      IB/core: convert to idr_alloc() · 3b069c5d
      Tejun Heo 提交于
      Convert to the much saner new idr interface.
      
      v2: Mike triggered WARN_ON() in idr_preload() because send_mad(),
          which may be used from non-process context, was calling
          idr_preload() unconditionally.  Preload iff @gfp_mask has
          __GFP_WAIT.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reviewed-by: NSean Hefty <sean.hefty@intel.com>
      Reported-by: N"Marciniszyn, Mike" <mike.marciniszyn@intel.com>
      Cc: Roland Dreier <roland@kernel.org>
      Cc: Sean Hefty <sean.hefty@intel.com>
      Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3b069c5d
  4. 30 11月, 2012 1 次提交
    • S
      RDMA/cm: Change return value from find_gid_port() · 63f05be2
      shefty 提交于
      Problem reported by Dan Carpenter <dan.carpenter@oracle.com>:
      
      The patch 3c86aa70: "RDMA/cm: Add RDMA CM support for IBoE
      devices" from Oct 13, 2010, leads to the following warning:
      net/sunrpc/xprtrdma/svc_rdma_transport.c:722 svc_rdma_create()
      	 error: passing non neg 1 to ERR_PTR
      
      This bug would result in a NULL dereference.  svc_rdma_create() is
      supposed to return ERR_PTRs or valid pointers, but instead it returns
      ERR_PTRs, valid pointers and 1.
      
      The call tree is:
      
      svc_rdma_create()
         => rdma_bind_addr()
            => cma_acquire_dev()
               => find_gid_port()
      
      rdma_bind_addr() should return a valid errno.  Fix this by having
      find_gid_port() also return a valid errno.  If we can't find the
      specified GID on a given port, return -EADDRNOTAVAIL, rather than
      -EAGAIN, to better indicate the error.  We also drop using the
      special return value of '1' and instead pass through the error
      returned by the underlying verbs call.  On such errors, rather
      than aborting the search,  we simply continue to check the next
      device/port.
      Signed-off-by: NSean Hefty <sean.hefty@intel.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      63f05be2
  5. 07 10月, 2012 1 次提交
  6. 05 10月, 2012 1 次提交
  7. 01 10月, 2012 1 次提交
  8. 28 7月, 2012 1 次提交
  9. 09 7月, 2012 4 次提交
  10. 20 6月, 2012 1 次提交
  11. 09 5月, 2012 1 次提交
    • S
      RDMA/cma: Fix lockdep false positive recursive locking · b6cec8aa
      Sean Hefty 提交于
      The following lockdep problem was reported by Or Gerlitz <ogerlitz@mellanox.com>:
      
          [ INFO: possible recursive locking detected ]
          3.3.0-32035-g1b2649e-dirty #4 Not tainted
          ---------------------------------------------
          kworker/5:1/418 is trying to acquire lock:
           (&id_priv->handler_mutex){+.+.+.}, at: [<ffffffffa0138a41>] rdma_destroy_i    d+0x33/0x1f0 [rdma_cm]
      
          but task is already holding lock:
           (&id_priv->handler_mutex){+.+.+.}, at: [<ffffffffa0135130>] cma_disable_ca    llback+0x24/0x45 [rdma_cm]
      
          other info that might help us debug this:
           Possible unsafe locking scenario:
      
                 CPU0
                 ----
            lock(&id_priv->handler_mutex);
            lock(&id_priv->handler_mutex);
      
           *** DEADLOCK ***
      
           May be due to missing lock nesting notation
      
          3 locks held by kworker/5:1/418:
           #0:  (ib_cm){.+.+.+}, at: [<ffffffff81042ac1>] process_one_work+0x210/0x4a    6
           #1:  ((&(&work->work)->work)){+.+.+.}, at: [<ffffffff81042ac1>] process_on    e_work+0x210/0x4a6
           #2:  (&id_priv->handler_mutex){+.+.+.}, at: [<ffffffffa0135130>] cma_disab    le_callback+0x24/0x45 [rdma_cm]
      
          stack backtrace:
          Pid: 418, comm: kworker/5:1 Not tainted 3.3.0-32035-g1b2649e-dirty #4
          Call Trace:
           [<ffffffff8102b0fb>] ? console_unlock+0x1f4/0x204
           [<ffffffff81068771>] __lock_acquire+0x16b5/0x174e
           [<ffffffff8106461f>] ? save_trace+0x3f/0xb3
           [<ffffffff810688fa>] lock_acquire+0xf0/0x116
           [<ffffffffa0138a41>] ? rdma_destroy_id+0x33/0x1f0 [rdma_cm]
           [<ffffffff81364351>] mutex_lock_nested+0x64/0x2ce
           [<ffffffffa0138a41>] ? rdma_destroy_id+0x33/0x1f0 [rdma_cm]
           [<ffffffff81065a78>] ? trace_hardirqs_on_caller+0x11e/0x155
           [<ffffffff81065abc>] ? trace_hardirqs_on+0xd/0xf
           [<ffffffffa0138a41>] rdma_destroy_id+0x33/0x1f0 [rdma_cm]
           [<ffffffffa0139c02>] cma_req_handler+0x418/0x644 [rdma_cm]
           [<ffffffffa012ee88>] cm_process_work+0x32/0x119 [ib_cm]
           [<ffffffffa0130299>] cm_req_handler+0x928/0x982 [ib_cm]
           [<ffffffffa01302f3>] ? cm_req_handler+0x982/0x982 [ib_cm]
           [<ffffffffa0130326>] cm_work_handler+0x33/0xfe5 [ib_cm]
           [<ffffffff81065a78>] ? trace_hardirqs_on_caller+0x11e/0x155
           [<ffffffffa01302f3>] ? cm_req_handler+0x982/0x982 [ib_cm]
           [<ffffffff81042b6e>] process_one_work+0x2bd/0x4a6
           [<ffffffff81042ac1>] ? process_one_work+0x210/0x4a6
           [<ffffffff813669f3>] ? _raw_spin_unlock_irq+0x2b/0x40
           [<ffffffff8104316e>] worker_thread+0x1d6/0x350
           [<ffffffff81042f98>] ? rescuer_thread+0x241/0x241
           [<ffffffff81046a32>] kthread+0x84/0x8c
           [<ffffffff8136e854>] kernel_thread_helper+0x4/0x10
           [<ffffffff81366d59>] ? retint_restore_args+0xe/0xe
           [<ffffffff810469ae>] ? __init_kthread_worker+0x56/0x56
           [<ffffffff8136e850>] ? gs_change+0xb/0xb
      
      The actual locking is fine, since we're dealing with different locks,
      but from the same lock class.  cma_disable_callback() acquires the
      listening id mutex, whereas rdma_destroy_id() acquires the mutex for
      the new connection id.  To fix this, delay the call to
      rdma_destroy_id() until we've released the listening id mutex.
      Signed-off-by: NSean Hefty <sean.hefty@intel.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      b6cec8aa
  12. 05 4月, 2012 1 次提交
  13. 05 1月, 2012 1 次提交
    • S
      RDMA/cma: Fix endianness bugs · 46ea5061
      Sean Hefty 提交于
      Fix endianness bugs reported by sparse in the RDMA core stack.  Note
      that these are real bugs, but don't affect any existing code to the
      best of my knowledge.  The mlid issue would only affect kernel users
      of rdma_join_multicast which have the rdma_cm attach/detach its QP.
      There are no current in tree users that do this. (rdma_join_multicast
      may be used called by user space applications, which does not have
      this issue.)  And the pkey setting is simply returned as
      informational.
      Signed-off-by: NSean Hefty <sean.hefty@intel.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      46ea5061
  14. 20 12月, 2011 1 次提交
  15. 23 11月, 2011 1 次提交
  16. 01 11月, 2011 1 次提交
  17. 14 10月, 2011 2 次提交
  18. 07 10月, 2011 3 次提交
  19. 19 7月, 2011 2 次提交
  20. 26 5月, 2011 4 次提交
    • N
      RDMA/cma: Save PID of ID's owner · 83e9502d
      Nir Muchtar 提交于
      Save the PID associated with an RDMA CM ID for reporting via netlink.
      Signed-off-by: NNir Muchtar <nirm@voltaire.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      83e9502d
    • N
      RDMA/cma: Add support for netlink statistics export · 753f618a
      Nir Muchtar 提交于
      Add callbacks and data types for statistics export of all current
      devices/ids.  The schema for RDMA CM is a series of netlink messages.
      Each one contains an rdma_cm_stat struct.  Additionally, two netlink
      attributes are created for the addresses for each message (if
      applicable).
      
      Their types used are:
      RDMA_NL_RDMA_CM_ATTR_SRC_ADDR (The source address for this ID)
      RDMA_NL_RDMA_CM_ATTR_DST_ADDR (The destination address for this ID)
      sockaddr_* structs are encapsulated within these attributes.
      
      In other words, every transaction contains a series of messages like:
      
      -------message 1-------
      struct rdma_cm_id_stats {
             __u32 qp_num;
             __u32 bound_dev_if;
             __u32 port_space;
             __s32 pid;
             __u8 cm_state;
             __u8 node_type;
             __u8 port_num;
             __u8 reserved;
      }
      RDMA_NL_RDMA_CM_ATTR_SRC_ADDR attribute - contains the source address
      RDMA_NL_RDMA_CM_ATTR_DST_ADDR attribute - contains the destination address
      -------end 1-------
      -------message 2-------
      struct rdma_cm_id_stats
      RDMA_NL_RDMA_CM_ATTR_SRC_ADDR attribute
      RDMA_NL_RDMA_CM_ATTR_DST_ADDR attribute
      -------end 2-------
      Signed-off-by: NNir Muchtar <nirm@voltaire.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      753f618a
    • S
      RDMA/cma: Pass QP type into rdma_create_id() · b26f9b99
      Sean Hefty 提交于
      The RDMA CM currently infers the QP type from the port space selected
      by the user.  In the future (eg with RDMA_PS_IB or XRC), there may not
      be a 1-1 correspondence between port space and QP type.  For netlink
      export of RDMA CM state, we want to export the QP type to userspace,
      so it is cleaner to explicitly associate a QP type to an ID.
      
      Modify rdma_create_id() to allow the user to specify the QP type, and
      use it to make our selections of datagram versus connected mode.
      Signed-off-by: NSean Hefty <sean.hefty@intel.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      b26f9b99
    • N
      RDMA/cma: Export enum cma_state in <rdma/rdma_cm.h> · 550e5ca7
      Nir Muchtar 提交于
      Move cma.c's internal definition of enum cma_state to enum rdma_cm_state
      in an exported header so that it can be exported via RDMA netlink.
      Signed-off-by: NNir Muchtar <nirm@voltaire.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      550e5ca7
  21. 10 5月, 2011 2 次提交
    • H
      RDMA/cma: Add an ID_REUSEADDR option · a9bb7912
      Hefty, Sean 提交于
      Lustre requires that clients bind to a privileged port number before
      connecting to a remote server.  On larger clusters (typically more
      than about 1000 nodes), the number of privileged ports is exhausted,
      resulting in lustre being unusable.
      
      To handle this, we add support for reusable addresses to the rdma_cm.
      This mimics the behavior of the socket option SO_REUSEADDR.  A user
      may set an rdma_cm_id to reuse an address before calling
      rdma_bind_addr() (explicitly or implicitly).  If set, other
      rdma_cm_id's may be bound to the same address, provided that they all
      have reuse enabled, and there are no active listens.
      
      If rdma_listen() is called on an rdma_cm_id that has reuse enabled, it
      will only succeed if there are no other id's bound to that same
      address.  The reuse option is exported to user space.  The behavior of
      the kernel reuse implementation was verified against that given by
      sockets.
      
      This patch is derived from a path by Ira Weiny <weiny2@llnl.gov>
      Signed-off-by: NSean Hefty <sean.hefty@intel.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      a9bb7912
    • H
      RDMA/cma: Fix handling of IPv6 addressing in cma_use_port · 43b752da
      Hefty, Sean 提交于
      cma_use_port() assumes that the sockaddr is an IPv4 address.  Since
      IPv6 addressing is supported (and also to support other address
      families) make the code more generic in its address handling.
      Signed-off-by: NSean Hefty <sean.hefty@intel.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      43b752da
  22. 16 3月, 2011 2 次提交
    • S
      RDMA/cma: Replace global lock in rdma_destroy_id() with id-specific one · a396d43a
      Sean Hefty 提交于
      rdma_destroy_id currently uses the global rdma cm 'lock' to test if an
      rdma_cm_id has been bound to a device.  This prevents an active
      address resolution callback handler from assigning a device to the
      rdma_cm_id after rdma_destroy_id checks for one.
      
      Instead, we can replace the use of the global lock around the check to
      the rdma_cm_id device pointer by setting the id state to destroying,
      then flushing all active callbacks.  The latter is accomplished by
      acquiring and releasing the handler_mutex.  Any active handler will
      complete first, and any newly scheduled handlers will find the
      rdma_cm_id in an invalid state.
      
      In addition to optimizing the current locking scheme, the use of the
      rdma_cm_id mutex is a more intuitive synchronization mechanism than
      that of the global lock.  These changes are based on feedback from
      Doug Ledford <dledford@redhat.com> while he was trying to debug a
      crash in the rdma cm destroy path.
      Signed-off-by: NSean Hefty <sean.hefty@intel.com>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      a396d43a
    • S
      RDMA/cma: Fix crash in request handlers · 25ae21a1
      Sean Hefty 提交于
      Doug Ledford and Red Hat reported a crash when running the rdma_cm on
      a real-time OS.  The crash has the following call trace:
      
          cm_process_work
             cma_req_handler
                cma_disable_callback
                rdma_create_id
                   kzalloc
                   init_completion
                cma_get_net_info
                cma_save_net_info
                cma_any_addr
                   cma_zero_addr
                rdma_translate_ip
                   rdma_copy_addr
                cma_acquire_dev
                   rdma_addr_get_sgid
                   ib_find_cached_gid
                   cma_attach_to_dev
                ucma_event_handler
                   kzalloc
                   ib_copy_ah_attr_to_user
                cma_comp
      
      [ preempted ]
      
          cma_write
              copy_from_user
              ucma_destroy_id
                 copy_from_user
                 _ucma_find_context
                 ucma_put_ctx
                 ucma_free_ctx
                    rdma_destroy_id
                       cma_exch
                       cma_cancel_operation
                       rdma_node_get_transport
      
              rt_mutex_slowunlock
              bad_area_nosemaphore
              oops_enter
      
      They were able to reproduce the crash multiple times with the
      following details:
      
          Crash seems to always happen on the:
                  mutex_unlock(&conn_id->handler_mutex);
          as conn_id looks to have been freed during this code path.
      
      An examination of the code shows that a race exists in the request
      handlers.  When a new connection request is received, the rdma_cm
      allocates a new connection identifier.  This identifier has a single
      reference count on it.  If a user calls rdma_destroy_id() from another
      thread after receiving a callback, rdma_destroy_id will proceed to
      destroy the id and free the associated memory.  However, the request
      handlers may still be in the process of running.  When control returns
      to the request handlers, they can attempt to access the newly created
      identifiers.
      
      Fix this by holding a reference on the newly created rdma_cm_id until
      the request handler is through accessing it.
      Signed-off-by: NSean Hefty <sean.hefty@intel.com>
      Acked-by: NDoug Ledford <dledford@redhat.com>
      Cc: <stable@kernel.org>
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      25ae21a1