1. 24 8月, 2014 11 次提交
    • J
      tipc: replace port pointer with socket pointer in registry · 9b50fd08
      Jon Paul Maloy 提交于
      In order to make tipc_sock the only entity referencable from other
      parts of the stack, we add a tipc_sock pointer instead of a tipc_port
      pointer to the registry. As a consequence, we also let the function
      tipc_port_lock() return a pointer to a tipc_sock instead  of a tipc_port.
      We keep the function's name for now, since the lock still is owned by
      the port.
      
      This is another step in the direction of eliminating port_lock, replacing
      its usage with lock_sock() and bh_lock_sock().
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Reviewed-by: NErik Hugne <erik.hugne@ericsson.com>
      Reviewed-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9b50fd08
    • J
      tipc: use registry when scanning sockets · 5a9ee0be
      Jon Paul Maloy 提交于
      The functions tipc_port_get_ports() and tipc_port_reinit() scan over
      all sockets/ports to access each of them. This is done by using a
      dedicated linked list, 'tipc_socks' where all sockets are members. The
      list is in turn protected by a spinlock, 'port_list_lock', while each
      socket is locked by using port_lock at the moment of access.
      
      In order to reduce complexity and risk of deadlock, we want to get
      rid of the linked list and the accompanying spinlock.
      
      This is what we do in this commit. Instead of the linked list, we use
      the port registry to scan across the sockets. We also add usage of
      bh_lock_sock() inside the scope of port_lock in both functions, as a
      preparation for the complete removal of port_lock.
      
      Finally, we move the functions from port.c to socket.c, and rename them
      to tipc_sk_sock_show() and tipc_sk_reinit() repectively.
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Reviewed-by: NErik Hugne <erik.hugne@ericsson.com>
      Reviewed-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5a9ee0be
    • J
      tipc: eliminate functions tipc_port_init and tipc_port_destroy · 5b8fa7ce
      Jon Paul Maloy 提交于
      After the latest changes to the socket/port layer the existence of
      the functions tipc_port_init() and tipc_port_destroy() cannot be
      justified. They are both called only once, from tipc_sk_create() and
      tipc_sk_delete() respectively, and their functionality can better be
      merged into the latter two functions.
      
      This also entails that all remaining references to port_lock now are
      made from inside socket.c, something that will make it easier to remove
      this lock.
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Reviewed-by: NErik Hugne <erik.hugne@ericsson.com>
      Reviewed-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5b8fa7ce
    • J
      tipc: redefine message acknowledge function · 739f5e4e
      Jon Paul Maloy 提交于
      The function tipc_acknowledge() is a remnant from the obsolete native
      API. Currently, it grabs port_lock, before building an acknowledge
      message and sending it to the peer.
      
      Since all access to socket members now is protected by the socket lock,
      it has become unnecessary to grab port_lock here.
      
      In this commit, we remove the usage of port_lock, simplify the
      function, and move it to socket.c, renaming it to tipc_sk_send_ack().
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Reviewed-by: NErik Hugne <erik.hugne@ericsson.com>
      Reviewed-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      739f5e4e
    • J
      tipc: eliminate port_connect()/port_disconnect() functions · dadebc00
      Jon Paul Maloy 提交于
      tipc_port_connect()/tipc_port_disconnect() are remnants of the obsolete
      native API. Their only task is to grab port_lock and call the functions
      __tipc_port_connect()/__tipc_port_disconnect() respectively, which will
      perform the actual state change.
      
      Since socket/port exection now is single-threaded the use of port_lock
      is not needed any more, so we can safely replace the two functions with
      their lock-free counterparts.
      
      In this commit, we remove the two functions. Furthermore, the contents
      of __tipc_port_disconnect() is so trivial that we choose to eliminate
      that function too, expanding its functionality into tipc_shutdown().
      __tipc_port_connect() is simplified, moved to socket.c, and given the
      more correct name tipc_sk_finish_conn(). Finally, we eliminate the
      function auto_connect(), and expand its contents into filter_connect().
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Reviewed-by: NErik Hugne <erik.hugne@ericsson.com>
      Reviewed-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      dadebc00
    • J
      tipc: eliminate function tipc_port_shutdown() · 80e44c22
      Jon Paul Maloy 提交于
      tipc_port_shutdown() is a remnant from the now obsolete native
      interface. As such it grabs port_lock in order to protect itself
      from concurrent BH processing.
      
      However, after the recent changes to the port/socket upcalls, sockets
      are now basically single-threaded, and all execution, except the read-only
      tipc_sk_timer(), is executing within the protection of lock_sock(). So
      the use of port_lock is not needed here.
      
      In this commit we eliminate the whole function, and merge it into its
      only caller, tipc_shutdown().
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Reviewed-by: NErik Hugne <erik.hugne@ericsson.com>
      Reviewed-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      80e44c22
    • J
      tipc: clean up socket timer function · 57289015
      Jon Paul Maloy 提交于
      The last remaining BH upcall to the socket, apart for the message
      reception function tipc_sk_rcv(), is the timer function.
      
      We prefer to let this function continue executing in BH, since it only
      does read-acces to semi-permanent data, but we make three changes to it:
      
      1) We introduce a bh_lock_sock()/bh_unlock_sock() inside the scope
         of port_lock.  This is a preparation for replacing port_lock with
         bh_lock_sock() at the locations where it is still used.
      
      2) We move the function from port.c to socket.c, as a further step
         of eliminating the port code level altogether.
      
      3) We let it make use of the newly introduced tipc_msg_create()
         function. This enables us to get rid of three context specific
         functions (port_create_self_abort_msg() etc.) in port.c
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Reviewed-by: NErik Hugne <erik.hugne@ericsson.com>
      Reviewed-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      57289015
    • J
      tipc: use message to abort connections when losing contact to node · 02be61a9
      Jon Paul Maloy 提交于
      In the current implementation, each 'struct tipc_node' instance keeps
      a linked list of those ports/sockets that are connected to the node
      represented by that struct. The purpose of this is to let the node
      object know which sockets to alert when it loses contact with its peer
      node, i.e., which sockets need to have their connections aborted.
      
      This entails an unwanted direct reference from the node structure
      back to the port/socket structure, and a need to grab port_lock
      when we have to make an upcall to the port. We want to get rid of
      this unecessary BH entry point into the socket, and also eliminate
      its use of port_lock.
      
      In this commit, we instead let the node struct keep list of "connected
      socket" structs, which each represents a connected socket, but is
      allocated independently by the node at the moment of connection. If
      the node loses contact with its peer node, the list is traversed, and
      a "connection abort" message is created for each entry in the list. The
      message is sent to it respective connected socket using the ordinary
      data path, and the receiving socket aborts its connections upon reception
      of the message.
      
      This enables us to get rid of the direct reference from 'struct node' to
      ´struct port', and another unwanted BH access point to the latter.
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Reviewed-by: NErik Hugne <erik.hugne@ericsson.com>
      Reviewed-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      02be61a9
    • J
      tipc: use pseudo message to wake up sockets after link congestion · 50100a5e
      Jon Paul Maloy 提交于
      The current link implementation keeps a linked list of blocked ports/
      sockets that is populated when there is link congestion. The purpose
      of this is to let the link know which users to wake up when the
      congestion abates.
      
      This adds unnecessary complexity to the data structure and the code,
      since it forces us to involve the link each time we want to delete
      a socket. It also forces us to grab the spinlock port_lock within
      the scope of node_lock. We want to get rid of this direct dependence,
      as well as the deadlock hazard resulting from the usage of port_lock.
      
      In this commit, we instead let the link keep list of a "wakeup" pseudo
      messages for use in such situations. Those messages are sent to the
      pending sockets via the ordinary message reception path, and wake up
      the socket's owner when they are received.
      
      This enables us to get rid of the 'waiting_ports' linked lists in struct
      tipc_port that manifest this direct reference. As a consequence, we can
      eliminate another BH entry into the socket, and hence the need to grab
      port_lock. This is a further step in our effort to remove port_lock
      altogether.
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Reviewed-by: NErik Hugne <erik.hugne@ericsson.com>
      Reviewed-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      50100a5e
    • J
      tipc: introduce new function tipc_msg_create() · 1dd0bd2b
      Jon Paul Maloy 提交于
      The function tipc_msg_init() has turned out to be of limited value
      in many cases. It take too few parameters to be usable for creating
      a complete message, it makes too many assumptions about what the
      message should be used for, and it does not allocate any buffer to
      be returned to the caller.
      
      Therefore, we now introduce the new function tipc_msg_create(), which
      takes all the parameters needed to create a full message, and returns
      a buffer of the requested size. The new function will be very useful
      for the changes we will be doing in later commits in this series.
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Reviewed-by: NErik Hugne <erik.hugne@ericsson.com>
      Reviewed-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1dd0bd2b
    • D
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net · f9474ddf
      David S. Miller 提交于
      Pulling to get some TIPC fixes that a net-next series depends
      upon.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f9474ddf
  2. 23 8月, 2014 29 次提交