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 Jul, 2017

5 commits


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
     

19 Mar, 2017

1 commit

  • 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
     

10 Dec, 2016

1 commit

  • Remove superfluous #include directives from the include/target/*.h
    files. Add missing #include directives to other *.h and *.c files.
    Use forward declarations for structures where possible. This
    change reduces the build time for make M=drivers/target on my
    laptop from 27.1s to 18.7s or by about 30%.

    Signed-off-by: Bart Van Assche
    Cc: Christoph Hellwig
    Cc: Bryant G. Ly

    Bart Van Assche
     

20 Jul, 2016

1 commit

  • max_discard_sectors only 32bits, and some non scsi backend
    devices will set this to the max 0xffffffff, so we can end up
    overflowing during the max_unmap_lba_count calculation.

    This fixes a regression caused by my patch:

    commit 8a9ebe717a133ba7bc90b06047f43cc6b8bcb8b3
    Author: Mike Christie
    Date: Mon Jan 18 14:09:27 2016 -0600

    target: Fix WRITE_SAME/DISCARD conversion to linux 512b sectors

    which can result in extra discards being sent to due the overflow
    causing max_unmap_lba_count to be smaller than what the backing
    device can actually support.

    Signed-off-by: Mike Christie
    Reviewed-by: Bart Van Assche
    Cc: stable@vger.kernel.org
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     

14 May, 2016

1 commit

  • The SRP target driver will need to allocate and chain it's own SGLs soon.
    For this export target_alloc_sgl, and add a new argument to it so that it
    can allocate an additional chain entry that doesn't point to a page. Also
    export transport_free_sgl after renaming it to target_free_sgl to free
    these SGLs again.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Bart Van Assche
    Signed-off-by: Doug Ledford

    Christoph Hellwig
     

30 Jan, 2016

1 commit

  • In a couple places we are not converting to/from the Linux
    block layer 512 bytes sectors.

    1.

    The request queue values and what we do are a mismatch of
    things:

    max_discard_sectors - This is in linux block layer 512 byte
    sectors. We are just copying this to max_unmap_lba_count.

    discard_granularity - This is in bytes. We are converting it
    to Linux block layer 512 byte sectors.

    discard_alignment - This is in bytes. We are just copying
    this over.

    The problem is that the core LIO code exports these values in
    spc_emulate_evpd_b0 and we use them to test request arguments
    in sbc_execute_unmap, but we never convert to the block size
    we export to the initiator. If we are not using 512 byte sectors
    then we are exporting the wrong values or are checks are off.
    And, for the discard_alignment/bytes case we are just plain messed
    up.

    2.

    blkdev_issue_discard's start and number of sector arguments
    are supposed to be in linux block layer 512 byte sectors. We are
    currently passing in the values we get from the initiator which
    might be based on some other sector size.

    There is a similar problem in iblock_execute_write_same where
    the bio functions want values in 512 byte sectors but we are
    passing in what we got from the initiator.

    Signed-off-by: Mike Christie
    Cc: stable@vger.kernel.org # 3.10+
    Signed-off-by: Nicholas Bellinger

    Mike Christie
     

24 Jul, 2015

1 commit

  • In case a LU spans 64bit sectors, fixed size sense data information
    field is only 32 bits which means the sector information will be truncated.

    Thus, if the LU spans 64bit sectors, use descriptor format sense data to
    correctly report sector information.

    Reported-by: Christoph Hellwig
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Martin K. Petersen
    Signed-off-by: Sagi Grimberg
    Signed-off-by: Nicholas Bellinger

    Sagi Grimberg
     

23 Jun, 2015

2 commits


01 Jun, 2015

4 commits

  • Consolidate the implementation of the backend attributes in a single file
    and single function per attribute show/store function instead of splitting
    it into multiple functions in multiple files.

    Also use the proper strto* helpers for exposed data types, add macros to
    implement the store methods for the most common data types and share the
    show methods between the two different attribute implementations.

    (Fix bogus store_pi_prot_format flag=0 return value - nab)

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

    Christoph Hellwig
     
  • Provide a common sets of dev_attrib attributes for all devices using the
    generic SPC/SBC parsers, and a second one with the minimal required read-only
    attributes for passthrough devices. The later is only used by pscsi for now,
    but will be wired up for the full-passthrough TCMU use case as well.

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

    Christoph Hellwig
     
  • Rewrite the backend driver registration based on what we did to the fabric
    drivers: introduce a read-only struct target_bakckend_ops that the driver
    registers, which is then instanciate as a struct target_backend by the
    core. This allows the ops vector to be smaller and allows us to mark it
    const. At the same time the registration function can set up the
    configfs attributes, avoiding the need to add additional boilerplate code
    for that to the drivers.

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

    Christoph Hellwig
     
  • This patch converts se_node_acl->device_list[] table for mappedluns
    to modern RCU hlist_head usage in order to support an arbitrary number
    of node_acl lun mappings.

    It converts transport_lookup_*_lun() fast-path code to use RCU read path
    primitives when looking up se_dev_entry. It adds a new hlist_head at
    se_node_acl->lun_entry_hlist for this purpose.

    For transport_lookup_cmd_lun() code, it works with existing per-cpu
    se_lun->lun_ref when associating se_cmd with se_lun + se_device.
    Also, go ahead and update core_create_device_list_for_node() +
    core_free_device_list_for_node() to use ->lun_entry_hlist.

    It also converts se_dev_entry->pr_ref_count access to use modern
    struct kref counting, and updates core_disable_device_list_for_node()
    to kref_put() and block on se_deve->pr_comp waiting for outstanding PR
    special-case PR references to drop, then invoke kfree_rcu() to wait
    for the RCU grace period to complete before releasing memory.

    So now that se_node_acl->lun_entry_hlist fast path access uses RCU
    protected pointers, go ahead and convert remaining non-fast path
    RCU updater code using ->lun_entry_lock to struct mutex to allow
    callers to block while walking se_node_acl->lun_entry_hlist.

    Finally drop the left-over core_clear_initiator_node_from_tpg() that
    originally cleared lun_access during se_node_acl shutdown, as post
    RCU conversion it now becomes duplicated logic.

    Reviewed-by: Hannes Reinecke
    Cc: Christoph Hellwig
    Cc: Sagi Grimberg
    Cc: Paul E. McKenney
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

31 May, 2015

3 commits

  • Instead of providing DIF verify routines for read/write
    that are almost identical and conditionally copy protection
    information, just let the caller do the right thing.

    Have a single sbc_dif_verify that handles an sgl (that
    does NOT copy any data) and a protection information copy
    routine used by rd_mcp and fileio backend.

    In the WRITE case, call sbc_dif_verify with cmd->t_prot_sg
    and then do the copy from it to local sgl (assuming the verify
    succeeded of course). In the READ case, call sbc_dif_verify
    with the local sgl and if it succeeds, copy it to t_prot_sg (or
    not if we are stripping it).

    (Fix apply breakage from commit c836777 - nab)

    Tested-by: Akinobu Mita
    Signed-off-by: Sagi Grimberg
    Signed-off-by: Nicholas Bellinger

    Sagi Grimberg
     
  • It seems like we only care if a transport is passthrough or not. Convert
    transport_type to a flags field and replace TRANSPORT_PLUGIN_* with a
    flag, TRANSPORT_FLAG_PASSTHROUGH.

    Signed-off-by: Andy Grover
    Reviewed-by: Ilias Tsitsimpis
    Signed-off-by: Nicholas Bellinger

    Andy Grover
     
  • Aside from whether they handle BIDI ops or not, parsing of the CDB by
    kernel and user SCSI passthrough modules should be identical. Move this
    into a new passthrough_parse_cdb() and call it from tcm-pscsi and tcm-user.

    Reported-by: Christoph Hellwig
    Reviewed-by: Ilias Tsitsimpis
    Signed-off-by: Andy Grover
    Signed-off-by: Nicholas Bellinger

    Andy Grover
     

20 Mar, 2015

1 commit

  • A check that rejects a CDB with FUA bit set if no write cache is
    emulated was added by the following commit:

    fde9f50 target: Add sanity checks for DPO/FUA bit usage

    The condition is as follows:

    if (!dev->dev_attrib.emulate_fua_write ||
    !dev->dev_attrib.emulate_write_cache)

    However, this check is wrong if the backend device supports WCE but
    "emulate_write_cache" is disabled.

    This patch uses se_dev_check_wce() (previously named
    spc_check_dev_wce) to invoke transport->get_write_cache() if the
    device has a write cache or check the "emulate_write_cache" attribute
    otherwise.

    Reported-by: Christoph Hellwig
    Signed-off-by: Christophe Vu-Brugier
    Signed-off-by: Nicholas Bellinger

    Christophe Vu-Brugier
     

10 Jan, 2015

1 commit


02 Dec, 2014

7 commits

  • Now that target_core_backend_configfs.h macros will be using these
    se_dev_set attribute functions externally to allow backend drivers
    to populate different attributes, go ahead and add EXPORT_SYMBOL()
    for the existing default set of 30 device attributes.

    Also update target_core_backend.h with proper function prototypes.

    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds support for dev_stat_cit as an external config_item_type
    using TB_CIT_SETUP() helper macro, and sets only ct_group_ops following
    existing code.

    It updates target_core_make_subdev() + target_core_setup_dev_attrib_cit() +
    struct target_backend_cits, and drops left-over target_core_dev_stat_cit
    from target_core_configfs.c code and update comments.

    This patch introduces no functional change from existing code.

    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds support for dev_alua_tg_pt_gps_cit as an external config_item_type
    using TB_CIT_SETUP() helper macro, and sets only ct_group_ops following
    existing code.

    It updates target_core_make_subdev() + target_core_setup_dev_attrib_cit() +
    struct target_backend_cits, and drops left-over target_core_dev_alua_tg_pt_gps_cit
    from target_core_configfs.c code and update comments.

    This patch introduces no functional change from existing code.

    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds support for dev_wwn_cit as an external config_item_type
    using TB_CIT_SETUP() helper macro, and sets both ct_item_ops + ct_attr
    following existing code.

    It updates target_core_make_subdev() + target_core_setup_dev_attrib_cit() +
    struct target_backend_cits, and drops left-over target_core_dev_wwn_cit
    from target_core_configfs.c code and update comments.

    This patch introduces no functional change from existing code.

    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds support for dev_pr_cit as an external config_item_type
    using TB_CIT_SETUP() helper macro, and sets both ct_item_ops + ct_attr
    following existing code.

    It updates target_core_make_subdev() + target_core_setup_dev_attrib_cit() +
    struct target_backend_cits, and drops left-over target_core_dev_pr_cit
    from target_core_configfs.c code and update comments.

    This patch introduces no functional change from existing code.

    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds support for dev_attrib_cit as an external config_item_type
    using TB_CIT_SETUP() helper macro, and sets both ct_item_ops + ct_attr
    following existing code.

    It updates target_core_make_subdev() + target_core_setup_dev_attrib_cit() +
    struct target_backend_cits, and drops left-over target_core_dev_attrib_cit
    from target_core_configfs.c code and update comments.

    This patch introduces no functional change from existing code.

    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds initial support for dev_cit as external config_item_type.

    This includes a new struct target_backend_cits to hold the external CITs
    within struct se_subsystem_api, and target_core_setup_sub_cits() to be
    used by backend drivers ahead of transport_subsystem_register().

    It adds a TB_CIT_SETUP() helper following target_core_fabric_configfs.c
    to perform the config_item_type assignments.

    Also, drop left-over target_core_dev_cit from target_core_configfs.c code
    and update comments.

    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

12 Jun, 2014

1 commit

  • When an initiator sends an allocation length bigger than what its
    command consumes, the target should only return the actual response data
    and set the residual length to the unused part of the allocation length.

    Add a helper function that command handlers (INQUIRY, READ CAPACITY,
    etc) can use to do this correctly, and use this code to get the correct
    residual for commands that don't use the full initiator allocation in the
    handlers for READ CAPACITY, READ CAPACITY(16), INQUIRY, MODE SENSE and
    REPORT LUNS.

    This addresses a handful of failures as reported by Christophe with
    the Windows Certification Kit:

    http://permalink.gmane.org/gmane.linux.scsi.target.devel/6515

    Signed-off-by: Roland Dreier
    Tested-by: Christophe Vu-Brugier
    Cc: stable@vger.kernel.org # 3.10+
    Signed-off-by: Nicholas Bellinger

    Roland Dreier
     

07 Apr, 2014

2 commits

  • Split up __sbc_dif_verify_read() so that VERIFY READ emulation can
    perform target-core specific READ_STRIP, seperate from the existing
    FILEIO/RAMDISK backend emulation code.

    Also add sbc_dif_read_strip() in order to determine number of sectors
    using cmd->prot_length, and skip the extra sbc_dif_copy_prot().

    Reviewed-by: Sagi Grimberg
    Cc: Martin K. Petersen
    Cc: Or Gerlitz
    Cc: Quinn Tran
    Cc: Giridhar Malavali
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds WRITE_INSERT emulation within target-core
    using TYPE1 / TYPE3 PI modes in sbc_dif_generate() code.

    This is useful in order for existing legacy fabrics that do not
    support protection offloads to interact with backend devices that
    currently have T10 PI enabled.

    v2 changes:
    - Rename to sbc_dif_generate() (Sagi)

    Cc: Martin K. Petersen
    Cc: Sagi Grimberg
    Cc: Or Gerlitz
    Cc: Quinn Tran
    Cc: Giridhar Malavali
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

18 Jan, 2014

2 commits

  • This patch adds support for DIF read/write verify emulation
    for TARGET_DIF_TYPE1_PROT + TARGET_DIF_TYPE3_PROT operation.

    This includes sbc_dif_verify_write() + sbc_dif_verify_read()
    calls accessable by backend drivers to perform DIF verify
    for SGL based data and protection information.

    Also included is sbc_dif_copy_prot() logic to copy protection
    information to/from backend provided protection SGLs.

    Based on scsi_debug.c DIF TYPE1+TYPE3 emulation.

    v2 changes:
    - Select CRC_T10DIF for TARGET_CORE in Kconfig (Fengguang)
    - Drop IP checksum logic from sbc_dif_v1_verify (MKP)
    - Fix offset on app_tag = 0xffff in sbc_dif_verify_read()

    Cc: Martin K. Petersen
    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Cc: Sagi Grimberg
    Cc: Or Gerlitz
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds DIF related definitions to target_core_base.h
    that includes enums for target_prot_op + target_prot_type +
    target_prot_version + target_guard_type + target_pi_error.

    Also included is struct se_dif_v1_tuple, along with changes
    to struct se_cmd, struct se_dev_attrib, and struct se_device.

    Also, add new se_subsystem_api->[init,format,free]_prot() callers
    used by target core code to setup backend specific protection
    information after the device has been configured.

    Enums taken from Sagi Grimberg's original patch.

    v2 changes:
    - Drop guard_type related definitions
    - Update target_prot_op + target_prot_ho definitions (Sagi)
    - Drop SCF_PROT + pi_prot_version flag
    - Add se_subsystem_api->format_prot() (Sagi)
    - Add hw_pi_prot_type device attribute

    Cc: Martin K. Petersen
    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Cc: Sagi Grimberg
    Cc: Or Gerlitz
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

13 Nov, 2013

1 commit

  • In addition to block size (already implemented), passing through
    alignment offset, logical-to-phys block exponent, I/O granularity and
    optimal I/O length will allow initiators to properly handle layout on
    LUNs with 4K block sizes.

    Tested with various weird values via scsi_debug module.

    One thing to look at with this patch is the new block limits values --
    instead of granularity 1 optimal 8192, Lio will now be returning whatever
    the block device says, which may affect performance.

    Signed-off-by: Andy Grover
    Acked-by: Martin K. Petersen
    Signed-off-by: Nicholas Bellinger

    Andy Grover
     

11 Sep, 2013

1 commit

  • Both target_alloc_sgl() and transport_generic_map_mem_to_cmd() are
    required by EXTENDED_COPY logic when setting up internally dispatched
    command descriptors, so go ahead and make both of these non static.

    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Cc: Martin Petersen
    Cc: Chris Mason
    Cc: Roland Dreier
    Cc: Zach Brown
    Cc: James Bottomley
    Cc: Nicholas Bellinger
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

10 Sep, 2013

1 commit

  • COMPARE_AND_WRITE expects to be able to send down a DMA_FROM_DEVICE
    to obtain the necessary READ payload for comparision against the
    first half of the WRITE payload containing the verify user data.

    Currently virtual backends expect to internally reference SGLs,
    SGL nents, and data_direction, so change IBLOCK, FILEIO and RD
    sbc_ops->execute_rw() to accept this values as function parameters.

    Also add default sbc_execute_rw() handler for the typical case for
    cmd->execute_rw() submission using cmd->t_data_sg, cmd->t_data_nents,
    and cmd->data_direction).

    v2 Changes:
    - Add SCF_COMPARE_AND_WRITE command flag
    - Use sbc_execute_rw() for normal cmd->execute_rw() submission
    with expected se_cmd members.

    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Cc: Martin Petersen
    Cc: Chris Mason
    Cc: James Bottomley
    Cc: Nicholas Bellinger
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

25 Apr, 2013

1 commit

  • iblock_execute_unmap() and fd_execute_unmap share a lot of code.
    Add sbc_execute_unmap() helper to remove duplicated code for
    iblock_execute_unmap() and fd_execute_unmap().

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

    Asias He