1. 31 5月, 2013 1 次提交
    • N
      iscsi-target: Fix iscsit_free_cmd() se_cmd->cmd_kref shutdown handling · aafc9d15
      Nicholas Bellinger 提交于
      With the introduction of target_get_sess_cmd() referencing counting for
      ISCSI_OP_SCSI_CMD processing with iser-target, iscsit_free_cmd() usage
      in traditional iscsi-target driver code now needs to be aware of the
      active I/O shutdown case when a remaining se_cmd->cmd_kref reference may
      exist after transport_generic_free_cmd() completes, requiring a final
      target_put_sess_cmd() to release iscsi_cmd descriptor memory.
      
      This patch changes iscsit_free_cmd() to invoke __iscsit_free_cmd() before
      transport_generic_free_cmd() -> target_put_sess_cmd(), and also avoids
      aquiring the per-connection queue locks for typical fast-path calls
      during normal ISTATE_REMOVE operation.
      
      Also update iscsit_free_cmd() usage throughout iscsi-target to
      use the new 'bool shutdown' parameter.
      
      This patch fixes a regression bug introduced during v3.10-rc1 in
      commit 3e1c81a9, that was causing the following WARNING to appear:
      
      [  257.235153] ------------[ cut here]------------
      [  257.240314] WARNING: at kernel/softirq.c:160 local_bh_enable_ip+0x3c/0x86()
      [  257.248089] Modules linked in: vhost_scsi ib_srpt ib_cm ib_sa ib_mad ib_core tcm_qla2xxx tcm_loop
      	tcm_fc libfc iscsi_target_mod target_core_pscsi target_core_file
      	target_core_iblock target_core_mod configfs ipv6 iscsi_tcp libiscsi_tcp
      	libiscsi scsi_transport_iscsi loop acpi_cpufreq freq_table mperf
      	kvm_intel kvm crc32c_intel button ehci_pci pcspkr joydev i2c_i801
      	microcode ext3 jbd raid10 raid456 async_pq async_xor xor async_memcpy
      	async_raid6_recov raid6_pq async_tx raid1 raid0 linear igb hwmon
      	i2c_algo_bit i2c_core ptp ata_piix libata qla2xxx uhci_hcd ehci_hcd
      	mlx4_core scsi_transport_fc scsi_tgt pps_core
      [  257.308748] CPU: 1 PID: 3295 Comm: iscsi_ttx Not tainted 3.10.0-rc2+ #103
      [  257.316329] Hardware name: Intel Corporation S5520HC/S5520HC, BIOS S5500.86B.01.00.0057.031020111721 03/10/2011
      [  257.327597]  ffffffff814c24b7 ffff880458331b58 ffffffff8138eef2 ffff880458331b98
      [  257.335892]  ffffffff8102c052 ffff880400000008 0000000000000000 ffff88085bdf0000
      [  257.344191]  ffff88085bdf00d8 ffff88085bdf00e0 ffff88085bdf00f8 ffff880458331ba8
      [  257.352488] Call Trace:
      [  257.355223]  [<ffffffff8138eef2>] dump_stack+0x19/0x1f
      [  257.360963]  [<ffffffff8102c052>] warn_slowpath_common+0x62/0x7b
      [  257.367669]  [<ffffffff8102c080>] warn_slowpath_null+0x15/0x17
      [  257.374181]  [<ffffffff81032345>] local_bh_enable_ip+0x3c/0x86
      [  257.380697]  [<ffffffff813917fd>] _raw_spin_unlock_bh+0x10/0x12
      [  257.387311]  [<ffffffffa029069c>] iscsit_free_r2ts_from_list+0x5e/0x67 [iscsi_target_mod]
      [  257.396438]  [<ffffffffa02906c5>] iscsit_release_cmd+0x20/0x223 [iscsi_target_mod]
      [  257.404893]  [<ffffffffa02977a4>] lio_release_cmd+0x3a/0x3e [iscsi_target_mod]
      [  257.412964]  [<ffffffffa01d59a1>] target_release_cmd_kref+0x7a/0x7c [target_core_mod]
      [  257.421712]  [<ffffffffa01d69bc>] target_put_sess_cmd+0x5f/0x7f [target_core_mod]
      [  257.430071]  [<ffffffffa01d6d6d>] transport_release_cmd+0x59/0x6f [target_core_mod]
      [  257.438625]  [<ffffffffa01d6eb4>] transport_put_cmd+0x131/0x140 [target_core_mod]
      [  257.446985]  [<ffffffffa01d6192>] ? transport_wait_for_tasks+0xfa/0x1d5 [target_core_mod]
      [  257.456121]  [<ffffffffa01d6f11>] transport_generic_free_cmd+0x4e/0x52 [target_core_mod]
      [  257.465159]  [<ffffffff81050537>] ? __migrate_task+0x110/0x110
      [  257.471674]  [<ffffffffa02904ba>] iscsit_free_cmd+0x46/0x55 [iscsi_target_mod]
      [  257.479741]  [<ffffffffa0291edb>] iscsit_immediate_queue+0x301/0x353 [iscsi_target_mod]
      [  257.488683]  [<ffffffffa0292f7e>] iscsi_target_tx_thread+0x1c6/0x2a8 [iscsi_target_mod]
      [  257.497623]  [<ffffffff81047486>] ? wake_up_bit+0x25/0x25
      [  257.503652]  [<ffffffffa0292db8>] ? iscsit_ack_from_expstatsn+0xd5/0xd5 [iscsi_target_mod]
      [  257.512882]  [<ffffffff81046f89>] kthread+0xb0/0xb8
      [  257.518329]  [<ffffffff81046ed9>] ? kthread_freezable_should_stop+0x60/0x60
      [  257.526105]  [<ffffffff81396fec>] ret_from_fork+0x7c/0xb0
      [  257.532133]  [<ffffffff81046ed9>] ? kthread_freezable_should_stop+0x60/0x60
      [  257.539906] ---[ end trace 5520397d0f2e0800 ]---
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      aafc9d15
  2. 25 4月, 2013 3 次提交
    • N
      iscsi-target: Refactor RX PDU logic + export request PDU handling · 3e1c81a9
      Nicholas Bellinger 提交于
      This patch refactors existing traditional iscsi RX side PDU handling
      to use iscsit_transport, and exports the necessary logic for external
      transport modules.
      
      This includes:
      
      - Refactor iscsit_handle_scsi_cmd() into PDU setup / processing
      - Add updated iscsit_handle_scsi_cmd() for tradtional iscsi code
      - Add iscsit_set_unsoliticed_dataout() wrapper
      - Refactor iscsit_handle_data_out() into PDU check / processing
      - Add updated iscsit_handle_data_out() for tradtional iscsi code
      - Add iscsit_handle_nop_out() + iscsit_handle_task_mgt_cmd() to
        accept pre-allocated struct iscsi_cmd
      - Add iscsit_build_r2ts_for_cmd() caller for iscsi_target_transport
        to handle ISTATE_SEND_R2T for TX immediate queue
      - Refactor main traditional iscsi iscsi_target_rx_thread() PDU switch
        into iscsi_target_rx_opcode() using iscsit_allocate_cmd()
      - Turn iscsi_target_rx_thread() process context into NOP for
        ib_isert side work-queue.
      
      v5 changes:
      
      - Make iscsit_handle_scsi_cmd() static (Fengguang)
      - Fix iscsit_handle_scsi_cmd() exception se_cmd leak (nab)
      
      v3 changes:
      - Add extra target_put_sess_cmd call in iscsit_add_reject_from_cmd
        after completion
      
      v2 changes:
      
      - Disable iscsit_ack_from_expstatsn() usage for RDMAExtentions=Yes
      - Disable iscsit_allocate_datain_req() usage for RDMAExtentions=Yes
      - Add target_get_sess_cmd() reference counting to
        iscsit_setup_scsi_cmd()
      - Add TFO->lio_check_stop_free() fabric API caller
      - Add export of iscsit_stop_dataout_timer() symbol
      - Add iscsit_build_r2ts_for_cmd() for iscsit_transport->iscsit_get_dataout()
      - Convert existing usage of iscsit_build_r2ts_for_cmd() to
        ->iscsit_get_dataout()
      - Drop RDMAExtentions=Yes specific check in iscsit_build_r2ts_for_cmd()
      - Fix RDMAExtentions -> RDMAExtensions typo (andy)
      - Pass correct dump_payload value into iscsit_get_immediate_data()
        for iscsit_handle_scsi_cmd()
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      3e1c81a9
    • N
      iscsi-target: Add per transport iscsi_cmd alloc/free · cdb72665
      Nicholas Bellinger 提交于
      This patch converts struct iscsi_cmd memory allocation + free to use
      ->iscsit_alloc_cmd() iscsit_transport API caller, and export
      iscsit_allocate_cmd() symbols
      
      Also add iscsi_cmd->release_cmd() to be used seperately from
      iscsit_transport for connection/session shutdown.
      
      v2 changes:
      
      - Remove unnecessary checks in iscsit_alloc_cmd (asias)
      - Drop iscsit_transport->iscsit_free_cmd() usage
      - Drop iscsit_transport->iscsit_unmap_cmd() usage
      - Add iscsi_cmd->release_cmd()
      - Convert lio_release_cmd() to use iscsi_cmd->release_cmd()
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      cdb72665
    • N
      iscsi-target: Initial traditional TCP conversion to iscsit_transport · baa4d64b
      Nicholas Bellinger 提交于
      This patch performs the initial conversion of existing traditional iscsi
      to use iscsit_transport API callers.  This includes:
      
      - iscsi-np cleanups for iscsit_transport_type
      - Add iscsi-np transport calls w/ ->iscsit_setup_up() and ->iscsit_free_np()
      - Convert login thread process context to use ->iscsit_accept_np() for
        connections with pre-allocated struct iscsi_conn
      - Convert existing socket accept code to iscsit_accept_np()
      - Convert login RX/TX callers to use ->iscsit_get_login_rx() and
        ->iscsit_put_login_tx() to exchange request/response PDUs
      - Convert existing socket login RX/TX calls into iscsit_get_login_rx()
        and iscsit_put_login_tx()
      - Change iscsit_close_connection() to invoke ->iscsit_free_conn() +
        iscsit_put_transport() calls.
      - Add iscsit_register_transport() + iscsit_unregister_transport() calls
        to module init/exit
      
      v4 changes:
      
      - Add missing iscsit_put_transport() call in iscsi_target_setup_login_socket()
        failure case
      
      v2 changes:
      
      - Update module init/exit to use register_transport() + unregister_transport()
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      baa4d64b
  3. 19 11月, 2012 1 次提交
  4. 07 11月, 2012 1 次提交
  5. 01 11月, 2012 1 次提交
    • R
      iscsi-target: Fix missed wakeup race in TX thread · d5627acb
      Roland Dreier 提交于
      The sleeping code in iscsi_target_tx_thread() is susceptible to the classic
      missed wakeup race:
      
       - TX thread finishes handle_immediate_queue() and handle_response_queue(),
         thinks both queues are empty.
       - Another thread adds a queue entry and does wake_up_process(), which does
         nothing because the TX thread is still awake.
       - TX thread does schedule_timeout() and sleeps forever.
      
      In practice this can kill an iSCSI connection if for example an initiator
      does single-threaded writes and the target misses the wakeup window when
      queueing an R2T; in this case the connection will be stuck until the
      initiator loses patience and does some task management operation (or kills
      the connection entirely).
      
      Fix this by converting to wait_event_interruptible(), which does not
      suffer from this sort of race.
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Cc: Andy Grover <agrover@redhat.com>
      Cc: Hannes Reinecke <hare@suse.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: stable@vger.kernel.org
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      d5627acb
  6. 04 10月, 2012 2 次提交
  7. 15 4月, 2012 5 次提交
  8. 26 2月, 2012 1 次提交
  9. 18 1月, 2012 1 次提交
    • N
      iscsi-target: Fix reject release handling in iscsit_free_cmd() · c1ce4bd5
      Nicholas Bellinger 提交于
      This patch addresses a bug where iscsit_free_cmd() was incorrectly calling
      iscsit_release_cmd() for ISCSI_OP_REJECT because iscsi_add_reject*() will
      overwrite the original iscsi_cmd->iscsi_opcode assignment.  This bug was
      introduced with the following commit:
      
      commit 0be67f2ed8f577d2c72d917928394c5885fa9134
      Author: Nicholas Bellinger <nab@linux-iscsi.org>
      Date:   Sun Oct 9 01:48:14 2011 -0700
      
          iscsi-target: Remove SCF_SE_LUN_CMD flag abuses
      
      and was manifesting itself as list corruption with the following:
      
      [  131.191092] ------------[ cut here ]------------
      [  131.191092] WARNING: at lib/list_debug.c:53 __list_del_entry+0x8d/0x98()
      [  131.191092] Hardware name: VMware Virtual Platform
      [  131.191092] list_del corruption. prev->next should be ffff880022d3c100, but was 6b6b6b6b6b6b6b6b
      [  131.191092] Modules linked in: tcm_vhost ib_srpt ib_cm ib_sa ib_mad ib_core tcm_qla2xxx qla2xxx tcm_loop tcm_fc libfc scsi_transport_fc crc32c iscsi_target_mod target_core_stgt scsi_tgt target_core_pscsi target_core_file target_core_iblock target_core_mod configfs ipv6 iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi sr_mod cdrom sd_mod e1000 ata_piix libata mptspi mptscsih mptbase [last unloaded: scsi_wait_scan]
      [  131.191092] Pid: 2250, comm: iscsi_ttx Tainted: G        W    3.2.0-rc4+ #42
      [  131.191092] Call Trace:
      [  131.191092]  [<ffffffff8103b553>] warn_slowpath_common+0x80/0x98
      [  131.191092]  [<ffffffff8103b5ff>] warn_slowpath_fmt+0x41/0x43
      [  131.191092]  [<ffffffff811d0279>] __list_del_entry+0x8d/0x98
      [  131.191092]  [<ffffffffa01395c9>] transport_lun_remove_cmd+0x9b/0xb7 [target_core_mod]
      [  131.191092]  [<ffffffffa013a55c>] transport_generic_free_cmd+0x5d/0x71 [target_core_mod]
      [  131.191092]  [<ffffffffa01a012b>] iscsit_free_cmd+0x1e/0x27 [iscsi_target_mod]
      [  131.191092]  [<ffffffffa01a13be>] iscsit_close_connection+0x14d/0x5b2 [iscsi_target_mod]
      [  131.191092]  [<ffffffffa0196a0c>] iscsit_take_action_for_connection_exit+0xdb/0xe0 [iscsi_target_mod]
      [  131.191092]  [<ffffffffa01a55d4>] iscsi_target_tx_thread+0x15cb/0x1608 [iscsi_target_mod]
      [  131.191092]  [<ffffffff8103609a>] ? check_preempt_wakeup+0x121/0x185
      [  131.191092]  [<ffffffff81030801>] ? __dequeue_entity+0x2e/0x33
      [  131.191092]  [<ffffffffa01a4009>] ? iscsit_send_text_rsp+0x25f/0x25f [iscsi_target_mod]
      [  131.191092]  [<ffffffffa01a4009>] ? iscsit_send_text_rsp+0x25f/0x25f [iscsi_target_mod]
      [  131.191092]  [<ffffffff8138f706>] ? schedule+0x55/0x57
      [  131.191092]  [<ffffffff81056c7d>] kthread+0x7d/0x85
      [  131.191092]  [<ffffffff81399534>] kernel_thread_helper+0x4/0x10
      [  131.191092]  [<ffffffff81056c00>] ? kthread_worker_fn+0x16d/0x16d
      [  131.191092]  [<ffffffff81399530>] ? gs_change+0x13/0x13
      
      Reported-by: <jrepac@yahoo.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      c1ce4bd5
  10. 14 12月, 2011 2 次提交
    • J
      target: remove useless casts · 8359cf43
      Jörn Engel 提交于
      A reader should spend an extra moment whenever noticing a cast,
      because either something special is going on that deserves extra
      attention or, as is all too often the case, the code is wrong.
      
      These casts, afaics, have all been useless.  They cast a foo* to a
      foo*, cast a void* to the assigned type, cast a foo* to void*, before
      assigning it to a void* variable, etc.
      
      In a few cases I also removed an additional &...[0], which is equally
      useless.
      
      Lastly I added three FIXMEs where, to the best of my judgement, the
      code appears to have a bug.  It would be good if someone could check
      these.
      Signed-off-by: NJoern Engel <joern@logfs.org>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      8359cf43
    • C
      target: header reshuffle, part2 · c4795fb2
      Christoph Hellwig 提交于
      This reorganized the headers under include/target into:
      
       - target_core_base.h stays as is with all target-wide data stuctures and defines
       - target_core_backend.h contains the whole interface to I/O backends
       - target_core_fabric.h contains the whole interface to fabric modules
      
      Except for those only the various configfs macro headers stay around.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      c4795fb2
  11. 24 10月, 2011 2 次提交
  12. 17 9月, 2011 2 次提交
    • N
      iscsi-target: Fix sendpage breakage with proper padding+DataDigest iovec offsets · 40b05497
      Nicholas Bellinger 提交于
      This patch fixes a bug in the iscsit_fe_sendpage_sg() transmit codepath that
      was originally introduced with the v3.1 iscsi-target merge that incorrectly
      uses hardcoded cmd->iov_data_count values to determine cmd->iov_data[] offsets
      for extra outgoing padding and DataDigest payload vectors.
      
      This code is obviously incorrect for the DataDigest enabled case with sendpage
      offload, and this fix ensures correct operation for padding + DataDigest,
      padding only, and DataDigest only cases.  The bug was introduced during a
      pre-merge change in iscsit_fe_sendpage_sg() to natively use struct scatterlist
      instead of the legacy v3.0 struct se_mem logic.
      
      Cc: Andy Grover <agrover@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      40b05497
    • N
      iscsi-target: Disable markers + remove dangerous local scope array usage · 2ff017f5
      Nicholas Bellinger 提交于
      This patch makes iscsi-target explictly disable OFMarker=Yes and IFMarker=yes
      parameter key usage during iscsi login by setting IFMarkInt_Reject and
      OFMarkInt_Reject values in iscsi_enforce_integrity_rules() to effectively
      disable iscsi marker usage.  With this patch, an initiator proposer asking
      to enable either marker parameter keys will be issued a 'No' response, and
      the target sets OFMarkInt + IFMarkInt parameter key response to 'Irrelevant'.
      
      With markers disabled during iscsi login, this patch removes the problematic
      on-stack local-scope array for marker intervals in iscsit_do_rx_data() +
      iscsit_do_tx_data(), and other related marker code in iscsi_target_util.c.
      This fixes a potentional stack smashing scenario with small range markers
      enabled and a large MRDSL as reported by DanC here:
      
      [bug report] target: stack can be smashed
      http://www.spinics.net/lists/target-devel/msg00453.htmlReported-by: NDan Carpenter <error27@gmail.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      2ff017f5
  13. 23 8月, 2011 1 次提交
  14. 26 7月, 2011 1 次提交
    • N
      iscsi-target: Add iSCSI fabric support for target v4.1 · e48354ce
      Nicholas Bellinger 提交于
      The Linux-iSCSI.org target module is a full featured in-kernel
      software implementation of iSCSI target mode (RFC-3720) for the
      current WIP mainline target v4.1 infrastructure code for the v3.1
      kernel.  More information can be found here:
      
      http://linux-iscsi.org/wiki/ISCSI
      
      This includes support for:
      
         * RFC-3720 defined request / response state machines and support for
           all defined iSCSI operation codes from Section 10.2.1.2 using libiscsi
           include/scsi/iscsi_proto.h PDU definitions
         * Target v4.1 compatible control plane using the generic layout in
           target_core_fabric_configfs.c and fabric dependent attributes
           within /sys/kernel/config/target/iscsi/ subdirectories.
         * Target v4.1 compatible iSCSI statistics based on RFC-4544 (iSCSI MIBS)
         * Support for IPv6 and IPv4 network portals in M:N mapping to TPGs
         * iSCSI Error Recovery Hierarchy support
         * Per iSCSI connection RX/TX thread pair scheduling affinity
         * crc32c + crc32c_intel SSEv4 instruction offload support using libcrypto
         * CHAP Authentication support using libcrypto
         * Conversion to use internal SGl allocation with iscsit_alloc_buffs() ->
           transport_generic_map_mem_to_cmd()
      
      (nab: Fix iscsi_proto.h struct scsi_lun usage from linux-next in commit:
            iscsi: Use struct scsi_lun in iscsi structs instead of u8[8])
      (nab: Fix 32-bit compile warnings)
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NAndy Grover <agrover@redhat.com>
      Acked-by: NRoland Dreier <roland@kernel.org>
      Signed-off-by: NNicholas A. Bellinger <nab@linux-iscsi.org>
      e48354ce