26 Jan, 2019

1 commit

  • [ Upstream commit ad669505c4e9db9af9faeb5c51aa399326a80d91 ]

    A session must only be released after all code that accesses the session
    structure has finished. Make sure that this is the case by introducing a
    new command counter per session that is only decremented after the
    .release_cmd() callback has finished. This patch fixes the following crash:

    BUG: KASAN: use-after-free in do_raw_spin_lock+0x1c/0x130
    Read of size 4 at addr ffff8801534b16e4 by task rmdir/14805
    CPU: 16 PID: 14805 Comm: rmdir Not tainted 4.18.0-rc2-dbg+ #5
    Call Trace:
    dump_stack+0xa4/0xf5
    print_address_description+0x6f/0x270
    kasan_report+0x241/0x360
    __asan_load4+0x78/0x80
    do_raw_spin_lock+0x1c/0x130
    _raw_spin_lock_irqsave+0x52/0x60
    srpt_set_ch_state+0x27/0x70 [ib_srpt]
    srpt_disconnect_ch+0x1b/0xc0 [ib_srpt]
    srpt_close_session+0xa8/0x260 [ib_srpt]
    target_shutdown_sessions+0x170/0x180 [target_core_mod]
    core_tpg_del_initiator_node_acl+0xf3/0x200 [target_core_mod]
    target_fabric_nacl_base_release+0x25/0x30 [target_core_mod]
    config_item_release+0x9c/0x110 [configfs]
    config_item_put+0x26/0x30 [configfs]
    configfs_rmdir+0x3b8/0x510 [configfs]
    vfs_rmdir+0xb3/0x1e0
    do_rmdir+0x262/0x2c0
    do_syscall_64+0x77/0x230
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    Cc: Nicholas Bellinger
    Cc: Mike Christie
    Cc: Christoph Hellwig
    Cc: David Disseldorp
    Cc: Hannes Reinecke
    Signed-off-by: Bart Van Assche
    Signed-off-by: Martin K. Petersen
    Signed-off-by: Sasha Levin

    Bart Van Assche
     

03 Aug, 2018

3 commits

  • This adds a function to remove a session which should be used by drivers
    that use target_setup_session. The next patches will convert the target
    drivers to use this new function.

    Signed-off-by: Mike Christie
    Reviewed-by: Bart Van Assche
    Reviewed-by: Christoph Hellwig
    Cc: Chris Boot
    Cc: Bryant G. Ly
    Cc: Michael Cyr
    Cc:
    Cc: Johannes Thumshirn
    Cc: Felipe Balbi
    Cc: Sebastian Andrzej Siewior
    Cc: Andrzej Pietrasiewicz
    Cc: Michael S. Tsirkin
    Cc: Juergen Gross
    Signed-off-by: Martin K. Petersen

    Mike Christie
     
  • Rename target_alloc_session to target_setup_session to avoid confusion with
    the other transport session allocation function that only allocates the
    session and because the target_alloc_session does so much more. It
    allocates the session, sets up the nacl and registers the session.

    The next patch will then add a remove function to match the setup in this
    one, so it should make sense for all drivers, except iscsi, to just call
    those 2 functions to setup and remove a session.

    iscsi will continue to be the odd driver.

    Signed-off-by: Mike Christie
    Reviewed-by: Bart Van Assche
    Reviewed-by: Christoph Hellwig
    Cc: Chris Boot
    Cc: Bryant G. Ly
    Cc: Michael Cyr
    Cc:
    Cc: Johannes Thumshirn
    Cc: Felipe Balbi
    Cc: Sebastian Andrzej Siewior
    Cc: Andrzej Pietrasiewicz
    Cc: Michael S. Tsirkin
    Cc: Juergen Gross
    Signed-off-by: Martin K. Petersen

    Mike Christie
     
  • transport_init_session_tags is only called from target_core_transport.c so
    make it static.

    Signed-off-by: Mike Christie
    Reviewed-by: Bart Van Assche
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Martin K. Petersen

    Mike Christie
     

31 Jul, 2018

1 commit

  • This just adds a helper function to check if a device is configured and it
    converts the target users to use it. The next patch will add a backend
    module user so those types of modules do not have to know the lio core
    details.

    Signed-off-by: Mike Christie
    Reviewed-by: Xiubo Li
    Signed-off-by: Martin K. Petersen

    Mike Christie
     

03 Jul, 2018

6 commits

  • se_dev_entry.ua_count is only used to check whether or not
    se_dev_entry.ua_list is empty. Use list_empty_careful() instead. Checking
    whether or not ua_list is empty without holding the lock that protects that
    list is fine because the code that dequeues from that list will check again
    whether or not that list is empty.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Mike Christie
    Cc: Mike Christie
    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Signed-off-by: Martin K. Petersen

    Bart Van Assche
     
  • Since most target drivers do not use the second fabric_make_tpg() argument
    ("group") and since it is trivial to derive the group pointer from the wwn
    pointer, do not pass the group pointer to fabric_make_tpg().

    Signed-off-by: Bart Van Assche
    Reviewed-by: Mike Christie
    Cc: Felipe Balbi
    Cc: Hannes Reinecke
    Cc: Christoph Hellwig
    Signed-off-by: Martin K. Petersen

    Bart Van Assche
     
  • Instead of embedding the completion that is used for waiting for command
    completion in struct se_cmd, let the context that waits for command
    completion allocate it. This makes it possible to have a single code path
    for non-aborted and aborted commands in target_release_cmd_kref() and
    avoids that transport_generic_free_cmd() has to call
    cmd->se_tfo->release_cmd() directly. This patch does not change any
    functionality. Note: transport_generic_free_cmd() only waits until the
    se_cmd reference count has reached zero after it has set both
    CMD_T_FABRIC_STOP and CMD_T_ABORTED.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Mike Christie
    Cc: Hannes Reinecke
    Cc: Christoph Hellwig
    Signed-off-by: Martin K. Petersen

    Bart Van Assche
     
  • Target drivers must call target_sess_cmd_list_set_waiting() and
    target_wait_for_sess_cmds() before freeing a session. Since freeing a
    session is only safe after all commands that are associated with a session
    have finished, make target_wait_for_sess_cmds() also wait for commands that
    are being aborted. Instead of setting a flag in each pending command from
    target_sess_cmd_list_set_waiting() and waiting in
    target_wait_for_sess_cmds() on a per-command completion, only set a
    per-session flag in the former function and wait on a per-session
    completion in the latter function. This change is safe because once a SCSI
    initiator system has submitted a command a target system is always allowed
    to execute it to completion. See also commit 0f4a943168f3 ("target: Fix
    remote-port TMR ABORT + se_cmd fabric stop").

    This patch is based on the following two patches:

    * Bart Van Assche, target: Simplify session shutdown code, February 19, 2015
    (https://github.com/bvanassche/linux/commit/8df5463d7d7619f2f1b70cfe5172eaef0aa52815).

    * Christoph Hellwig, target: Rework session shutdown code, December 7, 2015
    (http://thread.gmane.org/gmane.linux.scsi.target.devel/10695).

    Signed-off-by: Bart Van Assche
    Reviewed-by: Mike Christie
    Cc: Hannes Reinecke
    Cc: Christoph Hellwig
    Cc: Sagi Grimberg
    Signed-off-by: Martin K. Petersen

    Bart Van Assche
     
  • Other than initializing xcopy_pt_sess.sess_wait_list, this patch does not
    change any functionality.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Mike Christie
    Cc: Mike Christie
    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Signed-off-by: Martin K. Petersen

    Bart Van Assche
     
  • Signed-off-by: Bart Van Assche
    Reviewed-by: Mike Christie
    Cc: Mike Christie
    Cc: Hannes Reinecke
    Cc: Christoph Hellwig
    Signed-off-by: Martin K. Petersen

    Bart Van Assche
     

27 Jun, 2018

1 commit


20 Jun, 2018

2 commits

  • The sbitmap and the percpu_ida perform essentially the same task,
    allocating tags for commands. The sbitmap outperforms the percpu_ida as
    documented here: https://lkml.org/lkml/2014/4/22/553

    The sbitmap interface is a little harder to use, but being able to remove
    the percpu_ida code and getting better performance justifies the additional
    complexity.

    Signed-off-by: Matthew Wilcox
    Acked-by: Felipe Balbi # f_tcm
    Reviewed-by: Jens Axboe
    Signed-off-by: Martin K. Petersen

    Matthew Wilcox
     
  • Introduce target_free_tag() and convert all drivers to use it.

    Signed-off-by: Matthew Wilcox
    Reviewed-by: Jens Axboe
    Signed-off-by: Martin K. Petersen

    Matthew Wilcox
     

19 May, 2018

1 commit

  • When a tape drive is exported via LIO using the pscsi module, a read
    that requests more bytes per block than the tape can supply returns an
    empty buffer. This is because the pscsi pass-through target module sees
    the "ILI" illegal length bit set and thinks there is no reason to return
    the data.

    This is a long-standing transport issue, since it assumes that no data
    need be returned under a check condition, which isn't always the case
    for tape.

    Add in a check for tape reads with the ILI, EOM, or FM bits set, with a
    sense code of NO_SENSE, treating such cases as if the read
    succeeded. The layered tape driver then "does the right thing" when it
    gets such a response.

    Signed-off-by: Bodo Stroesser
    Signed-off-by: Lee Duncan
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Martin K. Petersen

    Lee Duncan
     

17 Jan, 2018

1 commit

  • This patch adds a new group of files that are to be used to
    have the kernel module execution some action. The next patch
    will have target_core_user use the group/files to be able to block
    a device and to reset its memory buffer used to pass commands
    between user/kernel space.

    This type of file is different from the existing device attributes
    in that they may be write only and when written to they result in
    the kernel module executing some function. These need to be
    separate from the normal device attributes which get/set device
    values so userspace can continue to loop over all the attribs and
    get/set them during initialization.

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

    Mike Christie
     

13 Jan, 2018

1 commit


25 Nov, 2017

1 commit

  • Pull SCSI target updates from Nicholas Bellinger:

    "This series is predominantly bug-fixes, with a few small improvements
    that have been outstanding over the last release cycle.

    As usual, the associated bug-fixes have CC' tags for stable.

    Also, things have been particularly quiet wrt new developments the
    last months, with most folks continuing to focus on stability atop 4.x
    stable kernels for their respective production configurations.

    Also at this point, the stable trees have been synced up with
    mainline. This will continue to be a priority, as production users
    tend to run exclusively atop stable kernels, a few releases behind
    mainline.

    The highlights include:

    - Fix PR PREEMPT_AND_ABORT null pointer dereference regression in
    v4.11+ (tangwenji)

    - Fix OOPs during removing TCMU device (Xiubo Li + Zhang Zhuoyu)

    - Add netlink command reply supported option for each device (Kenjiro
    Nakayama)

    - cxgbit: Abort the TCP connection in case of data out timeout (Varun
    Prakash)

    - Fix PR/ALUA file path truncation (David Disseldorp)

    - Fix double se_cmd completion during ->cmd_time_out (Mike Christie)

    - Fix QUEUE_FULL + SCSI task attribute handling in 4.1+ (Bryant Ly +
    nab)

    - Fix quiese during transport_write_pending_qf endless loop (nab)

    - Avoid early CMD_T_PRE_EXECUTE failures during ABORT_TASK in 3.14+
    (Don White + nab)"

    * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (35 commits)
    tcmu: Add a missing unlock on an error path
    tcmu: Fix some memory corruption
    iscsi-target: Fix non-immediate TMR reference leak
    iscsi-target: Make TASK_REASSIGN use proper se_cmd->cmd_kref
    target: Avoid early CMD_T_PRE_EXECUTE failures during ABORT_TASK
    target: Fix quiese during transport_write_pending_qf endless loop
    target: Fix caw_sem leak in transport_generic_request_failure
    target: Fix QUEUE_FULL + SCSI task attribute handling
    iSCSI-target: Use common error handling code in iscsi_decode_text_input()
    target/iscsi: Detect conn_cmd_list corruption early
    target/iscsi: Fix a race condition in iscsit_add_reject_from_cmd()
    target/iscsi: Modify iscsit_do_crypto_hash_buf() prototype
    target/iscsi: Fix endianness in an error message
    target/iscsi: Use min() in iscsit_dump_data_payload() instead of open-coding it
    target/iscsi: Define OFFLOAD_BUF_SIZE once
    target: Inline transport_put_cmd()
    target: Suppress gcc 7 fallthrough warnings
    target: Move a declaration of a global variable into a header file
    tcmu: fix double se_cmd completion
    target: return SAM_STAT_TASK_SET_FULL for TCM_OUT_OF_RESOURCES
    ...

    Linus Torvalds
     

15 Nov, 2017

1 commit

  • Pull configfs updates from Christoph Hellwig:
    "A couple of configfs cleanups:

    - proper use of the bool type (Thomas Meyer)

    - constification of struct config_item_type (Bhumika Goyal)"

    * tag 'configfs-for-4.15' of git://git.infradead.org/users/hch/configfs:
    RDMA/cma: make config_item_type const
    stm class: make config_item_type const
    ACPI: configfs: make config_item_type const
    nvmet: make config_item_type const
    usb: gadget: configfs: make config_item_type const
    PCI: endpoint: make config_item_type const
    iio: make function argument and some structures const
    usb: gadget: make config_item_type structures const
    dlm: make config_item_type const
    netconsole: make config_item_type const
    nullb: make config_item_type const
    ocfs2/cluster: make config_item_type const
    target: make config_item_type const
    configfs: make ci_type field, some pointers and function arguments const
    configfs: make config_item_type const
    configfs: Fix bool initialization/comparison

    Linus Torvalds
     

08 Nov, 2017

1 commit

  • 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
    Cc: stable@vger.kernel.org # 3.14+
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

05 Nov, 2017

1 commit

  • If a PERSISTENT RESERVE OUT command with a REGISTER service action or a
    REGISTER AND IGNORE EXISTING KEY service action or REGISTER AND MOVE
    service action is attempted, but there are insufficient device server
    resources to complete the operation, then the command shall be terminated
    with CHECK CONDITION status, with the sense key set to ILLEGAL REQUEST,and
    the additonal sense code set to INSUFFICIENT REGISTRATION RESOURCES.

    Signed-off-by: tangwenji
    Signed-off-by: Nicholas Bellinger

    tangwenji
     

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
     

19 Oct, 2017

1 commit

  • Make these structures const as they are either passed to the functions
    having the argument as const or stored as a reference in the "ci_type"
    const field of a config_item structure.

    Done using Coccinelle.

    Signed-off-by: Bhumika Goyal
    Signed-off-by: Christoph Hellwig

    Bhumika Goyal
     

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

1 commit

  • 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