14 Dec, 2012

1 commit

  • Thanks for reviews, looking a lot better.

    ---- 8< ----

    Initiator access config could be easier. The way other storage vendors
    have addressed this is to support initiator groups: the admin adds
    initiator WWNs to the group, and then LUN permissions can be granted for
    the entire group at once.

    Instead of changing ktarget's configfs interface, this patch keeps
    the configfs interface per-initiator-wwn and just adds a 'tag' field
    for each. This should be enough for user tools like targetcli to group
    initiator ACLs and sync their configurations.

    acl_tag is not used internally, but needs to be kept in configfs so that
    all user tools can avoid dependencies on each other.

    Code tested to work, although userspace pieces still to be implemented.

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

    Andy Grover
     

05 Dec, 2012

1 commit

  • This patch adds [dev,lun]_link_magic value assignment + checks within generic
    target_fabric_port_link() and target_fabric_mappedlun_link() code to ensure
    destination config_item *target_item sent from configfs_symlink() ->
    config_item_operations->allow_link() is the underlying se_device->dev_group
    and se_lun->lun_group that we expect to symlink.

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

    Nicholas Bellinger
     

28 Nov, 2012

1 commit

  • We already expect TFO->get_blocks() to return sector_t for zero value case
    when doing WRITE_SAME to the end of the backend device, so go ahead and return
    sector_t from spc_get_write_same_sectors() to handle this case properly.

    Also, update the single iblock_execute_write_same() caller of this code.

    Cc: Christoph Hellwig
    Cc: Martin K. Petersen
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

16 Nov, 2012

2 commits

  • This patch adds a new max_write_same_len device attribute for use with
    WRITE_SAME w/ UNMAP=0 backend emulation. This can be useful for
    lowering the default backend value (IBLOCK uses 0xFFFF).

    Also, update block limits VPD emulation code in spc_emulate_evpd_b0() to
    report MAXIMUM WRITE SAME LENGTH, and enforce max_write_same_len during
    sbc_parse() -> sbc_setup_write_same() CDB sanity checking for all emulated
    WRITE_SAME w/ UNMAP=0 cases.

    (Robert: Move max_write_same_len check in sbc_setup_write_same() to
    check both WRITE_SAME w/ UNMAP=1 and w/ UNMAP=0 cases)

    Cc: Christoph Hellwig
    Cc: Martin K. Petersen
    Cc: Robert Elliott
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds a new sbc_ops->execute_write_same_unmap() caller for use
    with WRITE_SAME w/ UNMAP=1, and performs the ->execute_cmd() setup based
    this bit within sbc_setup_write_same() code.

    Also, makes the changes in sbc_parse_cdb() to handle a sense_reason_t
    return from sbc_setup_write_same() on error.

    Reported-by: Christoph Hellwig
    Cc: Martin K. Petersen
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

07 Nov, 2012

9 commits


03 Oct, 2012

1 commit

  • This patch adds a new target_submit_cmd_map_sgls() to pass pre-allocated
    SGL memory using transport_generic_map_mem_to_cmd() logic into the generic
    target submit I/O codepath.

    It also adds a target_submit_cmd() wrapper around target_submit_cmd_map_sgls()
    for existing fabric code that already assumes internal target-core SGL memory
    allocation.

    (v2: Rename to target_submit_cmd_map_sgls + drop TARGET_SCF_MAP_MEM flag
    in favor of non zero sgl_count check)

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

    Nicholas Bellinger
     

18 Sep, 2012

3 commits

  • This patch drops se_subsystem_api->[write_cache,fua_write]_emulated flags
    set by viritual FILEIO/IBLOCK/RD_MCP backend drivers in favor of explict
    TRANSPORT_PLUGIN_PHBA_PDEV checks to know when to fail if userspace is
    attempting to set virtual emulation bits for an pSCSI (passthrough)
    backend device.

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

    Nicholas Bellinger
     
  • Every fabric driver has to supply a se_tfo->set_fabric_sense_len()
    method, just so iSCSI can return an offset of 2. However, every fabric
    driver is already allocating a sense buffer and passing it into the
    target core, either via transport_init_se_cmd() or target_submit_cmd().

    So instead of having iSCSI pass the start of its sense buffer into the
    core and then later tell the core to skip the first 2 bytes, it seems
    easier for iSCSI just to do the offset of 2 when it passes the sense
    buffer into the core. Then we can drop the se_tfo->set_fabric_sense_len()
    everywhere, and just add a couple of lines of code to iSCSI to set the
    sense data length to the beginning of the buffer right before it sends
    it over the network.

    (nab: Remove .set_fabric_sense_len usage from tcm_qla2xxx_npiv_ops +
    change transport_get_sense_buffer to follow v3.6-rc6 code w/o
    ->set_fabric_sense_len usage)

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

    Roland Dreier
     
  • There are no callers of se_tfo->get_fabric_sense_len(), so we should
    stop having every fabric driver implement it.

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

    Roland Dreier
     

08 Sep, 2012

1 commit

  • Similar to INQUIRY and MODE SENSE, construct the sense data in a
    buffer and later copy it to the scatterlist. Do not do anything,
    but still clear a pending unit attention condition, if the allocation
    length is zero.

    However, SPC tells us that "If a REQUEST SENSE command is terminated with
    CHECK CONDITION status [and] the REQUEST SENSE command was received on
    an I_T nexus with a pending unit attention condition (i.e., before the
    device server reports CHECK CONDITION status), then the device server
    shall not clear the pending unit attention condition." Do the
    transport_kmap_data_sg early to detect this case.

    It also tells us "Device servers shall not adjust the additional sense
    length to reflect truncation if the allocation length is less than the
    sense data available", so do not do that! Note that the err variable
    is write-only.

    Signed-off-by: Paolo Bonzini
    Signed-off-by: Nicholas Bellinger

    Paolo Bonzini
     

06 Sep, 2012

1 commit

  • The pointer to the sense buffer is fetched by transport_get_sense_data,
    but this is called by target_complete_ok_work long after pscsi_req_done
    has freed the struct that contains it.

    Pass instead the fabric's sense buffer to transport_complete,
    and copy the data to it directly in transport_complete. Setting
    SCF_TRANSPORT_TASK_SENSE also becomes a duty of transport_complete.

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

    Paolo Bonzini
     

22 Aug, 2012

1 commit


18 Jul, 2012

1 commit

  • We want it to be possible for target_submit_cmd() to return errors up
    to its fabric module callers. For now just update the prototype to
    return an int, and update all callers to handle non-zero return values
    as an error.

    This is immediately useful for tcm_qla2xxx to fix a long-standing active
    I/O session shutdown race, but tcm_fc, usb-gadget, and sbp-target the
    fabric maintainers need to check + ACK that handling a target_submit_cmd()
    failure due to session shutdown does not introduce regressions

    (nab: Respin against for-next after initial NACK + update docbook comment +
    fix double se_cmd init in exception path for usb-gadget)

    Cc: Chad Dupuis
    Cc: Arun Easi
    Cc: Chris Boot
    Cc: Stefan Richter
    Cc: Mark Rustad
    Cc: Sebastian Andrzej Siewior
    Cc: Felipe Balbi
    Cc: Andy Grover
    Signed-off-by: Roland Dreier
    Signed-off-by: Nicholas Bellinger

    Roland Dreier
     

17 Jul, 2012

17 commits

  • Many SCSI commands are defined to return a CHECK CONDITION / ILLEGAL
    REQUEST with ASC set to LOGICAL BLOCK ADDRESS OUT OF RANGE if the
    initiator sends a command that accesses a too-big LBA. Add an enum
    value and case entries so that target code can return this status.

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

    Roland Dreier
     
  • Since we set se_session.sess_tearing_down and stop new commands from
    being added to se_session.sess_cmd_list before we wait for commands to
    finish when freeing a session, there's no need for a separate
    sess_wait_list -- if we let new commands be added to sess_cmd_list
    after setting sess_tearing_down, that would be a bug that breaks the
    logic of waiting in-flight commands.

    Also rename target_splice_sess_cmd_list() to
    target_sess_cmd_list_set_waiting(), since we are no longer splicing
    onto a separate list.

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

    Roland Dreier
     
  • There are no in-tree users of target_get_sess_cmd() outside of
    target_core_transport.c. Any new code should use the higher-level
    target_submit_cmd() interface. So let's un-export target_get_sess_cmd()
    and make it static to the one file where it's actually used.

    (nab: Fix up minor fuzz to for-next)

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

    Roland Dreier
     
  • The last functionality of the target processing thread is offloading possibly
    long running task management requests from the submitter context. To keep
    TMR semantics the same we need a single threaded ordered queue, which can
    be provided by a per-device workqueue with the right flags.

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

    Christoph Hellwig
     
  • Remove this command submission path which is not used by any in-tree driver.
    This also removes the now unused new_cmd_map fabtric method, which a few
    drivers implemented despite never calling transport_generic_handle_cdb_map.

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

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

    Christoph Hellwig
     
  • Just call target_execute_cmd directly. Also, convert loopback, sbp,
    usb-gadget to use the newly exported target_execute_cmd().

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

    Christoph Hellwig
     
  • Having all the unmap payload parsing in the backed is a bit ugly, but until
    more drivers support it and we can find a good interface for all of them
    that seems the way to go.

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

    Christoph Hellwig
     
  • Add spc_ops->execute_write_same() caller for ->execute_cmd() setup,
    and update IBLOCK backends to use it.

    (nab: add export of spc_get_write_same_sectors symbol)
    (roland: Carry forward: Fix range calculation in WRITE SAME emulation
    when num blocks == 0)

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

    Christoph Hellwig
     
  • Add spc_ops->execute_sync_cache() caller for ->execute_cmd() setup,
    and update IBLOCK + FILEIO backends to use it.

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

    Christoph Hellwig
     
  • Remove the execute_cmd method in struct se_subsystem_api, and always use the
    one directly in struct se_cmd. To make life simpler for SBC virtual backends
    a struct spc_ops that is passed to sbc_parse_cmd is added. For now it
    only contains an execute_rw member, but more will follow with the subsequent
    commits.

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

    Christoph Hellwig
     
  • Remove the dead SCF_SE_ALLOW_EOO and SCF_DELAYED_CMD_FROM_SAM_ATTR
    from se_cmd_flags_table.

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

    Christoph Hellwig
     
  • Also remove the unused ref_task_lun field in struct se_tmr_req.

    (nab: Add missing TASK_REASSIGN ref_lun vs. ref_cmd orig_fe_lun checks
    in iscsit_tmr_task_reassign)

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

    Christoph Hellwig
     
  • Since "target: Drop se_device TCQ queue_depth usage from I/O path" we always
    submit all commands (or back then, tasks) from __transport_execute_tasks.

    That means the the execute list has lots its purpose, as we can simply
    submit the commands that are restarted in transport_complete_task_attr
    directly while we walk the list. In fact doing so also solves a race
    in the way it currently walks to delayed_cmd_list as well.

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

    Christoph Hellwig
     
  • Move the existing code in target_core_cdb.c into the files for the command
    sets that the emulations implement.

    (roland + nab: Squash patch: Fix range calculation in WRITE SAME emulation
    when num blocks == 0s)

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

    Christoph Hellwig
     
  • Instead of trying to handle all SCSI command sets in one function
    (transport_generic_cmd_sequencer) call out to the backend driver to perform
    this functionality. For pSCSI a copy of the existing code is used, but for
    all virtual backends we can use a new parse_sbc_cdb helper is used to
    provide a simple SBC emulation.

    For now this setups means a fair amount of duplication between pSCSI and the
    SBC library, but patches later in this series will sort out that problem.

    (nab: Fix up build failure in target_core_pscsi.c)

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

    Christoph Hellwig
     
  • We don't need three flags to classifiy the CDB as we can check for a NULL S/G
    list for a dataless command, and can infer from the absence of the data flag
    that we deal with a control CDB. Also remove the _SG_IO from the data CDB
    flag as all I/O is dont on S/G lists now.

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

    Christoph Hellwig
     

13 Jun, 2012

1 commit

  • This patch adds an optional target_core_fabric_ops->put_session() caller
    within the existing target_put_session() code path.

    This is required by tcm_qla2xxx code in order to invoke it's own fabric
    specific session shutdown handler using se_session->sess_kref.

    Signed-off-by: Joern Engel
    Cc: Roland Dreier
    Cc: Arun Easi
    Signed-off-by: Nicholas Bellinger

    Joern Engel