06 Dec, 2011

23 commits

  • Fix the following compile warning with hex2bin() usage:

    drivers/target/iscsi/iscsi_target_auth.c: In function ‘chap_string_to_hex’:
    drivers/target/iscsi/iscsi_target_auth.c:35: warning: ignoring return value of ‘hex2bin’, declared with attribute warn_unused_result

    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • If an attribute is present (but not yet supported) it should be OK
    to write 0 (a no-op) to the attribute.

    This is an issue because userspace should be able to save and restore all
    set attribute values without error.

    Signed-off-by: Andy Grover
    Signed-off-by: Nicholas Bellinger

    Andy Grover
     
  • So the code assumes that the sg list is only a array while in reality
    loopback SGL memory via scsi_cmnd into target-core may be already
    chained. This patch converts ramdisk code to use sg_miter logic from
    scatterlist.h in order to properly support passthrough SGL usage with
    transport_generic_map_mem_to_cmd() via loopback.

    With this patch the bug goes away. However after umount/mount of the
    device my files are gone. So something is still not right. After looking
    at it for a while I decided to rewrite the that part of the code and now
    things do work for me.

    For reference:
    - http://article.gmane.org/gmane.linux.scsi.target.devel/595
    the sg_next() conversion
    - http://article.gmane.org/gmane.linux.scsi.target.devel/602
    the rewrite of the copy code

    (nab: Fix compile warning in rd_MEMCPY)

    Signed-off-by: Sebastian Andrzej Siewior
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Sebastian Andrzej Siewior
     
  • Breakout rd_MEMCPY_do_task() usage of do_div() to tmp value during
    rd_request->rd_page assignment.

    Signed-off-by: Sebastian Andrzej Siewior
    Signed-off-by: Nicholas Bellinger

    Sebastian Andrzej Siewior
     
  • Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • This patch changes fileio to use for_each_sg() when walking se_task->task_sg
    memory passed into from loopback LLD struct scsi_cmnd scatterlist memory.

    This addresses an issue where FILEIO backends with loopback where hitting the
    following OOPs with mkfs.ext2:

    |kernel BUG at include/linux/scatterlist.h:97!
    |invalid opcode: 0000 [#1] PREEMPT SMP
    |Modules linked in: sd_mod tcm_loop target_core_stgt scsi_tgt target_core_pscsi target_core_file target_core_iblock target_core_mod configfs scsi_mod
    |
    |Pid: 671, comm: LIO_fileio Not tainted 3.1.0-rc10+ #139 Bochs Bochs
    |EIP: 0060:[] EFLAGS: 00010202 CPU: 0
    |EIP is at fd_do_task+0x396/0x420 [target_core_file]
    | [] __transport_execute_tasks+0xd4/0x190 [target_core_mod]
    | [] transport_execute_tasks+0x3c/0xf0 [target_core_mod]
    |EIP: [] fd_do_task+0x396/0x420 [target_core_file] SS:ESP 0068:dea47e90

    Signed-off-by: Sebastian Andrzej Siewior
    Cc: Christoph Hellwig
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Sebastian Andrzej Siewior
     
  • Some are never used, some are set but never read, dev_hoq_count is
    incremented and decremented, but never read.

    Signed-off-by: Joern Engel
    Signed-off-by: Nicholas Bellinger

    Jörn Engel
     
  • The LSB of the page length is at offset 3, not 2.

    Signed-off-by: Roland Dreier
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Roland Dreier
     
  • SBC-3 says:

    A TRANSFER LENGTH field set to zero specifies that 256 logical
    blocks shall be written. Any other value specifies the number
    of logical blocks that shall be written.

    The old code was always just returning the value in the TRANSFER LENGTH
    byte. Fix this to return 256 if the byte is 0.

    Signed-off-by: Roland Dreier
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Roland Dreier
     
  • IO commands with a TRANSFER LENGTH of 0 are not an error; for example,
    for READ (10) and WRITE (10), SBC-3 says:

    A TRANSFER LENGTH field set to zero specifies that no logical blocks
    shall be read. This condition shall not be considered an error.

    In case we have nothing to do, just complete the command with good status.

    Signed-off-by: Roland Dreier
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Roland Dreier
     
  • The semantic patch that makes this change is available
    in scripts/coccinelle/api/memdup.cocci.

    Signed-off-by: Thomas Meyer
    Signed-off-by: Nicholas Bellinger

    Thomas Meyer
     
  • This patch sets the missing ISCSI_FLAG_CMD_FINAL bit in
    iscsit_send_task_mgt_rsp() for a struct iscsi_tm_rsp PDU.

    This usage is hardcoded for all TM response PDUs in RFC-3720
    section 10.6.

    Reported-by: whucecil
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch fixes iscsi-target handling of underflow where residual data is
    causing an OOPs by using the incorrect iscsi_cmd_t->data_length initially
    assigned in iscsit_allocate_se_cmd(). It resets iscsi_cmd_t->data_length
    from se_cmd_t->data_length after transport_generic_allocate_tasks()
    has been invoked in iscsit_handle_scsi_cmd() RX context, and converts
    iscsi_cmd->residual_count usage to access iscsi_cmd->se_cmd.residual_count
    to get the proper residual count set by target-core.

    Reported-by:
    Cc: Christoph Hellwig
    Cc: Andy Grover
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch changes transport_generic_map_mem_to_cmd() to reject SCSI data
    overflow and to send exception status with CHECK_CONDITION + TCM_INVALID_CDB_FIELD
    for fabrics that are passing a pre-populated struct scatterlist (eg: tcm_loop
    and iscsi-target) being mapped into se_cmd->t_data_sg and se_cmd->t_data_nents.

    This addresses an OOPs where transport_allocate_data_tasks() would walk
    the incorrect post OVERFLOW cmd->data_length value beyond the end of
    the passed scatterlist.

    Cc: Christoph Hellwig
    Cc: Andy Grover
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • And use a SCF_BIDI flag instead.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • And use a SCF_FUA flag instead.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • We never walk ordered_cmd_list in the se_device, so remove all code related
    to supporting it.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • We already have a perfectly valid se_device pointer in the command, so
    remove the mostly useless duplicates.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • This patch removes config_item_name() informational usage of
    TFO->free_wwn() treewide in loopback, tcm_fc, ib_srpt and
    tcm_vhost module code.

    Using v4 target_core_fabric_configfs.c logic, a fabric call for
    config_item_name() in TFO->drop_wwn() context returns NULL as
    target_fabric_drop_wwn() invoking config_item_put() ->
    config_group_put() will release fabric_port->port_wwn.wwn_group
    before the last config_item_put() -> TFO->drop_wwn() is
    invoked.

    Reported-by: Bart Van Assche
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • Signed-off-by: Roland Dreier
    Signed-off-by: Nicholas Bellinger

    Roland Dreier
     
  • While testing ib_srpt I noticed that the target system became
    rather unresponsive during intensive I/O. The patch below made
    my target system responsive again during I/O without decreasing
    performance.

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

    Bart Van Assche
     
  • This patch adds missing kfree() for an allocation in iscsi_login_zero_tsih_s1()
    code, and make transport_init_session() check for IS_ERR() returns.

    Reported-by: Dan Carpenter
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch removes legacy usage of PYX_TRANSPORT_* return codes in a number
    of locations and addresses cases where transport_generic_request_failure()
    was returning the incorrect sense upon CHECK_CONDITION status after the
    v3.1 converson to use errno return codes.

    This includes the conversion of transport_generic_request_failure() to
    process cmd->scsi_sense_reason and handle extra TCM_RESERVATION_CONFLICT
    before calling transport_send_check_condition_and_sense() to queue up
    response status. It also drops PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES legacy
    usgae, and returns TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE w/ a response
    for these cases.

    transport_generic_allocate_tasks(), transport_generic_new_cmd(), backend
    SCF_SCSI_DATA_SG_IO_CDB ->do_task(), and emulated ->execute_task() have
    all been updated to set se_cmd->scsi_sense_reason and return errno codes
    universally upon failure. This includes cmd->scsi_sense_reason assignment
    in target_core_alua.c, target_core_pr.c and target_core_cdb.c emulation code.

    Finally it updates fabric modules to remove the legacy usage, and for
    TFO->new_cmd_map() callers forwards return values outside of fabric code.
    iscsi-target has also been updated to remove a handful of special cases
    related to the cleanup and signaling QUEUE_FULL handling w/ ft_write_pending()

    (v2: Drop extra SCF_SCSI_CDB_EXCEPTION check during failure from
    transport_generic_new_cmd, and re-add missing task->task_error_status
    assignment in transport_complete_task)

    Cc: Christoph Hellwig
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

07 Nov, 2011

2 commits

  • * 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux: (230 commits)
    Revert "tracing: Include module.h in define_trace.h"
    irq: don't put module.h into irq.h for tracking irqgen modules.
    bluetooth: macroize two small inlines to avoid module.h
    ip_vs.h: fix implicit use of module_get/module_put from module.h
    nf_conntrack.h: fix up fallout from implicit moduleparam.h presence
    include: replace linux/module.h with "struct module" wherever possible
    include: convert various register fcns to macros to avoid include chaining
    crypto.h: remove unused crypto_tfm_alg_modname() inline
    uwb.h: fix implicit use of asm/page.h for PAGE_SIZE
    pm_runtime.h: explicitly requires notifier.h
    linux/dmaengine.h: fix implicit use of bitmap.h and asm/page.h
    miscdevice.h: fix up implicit use of lists and types
    stop_machine.h: fix implicit use of smp.h for smp_processor_id
    of: fix implicit use of errno.h in include/linux/of.h
    of_platform.h: delete needless include
    acpi: remove module.h include from platform/aclinux.h
    miscdevice.h: delete unnecessary inclusion of module.h
    device_cgroup.h: delete needless include
    net: sch_generic remove redundant use of
    net: inet_timewait_sock doesnt need
    ...

    Fix up trivial conflicts (other header files, and removal of the ab3550 mfd driver) in
    - drivers/media/dvb/frontends/dibx000_common.c
    - drivers/media/video/{mt9m111.c,ov6650.c}
    - drivers/mfd/ab3550-core.c
    - include/linux/dmaengine.h

    Linus Torvalds
     
  • * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending:
    target: use ->exectute_task for all CDB emulation
    target: remove SCF_EMULATE_CDB_ASYNC
    target: refactor transport_emulate_control_cdb
    target: pass the se_task to the CDB emulation callback
    target: split core_scsi3_emulate_pr
    target: split core_scsi2_emulate_crh
    target: Add generic active I/O shutdown logic
    target: add back error handling in transport_complete_task
    target/pscsi: blk_make_request() returns an ERR_PTR()
    target: Remove core TRANSPORT_FREE_CMD_INTR usage
    target: Make TFO->check_stop_free return free status
    iscsi-target: Fix non-immediate TMR handling
    iscsi-target: Add missing CMDSN_LOWER_THAN_EXP check in iscsit_handle_scsi_cmd
    target: Avoid double list_del for aborted se_tmr_req
    target: Minor cleanups to core_tmr_drain_tmr_list
    target: Fix wrong se_tmr being added to drain_tmr_list
    target: Fix incorrect se_cmd assignment in core_tmr_drain_tmr_list
    target: Check -ENOMEM to signal QUEUE_FULL from fabric callbacks
    tcm_loop: Add explict read buffer memset for SCF_SCSI_CONTROL_SG_IO_CDB
    target: Fix compile warning w/ missing module.h include

    Linus Torvalds
     

04 Nov, 2011

7 commits

  • Instead of calling into transport_emulate_control_cdb from
    __transport_execute_tasks for some CDBs always set up ->exectute_tasks
    in the command sequence and use it uniformly.

    (nab: Add default passthrough break for SERVICE_ACTION_IN)

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • All ->execute_task instances now need to complete the I/O explicitly,
    which can either happen synchronously or asynchronously.

    Note that a lot of the CDB emulations appear to return success even if
    some lowlevel operations failed. Given that this is an existing issue
    this patch doesn't change that fact.

    (nab: Adding missing switch breaks in PR-IN + PR_OUT)

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • Encapsulate each CDB emulation into a function of its own, to prepare
    setting ->exectute_task to these routines.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • We want to be able to handle all CDBs through it and remove hacks like
    always using the first task in a CDB in target_report_luns.

    Also rename the callback to ->execute_task to better describe its use.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • Split core_scsi2_emulate_crh into one routine each for the
    PERSISTENT_RESERVE_IN and PERSISTENT_RESERVE_OUT side.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • Split core_scsi2_emulate_crh into one routine each for the reserve and
    release side. The common code now is in a helper called by both
    routines.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • This patch adds the initial pieces of generic active I/O shutdown logic.
    This is intended to be a 'opt-in' feature for fabric modules that
    includes the following functions to provide a mechinism for fabric
    modules to track se_cmd via se_session->sess_cmd_list:

    *) target_get_sess_cmd() - Add se_cmd to sess->sess_cmd_list, called
    from fabric module incoming I/O path.
    *) target_put_sess_cmd() - Check for completion or drop se_cmd from
    ->sess_cmd_list
    *) target_splice_sess_cmd_list() - Splice active I/O list from
    ->sess_cmd_list to ->sess_wait_list, can called with HW fabric
    lock held.
    *) target_wait_for_sess_cmds() - Walk ->sess_wait_list waiting on
    individual ->cmd_wait_comp. Optional transport_wait_for_tasks()
    call.

    target_splice_sess_cmd_list() is allowed to be called under HW fabric
    lock, and performs the splice into se_sess->sess_wait_list and set
    se_cmd->cmd_wait_set. Then target_wait_for_sess_cmds() walks the list
    waiting for individual target_put_sess_cmd() fabric callbacks to
    complete.

    It also adds TFO->check_release_cmd() to split the completion and memory
    release calls, where a fabric module uses target_put_sess_cmd() to check
    for I/O completion during session shutdown. This is currently pushed out
    into fabric modules as current fabric code may sleep here waiting for
    TFO->check_stop_free() to complete in main response path, and because
    target_wait_for_sess_cmds() calling TFO->release_cmd() to free fabric
    descriptor memory directly.

    Cc: Christoph Hellwig
    Cc: Roland Dreier
    Signed-off-by: Nicholas A. Bellinger

    Nicholas Bellinger
     

03 Nov, 2011

1 commit

  • The commit

    target: use a workqueue for I/O completions

    accidentally removed setting t_tasks_failed in transport_complete_task.
    Add it back in a slightly cleaner way; now it is set for every failed task
    instead of special casing the last one completing by using the success
    argument directly for it.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas A. Bellinger

    Christoph Hellwig
     

02 Nov, 2011

6 commits

  • The check is wrong here because blk_make_request() returns an
    ERR_PTR() and it doesn't return NULL.

    Signed-off-by: Dan Carpenter
    Signed-off-by: Nicholas A. Bellinger

    Dan Carpenter
     
  • This patch drops TRANSPORT_FREE_CMD_INTR usage from target core, which
    includes the removal of transport_generic_free_cmd_intr() symbol,
    TRANSPORT_FREE_CMD_INTR usage in transport_processing_thread(), and
    special case LUN_RESET handling to skip TRANSPORT_FREE_CMD_INTR processing
    in core_tmr_drain_cmd_list(). We now expect that fabric modules will
    use an internal workqueue to provide process context when releasing
    se_cmd descriptor resources via transport_generic_free_cmd().

    Reported-by: Christoph Hellwig
    Cc: Christoph Hellwig
    Cc: Roland Dreier
    Cc: Madhuranath Iyengar
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch converts target_core_fabric_ops->check_stop_free() usage in
    transport_cmd_check_stop() and associated fabric module usage to
    return '1' when the passed se_cmd has been released directly within
    ->check_stop_free(), or return '0' when the passed se_cmd has not
    been released.

    This addresses an issue where transport_cmd_finish_abort() ->
    transport_cmd_check_stop_to_fabric() was leaking descriptors during
    LUN_RESET for modules using ->check_stop_free(), but not directly
    releasing se_cmd in all cases.

    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch addresses two issues with non immediate TMR handling in
    iscsit_handle_task_mgt_cmd(). The first involves breakage due to
    v3.1-rc conversion of iscsit_sequence_cmd(), which upon good status
    would hit the iscsit_add_reject_from_cmd() block of code. This patch
    adds an explict check for CMDSN_ERROR_CANNOT_RECOVER.

    The second adds a check to return when non immediate TMR operation is
    detected after iscsit_ack_from_expstatsn(), as iscsit_sequence_cmd()
    -> iscsit_execute_cmd() will have called transport_generic_handle_tmr()
    for the non immediate TMR case already.

    Cc: Andy Grover
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds a missing CMDSN_LOWER_THAN_EXP return check for
    iscsit_sequence_cmd() in iscsit_handle_scsi_cmd() that was incorrectly
    dropped during the v3.1-rc cleanups to use iscsit_sequence_cmd().

    Cc: Andy Grover
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • After the list_del() in core_tmr_drain_tmr_list(),
    core_tmr_release_req() would list_del() the same object again.

    Call graph:
    core_tmr_drain_tmr_list
    transport_cmd_finish_abort_tmr
    transport_generic_remove
    transport_free_se_cmd
    core_tmr_release_req

    So use list_del_init(), as list_del() of an initialized list_head is
    safe and essentially a nop. In the CONFIG_DEBUG_LIST case, list_del()
    actually poisons the list_head, but that is fine as we free the object
    directly afterwards.

    Signed-off-by: Joern Engel
    Cc: stable@kernel.org
    Signed-off-by: Nicholas Bellinger

    Joern Engel
     

01 Nov, 2011

1 commit