16 Jul, 2016

1 commit


06 Jul, 2016

5 commits

  • Move to using RCU access to a peer's service connection tree when routing
    an incoming packet. This is done using a seqlock to trigger retrying of
    the tree walk if a change happened.

    Further, we no longer get a ref on the connection looked up in the
    data_ready handler unless we queue the connection's work item - and then
    only if the refcount > 0.

    Note that I'm avoiding the use of a hash table for service connections
    because each service connection is addressed by a 62-bit number
    (constructed from epoch and connection ID >> 2) that would allow the client
    to engage in bucket stuffing, given knowledge of the hash algorithm.
    Peers, however, are hashed as the network address is less controllable by
    the client. The total number of peers will also be limited in a future
    commit.

    Signed-off-by: David Howells

    David Howells
     
  • Prune the contents of the rxrpc_conn_proto struct. Most of the fields aren't
    used anymore.

    Signed-off-by: David Howells

    David Howells
     
  • Overhaul the usage count accounting for the rxrpc_connection struct to make
    it easier to implement RCU access from the data_ready handler.

    The problem is that currently we're using a lock to prevent the garbage
    collector from trying to clean up a connection that we're contemplating
    unidling. We could just stick incoming packets on the connection we find,
    but we've then got a problem that we may race when dispatching a work item
    to process it as we need to give that a ref to prevent the rxrpc_connection
    struct from disappearing in the meantime.

    Further, incoming packets may get discarded if attached to an
    rxrpc_connection struct that is going away. Whilst this is not a total
    disaster - the client will presumably resend - it would delay processing of
    the call. This would affect the AFS client filesystem's service manager
    operation.

    To this end:

    (1) We now maintain an extra count on the connection usage count whilst it
    is on the connection list. This mean it is not in use when its
    refcount is 1.

    (2) When trying to reuse an old connection, we only increment the refcount
    if it is greater than 0. If it is 0, we replace it in the tree with a
    new candidate connection.

    (3) Two connection flags are added to indicate whether or not a connection
    is in the local's client connection tree (used by sendmsg) or the
    peer's service connection tree (used by data_ready). This makes sure
    that we don't try and remove a connection if it got replaced.

    The flags are tested under lock with the removal operation to prevent
    the reaper from killing the rxrpc_connection struct whilst someone
    else is trying to effect a replacement.

    This could probably be alleviated by using memory barriers between the
    flag set/test and the rb_tree ops. The rb_tree op would still need to
    be under the lock, however.

    (4) When trying to reap an old connection, we try to flip the usage count
    from 1 to 0. If it's not 1 at that point, then it must've come back
    to life temporarily and we ignore it.

    Signed-off-by: David Howells

    David Howells
     
  • Move the lookup of a peer from a call that's being accepted into the
    function that creates a new incoming connection. This will allow us to
    avoid incrementing the peer's usage count in some cases in future.

    Note that I haven't bother to integrate rxrpc_get_addr_from_skb() with
    rxrpc_extract_addr_from_skb() as I'm going to delete the former in the very
    near future.

    Signed-off-by: David Howells

    David Howells
     
  • Split the service-specific connection code out into into its own file. The
    client-specific code has already been split out. This will leave just the
    common code in the original file.

    Signed-off-by: David Howells

    David Howells