30 Nov, 2017

1 commit

  • commit 1c21a48055a67ceb693e9c2587824a8de60a217c upstream.

    This patch fixes bug where early se_cmd exceptions that occur
    before backend execution can result in use-after-free if/when
    a subsequent ABORT_TASK occurs for the same tag.

    Since an early se_cmd exception will have had se_cmd added to
    se_session->sess_cmd_list via target_get_sess_cmd(), it will
    not have CMD_T_COMPLETE set by the usual target_complete_cmd()
    backend completion path.

    This causes a subsequent ABORT_TASK + __target_check_io_state()
    to signal ABORT_TASK should proceed. As core_tmr_abort_task()
    executes, it will bring the outstanding se_cmd->cmd_kref count
    down to zero releasing se_cmd, after se_cmd has already been
    queued with error status into fabric driver response path code.

    To address this bug, introduce a CMD_T_PRE_EXECUTE bit that is
    set at target_get_sess_cmd() time, and cleared immediately before
    backend driver dispatch in target_execute_cmd() once CMD_T_ACTIVE
    is set.

    Then, check CMD_T_PRE_EXECUTE within __target_check_io_state() to
    determine when an early exception has occured, and avoid aborting
    this se_cmd since it will have already been queued into fabric
    driver response path code.

    Reported-by: Donald White
    Cc: Donald White
    Cc: Mike Christie
    Cc: Hannes Reinecke
    Signed-off-by: Nicholas Bellinger
    Signed-off-by: Greg Kroah-Hartman

    Nicholas Bellinger
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

07 Aug, 2017

1 commit

  • This patch fixes a bug associated with iscsit_reset_np_thread()
    that can occur during parallel configfs rmdir of a single iscsi_np
    used across multiple iscsi-target instances, that would result in
    hung task(s) similar to below where configfs rmdir process context
    was blocked indefinately waiting for iscsi_np->np_restart_comp
    to finish:

    [ 6726.112076] INFO: task dcp_proxy_node_:15550 blocked for more than 120 seconds.
    [ 6726.119440] Tainted: G W O 4.1.26-3321 #2
    [ 6726.125045] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [ 6726.132927] dcp_proxy_node_ D ffff8803f202bc88 0 15550 1 0x00000000
    [ 6726.140058] ffff8803f202bc88 ffff88085c64d960 ffff88083b3b1ad0 ffff88087fffeb08
    [ 6726.147593] ffff8803f202c000 7fffffffffffffff ffff88083f459c28 ffff88083b3b1ad0
    [ 6726.155132] ffff88035373c100 ffff8803f202bca8 ffffffff8168ced2 ffff8803f202bcb8
    [ 6726.162667] Call Trace:
    [ 6726.165150] [] schedule+0x32/0x80
    [ 6726.170156] [] schedule_timeout+0x214/0x290
    [ 6726.176030] [] ? __send_signal+0x52/0x4a0
    [ 6726.181728] [] wait_for_completion+0x96/0x100
    [ 6726.187774] [] ? wake_up_state+0x10/0x10
    [ 6726.193395] [] iscsit_reset_np_thread+0x62/0xe0 [iscsi_target_mod]
    [ 6726.201278] [] iscsit_tpg_disable_portal_group+0x96/0x190 [iscsi_target_mod]
    [ 6726.210033] [] lio_target_tpg_store_enable+0x4f/0xc0 [iscsi_target_mod]
    [ 6726.218351] [] configfs_write_file+0xaa/0x110
    [ 6726.224392] [] vfs_write+0xa4/0x1b0
    [ 6726.229576] [] SyS_write+0x41/0xb0
    [ 6726.234659] [] system_call_fastpath+0x12/0x71

    It would happen because each iscsit_reset_np_thread() sets state
    to ISCSI_NP_THREAD_RESET, sends SIGINT, and then blocks waiting
    for completion on iscsi_np->np_restart_comp.

    However, if iscsi_np was active processing a login request and
    more than a single iscsit_reset_np_thread() caller to the same
    iscsi_np was blocked on iscsi_np->np_restart_comp, iscsi_np
    kthread process context in __iscsi_target_login_thread() would
    flush pending signals and only perform a single completion of
    np->np_restart_comp before going back to sleep within transport
    specific iscsit_transport->iscsi_accept_np code.

    To address this bug, add a iscsi_np->np_reset_count and update
    __iscsi_target_login_thread() to keep completing np->np_restart_comp
    until ->np_reset_count has reached zero.

    Reported-by: Gary Guo
    Tested-by: Gary Guo
    Cc: Mike Christie
    Cc: Hannes Reinecke
    Cc: stable@vger.kernel.org # 3.10+
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

12 Jul, 2017

1 commit

  • This patch re-introduces part of a long standing login workaround that
    was recently dropped by:

    commit 1c99de981f30b3e7868b8d20ce5479fa1c0fea46
    Author: Nicholas Bellinger
    Date: Sun Apr 2 13:36:44 2017 -0700

    iscsi-target: Drop work-around for legacy GlobalSAN initiator

    Namely, the workaround for FirstBurstLength ended up being required by
    Mellanox Flexboot PXE boot ROMs as reported by Robert.

    So this patch re-adds the work-around for FirstBurstLength within
    iscsi_check_proposer_for_optional_reply(), and makes the key optional
    to respond when the initiator does not propose, nor respond to it.

    Also as requested by Arun, this patch introduces a new TPG attribute
    named 'login_keys_workaround' that controls the use of both the
    FirstBurstLength workaround, as well as the two other existing
    workarounds for gPXE iSCSI boot client.

    By default, the workaround is enabled with login_keys_workaround=1,
    since Mellanox FlexBoot requires it, and Arun has verified the Qlogic
    MSFT initiator already proposes FirstBurstLength, so it's uneffected
    by this re-adding this part of the original work-around.

    Reported-by: Robert LeBlanc
    Cc: Robert LeBlanc
    Reviewed-by: Arun Easi
    Cc: # 3.1+
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

07 Jul, 2017

11 commits

  • transport_complete is no longer used, so drop the code.

    Signed-off-by: Mike Christie
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     
  • This adds a helper to copy sense from backend module buffer to
    the se_cmd's sense buffer.

    Signed-off-by: Mike Christie
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     
  • g_device_list is no longer needed because we now use the idr code
    for lookups and seaches.

    Signed-off-by: Mike Christie
    Reviewed-by: Bart Van Assche
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     
  • This adds a helper to find a se_device by dev_index. It will
    be used in the next patches so tcmu's netlink interface can
    execute commands on specific devices.

    Signed-off-by: Mike Christie
    Reviewed-by: Bart Van Assche
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     
  • In the next patches we will add tcmu netlink support that allows
    userspace to send commands to target_core_user. To execute operations
    on a se_device/tcmu_dev we need to be able to look up a dev by any old
    id. This patch replaces the se_device->dev_index with a idr created
    id.

    The next patches will also remove the g_device_list and replace it with
    the idr.

    Signed-off-by: Mike Christie
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     
  • With this patch free_device is now used to free what is allocated in the
    alloc_device callback and destroy_device tears down the resources that are
    setup in the configure_device callback.

    This patch will be needed in the next patch where tcmu needs
    to be able to look up the device in the destroy callback.

    Signed-off-by: Mike Christie
    Reviewed-by: Bart Van Assche
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     
  • Introduce target_show_cmd() and use it where appropriate. If
    transport_wait_for_tasks() takes too long, make it show the
    state of the command it is waiting for.

    (Add missing brackets around multi-line conditions - nab)

    Signed-off-by: Bart Van Assche
    Cc: Hannes Reinecke
    Cc: Christoph Hellwig
    Cc: Andy Grover
    Cc: David Disseldorp
    Signed-off-by: Nicholas Bellinger

    Bart Van Assche
     
  • With commit 25cdda95fda7 in place to address the initial login
    PDU asynchronous socket close OOPs, go ahead and kill off the
    left-over iscsi_target_do_cleanup() and ->login_cleanup_work.

    Reported-by: Mike Christie
    Cc: Mike Christie
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • Introduce the function get_unaligned_be24(). Use {get,put}_unaligned_be*()
    where appropriate. This patch does not change any functionality.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Hannes Reinecke
    Cc: Andy Grover
    Cc: David Disseldorp
    Signed-off-by: Nicholas Bellinger

    Bart Van Assche
     
  • The last user of se_device.dev_list was removed through commit
    0fd97ccf45be ("target: kill struct se_subsystem_dev"). Hence
    also remove se_device.dev_list.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Cc: Andy Grover
    Cc: David Disseldorp
    Signed-off-by: Nicholas Bellinger

    Bart Van Assche
     
  • This patch introduces support in target_submit_tmr() for locating a
    unpacked_lun from an existing se_cmd->tag during ABORT_TASK.

    When TARGET_SCF_LOOKUP_LUN_FROM_TAG is set, target_submit_tmr()
    will do the extra lookup via target_lookup_lun_from_tag() and
    subsequently invoke transport_lookup_tmr_lun() so a proper
    percpu se_lun->lun_ref is taken before workqueue dispatch into
    se_device->tmr_wq happens.

    Aside from the extra target_lookup_lun_from_tag(), the existing
    code-path remains unchanged.

    Reviewed-by: Himanshu Madhani
    Reviewed-by: Quinn Tran
    Cc: Mike Christie
    Cc: Hannes Reinecke
    Cc: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

09 Jun, 2017

2 commits

  • Instead of using a hardcoded magic value in se_lun when verifying
    a target config_item symlink source during target_fabric_mappedlun_link(),
    go ahead and use target_fabric_port_item_ops directly instead.

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

    Nicholas Bellinger
     
  • Instead of using a hardcoded magic value in se_device when verifying
    a target config_item symlink source during target_fabric_port_link(),
    go ahead and use target_core_dev_item_ops directly instead.

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

    Nicholas Bellinger
     

01 Jun, 2017

1 commit

  • This patch fixes a OOPs originally introduced by:

    commit bb048357dad6d604520c91586334c9c230366a14
    Author: Nicholas Bellinger
    Date: Thu Sep 5 14:54:04 2013 -0700

    iscsi-target: Add sk->sk_state_change to cleanup after TCP failure

    which would trigger a NULL pointer dereference when a TCP connection
    was closed asynchronously via iscsi_target_sk_state_change(), but only
    when the initial PDU processing in iscsi_target_do_login() from iscsi_np
    process context was blocked waiting for backend I/O to complete.

    To address this issue, this patch makes the following changes.

    First, it introduces some common helper functions used for checking
    socket closing state, checking login_flags, and atomically checking
    socket closing state + setting login_flags.

    Second, it introduces a LOGIN_FLAGS_INITIAL_PDU bit to know when a TCP
    connection has dropped via iscsi_target_sk_state_change(), but the
    initial PDU processing within iscsi_target_do_login() in iscsi_np
    context is still running. For this case, it sets LOGIN_FLAGS_CLOSED,
    but doesn't invoke schedule_delayed_work().

    The original NULL pointer dereference case reported by MNC is now handled
    by iscsi_target_do_login() doing a iscsi_target_sk_check_close() before
    transitioning to FFP to determine when the socket has already closed,
    or iscsi_target_start_negotiation() if the login needs to exchange
    more PDUs (eg: iscsi_target_do_login returned 0) but the socket has
    closed. For both of these cases, the cleanup up of remaining connection
    resources will occur in iscsi_target_start_negotiation() from iscsi_np
    process context once the failure is detected.

    Finally, to handle to case where iscsi_target_sk_state_change() is
    called after the initial PDU procesing is complete, it now invokes
    conn->login_work -> iscsi_target_do_login_rx() to perform cleanup once
    existing iscsi_target_sk_check_close() checks detect connection failure.
    For this case, the cleanup of remaining connection resources will occur
    in iscsi_target_do_login_rx() from delayed workqueue process context
    once the failure is detected.

    Reported-by: Mike Christie
    Reviewed-by: Mike Christie
    Tested-by: Mike Christie
    Cc: Mike Christie
    Reported-by: Hannes Reinecke
    Cc: Hannes Reinecke
    Cc: Sagi Grimberg
    Cc: Varun Prakash
    Cc: # v3.12+
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

02 May, 2017

2 commits

  • This adds initial PGR support for just TCMU, since tcmu doesn't
    have the necessary IT_NEXUS info to process PGR in userspace,
    so have those commands be processed in kernel.

    HA support is not available yet, we will work on it if this patch
    is acceptable.

    Signed-off-by: Bryant G. Ly
    Signed-off-by: Nicholas Bellinger

    Bryant G. Ly
     
  • Currently ramdisk and fileio always perform PI verification
    before and after backend IO. This approach is not very flexible.
    Because some one may want to postpone this work to other layers in
    IO stack. For example if we want to test blk_integrity_profile

    testcase:
    https://github.com/dmonakhov/xfstests/commit/dee408c868861d6b6871dbb3381facee7effdbe4
    Signed-off-by: Dmitry Monakhov
    Signed-off-by: Nicholas Bellinger

    Dmitry Monakhov
     

31 Mar, 2017

2 commits

  • Multiple threads could be writing to alua_access_state at
    the same time, or there could be multiple STPGs in flight
    (different initiators sending them or one initiator sending
    them to different ports), or a combo of both and the
    core_alua_do_transition_tg_pt calls will race with each other.

    Because from the last patches we no longer delay running
    core_alua_do_transition_tg_pt_work, there does not seem to be
    any point in running that in a workqueue. And, we always
    wait for it to complete one way or another, so we can sleep
    in this code path. So, this patch made over target-pending just adds a
    mutex and does the work core_alua_do_transition_tg_pt_work was doing in
    core_alua_do_transition_tg_pt.

    There is also no need to use an atomic for the
    tg_pt_gp_alua_access_state. In core_alua_do_transition_tg_pt we will
    test and set it under the transition mutex. And, it is a int/32 bits
    so in the other places where it is read, we will never see it partially
    updated.

    Signed-off-by: Mike Christie
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     
  • This patch fixes a set of queue-full response handling
    bugs, where outgoing responses are leaked when a fabric
    driver is propagating non -EAGAIN or -ENOMEM errors
    to target-core.

    It introduces TRANSPORT_COMPLETE_QF_ERR state used to
    signal when CHECK_CONDITION status should be generated,
    when fabric driver ->write_pending(), ->queue_data_in(),
    or ->queue_status() callbacks fail with non -EAGAIN or
    -ENOMEM errors, and data-transfer should not be retried.

    Note all fabric driver -EAGAIN and -ENOMEM errors are
    still retried indefinately with associated data-transfer
    callbacks, following existing queue-full logic.

    Also fix two missing ->queue_status() queue-full cases
    related to CMD_T_ABORTED w/ TAS status handling.

    Reported-by: Potnuri Bharat Teja
    Reviewed-by: Potnuri Bharat Teja
    Tested-by: Potnuri Bharat Teja
    Cc: Potnuri Bharat Teja
    Reported-by: Steve Wise
    Cc: Steve Wise
    Cc: Sagi Grimberg
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

30 Mar, 2017

1 commit

  • This patch closes a race between se_lun deletion during configfs
    unlink in target_fabric_port_unlink() -> core_dev_del_lun()
    -> core_tpg_remove_lun(), when transport_clear_lun_ref() blocks
    waiting for percpu_ref RCU grace period to finish, but a new
    NodeACL mappedlun is added before the RCU grace period has
    completed.

    This can happen in target_fabric_mappedlun_link() because it
    only checks for se_lun->lun_se_dev, which is not cleared until
    after transport_clear_lun_ref() percpu_ref RCU grace period
    finishes.

    This bug originally manifested as NULL pointer dereference
    OOPsen in target_stat_scsi_att_intr_port_show_attr_dev() on
    v4.1.y code, because it dereferences lun->lun_se_dev without
    a explicit NULL pointer check.

    In post v4.1 code with target-core RCU conversion, the code
    in target_stat_scsi_att_intr_port_show_attr_dev() no longer
    uses se_lun->lun_se_dev, but the same race still exists.

    To address the bug, go ahead and set se_lun>lun_shutdown as
    early as possible in core_tpg_remove_lun(), and ensure new
    NodeACL mappedlun creation in target_fabric_mappedlun_link()
    fails during se_lun shutdown.

    Reported-by: James Shen
    Cc: James Shen
    Tested-by: James Shen
    Cc: stable@vger.kernel.org # 3.10+
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

19 Mar, 2017

2 commits

  • The implicit transition time tells initiators the min time
    to wait before timing out a transition. We currently schedule
    the transition to occur in tg_pt_gp_implicit_trans_secs
    seconds so there is no room for delays. If
    core_alua_do_transition_tg_pt_work->core_alua_update_tpg_primary_metadata
    needs to write out info to a remote file, then the initiator can
    easily time out the operation.

    Signed-off-by: Mike Christie
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     
  • This patch allows passthrough backends to use the core/base LIO
    ALUA setup and state checks, but still handle the execution of
    commands.

    This will allow the target_core_user module to execute STPG and RTPG
    in userspace, and not have to duplicate the ALUA state checks, path
    information (needed so we can check if command is executable on
    specific paths) and setup (rtslib sets/updates the configfs ALUA
    interface like it does for iblock or file).

    For STPG, the target_core_user userspace daemon, tcmu-runner will
    still execute the STPG, and to update the core/base LIO state it
    will use the existing configfs interface. For RTPG, tcmu-runner
    will loop over configfs and/or cache the state.

    Signed-off-by: Mike Christie
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     

04 Mar, 2017

1 commit

  • Pull sched.h split-up from Ingo Molnar:
    "The point of these changes is to significantly reduce the
    header footprint, to speed up the kernel build and to
    have a cleaner header structure.

    After these changes the new 's typical preprocessed
    size goes down from a previous ~0.68 MB (~22K lines) to ~0.45 MB (~15K
    lines), which is around 40% faster to build on typical configs.

    Not much changed from the last version (-v2) posted three weeks ago: I
    eliminated quirks, backmerged fixes plus I rebased it to an upstream
    SHA1 from yesterday that includes most changes queued up in -next plus
    all sched.h changes that were pending from Andrew.

    I've re-tested the series both on x86 and on cross-arch defconfigs,
    and did a bisectability test at a number of random points.

    I tried to test as many build configurations as possible, but some
    build breakage is probably still left - but it should be mostly
    limited to architectures that have no cross-compiler binaries
    available on kernel.org, and non-default configurations"

    * 'WIP.sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (146 commits)
    sched/headers: Clean up
    sched/headers: Remove #ifdefs from
    sched/headers: Remove the include from
    sched/headers, hrtimer: Remove the include from
    sched/headers, x86/apic: Remove the header inclusion from
    sched/headers, timers: Remove the include from
    sched/headers: Remove from
    sched/headers: Remove from
    sched/core: Remove unused prefetch_stack()
    sched/headers: Remove from
    sched/headers: Remove the 'init_pid_ns' prototype from
    sched/headers: Remove from
    sched/headers: Remove from
    sched/headers: Remove the runqueue_is_locked() prototype
    sched/headers: Remove from
    sched/headers: Remove from
    sched/headers: Remove from
    sched/headers: Remove from
    sched/headers: Remove the include from
    sched/headers: Remove from
    ...

    Linus Torvalds
     

03 Mar, 2017

2 commits

  • It's not used by anything in anymore.

    This reduces the preprocessed size of and
    speeds up the build a bit.

    Also fix code that implicitly relied on headers included by .

    Acked-by: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Pull SCSI target updates from Nicholas Bellinger:
    "The highlights this round include:

    - enable dual mode (initiator + target) qla2xxx operation. (Quinn +
    Himanshu)

    - add a framework for qla2xxx async fabric discovery. (Quinn +
    Himanshu)

    - enable iscsi PDU DDP completion offload in cxgbit/T6 NICs. (Varun)

    - fix target-core handling of aborted failed commands. (Bart)

    - fix a long standing target-core issue NULL pointer dereference with
    active I/O LUN shutdown. (Rob Millner + Bryant + nab)"

    * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (44 commits)
    target: Add counters for ABORT_TASK success + failure
    iscsi-target: Fix early login failure statistics misses
    target: Fix NULL dereference during LUN lookup + active I/O shutdown
    target: Delete tmr from list before processing
    target: Fix handling of aborted failed commands
    uapi: fix linux/target_core_user.h userspace compilation errors
    target: export protocol identifier
    qla2xxx: Fix a warning reported by the "smatch" static checker
    target/iscsi: Fix unsolicited data seq_end_offset calculation
    target/cxgbit: add T6 iSCSI DDP completion feature
    target/cxgbit: Enable DDP for T6 only if data sequence and pdu are in order
    target/cxgbit: Use T6 specific macros to get ETH/IP hdr len
    target/cxgbit: use cxgb4_tp_smt_idx() to get smt idx
    target/iscsi: split iscsit_check_dataout_hdr()
    target: Remove command flag CMD_T_DEV_ACTIVE
    target: Remove command flag CMD_T_BUSY
    target: Move session check from target_put_sess_cmd() into target_release_cmd_kref()
    target: Inline transport_cmd_check_stop()
    target: Remove an overly chatty debug message
    target: Stop execution if CMD_T_STOP has been set
    ...

    Linus Torvalds
     

02 Mar, 2017

1 commit

  • In the following patches we are going to remove various headers
    from sched.h and other headers that sched.h includes.

    To make those patches build cleanly prepare the scene by adding
    dependencies to various files that learned to rely on those
    to-be-removed dependencies.

    These changes all make sense standalone: they add a header for
    a data type that a particular .c or .h file is using.

    Acked-by: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

27 Feb, 2017

2 commits

  • This patch introduces two counters for ABORT_TASK success +
    failure under:

    /sys/kernel/config/target/core/$HBA/$DEV/statistics/scsi_tgt_dev/

    that are useful for diagnosing various backend device latency
    and front fabric issues.

    Normally when folks see alot of aborts_complete happening,
    it means the backend device I/O completion latency is high,
    and not returning completions fast enough before host side
    timeouts trigger.

    And normally when folks see alot of aborts_no_task, it means
    completions are being posted by target-core into fabric driver
    code, but the responses aren't making it back to the host.

    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • When transport_clear_lun_ref() is shutting down a se_lun via
    configfs with new I/O in-flight, it's possible to trigger a
    NULL pointer dereference in transport_lookup_cmd_lun() due
    to the fact percpu_ref_get() doesn't do any __PERCPU_REF_DEAD
    checking before incrementing lun->lun_ref.count after
    lun->lun_ref has switched to atomic_t mode.

    This results in a NULL pointer dereference as LUN shutdown
    code in core_tpg_remove_lun() continues running after the
    existing ->release() -> core_tpg_lun_ref_release() callback
    completes, and clears the RCU protected se_lun->lun_se_dev
    pointer.

    During the OOPs, the state of lun->lun_ref in the process
    which triggered the NULL pointer dereference looks like
    the following on v4.1.y stable code:

    struct se_lun {
    lun_link_magic = 4294932337,
    lun_status = TRANSPORT_LUN_STATUS_FREE,

    .....

    lun_se_dev = 0x0,
    lun_sep = 0x0,

    .....

    lun_ref = {
    count = {
    counter = 1
    },
    percpu_count_ptr = 3,
    release = 0xffffffffa02fa1e0 ,
    confirm_switch = 0x0,
    force_atomic = false,
    rcu = {
    next = 0xffff88154fa1a5d0,
    func = 0xffffffff8137c4c0
    }
    }
    }

    To address this bug, use percpu_ref_tryget_live() to ensure
    once __PERCPU_REF_DEAD is visable on all CPUs and ->lun_ref
    has switched to atomic_t, all new I/Os will fail to obtain
    a new lun->lun_ref reference.

    Also use an explicit percpu_ref_kill_and_confirm() callback
    to block on ->lun_ref_comp to allow the first stage and
    associated RCU grace period to complete, and then block on
    ->lun_ref_shutdown waiting for the final percpu_ref_put()
    to drop the last reference via transport_lun_remove_cmd()
    before continuing with core_tpg_remove_lun() shutdown.

    Reported-by: Rob Millner
    Tested-by: Rob Millner
    Cc: Rob Millner
    Tested-by: Vaibhav Tandon
    Cc: Vaibhav Tandon
    Tested-by: Bryant G. Ly
    Cc: # v3.14+
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

24 Feb, 2017

1 commit

  • Pull rdma updates from Doug Ledford:
    "First set of updates for 4.11 kernel merge window

    - Add new Broadcom bnxt_re RoCE driver
    - rxe driver updates
    - ioctl cleanups
    - ETH_P_IBOE declaration cleanup
    - IPoIB changes
    - Add port state cache
    - Allow srpt driver to accept guids as port names in config
    - Update to hfi1 driver
    - Update to srp driver
    - Lots of misc minor changes all over"

    * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma: (114 commits)
    RDMA/bnxt_re: fix for "bnxt_en: Update to firmware interface spec 1.7.0."
    rdma_cm: fail iwarp accepts w/o connection params
    IB/srp: Drain the send queue before destroying a QP
    IB/core: Add support for draining IB_POLL_DIRECT completion queues
    IB/srp: Improve an error path
    IB/srp: Make a diagnostic message more informative
    IB/srp: Document locking conventions
    IB/srp: Fix race conditions related to task management
    IB/srp: Avoid that duplicate responses trigger a kernel bug
    IB/SRP: Avoid using IB_MR_TYPE_SG_GAPS
    RDMA/qedr: Fix some error handling
    RDMA/bnxt_re: add DCB dependency
    IB/hns: include linux/module.h
    IB/vmw_pvrdma: Expose vendor error to ULPs
    vmw_pvrdma: switch to pci_alloc_irq_vectors
    IB/hfi1: use size_t for passing array length
    IB/ipoib: Remove redudant label
    IB/ipoib: remove the unnecessary memory free
    IB/mthca: switch to pci_alloc_irq_vectors
    IB/hfi1: Code reuse with memdup_copy
    ...

    Linus Torvalds
     

19 Feb, 2017

1 commit

  • Split iscsit_check_dataout_hdr() into two functions
    1. __iscsit_check_dataout_hdr() - This function
    validates data out hdr.
    2. iscsit_check_dataout_hdr() - This function finds
    iSCSI cmd using iscsit_find_cmd_from_itt_or_dump(),
    then it calls __iscsit_check_dataout_hdr() to
    validate iSCSI hdr.

    This split is required to support Chelsio T6 iSCSI
    DDP completion feature. T6 adapters reduce number of
    completions to host by generating single completion
    for all directly placed(DDP) iSCSI pdus in a sequence,
    DDP completion contains iSCSI hdr of the last pdu in a
    sequence.

    On receiving DDP completion cxgbit driver will first
    find iSCSI cmd using iscsit_find_cmd_from_itt_or_dump()
    then updates cmd->write_data_done, cmd->next_burst_len,
    cmd->data_sn and calls __iscsit_check_dataout_hdr()
    to validate iSCSI hdr.

    (Move XRDSL check ahead of itt lookup / dump - nab)

    Signed-off-by: Varun Prakash
    Signed-off-by: Bart Van Assche
    Signed-off-by: Nicholas Bellinger

    Varun Prakash
     

09 Feb, 2017

6 commits

  • The code that tests the CMD_T_DEV_ACTIVE flag has been removed. Hence
    also remove the flag itself.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Andy Grover
    Reviewed-by: Sagi Grimberg
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Nicholas Bellinger

    Bart Van Assche
     
  • The patch that reworks task management function handling guarantees
    that target_remove_from_state_list() is always called with CMD_T_BUSY
    cleared. Since that function is the only function that tests that flag
    this means that that flag is now superfluous. Hence remove that flag.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Andy Grover
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Sagi Grimberg
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Nicholas Bellinger

    Bart Van Assche
     
  • The function transport_cmd_check_stop() has two callers. These callers
    invoke this function as follows:
    * transport_cmd_check_stop(cmd, true, false)
    * transport_cmd_check_stop(cmd, false, true)
    Hence inline this function into its callers.

    This patch does not change any functionality but improves source
    code readability.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Bryant G. Ly
    Cc: Christoph Hellwig
    Cc: Andy Grover
    Cc: David Disseldorp
    Signed-off-by: Nicholas Bellinger

    Bart Van Assche
     
  • Member tmr_lun of se_tmr_req is set but not used. Hence remove it.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Himanshu Madhani
    Cc: Giridhar Malavali
    Signed-off-by: Nicholas Bellinger

    Bart Van Assche
     
  • This patch does not change any functionality.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Cc: Nicholas A. Bellinger
    Signed-off-by: Nicholas Bellinger

    Bart Van Assche
     
  • This patch addresses a long-standing bug with multi-session
    (eg: iscsi-target + iser-target) se_node_acl dynamic free
    withini transport_deregister_session().

    This bug is caused when a storage endpoint is configured with
    demo-mode (generate_node_acls = 1 + cache_dynamic_acls = 1)
    initiators, and initiator login creates a new dynamic node acl
    and attaches two sessions to it.

    After that, demo-mode for the storage instance is disabled via
    configfs (generate_node_acls = 0 + cache_dynamic_acls = 0) and
    the existing dynamic acl is never converted to an explicit ACL.

    The end result is dynamic acl resources are released twice when
    the sessions are shutdown in transport_deregister_session().

    If the storage instance is not changed to disable demo-mode,
    or the dynamic acl is converted to an explict ACL, or there
    is only a single session associated with the dynamic ACL,
    the bug is not triggered.

    To address this big, move the release of dynamic se_node_acl
    memory into target_complete_nacl() so it's only freed once
    when se_node_acl->acl_kref reaches zero.

    (Drop unnecessary list_del_init usage - HCH)

    Reported-by: Rob Millner
    Tested-by: Rob Millner
    Cc: Rob Millner
    Cc: stable@vger.kernel.org # 4.1+
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

28 Jan, 2017

1 commit

  • Port and ACL information must be configured before an initiator
    logs in. Make it possible to configure this information before
    a subnet prefix has been assigned to a port by not only accepting
    GIDs as target port and initiator port names but by also accepting
    port GUIDs.

    Add a 'priv' member to struct se_wwn to allow target drivers to
    associate their own data with struct se_wwn.

    Reported-by: Doug Ledford
    References: http://www.spinics.net/lists/linux-rdma/msg39505.html
    Signed-off-by: Bart Van Assche
    Cc: Christoph Hellwig
    Cc: Nicholas Bellinger
    Signed-off-by: Doug Ledford

    Bart Van Assche