24 Nov, 2014

2 commits

  • Drop the now unused reason argument from the ->change_queue_depth method.
    Also add a return value to scsi_adjust_queue_depth, and rename it to
    scsi_change_queue_depth now that it can be used as the default
    ->change_queue_depth implementation.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Mike Christie
    Reviewed-by: Hannes Reinecke

    Christoph Hellwig
     
  • All drivers use the implementation for ramping the queue up and down, so
    instead of overloading the change_queue_depth method call the
    implementation diretly if the driver opts into it by setting the
    track_queue_depth flag in the host template.

    Note that a few drivers validated the new queue depth in their
    change_queue_depth method, but as we never go over the queue depth
    set during slave_configure or the sysfs file this isn't nessecary
    and can safely be removed.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Mike Christie
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Venkatesh Srinivas

    Christoph Hellwig
     

30 Sep, 2014

1 commit


24 May, 2014

1 commit

  • Define separate fields in the sock structure for configuring disabling
    checksums in both TX and RX-- sk_no_check_tx and sk_no_check_rx.
    The SO_NO_CHECK socket option only affects sk_no_check_tx. Also,
    removed UDP_CSUM_* defines since they are no longer necessary.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     

12 Apr, 2014

1 commit

  • Several spots in the kernel perform a sequence like:

    skb_queue_tail(&sk->s_receive_queue, skb);
    sk->sk_data_ready(sk, skb->len);

    But at the moment we place the SKB onto the socket receive queue it
    can be consumed and freed up. So this skb->len access is potentially
    to freed up memory.

    Furthermore, the skb->len can be modified by the consumer so it is
    possible that the value isn't accurate.

    And finally, no actual implementation of this callback actually uses
    the length argument. And since nobody actually cared about it's
    value, lots of call sites pass arbitrary values in such as '0' and
    even '1'.

    So just remove the length argument from the callback, that way there
    is no confusion whatsoever and all of these use-after-free cases get
    fixed as a side effect.

    Based upon a patch by Eric Dumazet and his suggestion to audit this
    issue tree-wide.

    Signed-off-by: David S. Miller

    David S. Miller
     

16 Mar, 2014

2 commits

  • Check that the session is setup before accessing its
    connection. This fixes a oops where userspace tries
    to get the ip address before the session is bound to
    a host.

    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Mike Christie
     
  • Replace the session lock with two locks, a forward lock and
    a backwards lock named frwd_lock and back_lock respectively.

    The forward lock protects resources that change while sending a
    request to the target, such as cmdsn, queued_cmdsn, and allocating
    task from the commands' pool with kfifo_out.

    The backward lock protects resources that change while processing
    a response or in error path, such as cmdsn_exp, cmdsn_max, and
    returning tasks to the commands' pool with kfifo_in.

    Under a steady state fast-path situation, that is when one
    or more processes/threads submit IO to an iscsi device and
    a single kernel upcall (e.g softirq) is dealing with processing
    of responses without errors, this patch eliminates the contention
    between the queuecommand()/request response/scsi_done() flows
    associated with iscsi sessions.

    Between the forward and the backward locks exists a strict locking
    hierarchy. The mutual exclusion zone protected by the forward lock can
    enclose the mutual exclusion zone protected by the backward lock but not
    vice versa.

    For example, in iscsi_conn_teardown or in iscsi_xmit_data when there is
    a failure and __iscsi_put_task is called, the backward lock is taken while
    the forward lock is still taken. On the other hand, if in the RX path a nop
    is to be sent, for example in iscsi_handle_reject or __iscsi_complete_pdu
    than the forward lock is released and the backward lock is taken for the
    duration of iscsi_send_nopout, later the backward lock is released and the
    forward lock is retaken.

    libiscsi_tcp uses two kernel fifos the r2t pool and the r2t queue.

    The insertion and deletion from these queues didn't corespond to the
    assumption taken by the new forward/backwards session locking paradigm.

    That is, in iscsi_tcp_clenup_task which belongs to the RX (backwards)
    path, r2t is taken out from r2t queue and inserted to the r2t pool.
    In iscsi_tcp_get_curr_r2t which belong to the TX (forward) path, r2t
    is also inserted to the r2t pool and another r2t is pulled from r2t
    queue.

    Only in iscsi_tcp_r2t_rsp which is called in the RX path but can requeue
    to the TX path, r2t is taken from the r2t pool and inserted to the r2t
    queue.

    In order to cope with this situation, two spin locks were added,
    pool2queue and queue2pool. The former protects extracting from the
    r2t pool and inserting to the r2t queue, and the later protects the
    extracing from the r2t queue and inserting to the r2t pool.

    Signed-off-by: Shlomo Pongratz
    Signed-off-by: Or Gerlitz
    [minor fix up to apply cleanly and compile fix]
    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Shlomo Pongratz
     

25 Oct, 2013

1 commit

  • It seems some iSCSI targets (including the Linux kernel target) close
    the TCP connection from the target side immediately after processing a
    session logout.

    When a TCP FIN comes in right after the iSCSI logout response,
    iscsi_sw_sk_state_check sees the local socket as not yet being in
    CLOSE_WAIT or CLOSE and logs an error. But the initiator would close
    the connection right after processing the logout response anyway, and
    the error is confusing to admins who just requested that the session be
    shut down.

    This adds a check of the session state, and suppresses the error if we
    are in the process of logging out.

    Signed-off-by: Chris Leech
    Reviewed-by: Mike Christie
    Signed-off-by: James Bottomley

    Chris Leech
     

12 Apr, 2013

1 commit


24 Sep, 2012

1 commit


22 Apr, 2012

1 commit


19 Feb, 2012

1 commit

  • Problem description from Xi Wang:
    A large max_r2t could lead to integer overflow in subsequent call to
    iscsi_tcp_r2tpool_alloc(), allocating a smaller buffer than expected
    and leading to out-of-bounds write.

    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Mike Christie
     

04 Jan, 2012

1 commit


01 Nov, 2011

1 commit


27 Aug, 2011

3 commits


30 Jun, 2011

1 commit

  • iscsi_sw_tcp_conn_restore_callbacks could have set
    the sk_user_data field to NULL then iscsi_sw_tcp_data_ready
    could read that and try to access the NULL pointer. This
    adds some checks for NULL sk_user_data in the sk
    callback functions and it uses the sk_callback_lock to
    set/get that sk_user_data field.

    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Mike Christie
     

31 Mar, 2011

1 commit


25 Feb, 2011

1 commit

  • This has iscsi_tcp use the iscsi_conn_get_addr_param
    libiscsi function. It also drops the use of the libiscsi
    session portal buffers, so they can be removed in
    the next patches. Instead of copying the values
    at bind time we get them during get() time. If we are
    not connected userspace will now get -ENOTCONN,
    so it knows that connection is disconnected instead
    of a possible stale value.

    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Mike Christie
     

25 May, 2010

1 commit


22 May, 2010

1 commit

  • The removal of the 'waitqueue_active()' test in commit d7d05548a6
    ("[SCSI] iscsi_tcp: fix relogin/shutdown hang") got incorrectly resolved
    by David when he back-merged the main git tree into the networking tree
    in commit 278554bd65 ("Merge branch 'master' of master.kernel.org:...").

    There was a content conflict due to 'sock->sk->sk_sleep' being changed
    into 'sk_sleep(sock->sk)' in the networking tree, but David didn't pick
    up the iscsi change from the main tree.

    Reported-by: James Bottomley
    Cc: David Miller
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

21 May, 2010

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (182 commits)
    [SCSI] aacraid: add an ifdef'd device delete case instead of taking the device offline
    [SCSI] aacraid: prohibit access to array container space
    [SCSI] aacraid: add support for handling ATA pass-through commands.
    [SCSI] aacraid: expose physical devices for models with newer firmware
    [SCSI] aacraid: respond automatically to volumes added by config tool
    [SCSI] fcoe: fix fcoe module ref counting
    [SCSI] libfcoe: FIP Keep-Alive messages for VPorts are sent with incorrect port_id and wwn
    [SCSI] libfcoe: Fix incorrect MAC address clearing
    [SCSI] fcoe: fix a circular locking issue with rtnl and sysfs mutex
    [SCSI] libfc: Move the port_id into lport
    [SCSI] fcoe: move link speed checking into its own routine
    [SCSI] libfc: Remove extra pointer check
    [SCSI] libfc: Remove unused fc_get_host_port_type
    [SCSI] fcoe: fixes wrong error exit in fcoe_create
    [SCSI] libfc: set seq_id for incoming sequence
    [SCSI] qla2xxx: Updates to ISP82xx support.
    [SCSI] qla2xxx: Optionally disable target reset.
    [SCSI] qla2xxx: ensure flash operation and host reset via sg_reset are mutually exclusive
    [SCSI] qla2xxx: Silence bogus warning by gcc for wrap and did.
    [SCSI] qla2xxx: T10 DIF support added.
    ...

    Linus Torvalds
     

18 May, 2010

1 commit


21 Apr, 2010

1 commit

  • Define a new function to return the waitqueue of a "struct sock".

    static inline wait_queue_head_t *sk_sleep(struct sock *sk)
    {
    return sk->sk_sleep;
    }

    Change all read occurrences of sk_sleep by a call to this function.

    Needed for a future RCU conversion. sk_sleep wont be a field directly
    available.

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

12 Apr, 2010

2 commits

  • This patch changes the arguments to iscsi_sw_tcp_conn_restore_callbacks,
    so that it works like the function to set the callbacks and because
    in upcoming patches we need a iscsi_conn.

    Signed-off-by: Avi Kaplan
    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Avi Kaplan
     
  • When I made this patch:
    b64e77f70b8c11766e967e3485331a9e6ef01390
    it was to solve a problem where we were already on the waitqueue
    becuase a connection problem/logout caused us to be on there
    when we were cleaning up the session. If we happen to get
    on queue for more normal reasons like their just does not happen
    to be any send space at the same time we are closing the connection
    we hit a race and get stuck in the wait.

    We should not check if the waitqueue is active
    because we could race with the network code. If
    the network xmit code is just about to enter the
    prepare to wait when we check for the waitqueue to
    be active then we will miss each other and the
    network code will fall into the wait and we will
    not run wake_up.

    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Mike Christie
     

30 Mar, 2010

1 commit

  • …it 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: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

03 Mar, 2010

1 commit


18 Feb, 2010

1 commit


05 Dec, 2009

1 commit


03 Oct, 2009

1 commit


05 Sep, 2009

2 commits


21 Jun, 2009

1 commit

  • The net layer might return -EAGAIN because it could not
    get space/mem within the sock sndtimeo or becuase the tcp/ip
    connection was down. For the latter we do not want to retry
    because the conn/session should just be shutdown and restarted.
    libiscsi knows the state of the session recovery so propogate
    this error to that layer. It will either do iscsi recovery
    or have us retry the operation. Right now if we have partially
    sent a pdu we would always retry the IO xmit slowing down
    recovery.

    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Mike Christie
     

27 Apr, 2009

2 commits

  • Set target can queue limit to the number of preallocated
    session tasks we have.

    This along with the cxgb3i can_queue patch will fix a throughput
    problem where it could only queue one LU worth of data at a time.

    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Mike Christie
     
  • If a command's scsi cmd pdu setup fails then we can just fail
    the IO to the scsi layer. If a DATA_OUT for a R2T fails then
    we will want to drop the session, because it means we got a
    bad request from the target (iscsi protocol error).

    This patch has us propogate the error upwards so libiscsi_tcp
    or libiscsi can decide what the best action is to take. It
    also fixes a bug where we could try to grab the session lock
    while holding it, because if iscsi_tcp drops the session in the
    pdu setup callout the session lock is held when setting up the
    scsi cmd pdu.

    Signed-off-by: Mike Christie
    Signed-off-by: James Bottomley

    Mike Christie
     

14 Mar, 2009

3 commits