14 Jul, 2020

1 commit

  • Simple fixes which require no deep knowledge of the code.

    Cc: Eric Van Hensbergen
    Cc: Latchesar Ionkov
    Cc: Dominique Martinet
    Signed-off-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Andrew Lunn
     

05 Aug, 2019

1 commit

  • Send and Receive completion is handled on a single CPU selected at
    the time each Completion Queue is allocated. Typically this is when
    an initiator instantiates an RDMA transport, or when a target
    accepts an RDMA connection.

    Some ULPs cannot open a connection per CPU to spread completion
    workload across available CPUs and MSI vectors. For such ULPs,
    provide an API that allows the RDMA core to select a completion
    vector based on the device's complement of available comp_vecs.

    ULPs that invoke ib_alloc_cq() with only comp_vector 0 are converted
    to use the new API so that their completion workloads interfere less
    with each other.

    Suggested-by: Håkon Bugge
    Signed-off-by: Chuck Lever
    Reviewed-by: Leon Romanovsky
    Cc:
    Cc:
    Link: https://lore.kernel.org/r/20190729171923.13428.52555.stgit@manet.1015granger.net
    Signed-off-by: Doug Ledford

    Chuck Lever
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with this program if not write to free software
    foundation 51 franklin street fifth floor boston ma 02111 1301 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 27 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Richard Fontana
    Reviewed-by: Alexios Zavras
    Reviewed-by: Steve Winslow
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190528170026.981318839@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

08 Sep, 2018

4 commits

  • the client c is always dereferenced to get the rdma struct, so c has to
    be a valid pointer at this point.
    Gcc would optimize that away but let's make coverity happy...

    Link: http://lkml.kernel.org/r/1536339057-21974-3-git-send-email-asmadeus@codewreck.org
    Addresses-Coverity-ID: 102778 ("Dereference before null check")
    Signed-off-by: Dominique Martinet

    Dominique Martinet
     
  • 9p/rdma would sometimes drop the connection and display errors in
    recv_done when the user does ^C.
    The errors were caused by recv buffers that were posted at the time
    of disconnect, and we just do not want to disconnect when
    down_interruptible is... interrupted.

    Link: http://lkml.kernel.org/r/1535625307-18019-1-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet

    Dominique Martinet
     
  • To avoid use-after-free(s), use a refcount to keep track of the
    usable references to any instantiated struct p9_req_t.

    This commit adds p9_req_put(), p9_req_get() and p9_req_try_get() as
    wrappers to kref_put(), kref_get() and kref_get_unless_zero().
    These are used by the client and the transports to keep track of
    valid requests' references.

    p9_free_req() is added back and used as callback by kref_put().

    Add SLAB_TYPESAFE_BY_RCU as it ensures that the memory freed by
    kmem_cache_free() will not be reused for another type until the rcu
    synchronisation period is over, so an address gotten under rcu read
    lock is safe to inc_ref() without corrupting random memory while
    the lock is held.

    Link: http://lkml.kernel.org/r/1535626341-20693-1-git-send-email-asmadeus@codewreck.org
    Co-developed-by: Dominique Martinet
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+467050c1ce275af2a5b8@syzkaller.appspotmail.com
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     
  • 'msize' is often a power of two, or at least page-aligned, so avoiding
    an overhead of two dozen bytes for each allocation will help the
    allocator do its work and reduce memory fragmentation.

    Link: http://lkml.kernel.org/r/1533825236-22896-1-git-send-email-asmadeus@codewreck.org
    Suggested-by: Matthew Wilcox
    Signed-off-by: Dominique Martinet
    Reviewed-by: Greg Kurz
    Acked-by: Jun Piao
    Cc: Matthew Wilcox

    Dominique Martinet
     

18 Aug, 2018

1 commit

  • Pull 9p updates from Dominique Martinet:
    "This contains mostly fixes (6 to be backported to stable) and a few
    changes, here is the breakdown:

    - rework how fids are attributed by replacing some custom tracking in
    a list by an idr

    - for packet-based transports (virtio/rdma) validate that the packet
    length matches what the header says

    - a few race condition fixes found by syzkaller

    - missing argument check when NULL device is passed in sys_mount

    - a few virtio fixes

    - some spelling and style fixes"

    * tag '9p-for-4.19-2' of git://github.com/martinetd/linux: (21 commits)
    net/9p/trans_virtio.c: add null terminal for mount tag
    9p/virtio: fix off-by-one error in sg list bounds check
    9p: fix whitespace issues
    9p: fix multiple NULL-pointer-dereferences
    fs/9p/xattr.c: catch the error of p9_client_clunk when setting xattr failed
    9p: validate PDU length
    net/9p/trans_fd.c: fix race by holding the lock
    net/9p/trans_fd.c: fix race-condition by flushing workqueue before the kfree()
    net/9p/virtio: Fix hard lockup in req_done
    net/9p/trans_virtio.c: fix some spell mistakes in comments
    9p/net: Fix zero-copy path in the 9p virtio transport
    9p: Embed wait_queue_head into p9_req_t
    9p: Replace the fidlist with an IDR
    9p: Change p9_fid_create calling convention
    9p: Fix comment on smp_wmb
    net/9p/client.c: version pointer uninitialized
    fs/9p/v9fs.c: fix spelling mistake "Uknown" -> "Unknown"
    net/9p: fix error path of p9_virtio_probe
    9p/net/protocol.c: return -ENOMEM when kmalloc() failed
    net/9p/client.c: add missing '\n' at the end of p9_debug()
    ...

    Linus Torvalds
     

13 Aug, 2018

2 commits

  • Added checks to prevent GPFs from raising.

    Link: http://lkml.kernel.org/r/20180727110558.5479-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+1a262da37d3bead15c39@syzkaller.appspotmail.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     
  • This commit adds length check for the PDU size.
    The size contained in the header has to match the actual size,
    except for TCP (trans_fd.c) where actual length is not known ahead
    and the header's length will be checked only against the validity
    range.

    Link: http://lkml.kernel.org/r/20180723154404.2406-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+65c6b72f284a39d416b4@syzkaller.appspotmail.com
    To: Eric Van Hensbergen
    To: Ron Minnich
    To: Latchesar Ionkov
    Cc: David S. Miller
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     

25 Jul, 2018

1 commit


10 May, 2018

1 commit

  • There are follow comment errors:
    1 The function name is wrong in p9_release_pages() comment.
    2 The function name and variable name is wrong in p9_poll_workfn() comment.
    3 There is no variable dm_mr and lkey in struct p9_trans_rdma.
    4 The function name is wrong in rdma_create_trans() comment.
    5 There is no variable initialized in struct virtio_chan.
    6 The variable name is wrong in p9_virtio_zc_request() comment.

    Signed-off-by: Sun Lianwen
    Reviewed-by: Randy Dunlap
    Reviewed-by: Randy Dunlap
    Signed-off-by: David S. Miller

    Sun Lianwen
     

11 Jul, 2017

1 commit

  • Implement the show_options superblock op for 9p as part of a bid to get
    rid of s_options and generic_show_options() to make it easier to implement
    a context-based mount where the mount options can be passed individually
    over a file descriptor.

    Signed-off-by: David Howells
    cc: Eric Van Hensbergen
    cc: Ron Minnich
    cc: Latchesar Ionkov
    cc: v9fs-developer@lists.sourceforge.net
    Signed-off-by: Al Viro

    David Howells
     

24 Sep, 2016

1 commit

  • Instead of exposing ib_get_dma_mr to ULPs and letting them use it more or
    less unchecked, this moves the capability of creating a global rkey into
    the RDMA core, where it can be easily audited. It also prints a warning
    everytime this feature is used as well.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Sagi Grimberg
    Reviewed-by: Jason Gunthorpe
    Reviewed-by: Steve Wise
    Signed-off-by: Doug Ledford

    Christoph Hellwig
     

11 Mar, 2016

1 commit


29 Oct, 2015

1 commit

  • Add support for network namespaces in the ib_cma module. This is
    accomplished by:

    1. Adding network namespace parameter for rdma_create_id. This parameter is
    used to populate the network namespace field in rdma_id_private.
    rdma_create_id keeps a reference on the network namespace.
    2. Using the network namespace from the rdma_id instead of init_net inside
    of ib_cma, when listening on an ID and when looking for an ID for an
    incoming request.
    3. Decrementing the reference count for the appropriate network namespace
    when calling rdma_destroy_id.

    In order to preserve the current behavior init_net is passed when calling
    from other modules.

    Signed-off-by: Guy Shapiro
    Signed-off-by: Haggai Eran
    Signed-off-by: Yotam Kenneth
    Signed-off-by: Shachar Raindel
    Signed-off-by: Doug Ledford

    Guy Shapiro
     

31 Aug, 2015

1 commit


13 Jun, 2015

1 commit


22 Mar, 2015

1 commit


26 Mar, 2014

4 commits

  • When parsing options, make sure we have found a proper token before
    doing a numeric conversion.

    Without this check, the current code will end up following random
    pointers that just happened to be on the stack when this function was
    called, because match_token() will not touch the 'args' list unless a
    valid token is found.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     
  • Take into account posted recv buffers that will never receive their
    reply.

    The RDMA code posts a recv buffer for each request that it sends.
    When a request is flushed, it is possible that this request will
    never receive a reply, and that one recv buffer will stay unused on
    the recv queue.

    It is then possible, if this scenario happens several times, to have the
    recv queue full, and have the 9pnet_rmda module unable to send new requests.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     
  • This will be needed by the flush logic.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     
  • We need barriers to guarantee this pattern works as intended:
    [w] req->rc, 1 [r] req->status, 1
    wmb rmb
    [w] req->status, 1 [r] req->rc

    Where the wmb ensures that rc gets written before status,
    and the rmb ensures that if you observe status == 1, rc is the new value.

    Signed-off-by: Dominique Martinet
    Signed-off-by: Eric Van Hensbergen

    Dominique Martinet
     

25 Jul, 2013

1 commit

  • This patch gets rid of the following warning:

    net/9p/trans_rdma.c:594:12: warning: ‘rdma_cancelled’ defined but not used [-Wunused-function]
    static int rdma_cancelled(struct p9_client *client, struct p9_req_t *req)

    The rdma_cancelled function is not called anywhere in the kernel

    Signed-off-by: Andi Shyti
    Signed-off-by: David S. Miller

    Andi Shyti
     

08 Jul, 2013

8 commits

  • RDMA needs to post a buffer for each incoming reply.
    Hence it needs to keep count of these and needs to be
    aware of whether a flushed request has received a reply
    or not.

    This patch adds the cancelled() callback to the transport modules.
    It is called when RFLUSH has been received and that the corresponding
    request will never receive a reply.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     
  • In rdma_request():

    If an error occurs between posting the recv and the send,
    there will be a reply context posted without a pending
    request.
    Since there is no way to "un-post" it, we remember it and
    skip post_recv() for the next request.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     
  • Most importantly:
    - do not free the recv context (rpl_context) after a successful post_recv()
    - but do free the send context (c) after a failed send.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     
  • rdma_request() should never be in charge of freeing rc.

    When an error occurs:
    * Either the rc buffer has been recv_post()'ed.
    then kfree()'ing it certainly is a bad idea.
    * Or is has not, and in that case req->rc still points to it,
    hence it needs not be freed.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     
  • The current code keeps track of the number of buffers posted in the RQ,
    and will prevent it from overflowing. But it does so by simply dropping
    post requests (And leaking memory in the process).
    When this happens there will actually be too few buffers posted, and
    soon the 9P server will complain about 'RNR retry counter exceeded'
    errors.

    Instead, use a semaphore, and block until the RQ is ready for another
    buffer to be posted.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     
  • A well-behaved server would not send twice the reply to a request.
    But if it ever happens...
    This additional check prevents the kernel from leaking memory
    and possibly more nasty consequences in that unlikely event.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     
  • The current value is too low to get good performance.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     
  • p9_tag_alloc() takes care of that.

    Signed-off-by: Simon Derr
    Signed-off-by: Eric Van Hensbergen

    Simon Derr
     

06 Jan, 2012

1 commit

  • Reduce object size by deduplicating formats.

    Use vsprintf extension %pV.
    Rename P9_DPRINTK uses to p9_debug, align arguments.
    Add function for _p9_debug and macro to add __func__.
    Add missing "\n"s to p9_debug uses.
    Remove embedded function names as p9_debug adds it.
    Remove P9_EPRINTK macro and convert use to pr_.
    Add and use pr_fmt and pr_.

    $ size fs/9p/built-in.o*
    text data bss dec hex filename
    62133 984 16000 79117 1350d fs/9p/built-in.o.new
    67342 984 16928 85254 14d06 fs/9p/built-in.o.old
    $ size net/9p/built-in.o*
    text data bss dec hex filename
    88792 4148 22024 114964 1c114 net/9p/built-in.o.new
    94072 4148 23232 121452 1da6c net/9p/built-in.o.old

    Signed-off-by: Joe Perches
    Signed-off-by: Eric Van Hensbergen

    Joe Perches
     

27 May, 2011

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband:
    RDMA/cma: Save PID of ID's owner
    RDMA/cma: Add support for netlink statistics export
    RDMA/cma: Pass QP type into rdma_create_id()
    RDMA: Update exported headers list
    RDMA/cma: Export enum cma_state in
    RDMA/nes: Add a check for strict_strtoul()
    RDMA/cxgb3: Don't post zero-byte read if endpoint is going away
    RDMA/cxgb4: Use completion objects for event blocking
    IB/srp: Fix integer -> pointer cast warnings
    IB: Add devnode methods to cm_class and umad_class
    IB/mad: Return EPROTONOSUPPORT when an RDMA device lacks the QP required
    IB/uverbs: Add devnode method to set path/mode
    RDMA/ucma: Add .nodename/.mode to tell userspace where to create device node
    RDMA: Add netlink infrastructure
    RDMA: Add error handling to ib_core_init()

    Linus Torvalds
     

26 May, 2011

1 commit

  • 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: Sean Hefty
    Signed-off-by: Roland Dreier

    Sean Hefty
     

20 May, 2011

1 commit


23 Mar, 2011

1 commit

  • Without this we can cause reclaim allocation in writepage.

    [ 3433.448430] =================================
    [ 3433.449117] [ INFO: inconsistent lock state ]
    [ 3433.449117] 2.6.38-rc5+ #84
    [ 3433.449117] ---------------------------------
    [ 3433.449117] inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-R} usage.
    [ 3433.449117] kswapd0/505 [HC0[0]:SC0[0]:HE1:SE1] takes:
    [ 3433.449117] (iprune_sem){+++++-}, at: [] shrink_icache_memory+0x45/0x2b1
    [ 3433.449117] {RECLAIM_FS-ON-W} state was registered at:
    [ 3433.449117] [] mark_held_locks+0x52/0x70
    [ 3433.449117] [] lockdep_trace_alloc+0x85/0x9f
    [ 3433.449117] [] slab_pre_alloc_hook+0x18/0x3c
    [ 3433.449117] [] kmem_cache_alloc+0x23/0xa2
    [ 3433.449117] [] idr_pre_get+0x2d/0x6f
    [ 3433.449117] [] p9_idpool_get+0x30/0xae
    [ 3433.449117] [] p9_client_rpc+0xd7/0x9b0
    [ 3433.449117] [] p9_client_clunk+0x88/0xdb
    [ 3433.449117] [] v9fs_evict_inode+0x3c/0x48
    [ 3433.449117] [] evict+0x1f/0x87
    [ 3433.449117] [] dispose_list+0x47/0xe3
    [ 3433.449117] [] evict_inodes+0x138/0x14f
    [ 3433.449117] [] generic_shutdown_super+0x57/0xe8
    [ 3433.449117] [] kill_anon_super+0x11/0x50
    [ 3433.449117] [] v9fs_kill_super+0x49/0xab
    [ 3433.449117] [] deactivate_locked_super+0x21/0x46
    [ 3433.449117] [] deactivate_super+0x40/0x44
    [ 3433.449117] [] mntput_no_expire+0x100/0x109
    [ 3433.449117] [] sys_umount+0x2f1/0x31c
    [ 3433.449117] [] system_call_fastpath+0x16/0x1b
    [ 3433.449117] irq event stamp: 192941
    [ 3433.449117] hardirqs last enabled at (192941): [] _raw_spin_unlock_irq+0x2b/0x30
    [ 3433.449117] hardirqs last disabled at (192940): [] shrink_inactive_list+0x290/0x2f5
    [ 3433.449117] softirqs last enabled at (188470): [] __do_softirq+0x133/0x152
    [ 3433.449117] softirqs last disabled at (188455): [] call_softirq+0x1c/0x28
    [ 3433.449117]
    [ 3433.449117] other info that might help us debug this:
    [ 3433.449117] 1 lock held by kswapd0/505:
    [ 3433.449117] #0: (shrinker_rwsem){++++..}, at: [] shrink_slab+0x38/0x15f
    [ 3433.449117]
    [ 3433.449117] stack backtrace:
    [ 3433.449117] Pid: 505, comm: kswapd0 Not tainted 2.6.38-rc5+ #84
    [ 3433.449117] Call Trace:
    [ 3433.449117] [] ? valid_state+0x17e/0x191
    [ 3433.449117] [] ? save_stack_trace+0x28/0x45
    [ 3433.449117] [] ? check_usage_forwards+0x0/0x87
    [ 3433.449117] [] ? mark_lock+0x113/0x22c
    [ 3433.449117] [] ? __lock_acquire+0x37a/0xcf7
    [ 3433.449117] [] ? mark_lock+0x2d/0x22c
    [ 3433.449117] [] ? __lock_acquire+0x392/0xcf7
    [ 3433.449117] [] ? determine_dirtyable_memory+0x15/0x28
    [ 3433.449117] [] ? lock_acquire+0x57/0x6d
    [ 3433.449117] [] ? shrink_icache_memory+0x45/0x2b1
    [ 3433.449117] [] ? down_read+0x47/0x5c
    [ 3433.449117] [] ? shrink_icache_memory+0x45/0x2b1
    [ 3433.449117] [] ? shrink_icache_memory+0x45/0x2b1
    [ 3433.449117] [] ? shrink_slab+0xdb/0x15f
    [ 3433.449117] [] ? kswapd+0x574/0x96a
    [ 3433.449117] [] ? kswapd+0x0/0x96a
    [ 3433.449117] [] ? kthread+0x7d/0x85
    [ 3433.449117] [] ? kernel_thread_helper+0x4/0x10
    [ 3433.449117] [] ? restore_args+0x0/0x30
    [ 3433.449117] [] ? kthread+0x0/0x85
    [ 3433.449117] [] ? kernel_thread_helper+0x0/0x10

    Signed-off-by: Aneesh Kumar K.V
    Signed-off-by: Venkateswararao Jujjuri
    Signed-off-by: Eric Van Hensbergen

    Aneesh Kumar K.V
     

20 Jan, 2011

1 commit

  • Clean up some unused macros in net/*.
    1. be left for code change. e.g. PGV_FROM_VMALLOC, PGV_FROM_VMALLOC, KMEM_SAFETYZONE.
    2. never be used since introduced to kernel.
    e.g. P9_RDMA_MAX_SGE, UTIL_CTRL_PKT_SIZE.

    Signed-off-by: Shan Wei
    Acked-by: Sjur Braendeland
    Signed-off-by: David S. Miller

    Shan Wei
     

27 Sep, 2010

1 commit


18 May, 2010

1 commit

  • This patch removes from net/ (but not any netfilter files)
    all the unnecessary return; statements that precede the
    last closing brace of void functions.

    It does not remove the returns that are immediately
    preceded by a label as gcc doesn't like that.

    Done via:
    $ grep -rP --include=*.[ch] -l "return;\n}" net/ | \
    xargs perl -i -e 'local $/ ; while (<>) { s/\n[ \t\n]+return;\n}/\n}/g; print; }'

    Signed-off-by: Joe Perches
    Signed-off-by: David S. Miller

    Joe Perches