1. 06 8月, 2016 1 次提交
    • D
      rxrpc: Fix races between skb free, ACK generation and replying · 372ee163
      David Howells 提交于
      Inside the kafs filesystem it is possible to occasionally have a call
      processed and terminated before we've had a chance to check whether we need
      to clean up the rx queue for that call because afs_send_simple_reply() ends
      the call when it is done, but this is done in a workqueue item that might
      happen to run to completion before afs_deliver_to_call() completes.
      
      Further, it is possible for rxrpc_kernel_send_data() to be called to send a
      reply before the last request-phase data skb is released.  The rxrpc skb
      destructor is where the ACK processing is done and the call state is
      advanced upon release of the last skb.  ACK generation is also deferred to
      a work item because it's possible that the skb destructor is not called in
      a context where kernel_sendmsg() can be invoked.
      
      To this end, the following changes are made:
      
       (1) kernel_rxrpc_data_consumed() is added.  This should be called whenever
           an skb is emptied so as to crank the ACK and call states.  This does
           not release the skb, however.  kernel_rxrpc_free_skb() must now be
           called to achieve that.  These together replace
           rxrpc_kernel_data_delivered().
      
       (2) kernel_rxrpc_data_consumed() is wrapped by afs_data_consumed().
      
           This makes afs_deliver_to_call() easier to work as the skb can simply
           be discarded unconditionally here without trying to work out what the
           return value of the ->deliver() function means.
      
           The ->deliver() functions can, via afs_data_complete(),
           afs_transfer_reply() and afs_extract_data() mark that an skb has been
           consumed (thereby cranking the state) without the need to
           conditionally free the skb to make sure the state is correct on an
           incoming call for when the call processor tries to send the reply.
      
       (3) rxrpc_recvmsg() now has to call kernel_rxrpc_data_consumed() when it
           has finished with a packet and MSG_PEEK isn't set.
      
       (4) rxrpc_packet_destructor() no longer calls rxrpc_hard_ACK_data().
      
           Because of this, we no longer need to clear the destructor and put the
           call before we free the skb in cases where we don't want the ACK/call
           state to be cranked.
      
       (5) The ->deliver() call-type callbacks are made to return -EAGAIN rather
           than 0 if they expect more data (afs_extract_data() returns -EAGAIN to
           the delivery function already), and the caller is now responsible for
           producing an abort if that was the last packet.
      
       (6) There are many bits of unmarshalling code where:
      
       		ret = afs_extract_data(call, skb, last, ...);
      		switch (ret) {
      		case 0:		break;
      		case -EAGAIN:	return 0;
      		default:	return ret;
      		}
      
           is to be found.  As -EAGAIN can now be passed back to the caller, we
           now just return if ret < 0:
      
       		ret = afs_extract_data(call, skb, last, ...);
      		if (ret < 0)
      			return ret;
      
       (7) Checks for trailing data and empty final data packets has been
           consolidated as afs_data_complete().  So:
      
      		if (skb->len > 0)
      			return -EBADMSG;
      		if (!last)
      			return 0;
      
           becomes:
      
      		ret = afs_data_complete(call, skb, last);
      		if (ret < 0)
      			return ret;
      
       (8) afs_transfer_reply() now checks the amount of data it has against the
           amount of data desired and the amount of data in the skb and returns
           an error to induce an abort if we don't get exactly what we want.
      
      Without these changes, the following oops can occasionally be observed,
      particularly if some printks are inserted into the delivery path:
      
      general protection fault: 0000 [#1] SMP
      Modules linked in: kafs(E) af_rxrpc(E) [last unloaded: af_rxrpc]
      CPU: 0 PID: 1305 Comm: kworker/u8:3 Tainted: G            E   4.7.0-fsdevel+ #1303
      Hardware name: ASUS All Series/H97-PLUS, BIOS 2306 10/09/2014
      Workqueue: kafsd afs_async_workfn [kafs]
      task: ffff88040be041c0 ti: ffff88040c070000 task.ti: ffff88040c070000
      RIP: 0010:[<ffffffff8108fd3c>]  [<ffffffff8108fd3c>] __lock_acquire+0xcf/0x15a1
      RSP: 0018:ffff88040c073bc0  EFLAGS: 00010002
      RAX: 6b6b6b6b6b6b6b6b RBX: 0000000000000000 RCX: ffff88040d29a710
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88040d29a710
      RBP: ffff88040c073c70 R08: 0000000000000001 R09: 0000000000000001
      R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
      R13: 0000000000000000 R14: ffff88040be041c0 R15: ffffffff814c928f
      FS:  0000000000000000(0000) GS:ffff88041fa00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007fa4595f4750 CR3: 0000000001c14000 CR4: 00000000001406f0
      Stack:
       0000000000000006 000000000be04930 0000000000000000 ffff880400000000
       ffff880400000000 ffffffff8108f847 ffff88040be041c0 ffffffff81050446
       ffff8803fc08a920 ffff8803fc08a958 ffff88040be041c0 ffff88040c073c38
      Call Trace:
       [<ffffffff8108f847>] ? mark_held_locks+0x5e/0x74
       [<ffffffff81050446>] ? __local_bh_enable_ip+0x9b/0xa1
       [<ffffffff8108f9ca>] ? trace_hardirqs_on_caller+0x16d/0x189
       [<ffffffff810915f4>] lock_acquire+0x122/0x1b6
       [<ffffffff810915f4>] ? lock_acquire+0x122/0x1b6
       [<ffffffff814c928f>] ? skb_dequeue+0x18/0x61
       [<ffffffff81609dbf>] _raw_spin_lock_irqsave+0x35/0x49
       [<ffffffff814c928f>] ? skb_dequeue+0x18/0x61
       [<ffffffff814c928f>] skb_dequeue+0x18/0x61
       [<ffffffffa009aa92>] afs_deliver_to_call+0x344/0x39d [kafs]
       [<ffffffffa009ab37>] afs_process_async_call+0x4c/0xd5 [kafs]
       [<ffffffffa0099e9c>] afs_async_workfn+0xe/0x10 [kafs]
       [<ffffffff81063a3a>] process_one_work+0x29d/0x57c
       [<ffffffff81064ac2>] worker_thread+0x24a/0x385
       [<ffffffff81064878>] ? rescuer_thread+0x2d0/0x2d0
       [<ffffffff810696f5>] kthread+0xf3/0xfb
       [<ffffffff8160a6ff>] ret_from_fork+0x1f/0x40
       [<ffffffff81069602>] ? kthread_create_on_node+0x1cf/0x1cf
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      372ee163
  2. 06 7月, 2016 2 次提交
    • D
      rxrpc: Access socket accept queue under right lock · 30b515f4
      David Howells 提交于
      The socket's accept queue (socket->acceptq) should be accessed under
      socket->call_lock, not under the connection lock.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      30b515f4
    • D
      rxrpc: Release a call's connection ref on call disconnection · e653cfe4
      David Howells 提交于
      When a call is disconnected, clear the call's pointer to the connection and
      release the associated ref on that connection.  This means that the call no
      longer pins the connection and the connection can be discarded even before
      the call is.
      
      As the code currently stands, the call struct is effectively pinned by
      userspace until userspace has enacted a recvmsg() to retrieve the final
      call state as sk_buffs on the receive queue pin the call to which they're
      related because:
      
       (1) The rxrpc_call struct contains the userspace ID that recvmsg() has to
           include in the control message buffer to indicate which call is being
           referred to.  This ID must remain valid until the terminal packet is
           completely read and must be invalidated immediately at that point as
           userspace is entitled to immediately reuse it.
      
       (2) The final ACK to the reply to a client call isn't sent until the last
           data packet is entirely read (it's probably worth altering this in
           future to be send the ACK as soon as all the data has been received).
      
      
      This change requires a bit of rearrangement to make sure that the call
      isn't going to try and access the connection again after protocol
      completion:
      
       (1) Delete the error link earlier when we're releasing the call.  Possibly
           network errors should be distributed via connections at the cost of
           adding in an access to the rxrpc_connection struct.
      
       (2) Remove the call from the connection's call tree before disconnecting
           the call.  The call tree needs to be removed anyway and incoming
           packets delivered by channel pointer instead.
      
       (3) The release call event should be considered last after all other
           events have been processed so that we don't need access to the
           connection again.
      
       (4) Move the channel_lock taking from rxrpc_release_call() to
           rxrpc_disconnect_call() where it will be required in future.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      e653cfe4
  3. 22 6月, 2016 3 次提交
  4. 15 6月, 2016 1 次提交
    • D
      rxrpc: Use the peer record to distribute network errors · f66d7490
      David Howells 提交于
      Use the peer record to distribute network errors rather than the transport
      object (which I want to get rid of).  An error from a particular peer
      terminates all calls on that peer.
      
      For future consideration:
      
       (1) For ICMP-induced errors it might be worth trying to extract the RxRPC
           header from the offending packet, if one is returned attached to the
           ICMP packet, to better direct the error.
      
           This may be overkill, though, since an ICMP packet would be expected
           to be relating to the destination port, machine or network.  RxRPC
           ABORT and BUSY packets give notice at RxRPC level.
      
       (2) To also abort connection-level communications (such as CHALLENGE
           packets) where indicted by an error - but that requires some revamping
           of the connection event handling first.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      f66d7490
  5. 13 6月, 2016 1 次提交
    • D
      rxrpc: Rename files matching ar-*.c to git rid of the "ar-" prefix · 8c3e34a4
      David Howells 提交于
      Rename files matching net/rxrpc/ar-*.c to get rid of the "ar-" prefix.
      This will aid splitting those files by making easier to come up with new
      names.
      
      Note that the not all files are simply renamed from ar-X.c to X.c.  The
      following exceptions are made:
      
       (*) ar-call.c -> call_object.c
           ar-ack.c -> call_event.c
      
           call_object.c is going to contain the core of the call object
           handling.  Call event handling is all going to be in call_event.c.
      
       (*) ar-accept.c -> call_accept.c
      
           Incoming call handling is going to be here.
      
       (*) ar-connection.c -> conn_object.c
           ar-connevent.c -> conn_event.c
      
           The former file is going to have the basic connection object handling,
           but there will likely be some differentiation between client
           connections and service connections in additional files later.  The
           latter file will have all the connection-level event handling.
      
       (*) ar-local.c -> local_object.c
      
           This will have the local endpoint object handling code.  The local
           endpoint event handling code will later be split out into
           local_event.c.
      
       (*) ar-peer.c -> peer_object.c
      
           This will have the peer endpoint object handling code.  Peer event
           handling code will be placed in peer_event.c (for the moment, there is
           none).
      
       (*) ar-error.c -> peer_event.c
      
           This will become the peer event handling code, though for the moment
           it's actually driven from the local endpoint's perspective.
      
      Note that I haven't renamed ar-transport.c to transport_object.c as the
      intention is to delete it when the rxrpc_transport struct is excised.
      
      The only file that actually has its contents changed is net/rxrpc/Makefile.
      
      net/rxrpc/ar-internal.h will need its section marker comments updating, but
      I'll do that in a separate patch to make it easier for git to follow the
      history across the rename.  I may also want to rename ar-internal.h at some
      point - but that would mean updating all the #includes and I'd rather do
      that in a separate step.
      
      Signed-off-by: David Howells <dhowells@redhat.com.
      8c3e34a4
  6. 04 6月, 2016 1 次提交
    • J
      rxrpc: Use pr_<level> and pr_fmt, reduce object size a few KB · 9b6d5398
      Joe Perches 提交于
      Use the more common kernel logging style and reduce object size.
      
      The logging message prefix changes from a mixture of
      "RxRPC:" and "RXRPC:" to "af_rxrpc: ".
      
      $ size net/rxrpc/built-in.o*
         text	   data	    bss	    dec	    hex	filename
        64172	   1972	   8304	  74448	  122d0	net/rxrpc/built-in.o.new
        67512	   1972	   8304	  77788	  12fdc	net/rxrpc/built-in.o.old
      
      Miscellanea:
      
      o Consolidate the ASSERT macros to use a single pr_err call with
        decimal and hexadecimal output and a stringified #OP argument
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9b6d5398
  7. 12 4月, 2016 5 次提交
  8. 14 3月, 2016 1 次提交
  9. 04 3月, 2016 3 次提交
    • D
      rxrpc: Keep the skb private record of the Rx header in host byte order · 0d12f8a4
      David Howells 提交于
      Currently, a copy of the Rx packet header is copied into the the sk_buff
      private data so that we can advance the pointer into the buffer,
      potentially discarding the original.  At the moment, this copy is held in
      network byte order, but this means we're doing a lot of unnecessary
      translations.
      
      The reasons it was done this way are that we need the values in network
      byte order occasionally and we can use the copy, slightly modified, as part
      of an iov array when sending an ack or an abort packet.
      
      However, it seems more reasonable on review that it would be better kept in
      host byte order and that we make up a new header when we want to send
      another packet.
      
      To this end, rename the original header struct to rxrpc_wire_header (with
      BE fields) and institute a variant called rxrpc_host_header that has host
      order fields.  Change the struct in the sk_buff private data into an
      rxrpc_host_header and translate the values when filling it in.
      
      This further allows us to keep values kept in various structures in host
      byte order rather than network byte order and allows removal of some fields
      that are byteswapped duplicates.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      0d12f8a4
    • D
      rxrpc: Rename call events to begin RXRPC_CALL_EV_ · 4c198ad1
      David Howells 提交于
      Rename call event names to begin RXRPC_CALL_EV_ to distinguish them from the
      flags.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      4c198ad1
    • D
      rxrpc: Convert call flag and event numbers into enums · 5b8848d1
      David Howells 提交于
      Convert call flag and event numbers into enums and move their definitions
      outside of the struct.
      
      Also move the call state enum outside of the struct and add an extra
      element to count the number of states.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      5b8848d1
  10. 25 11月, 2015 1 次提交
    • D
      rxrpc: Correctly handle ack at end of client call transmit phase · 33c40e24
      David Howells 提交于
      Normally, the transmit phase of a client call is implicitly ack'd by the
      reception of the first data packet of the response being received.
      However, if a security negotiation happens, the transmit phase, if it is
      entirely contained in a single packet, may get an ack packet in response
      and then may get aborted due to security negotiation failure.
      
      Because the client has shifted state to RXRPC_CALL_CLIENT_AWAIT_REPLY due
      to having transmitted all the data, the code that handles processing of the
      received ack packet doesn't note the hard ack the data packet.
      
      The following abort packet in the case of security negotiation failure then
      incurs an assertion failure when it tries to drain the Tx queue because the
      hard ack state is out of sync (hard ack means the packets have been
      processed and can be discarded by the sender; a soft ack means that the
      packets are received but could still be discarded and rerequested by the
      receiver).
      
      To fix this, we should record the hard ack we received for the ack packet.
      
      The assertion failure looks like:
      
      	RxRPC: Assertion failed
      	1 <= 0 is false
      	0x1 <= 0x0 is false
      	------------[ cut here ]------------
      	kernel BUG at ../net/rxrpc/ar-ack.c:431!
      	...
      	RIP: 0010:[<ffffffffa006857b>]  [<ffffffffa006857b>] rxrpc_rotate_tx_window+0xbc/0x131 [af_rxrpc]
      	...
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      33c40e24
  11. 02 3月, 2015 2 次提交
  12. 27 2月, 2014 3 次提交
    • D
      af_rxrpc: Expose more RxRPC parameters via sysctls · 817913d8
      David Howells 提交于
      Expose RxRPC parameters via sysctls to control the Rx window size, the Rx MTU
      maximum size and the number of packets that can be glued into a jumbo packet.
      
      More info added to Documentation/networking/rxrpc.txt.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      817913d8
    • D
      af_rxrpc: Improve ACK production · 9823f39a
      David Howells 提交于
      Improve ACK production by the following means:
      
       (1) Don't send an ACK_REQUESTED ack immediately even if the RXRPC_MORE_PACKETS
           flag isn't set on a data packet that has also has RXRPC_REQUEST_ACK set.
      
           MORE_PACKETS just means that the sender just emptied its Tx data buffer.
           More data will be forthcoming unless RXRPC_LAST_PACKET is also flagged.
      
           It is possible to see runs of DATA packets with MORE_PACKETS unset that
           aren't waiting for an ACK.
      
           It is therefore better to wait a small instant to see if we can combine an
           ACK for several packets.
      
       (2) Don't send an ACK_IDLE ack immediately unless we're responding to the
           terminal data packet of a call.
      
           Whilst sending an ACK_IDLE mid-call serves to let the other side know
           that we won't be asking it to resend certain Tx buffers and that it can
           discard them, spamming it with loads of acks just because we've
           temporarily run out of data just distracts it.
      
       (3) Put the ACK_IDLE ack generation timeout up to half a second rather than a
           single jiffy.  Just because we haven't been given more data immediately
           doesn't mean that more isn't forthcoming.  The other side may be busily
           finding the data to send to us.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      9823f39a
    • D
      af_rxrpc: Add sysctls for configuring RxRPC parameters · 5873c083
      David Howells 提交于
      Add sysctls for configuring RxRPC protocol handling, specifically controls on
      delays before ack generation, the delay before resending a packet, the maximum
      lifetime of a call and the expiration times of calls, connections and
      transports that haven't been recently used.
      
      More info added in Documentation/networking/rxrpc.txt.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      5873c083
  13. 22 1月, 2014 1 次提交
  14. 16 4月, 2012 1 次提交
  15. 20 12月, 2011 1 次提交
  16. 20 5月, 2011 1 次提交
  17. 05 8月, 2010 1 次提交
    • D
      RxRPC: Fix a potential deadlock between the call resend_timer and state_lock · 3b5bac2b
      David Howells 提交于
      RxRPC can potentially deadlock as rxrpc_resend_time_expired() wants to get
      call->state_lock so that it can alter the state of an RxRPC call.  However, its
      caller (call_timer_fn()) has an apparent lock on the timer struct.
      
      The problem is that rxrpc_resend_time_expired() isn't permitted to lock
      call->state_lock as this could cause a deadlock against rxrpc_send_abort() as
      that takes state_lock and then attempts to delete the resend timer by calling
      del_timer_sync().
      
      The deadlock can occur because del_timer_sync() will sit there forever waiting
      for rxrpc_resend_time_expired() to return, but the latter may then wait for
      call->state_lock, which rxrpc_send_abort() holds around del_timer_sync()...
      
      This leads to a warning appearing in the kernel log that looks something like
      the attached.
      
      It should be sufficient to simply dispense with the locks.  It doesn't matter
      if we set the resend timer expired event bit and queue the event processor
      whilst we're changing state to one where the resend timer is irrelevant as the
      event can just be ignored by the processor thereafter.
      
      =======================================================
      [ INFO: possible circular locking dependency detected ]
      2.6.35-rc3-cachefs+ #115
      -------------------------------------------------------
      swapper/0 is trying to acquire lock:
       (&call->state_lock){++--..}, at: [<ffffffffa00200d4>] rxrpc_resend_time_expired+0x56/0x96 [af_rxrpc]
      
      but task is already holding lock:
       (&call->resend_timer){+.-...}, at: [<ffffffff8103b675>] run_timer_softirq+0x182/0x2a5
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #1 (&call->resend_timer){+.-...}:
             [<ffffffff810560bc>] __lock_acquire+0x889/0x8fa
             [<ffffffff81056184>] lock_acquire+0x57/0x6d
             [<ffffffff8103bb9c>] del_timer_sync+0x3c/0x86
             [<ffffffffa002bb7a>] rxrpc_send_abort+0x50/0x97 [af_rxrpc]
             [<ffffffffa002bdd9>] rxrpc_kernel_abort_call+0xa1/0xdd [af_rxrpc]
             [<ffffffffa0061588>] afs_deliver_to_call+0x129/0x368 [kafs]
             [<ffffffffa006181b>] afs_process_async_call+0x54/0xff [kafs]
             [<ffffffff8104261d>] worker_thread+0x1ef/0x2e2
             [<ffffffff81045f47>] kthread+0x7a/0x82
             [<ffffffff81002cd4>] kernel_thread_helper+0x4/0x10
      
      -> #0 (&call->state_lock){++--..}:
             [<ffffffff81055237>] validate_chain+0x727/0xd23
             [<ffffffff810560bc>] __lock_acquire+0x889/0x8fa
             [<ffffffff81056184>] lock_acquire+0x57/0x6d
             [<ffffffff813e6b69>] _raw_read_lock_bh+0x34/0x43
             [<ffffffffa00200d4>] rxrpc_resend_time_expired+0x56/0x96 [af_rxrpc]
             [<ffffffff8103b6e6>] run_timer_softirq+0x1f3/0x2a5
             [<ffffffff81036828>] __do_softirq+0xa2/0x13e
             [<ffffffff81002dcc>] call_softirq+0x1c/0x28
             [<ffffffff810049f0>] do_softirq+0x38/0x80
             [<ffffffff810361a2>] irq_exit+0x45/0x47
             [<ffffffff81018fb3>] smp_apic_timer_interrupt+0x88/0x96
             [<ffffffff81002893>] apic_timer_interrupt+0x13/0x20
             [<ffffffff810011ac>] cpu_idle+0x4d/0x83
             [<ffffffff813e06f3>] start_secondary+0x1bd/0x1c1
      
      other info that might help us debug this:
      
      1 lock held by swapper/0:
       #0:  (&call->resend_timer){+.-...}, at: [<ffffffff8103b675>] run_timer_softirq+0x182/0x2a5
      
      stack backtrace:
      Pid: 0, comm: swapper Not tainted 2.6.35-rc3-cachefs+ #115
      Call Trace:
       <IRQ>  [<ffffffff81054414>] print_circular_bug+0xae/0xbd
       [<ffffffff81055237>] validate_chain+0x727/0xd23
       [<ffffffff810560bc>] __lock_acquire+0x889/0x8fa
       [<ffffffff810539a7>] ? mark_lock+0x42f/0x51f
       [<ffffffff81056184>] lock_acquire+0x57/0x6d
       [<ffffffffa00200d4>] ? rxrpc_resend_time_expired+0x56/0x96 [af_rxrpc]
       [<ffffffff813e6b69>] _raw_read_lock_bh+0x34/0x43
       [<ffffffffa00200d4>] ? rxrpc_resend_time_expired+0x56/0x96 [af_rxrpc]
       [<ffffffffa00200d4>] rxrpc_resend_time_expired+0x56/0x96 [af_rxrpc]
       [<ffffffff8103b6e6>] run_timer_softirq+0x1f3/0x2a5
       [<ffffffff8103b675>] ? run_timer_softirq+0x182/0x2a5
       [<ffffffffa002007e>] ? rxrpc_resend_time_expired+0x0/0x96 [af_rxrpc]
       [<ffffffff810367ef>] ? __do_softirq+0x69/0x13e
       [<ffffffff81036828>] __do_softirq+0xa2/0x13e
       [<ffffffff81002dcc>] call_softirq+0x1c/0x28
       [<ffffffff810049f0>] do_softirq+0x38/0x80
       [<ffffffff810361a2>] irq_exit+0x45/0x47
       [<ffffffff81018fb3>] smp_apic_timer_interrupt+0x88/0x96
       [<ffffffff81002893>] apic_timer_interrupt+0x13/0x20
       <EOI>  [<ffffffff81049de1>] ? __atomic_notifier_call_chain+0x0/0x86
       [<ffffffff8100955b>] ? mwait_idle+0x6e/0x78
       [<ffffffff81009552>] ? mwait_idle+0x65/0x78
       [<ffffffff810011ac>] cpu_idle+0x4d/0x83
       [<ffffffff813e06f3>] start_secondary+0x1bd/0x1c1
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3b5bac2b
  18. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  19. 16 9月, 2009 1 次提交
  20. 06 8月, 2009 1 次提交
  21. 18 2月, 2008 1 次提交
    • J
      net/rxrpc: Use BUG_ON · 163e3cb7
      Julia Lawall 提交于
      if (...) BUG(); should be replaced with BUG_ON(...) when the test has no
      side-effects to allow a definition of BUG_ON that drops the code completely.
      
      The semantic patch that makes this change is as follows:
      (http://www.emn.fr/x-info/coccinelle/)
      
      // <smpl>
      @ disable unlikely @ expression E,f; @@
      
      (
        if (<... f(...) ...>) { BUG(); }
      |
      - if (unlikely(E)) { BUG(); }
      + BUG_ON(E);
      )
      
      @@ expression E,f; @@
      
      (
        if (<... f(...) ...>) { BUG(); }
      |
      - if (E) { BUG(); }
      + BUG_ON(E);
      )
      // </smpl>
      Signed-off-by: NJulia Lawall <julia@diku.dk>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      163e3cb7
  22. 05 5月, 2007 1 次提交
    • D
      [AF_RXRPC]: Sort out MTU handling. · 224711df
      David Howells 提交于
      Sort out the MTU determination and handling in AF_RXRPC:
      
       (1) If it's present, parse the additional information supplied by the peer at
           the end of the ACK packet (struct ackinfo) to determine the MTU sizes
           that peer is willing to support.
      
       (2) Initialise the MTU size to that peer from the kernel's routing records.
      
       (3) Send ACKs rather than ACKALLs as the former carry the additional info,
           and the latter do not.
      
       (4) Declare the interface MTU size in outgoing ACKs as a maximum amount of
           data that can be stuffed into an RxRPC packet without it having to be
           fragmented to come in this computer's NIC.
      
       (5) If sendmsg() is given MSG_MORE then it should allocate an skb of the
           maximum size rather than one just big enough for the data it's got left
           to process on the theory that there is more data to come that it can
           append to that packet.
      
           This means, for example, that if AFS does a large StoreData op, all the
           packets barring the last will be filled to the maximum unfragmented size.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      224711df
  23. 27 4月, 2007 2 次提交
    • D
      [AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use · 651350d1
      David Howells 提交于
      Add an interface to the AF_RXRPC module so that the AFS filesystem module can
      more easily make use of the services available.  AFS still opens a socket but
      then uses the action functions in lieu of sendmsg() and registers an intercept
      functions to grab messages before they're queued on the socket Rx queue.
      
      This permits AFS (or whatever) to:
      
       (1) Avoid the overhead of using the recvmsg() call.
      
       (2) Use different keys directly on individual client calls on one socket
           rather than having to open a whole slew of sockets, one for each key it
           might want to use.
      
       (3) Avoid calling request_key() at the point of issue of a call or opening of
           a socket.  This is done instead by AFS at the point of open(), unlink() or
           other VFS operation and the key handed through.
      
       (4) Request the use of something other than GFP_KERNEL to allocate memory.
      
      Furthermore:
      
       (*) The socket buffer markings used by RxRPC are made available for AFS so
           that it can interpret the cooked RxRPC messages itself.
      
       (*) rxgen (un)marshalling abort codes are made available.
      
      
      The following documentation for the kernel interface is added to
      Documentation/networking/rxrpc.txt:
      
      =========================
      AF_RXRPC KERNEL INTERFACE
      =========================
      
      The AF_RXRPC module also provides an interface for use by in-kernel utilities
      such as the AFS filesystem.  This permits such a utility to:
      
       (1) Use different keys directly on individual client calls on one socket
           rather than having to open a whole slew of sockets, one for each key it
           might want to use.
      
       (2) Avoid having RxRPC call request_key() at the point of issue of a call or
           opening of a socket.  Instead the utility is responsible for requesting a
           key at the appropriate point.  AFS, for instance, would do this during VFS
           operations such as open() or unlink().  The key is then handed through
           when the call is initiated.
      
       (3) Request the use of something other than GFP_KERNEL to allocate memory.
      
       (4) Avoid the overhead of using the recvmsg() call.  RxRPC messages can be
           intercepted before they get put into the socket Rx queue and the socket
           buffers manipulated directly.
      
      To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket,
      bind an addess as appropriate and listen if it's to be a server socket, but
      then it passes this to the kernel interface functions.
      
      The kernel interface functions are as follows:
      
       (*) Begin a new client call.
      
      	struct rxrpc_call *
      	rxrpc_kernel_begin_call(struct socket *sock,
      				struct sockaddr_rxrpc *srx,
      				struct key *key,
      				unsigned long user_call_ID,
      				gfp_t gfp);
      
           This allocates the infrastructure to make a new RxRPC call and assigns
           call and connection numbers.  The call will be made on the UDP port that
           the socket is bound to.  The call will go to the destination address of a
           connected client socket unless an alternative is supplied (srx is
           non-NULL).
      
           If a key is supplied then this will be used to secure the call instead of
           the key bound to the socket with the RXRPC_SECURITY_KEY sockopt.  Calls
           secured in this way will still share connections if at all possible.
      
           The user_call_ID is equivalent to that supplied to sendmsg() in the
           control data buffer.  It is entirely feasible to use this to point to a
           kernel data structure.
      
           If this function is successful, an opaque reference to the RxRPC call is
           returned.  The caller now holds a reference on this and it must be
           properly ended.
      
       (*) End a client call.
      
      	void rxrpc_kernel_end_call(struct rxrpc_call *call);
      
           This is used to end a previously begun call.  The user_call_ID is expunged
           from AF_RXRPC's knowledge and will not be seen again in association with
           the specified call.
      
       (*) Send data through a call.
      
      	int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
      				   size_t len);
      
           This is used to supply either the request part of a client call or the
           reply part of a server call.  msg.msg_iovlen and msg.msg_iov specify the
           data buffers to be used.  msg_iov may not be NULL and must point
           exclusively to in-kernel virtual addresses.  msg.msg_flags may be given
           MSG_MORE if there will be subsequent data sends for this call.
      
           The msg must not specify a destination address, control data or any flags
           other than MSG_MORE.  len is the total amount of data to transmit.
      
       (*) Abort a call.
      
      	void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
      
           This is used to abort a call if it's still in an abortable state.  The
           abort code specified will be placed in the ABORT message sent.
      
       (*) Intercept received RxRPC messages.
      
      	typedef void (*rxrpc_interceptor_t)(struct sock *sk,
      					    unsigned long user_call_ID,
      					    struct sk_buff *skb);
      
      	void
      	rxrpc_kernel_intercept_rx_messages(struct socket *sock,
      					   rxrpc_interceptor_t interceptor);
      
           This installs an interceptor function on the specified AF_RXRPC socket.
           All messages that would otherwise wind up in the socket's Rx queue are
           then diverted to this function.  Note that care must be taken to process
           the messages in the right order to maintain DATA message sequentiality.
      
           The interceptor function itself is provided with the address of the socket
           and handling the incoming message, the ID assigned by the kernel utility
           to the call and the socket buffer containing the message.
      
           The skb->mark field indicates the type of message:
      
      	MARK				MEANING
      	===============================	=======================================
      	RXRPC_SKB_MARK_DATA		Data message
      	RXRPC_SKB_MARK_FINAL_ACK	Final ACK received for an incoming call
      	RXRPC_SKB_MARK_BUSY		Client call rejected as server busy
      	RXRPC_SKB_MARK_REMOTE_ABORT	Call aborted by peer
      	RXRPC_SKB_MARK_NET_ERROR	Network error detected
      	RXRPC_SKB_MARK_LOCAL_ERROR	Local error encountered
      	RXRPC_SKB_MARK_NEW_CALL		New incoming call awaiting acceptance
      
           The remote abort message can be probed with rxrpc_kernel_get_abort_code().
           The two error messages can be probed with rxrpc_kernel_get_error_number().
           A new call can be accepted with rxrpc_kernel_accept_call().
      
           Data messages can have their contents extracted with the usual bunch of
           socket buffer manipulation functions.  A data message can be determined to
           be the last one in a sequence with rxrpc_kernel_is_data_last().  When a
           data message has been used up, rxrpc_kernel_data_delivered() should be
           called on it..
      
           Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose
           of.  It is possible to get extra refs on all types of message for later
           freeing, but this may pin the state of a call until the message is finally
           freed.
      
       (*) Accept an incoming call.
      
      	struct rxrpc_call *
      	rxrpc_kernel_accept_call(struct socket *sock,
      				 unsigned long user_call_ID);
      
           This is used to accept an incoming call and to assign it a call ID.  This
           function is similar to rxrpc_kernel_begin_call() and calls accepted must
           be ended in the same way.
      
           If this function is successful, an opaque reference to the RxRPC call is
           returned.  The caller now holds a reference on this and it must be
           properly ended.
      
       (*) Reject an incoming call.
      
      	int rxrpc_kernel_reject_call(struct socket *sock);
      
           This is used to reject the first incoming call on the socket's queue with
           a BUSY message.  -ENODATA is returned if there were no incoming calls.
           Other errors may be returned if the call had been aborted (-ECONNABORTED)
           or had timed out (-ETIME).
      
       (*) Record the delivery of a data message and free it.
      
      	void rxrpc_kernel_data_delivered(struct sk_buff *skb);
      
           This is used to record a data message as having been delivered and to
           update the ACK state for the call.  The socket buffer will be freed.
      
       (*) Free a message.
      
      	void rxrpc_kernel_free_skb(struct sk_buff *skb);
      
           This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
           socket.
      
       (*) Determine if a data message is the last one on a call.
      
      	bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
      
           This is used to determine if a socket buffer holds the last data message
           to be received for a call (true will be returned if it does, false
           if not).
      
           The data message will be part of the reply on a client call and the
           request on an incoming call.  In the latter case there will be more
           messages, but in the former case there will not.
      
       (*) Get the abort code from an abort message.
      
      	u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
      
           This is used to extract the abort code from a remote abort message.
      
       (*) Get the error number from a local or network error message.
      
      	int rxrpc_kernel_get_error_number(struct sk_buff *skb);
      
           This is used to extract the error number from a message indicating either
           a local error occurred or a network error occurred.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      651350d1
    • D
      [AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both · 17926a79
      David Howells 提交于
      Provide AF_RXRPC sockets that can be used to talk to AFS servers, or serve
      answers to AFS clients.  KerberosIV security is fully supported.  The patches
      and some example test programs can be found in:
      
      	http://people.redhat.com/~dhowells/rxrpc/
      
      This will eventually replace the old implementation of kernel-only RxRPC
      currently resident in net/rxrpc/.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      17926a79