25 Nov, 2021

1 commit

  • [ Upstream commit ed1227e080990ffec5bf39006ec8a57358e6689a ]

    This patch fixes the following bugs:

    1. If there are multiple ordered cmds queued and multiple simple cmds
    completing, target_restart_delayed_cmds() could be called on different
    CPUs and each instance could start a ordered cmd. They could then run in
    different orders than they were queued.

    2. target_restart_delayed_cmds() and target_handle_task_attr() can race
    where:

    1. target_handle_task_attr() has passed the simple_cmds == 0 check.

    2. transport_complete_task_attr() then decrements simple_cmds to 0.

    3. transport_complete_task_attr() runs target_restart_delayed_cmds() and
    it does not see any cmds on the delayed_cmd_list.

    4. target_handle_task_attr() adds the cmd to the delayed_cmd_list.

    The cmd will then end up timing out.

    3. If we are sent > 1 ordered cmds and simple_cmds == 0, we can execute
    them out of order, because target_handle_task_attr() will hit that
    simple_cmds check first and return false for all ordered cmds sent.

    4. We run target_restart_delayed_cmds() after every cmd completion, so if
    there is more than 1 simple cmd running, we start executing ordered cmds
    after that first cmd instead of waiting for all of them to complete.

    5. Ordered cmds are not supposed to start until HEAD OF QUEUE and all older
    cmds have completed, and not just simple.

    6. It's not a bug but it doesn't make sense to take the delayed_cmd_lock
    for every cmd completion when ordered cmds are almost never used. Just
    replacing that lock with an atomic increases IOPs by up to 10% when
    completions are spread over multiple CPUs and there are multiple
    sessions/ mqs/thread accessing the same device.

    This patch moves the queued delayed handling to a per device work to
    serialze the cmd executions for each device and adds a new counter to track
    HEAD_OF_QUEUE and SIMPLE cmds. We can then check the new counter to
    determine when to run the work on the completion path.

    Link: https://lore.kernel.org/r/20210930020422.92578-3-michael.christie@oracle.com
    Signed-off-by: Mike Christie
    Signed-off-by: Martin K. Petersen
    Signed-off-by: Sasha Levin

    Mike Christie
     

05 Mar, 2021

2 commits

  • It may not always be best to complete the IO on same CPU as it was
    submitted on. This commit allows userspace to configure it.

    This has been useful for vhost-scsi where we have a single thread for
    submissions and completions. If we force the completion on the submission
    CPU we may be adding conflicts with what the user has setup in the lower
    levels with settings like the block layer rq_affinity or the driver's IRQ
    or softirq (the network's rps_cpus value) settings.

    We may also want to set it up where the vhost thread runs on CPU N and does
    its submissions/completions there, and then have LIO do its completion
    booking on CPU M, but can't configure the lower levels due to issues like
    using dm-multipath with lots of paths (the path selector can throw commands
    all over the system because it's only taking into account latency/throughput
    at its level).

    The new setting is in:

    /sys/kernel/config/target/$fabric/$target/param/cmd_completion_affinity

    Writing:

    -1 -> Gives the current default behavior of completing on the
    submission CPU.

    -2 -> Completes the cmd on the CPU the lower layers sent it to us from.

    > 0 -> Completes on the CPU userspace has specified.

    Link: https://lore.kernel.org/r/20210227170006.5077-26-michael.christie@oracle.com
    Reviewed-by: Himanshu Madhani
    Signed-off-by: Mike Christie
    Signed-off-by: Martin K. Petersen

    Mike Christie
     
  • loop and vhost/scsi do their target cmd submission from driver
    workqueues. This allows them to avoid an issue where the backend may block
    waiting for resources like tags/requests, mem/locks, etc and that ends up
    blocking their entire submission path and for the case of vhost-scsi both
    the submission and completion path.

    This patch adds a helper drivers can use to submit from a LIO workqueue.
    This code will then be extended in the next patches to fix the plugging of
    backend devices.

    We are only converting vhost/loop initially, but the workqueue based
    submission will work for other drivers and have similar benefits where the
    main target loops will not end up blocking one some backend resource.

    Link: https://lore.kernel.org/r/20210227170006.5077-17-michael.christie@oracle.com
    Tested-by: Laurence Oberman
    Reviewed-by: Bodo Stroesser
    Signed-off-by: Mike Christie
    Signed-off-by: Martin K. Petersen

    Mike Christie
     

08 Jul, 2020

1 commit

  • transport_init_session can allocate memory via percpu_ref_init, and
    target_xcopy_release_pt never frees it. This adds a
    transport_uninit_session function to handle cleanup of resources allocated
    in the init function.

    Link: https://lore.kernel.org/r/1593654203-12442-3-git-send-email-michael.christie@oracle.com
    Signed-off-by: Mike Christie
    Signed-off-by: Martin K. Petersen

    Mike Christie
     

08 Dec, 2018

1 commit

  • Instead of invoking target driver callback functions from the context that
    handles an abort or LUN RESET task management function, only set the abort
    flag from that context and perform the actual abort handling from the
    context of the regular command processing flow. This approach has the
    advantage that the task management code becomes much easier to read and to
    verify since the number of potential race conditions against the command
    processing flow is strongly reduced.

    This patch has been tested by running the following two shell commands
    concurrently for about ten minutes for both the iSCSI and the SRP target
    drivers ($dev is an initiator device node connected with storage provided
    by the target driver under test):

    * fio with data verification enabled on a filesystem mounted on top of
    $dev.

    * while true; do sg_reset -d $dev; echo -n .; sleep .1; done

    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

    Bart Van Assche
     

03 Jul, 2018

1 commit


19 Apr, 2018

1 commit

  • The target database root directory, dbroot, has defaulted to /var/target
    for a while, but its main client, targetcli-fb, has been moving it to
    /etc/target for quite some time. With the plethora of target drivers now
    appearing, it has become more difficult to initialize this attribute
    before use by any child drivers.

    If the directory /etc/target exists, use that as the DB root. Otherwise,
    fall back to using /var/target.

    The ability to override this dbroot attribute still exists via sysfs.

    Signed-off-by: Lee Duncan
    Reviewed-by: Christoph Hellwig
    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

  • iscsi_parse_pr_out_transport_id launders the const away via a call to
    strstr(), and then modifies the buffer (writing a nul byte) through
    the return value. It's cleaner to be honest and simply declare the
    parameter as "char*", fixing up the call chain, and allowing us to
    drop the cast in the return statement.

    Amusingly, the two current callers found it necessary to cast a
    non-const pointer to a const.

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Nicholas Bellinger

    Rasmus Villemoes
     

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
     

05 Nov, 2017

1 commit

  • This patch avoids that sparse reports the following warning:

    drivers/target/target_core_configfs.c:2267:33: warning: symbol 'target_core_dev_item_ops' was not declared. Should it be static?

    Fixes: c17cd24959cd ("target/configfs: Kill se_device->dev_link_magic")
    Signed-off-by: Bart Van Assche
    Cc: Christoph Hellwig
    Cc: Mike Christie
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Nicholas Bellinger

    Bart Van Assche
     

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

2 commits


09 Jun, 2017

1 commit

  • This patch fixes a se_cmd->cmd_kref underflow during CMD_T_ABORTED
    when a fabric driver drops it's second reference from below the
    target_core_tmr.c based callers of transport_cmd_finish_abort().

    Recently with the conversion of kref to refcount_t, this bug was
    manifesting itself as:

    [705519.601034] refcount_t: underflow; use-after-free.
    [705519.604034] INFO: NMI handler (kgdb_nmi_handler) took too long to run: 20116.512 msecs
    [705539.719111] ------------[ cut here ]------------
    [705539.719117] WARNING: CPU: 3 PID: 26510 at lib/refcount.c:184 refcount_sub_and_test+0x33/0x51

    Since the original kref atomic_t based kref_put() didn't check for
    underflow and only invoked the final callback when zero was reached,
    this bug did not manifest in practice since all se_cmd memory is
    using preallocated tags.

    To address this, go ahead and propigate the existing return from
    transport_put_cmd() up via transport_cmd_finish_abort(), and
    change transport_cmd_finish_abort() + core_tmr_handle_tas_abort()
    callers to only do their local target_put_sess_cmd() if necessary.

    Reported-by: Bart Van Assche
    Tested-by: Bart Van Assche
    Cc: Mike Christie
    Cc: Hannes Reinecke
    Cc: Christoph Hellwig
    Cc: Himanshu Madhani
    Cc: Sagi Grimberg
    Cc: stable@vger.kernel.org # 3.14+
    Tested-by: Gary Guo
    Tested-by: Chu Yuan Lin
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

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

  • If a command with a Simple task attribute is failed due to a Unit
    Attention, then a subsequent command with an Ordered task attribute
    will hang forever. The reason for this is that the Unit Attention
    status is checked for in target_setup_cmd_from_cdb, before the call
    to target_execute_cmd, which calls target_handle_task_attr, which
    in turn increments dev->simple_cmds.

    However, transport_generic_request_failure still calls
    transport_complete_task_attr, which will decrement dev->simple_cmds.
    In this case, simple_cmds is now -1. So when a command with the
    Ordered task attribute is sent, target_handle_task_attr sees that
    dev->simple_cmds is not 0, so it decides it can't execute the
    command until all the (nonexistent) Simple commands have completed.

    Reported-by: Michael Cyr
    Tested-by: Michael Cyr
    Reported-by: Bryant G. Ly
    Tested-by: Bryant G. Ly
    Cc: stable@vger.kernel.org # 4.4+
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

10 May, 2016

1 commit

  • This commit adds the read-write attribute "dbroot",
    in the top-level CONFIGFS (core) target directory,
    normally /sys/kernel/config/target. This attribute
    defaults to "/var/target" but can be changed by
    writing a new pathname string to it. Changing this
    attribute is only allowed when no fabric drivers
    are loaded and the supplied value specifies an
    existing directory.

    Target modules that care about the target database
    root directory will be modified to use this
    attribute in a future commit.

    Signed-off-by: Lee Duncan
    Signed-off-by: Nicholas Bellinger

    Lee Duncan
     

23 Mar, 2016

1 commit

  • Pull SCSI target updates from Nicholas Bellinger:
    "The highlights this round include:

    - Add target_alloc_session() w/ callback helper for doing se_session
    allocation + tag + se_node_acl lookup. (HCH + nab)

    - Tree-wide fabric driver conversion to use target_alloc_session()

    - Convert sbp-target to use percpu_ida tag pre-allocation, and
    TARGET_SCF_ACK_KREF I/O krefs (Chris Boot + nab)

    - Convert usb-gadget to use percpu_ida tag pre-allocation, and
    TARGET_SCF_ACK_KREF I/O krefs (Andrzej Pietrasiewicz + nab)

    - Convert xen-scsiback to use percpu_ida tag pre-allocation, and
    TARGET_SCF_ACK_KREF I/O krefs (Juergen Gross + nab)

    - Convert tcm_fc to use TARGET_SCF_ACK_KREF I/O + TMR krefs

    - Convert ib_srpt to use percpu_ida tag pre-allocation

    - Add DebugFS node for qla2xxx target sess list (Quinn)

    - Rework iser-target connection termination (Jenny + Sagi)

    - Convert iser-target to new CQ API (HCH)

    - Add pass-through WRITE_SAME support for IBLOCK (Mike Christie)

    - Introduce data_bitmap for asynchronous access of data area (Sheng
    Yang + Andy)

    - Fix target_release_cmd_kref shutdown comp leak (Himanshu Madhani)

    Also, there is a separate PULL request coming for cxgb4 NIC driver
    prerequisites for supporting hw iscsi segmentation offload (ISO), that
    will be the base for a number of v4.7 developments involving
    iscsi-target hw offloads"

    * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (36 commits)
    target: Fix target_release_cmd_kref shutdown comp leak
    target: Avoid DataIN transfers for non-GOOD SAM status
    target/user: Report capability of handling out-of-order completions to userspace
    target/user: Fix size_t format-spec build warning
    target/user: Don't free expired command when time out
    target/user: Introduce data_bitmap, replace data_length/data_head/data_tail
    target/user: Free data ring in unified function
    target/user: Use iovec[] to describe continuous area
    target: Remove enum transport_lunflags_table
    target/iblock: pass WRITE_SAME to device if possible
    iser-target: Kill the ->isert_cmd back pointer in struct iser_tx_desc
    iser-target: Kill struct isert_rdma_wr
    iser-target: Convert to new CQ API
    iser-target: Split and properly type the login buffer
    iser-target: Remove ISER_RECV_DATA_SEG_LEN
    iser-target: Remove impossible condition from isert_wait_conn
    iser-target: Remove redundant wait in release_conn
    iser-target: Rework connection termination
    iser-target: Separate flows for np listeners and connections cma events
    iser-target: Add new state ISER_CONN_BOUND to isert_conn
    ...

    Linus Torvalds
     

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
     

06 Mar, 2016

1 commit

  • Replace the current NULL-terminated array of default groups with a linked
    list. This gets rid of lots of nasty code to size and/or dynamically
    allocate the array.

    While we're at it also provide a conveniant helper to remove the default
    groups.

    Signed-off-by: Christoph Hellwig
    Acked-by: Felipe Balbi [drivers/usb/gadget]
    Acked-by: Joel Becker
    Acked-by: Nicholas Bellinger
    Reviewed-by: Sagi Grimberg

    Christoph Hellwig
     

07 Feb, 2016

1 commit


14 Oct, 2015

1 commit

  • This also allows to remove the target-specific old configfs macros, and
    gets rid of the target_core_fabric_configfs.h header which only had one
    function declaration left that could be moved to a better place.

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

    Christoph Hellwig
     

23 Jun, 2015

1 commit


16 Jun, 2015

1 commit


01 Jun, 2015

6 commits

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

4 commits

  • Now that struct se_portal_group contains a protocol identifier field we can
    take all the code to format an parse protocol identifiers in CDBs into common
    code instead of leaving this to low-level drivers.

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

    Christoph Hellwig
     
  • By always allocating and adding, respectively removing and freeing
    the se_node_acl structure in core code we can remove tons of repeated
    code in the init_nodeacl and drop_nodeacl routines. Additionally
    this now respects the get_default_queue_depth method in this code
    path as well.

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

    Christoph Hellwig
     
  • Drivers may override the WCE flag, in which case the DPOFUA flag in
    MODE SENSE might differ from the check used to reject invalid FUA
    bits in sbc_check_dpofua. Also now that we reject invalid FUA
    bits early there is no need to duplicate the same buggy check
    down in the fileio code.

    As the DPOFUA flag controls th support for FUA bits on read and
    write commands as well as DPO key off all the checks off a single
    helper, and deprecate the emulate_dpo and emulate_fua_read attributs.

    This fixes various failures in the libiscsi testsuite.

    Personally I'd prefer to also remove the emulate_fua_write attribute
    as there is no good reason to disable it, but I'll leave that for
    a separate discussion.

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

    Christoph Hellwig
     
  • There is just one configfs subsystem in the target code, so we might as
    well add two helpers to reference / unreference it from the core code
    instead of passing pointers to it around.

    This fixes a regression introduced for v4.1-rc1 with commit 9ac8928e6,
    where configfs_depend_item() callers using se_tpg_tfo->tf_subsys would
    fail, because the assignment from the original target_core_subsystem[]
    is no longer happening at target_register_template() time.

    (Fix target_core_exit_configfs pointer dereference - Sagi)

    Signed-off-by: Christoph Hellwig
    Reported-by: Himanshu Madhani
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     

27 Mar, 2015

1 commit


02 Dec, 2014

1 commit

  • 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
     

04 Oct, 2014

1 commit

  • This patch adds a force_pr_aptpl device attribute used to force SPC-3 PR
    Activate Persistence across Target Power Loss (APTPL) operation. This
    makes PR metadata write-out occur during state change regardless if new
    PERSISTENT_RESERVE_OUT CDBs have their APTPL feature bit set.

    This is useful during H/A failover in active/passive setups where all PR
    state is being re-created on a different node, driven by configfs backend
    device + export layout and pre-loaded $DEV/pr/res_aptpl_metadata.

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

    Nicholas Bellinger
     

02 Oct, 2014

2 commits