10 May, 2016

4 commits


11 Mar, 2016

1 commit

  • se_dev_entry.lun_flags and se_lun.lun_access are only used for keeping
    track of read-write vs. read-only state. Since this is an either/or thing
    we can represent it as bool, and remove the unneeded enum
    transport_lunflags_table, which is left over from when there were more
    flags.

    Change code that uses this enum to just use true/false, and make it clear
    through variable and param names that true means read-only, false means
    read-write.

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

    Andy Grover
     

20 Jan, 2016

2 commits

  • This patch addresses a long standing race where obtaining
    se_node_acl->acl_kref in __transport_register_session()
    happens a bit too late, and leaves open the potential
    for core_tpg_del_initiator_node_acl() to hit a NULL
    pointer dereference.

    Instead, take ->acl_kref in core_tpg_get_initiator_node_acl()
    while se_portal_group->acl_node_mutex is held, and move the
    final target_put_nacl() from transport_deregister_session()
    into transport_free_session() so that fabric driver login
    failure handling using the modern method to still work
    as expected.

    Also, update core_tpg_get_initiator_node_acl() to take
    an extra reference for dynamically generated acls for
    demo-mode, before returning to fabric caller. Also
    update iscsi-target sendtargets special case handling
    to use target_tpg_has_node_acl() when checking if
    demo_mode_discovery == true during discovery lookup.

    Note the existing wait_for_completion(&acl->acl_free_comp)
    in core_tpg_del_initiator_node_acl() does not change.

    Cc: Sagi Grimberg
    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Cc: Andy Grover
    Cc: Mike Christie
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch converts core_tpg_set_initiator_node_queue_depth()
    to use struct se_node_acl->acl_sess_list when performing
    explicit se_tpg_tfo->shutdown_session() for active sessions,
    in order for new se_node_acl->queue_depth to take effect.

    This follows how core_tpg_del_initiator_node_acl() currently
    works when invoking se_tpg_tfo->shutdown-session(), and ahead
    of the next patch to take se_node_acl->acl_kref during lookup,
    the extra get_initiator_node_acl() can go away. In order to
    achieve this, go ahead and change target_get_session() to use
    kref_get_unless_zero() and propigate up the return value
    to know when a session is already being released.

    This is because se_node_acl->acl_group is already protecting
    se_node_acl->acl_group reference via configfs, and shutdown
    within core_tpg_del_initiator_node_acl() won't occur until
    sys_write() to core_tpg_set_initiator_node_queue_depth()
    attribute returns back to user-space.

    Also, drop the left-over iscsi-target hack, and obtain
    se_portal_group->session_lock in lio_tpg_shutdown_session()
    internally. Remove iscsi-target wrapper and unused se_tpg +
    force parameters and associated code.

    Reported-by: Christoph Hellwig
    Cc: Sagi Grimberg
    Cc: Hannes Reinecke
    Cc: Andy Grover
    Cc: Mike Christie
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

08 Jan, 2016

1 commit

  • The num_node_acls member in struct se_portal_group is modified
    by several functions but is never read. Hence remove it.

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

    Bart Van Assche
     

25 Sep, 2015

1 commit

  • This patch adds a DF_READ_ONLY flag that is used by IBLOCK to
    signal when a backend has been set to read-only mode, in order
    to propigate read-only status up to core_tpg_add_lun() for all
    future LUN fabric exports.

    With this is place, existing emulation for reporting read-only
    in spc_emulate_modesense() and normal transport_lookup_cmd_lun()
    TCM_WRITE_PROTECTED status checking just works as expected.

    Reported-by: Joeue Deng
    Reported-by: Andy Grover
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

24 Jul, 2015

1 commit


05 Jul, 2015

1 commit

  • Pull SCSI target updates from Nicholas Bellinger:
    "It's been a busy development cycle for target-core in a number of
    different areas.

    The fabric API usage for se_node_acl allocation is now within
    target-core code, dropping the external API callers for all fabric
    drivers tree-wide.

    There is a new conversion to RCU hlists for se_node_acl and
    se_portal_group LUN mappings, that turns fast-past LUN lookup into a
    completely lockless code-path. It also removes the original
    hard-coded limitation of 256 LUNs per fabric endpoint.

    The configfs attributes for backends can now be shared between core
    and driver code, allowing existing drivers to use common code while
    still allowing flexibility for new backend provided attributes.

    The highlights include:

    - Merge sbc_verify_dif_* into common code (sagi)
    - Remove iscsi-target support for obsolete IFMarker/OFMarker
    (Christophe Vu-Brugier)
    - Add bidi support in target/user backend (ilias + vangelis + agover)
    - Move se_node_acl allocation into target-core code (hch)
    - Add crc_t10dif_update common helper (akinobu + mkp)
    - Handle target-core odd SGL mapping for data transfer memory
    (akinobu)
    - Move transport ID handling into target-core (hch)
    - Move task tag into struct se_cmd + support 64-bit tags (bart)
    - Convert se_node_acl->device_list[] to RCU hlist (nab + hch +
    paulmck)
    - Convert se_portal_group->tpg_lun_list[] to RCU hlist (nab + hch +
    paulmck)
    - Simplify target backend driver registration (hch)
    - Consolidate + simplify target backend attribute implementations
    (hch + nab)
    - Subsume se_port + t10_alua_tg_pt_gp_member into se_lun (hch)
    - Drop lun_sep_lock for se_lun->lun_se_dev RCU usage (hch + nab)
    - Drop unnecessary core_tpg_register TFO parameter (nab)
    - Use 64-bit LUNs tree-wide (hannes)
    - Drop left-over TARGET_MAX_LUNS_PER_TRANSPORT limit (hannes)"

    * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (76 commits)
    target: Bump core version to v5.0
    target: remove target_core_configfs.h
    target: remove unused TARGET_CORE_CONFIG_ROOT define
    target: consolidate version defines
    target: implement WRITE_SAME with UNMAP bit using ->execute_unmap
    target: simplify UNMAP handling
    target: replace se_cmd->execute_rw with a protocol_data field
    target/user: Fix inconsistent kmap_atomic/kunmap_atomic
    target: Send UA when changing LUN inventory
    target: Send UA upon LUN RESET tmr completion
    target: Send UA on ALUA target port group change
    target: Convert se_lun->lun_deve_lock to normal spinlock
    target: use 'se_dev_entry' when allocating UAs
    target: Remove 'ua_nacl' pointer from se_ua structure
    target_core_alua: Correct UA handling when switching states
    xen-scsiback: Fix compile warning for 64-bit LUN
    target: Remove TARGET_MAX_LUNS_PER_TRANSPORT
    target: use 64-bit LUNs
    target: Drop duplicate + unused se_dev_check_wce
    target: Drop unnecessary core_tpg_register TFO parameter
    ...

    Linus Torvalds
     

23 Jun, 2015

1 commit


16 Jun, 2015

3 commits

  • LUN allocation is now fully dynamic, so there is no need to
    artificially restrain the number of exported LUNs.

    Signed-off-by: Hannes Reinecke
    Signed-off-by: Nicholas Bellinger

    Hannes Reinecke
     
  • As we're now using a list to hold the LUNs the target core
    can now converted to use 64-bit LUNs internally.

    Signed-off-by: Hannes Reinecke
    Signed-off-by: Nicholas Bellinger

    Hannes Reinecke
     
  • This patch drops unnecessary target_core_fabric_ops parameter usage
    for core_tpg_register() during fabric driver TFO->fabric_make_tpg()
    se_portal_group creation callback execution.

    Instead, use the existing se_wwn->wwn_tf->tf_ops pointer to ensure
    fabric driver is really using the same TFO provided at module_init
    time.

    Also go ahead and drop the forward TFO declarations tree-wide, and
    handling the special case for iscsi-target discovery TPG.

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

    Nicholas Bellinger
     

02 Jun, 2015

1 commit

  • Only include SCSI initiator header files in target code that needs
    these header files, namely the SCSI pass-through code and the tcm_loop
    driver. Change SCSI_SENSE_BUFFERSIZE into TRANSPORT_SENSE_BUFFER in
    target code because the former is intended for initiator code and the
    latter for target code. With this patch the only initiator include
    directives in target code that remain are as follows:

    $ git grep -nHE 'include .scsi/(scsi.h|scsi_host.h|scsi_device.h|scsi_cmnd.h)' drivers/target drivers/infiniband/ulp/{isert,srpt} drivers/usb/gadget/legacy/tcm_*.[ch] drivers/{vhost,xen} include/{target,trace/events/target.h}
    drivers/target/loopback/tcm_loop.c:29:#include
    drivers/target/loopback/tcm_loop.c:31:#include
    drivers/target/loopback/tcm_loop.c:32:#include
    drivers/target/loopback/tcm_loop.c:33:#include
    drivers/target/target_core_pscsi.c:39:#include
    drivers/target/target_core_pscsi.c:40:#include
    drivers/xen/xen-scsiback.c:52:#include /* SG_ALL */

    Signed-off-by: Bart Van Assche
    Reviewed-by: Christoph Hellwig
    Signed-off-by: James Bottomley

    Bart Van Assche
     

01 Jun, 2015

11 commits

  • With se_port_t and t10_alua_tg_pt_gp_member being absored into se_lun,
    there is no need for an extra atomic_t based reference count for PR
    ALL_TG_PT=1 and ALUA access state transition.

    Go ahead and use the existing percpu se_lun->lun_ref instead, and
    convert the two special cases to percpu_ref_tryget_live() to avoid
    se_lun if transport_clear_lun_ref() has already been invoked to
    shutdown the se_lun.

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

    Nicholas Bellinger
     
  • With se_port and t10_alua_tg_pt_gp_member being absored into se_lun,
    there is no need for an extra lock to protect se_lun->lun_se_dev
    assignment.

    This patch also converts backend drivers to use call_rcu() release
    to allow any se_device readers to complete. The call_rcu() instead
    of kfree_rcu() is required here because se_device is embedded into
    the backend driver specific structure.

    Also, convert se_lun->lun_stats to use atomic_long_t within the
    target_complete_ok_work() completion callback, and add FIXME for
    transport_lookup_tmr_lun() with se_lun->lun_ref.

    Finally, update sbp_update_unit_directory() special case usage with
    proper rcu_dereference_raw() and configfs symlink comment.

    Reported-by: Christoph Hellwig
    Reviewed-by: Hannes Reinecke
    Cc: Paul E. McKenney
    Cc: Chris Boot
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch eliminates all se_port + t10_alua_tg_pt_gp_member usage,
    and converts current users to direct se_lun pointer dereference.

    This includes the removal of core_export_port(), core_release_port()
    core_dev_export() and core_dev_unexport(). Along with conversion
    of special case se_lun pointer dereference within PR ALL_TG_PT=1
    and ALUA access state transition UNIT_ATTENTION handling.

    Also, update core_enable_device_list_for_node() to reference the
    new per se_lun->lun_deve_list when creating a new entry, or
    replacing an existing one via RCU.

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

    Christoph Hellwig
     
  • Instead of starting a thread from transport_clear_lun_ref() that
    waits for LUN shutdown, wait in that function for LUN shutdown
    to finish. Additionally, change the return type of
    transport_clear_lun_ref() from int to void.

    Signed-off-by: Bart Van Assche
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Bart Van Assche
     
  • Now that se_portal_group->tpg_lun_hlist is a RCU protected hlist,
    go ahead and drop the left-over lun->lun_status usage.

    Reported-by: Christoph Hellwig
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch changes core_tpg_add_node_to_devs() to avoid unnecessarly
    resetting every se_dev_entry in se_node_acl->tpg_lun_hlist when the
    operation is driven by an explicit configfs se_lun->lun_group creation
    via core_dev_add_lun() to only update a single se_lun.

    Otherwise for the second core_tpg_check_initiator_node_acl() case, go
    ahead and continue to scan the full set of currently active se_lun in
    se_portal_group->tpg_lun_hlist.

    Reviewed-by: Hannes Reinecke
    Cc: Christoph Hellwig
    Cc: Sagi Grimberg
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • Reviewed-by: Hannes Reinecke
    Cc: Christoph Hellwig
    Cc: Sagi Grimberg
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch converts core_tpg_deregister() to perform a list splice
    for any remaining dynamically generated se_node_acls attached to
    se_tpg, before calling kfree(nacl) to free memory.

    Reviewed-by: Hannes Reinecke
    Cc: Christoph Hellwig
    Cc: Sagi Grimberg
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch converts se_tpg->acl_node_lock to struct mutex, so that
    ->acl_node_acl walkers in core_clear_lun_from_tpg() can block when
    calling core_disable_device_list_for_node().

    It also updates core_dev_add_lun() to hold ->acl_node_mutex when
    calling core_tpg_add_node_to_devs() to build ->lun_entry_hlist
    for dynamically generated se_node_acl.

    Reviewed-by: Hannes Reinecke
    Cc: Christoph Hellwig
    Cc: Sagi Grimberg
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch converts the fixed size se_portal_group->tpg_lun_list[]
    to use modern RCU with hlist_head in order to support an arbitary
    number of se_lun ports per target endpoint.

    It includes dropping core_tpg_alloc_lun() from core_dev_add_lun(),
    and calling it directly from target_fabric_make_lun() to allocate
    a new se_lun. And add a new target_fabric_port_release() configfs
    item callback to invoke kfree_rcu() to release memory during
    se_lun->lun_group shutdown.

    Also now that se_node_acl->lun_entry_hlist is using RCU, convert
    existing tpg_lun_lock to struct mutex so core_tpg_add_node_to_devs()
    can perform RCU updater logic without releasing ->tpg_lun_mutex.

    Also, drop core_tpg_clear_object_luns() and it's single consumer
    in iscsi-target, which is duplicating TPG LUN shutdown logic and
    is current code results in a NOP.

    Finally, sbp-target and xen-scsiback fabric driver conversions are
    included, which are required due to the non-standard way they use
    ->tpg_lun_hlist.

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

    Nicholas Bellinger
     
  • 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

5 commits


15 Apr, 2015

1 commit

  • Instead of calling target_fabric_configfs_init() +
    target_fabric_configfs_register() / target_fabric_configfs_deregister()
    target_fabric_configfs_free() from every target driver, rewrite the API
    so that we have simple register/unregister functions that operate on
    a const operations vector.

    This patch also fixes a memory leak in several target drivers. Several
    target drivers namely called target_fabric_configfs_deregister()
    without calling target_fabric_configfs_free().

    A large part of this patch is based on earlier changes from
    Bart Van Assche .

    (v2: Add a new TF_CIT_SETUP_DRV macro so that the core configfs code
    can declare attributes as either core only or for drivers)

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

    Christoph Hellwig
     

22 Oct, 2014

1 commit

  • Pull SCSI target updates from Nicholas Bellinger:
    "Here are the target updates for v3.18-rc2 code. These where
    originally destined for -rc1, but due to the combination of travel
    last week for KVM Forum and my mistake of taking the three week merge
    window literally, the pull request slipped.. Apologies for that.

    Things where reasonably quiet this round. The highlights include:

    - New userspace backend driver (target_core_user.ko) by Shaohua Li
    and Andy Grover
    - A number of cleanups in target, iscsi-taret and qla_target code
    from Joern Engel
    - Fix an OOPs related to queue full handling with CHECK_CONDITION
    status from Quinn Tran
    - Fix to disable TX completion interrupt coalescing in iser-target,
    that was causing problems on some hardware
    - Fix for PR APTPL metadata handling with demo-mode ACLs

    I'm most excited about the new backend driver that uses UIO + shared
    memory ring to dispatch I/O and control commands into user-space.
    This was probably the most requested feature by users over the last
    couple of years, and opens up a new area of development + porting of
    existing user-space storage applications to LIO. Thanks to Shaohua +
    Andy for making this happen.

    Also another honorable mention, a new Xen PV SCSI driver was merged
    via the xen/tip.git tree recently, which puts us now at 10 target
    drivers in upstream! Thanks to David Vrabel + Juergen Gross for their
    work to get this code merged"

    * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (40 commits)
    target/file: fix inclusive vfs_fsync_range() end
    iser-target: Disable TX completion interrupt coalescing
    target: Add force_pr_aptpl device attribute
    target: Fix APTPL metadata handling for dynamic MappedLUNs
    qla_target: don't delete changed nacls
    target/user: Recalculate pad size inside is_ring_space_avail()
    tcm_loop: Fixup tag handling
    iser-target: Fix smatch warning
    target/user: Fix up smatch warnings in tcmu_netlink_event
    target: Add a user-passthrough backstore
    target: Add documentation on the target userspace pass-through driver
    uio: Export definition of struct uio_device
    target: Remove unneeded check in sbc_parse_cdb
    target: Fix queue full status NULL pointer for SCF_TRANSPORT_TASK_SENSE
    qla_target: rearrange struct qla_tgt_prm
    qla_target: improve qlt_unmap_sg()
    qla_target: make some global functions static
    qla_target: remove unused parameter
    target: simplify core_tmr_abort_task
    target: encapsulate smp_mb__after_atomic()
    ...

    Linus Torvalds
     

04 Oct, 2014

1 commit

  • This patch fixes a bug in handling of SPC-3 PR Activate Persistence
    across Target Power Loss (APTPL) logic where re-creation of state for
    MappedLUNs from dynamically generated NodeACLs did not occur during
    I_T Nexus establishment.

    It adds the missing core_scsi3_check_aptpl_registration() call during
    core_tpg_check_initiator_node_acl() -> core_tpg_add_node_to_devs() in
    order to replay any pre-loaded APTPL metadata state associated with
    the newly connected SCSI Initiator Port.

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

    Nicholas Bellinger
     

02 Oct, 2014

3 commits


25 Sep, 2014

1 commit

  • With the recent addition of percpu_ref_reinit(), percpu_ref now can be
    used as a persistent switch which can be turned on and off repeatedly
    where turning off maps to killing the ref and waiting for it to drain;
    however, there currently isn't a way to initialize a percpu_ref in its
    off (killed and drained) state, which can be inconvenient for certain
    persistent switch use cases.

    Similarly, percpu_ref_switch_to_atomic/percpu() allow dynamic
    selection of operation mode; however, currently a newly initialized
    percpu_ref is always in percpu mode making it impossible to avoid the
    latency overhead of switching to atomic mode.

    This patch adds @flags to percpu_ref_init() and implements the
    following flags.

    * PERCPU_REF_INIT_ATOMIC : start ref in atomic mode
    * PERCPU_REF_INIT_DEAD : start ref killed and drained

    These flags should be able to serve the above two use cases.

    v2: target_core_tpg.c conversion was missing. Fixed.

    Signed-off-by: Tejun Heo
    Reviewed-by: Kent Overstreet
    Cc: Jens Axboe
    Cc: Christoph Hellwig
    Cc: Johannes Weiner

    Tejun Heo
     

08 Sep, 2014

1 commit

  • Percpu allocator now supports allocation mask. Add @gfp to
    percpu_ref_init() so that !GFP_KERNEL allocation masks can be used
    with percpu_refs too.

    This patch doesn't make any functional difference.

    v2: blk-mq conversion was missing. Updated.

    Signed-off-by: Tejun Heo
    Cc: Kent Overstreet
    Cc: Benjamin LaHaise
    Cc: Li Zefan
    Cc: Nicholas A. Bellinger
    Cc: Jens Axboe

    Tejun Heo