1. 23 8月, 2011 20 次提交
    • R
      target: Convert acl_node_lock to be IRQ-disabling · 28638887
      Roland Dreier 提交于
      With qla2xxx, acl_node_lock is taken inside qla2xxx's hardware_lock,
      which is taken in hardirq context.  This means acl_node_lock must become
      an IRQ-disabling lock; in particular this fixes lockdep warnings along
      the lines of
      
          ======================================================
          [ INFO: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected ]
      
           (&(&se_tpg->acl_node_lock)->rlock){+.....}, at: [<ffffffffa026f872>] transport_deregister_session+0x92/0x140 [target_core_mod]
      
          and this task is already holding:
           (&(&ha->hardware_lock)->rlock){-.-...}, at: [<ffffffffa017c5e7>] qla_tgt_stop_phase1+0x57/0x2c0 [qla2xxx]
          which would create a new lock dependency:
           (&(&ha->hardware_lock)->rlock){-.-...} -> (&(&se_tpg->acl_node_lock)->rlock){+.....}
      
          but this new dependency connects a HARDIRQ-irq-safe lock:
           (&(&ha->hardware_lock)->rlock){-.-...}
      
          to a HARDIRQ-irq-unsafe lock:
           (&(&se_tpg->acl_node_lock)->rlock){+.....}
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      28638887
    • R
      target: Make locking in transport_deregister_session() IRQ safe · e63a8e19
      Roland Dreier 提交于
      At least the tcm_qla2xxx fabric driver calls into transport_deregister_session()
      while holding an IRQ-disabled spinlock, so the inner locking needs to
      use spin_lock_irqsave() instead of spin_lock_bh().
      
      This fixes warnings seen with tcm_qla2xxx like:
      
          WARNING: at kernel/softirq.c:159 local_bh_enable_ip+0x98/0xb0()
          Call Trace:
           [<ffffffff8104e65f>] warn_slowpath_common+0x7f/0xc0
           [<ffffffff8104e6ba>] warn_slowpath_null+0x1a/0x20
           [<ffffffff81055368>] local_bh_enable_ip+0x98/0xb0
           [<ffffffff814d5284>] _raw_spin_unlock_bh+0x14/0x20
           [<ffffffffa027b7f6>] transport_deregister_session+0x96/0x180 [target_core_mod]
           [<ffffffffa00f7731>] tcm_qla2xxx_free_session+0xd1/0x170 [tcm_qla2xxx]
           [<ffffffffa01b9173>] qla_tgt_sess_put+0xc3/0x140 [qla2xxx]
           [<ffffffffa01bf40f>] qla_tgt_stop_phase1+0x8f/0x2c0 [qla2xxx]
           [<ffffffffa00f735e>] tcm_qla2xxx_tpg_store_enable+0x6e/0xd0 [tcm_qla2xxx]
           [<ffffffffa026ca29>] target_fabric_tpg_attr_store+0x39/0x40 [target_core_mod]
           [<ffffffffa00a575d>] configfs_write_file+0xbd/0x120 [configfs]
           [<ffffffff811464a6>] vfs_write+0xc6/0x180
           [<ffffffff811467c1>] sys_write+0x51/0x90
           [<ffffffff814dd382>] system_call_fastpath+0x16/0x1b
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      e63a8e19
    • R
      tcm_fc: init/exit functions should not be protected by "#ifdef MODULE" · 4e0f0529
      Roland Dreier 提交于
      There's no need for the #ifdef protection when building into the kernel,
      and in fact we need the module_init() for the initialization function to
      be called.
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      4e0f0529
    • R
      target: Print subpage too for unhandled MODE SENSE pages · f15ea578
      Roland Dreier 提交于
      Make a log message more useful by printing both the page and subpage
      that an initiator is requesting.
      Signed-off-by: NRoland Dreier <roland@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      f15ea578
    • D
      iscsi-target: Fix iscsit_allocate_se_cmd_for_tmr failure path bugs · ba773669
      Dan Carpenter 提交于
      This patch fixes two bugs in allocation failure handling in
      iscsit_allocate_se_cmd_for_tmr():
      
      This first reported by DanC is a free-after call to transport_free_se_cmd(), this
      patch drops the transport_free_se_cmd() call all together, as iscsit_release_cmd()
      will release existing allocations as expected.
      
      The second is a bug where iscsi_cmd_t was being leaked on a cmd->tmr_req allocation
      failure, so make this jump to iscsit_release_cmd() as well.
      Signed-off-by: NDan Carpenter <error27@gmail.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      ba773669
    • C
      iscsi-target: Implement iSCSI target IPv6 address printing. · 6626a057
      Chris Boot 提交于
      The iSCSI target configfs code to print out an initiator's IPv6 address
      is not fully implemented. This patch uses snprintf() with the "%pI6c"
      format string to format the IPv6 address for display purposes.
      Signed-off-by: NChris Boot <bootc@bootc.net>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      6626a057
    • N
      target: Fix task SGL chaining breakage with transport_allocate_data_tasks · c3c74c7a
      Nicholas Bellinger 提交于
      This patch fixes two bugs associated with transport_do_task_sg_chain()
      operation where transport_allocate_data_tasks() was incorrectly setting
      task_padded_sg for all tasks, and causing bogus task->task_sg_nents
      assignments + OOPsen with fabrics depending upon this code.  The first bit
      here adds a task_sg_nents_padded check in transport_allocate_data_tasks()
      to include an extra SGL vector when necessary for tasks that expect to
      be linked using sg_chain().
      
      The second change involves making transport_do_task_sg_chain() properly
      account for the extra SGL vector when task->task_padded_sg is set for
      the non trailing ->task_sg or single ->task_sg allocations.  Note this
      patch also removes the BUG_ON(!task->task_padded_sg) check within
      transport_do_task_sg_chain() as we expect this to happen normally
      with the updated logic in transport_allocate_data_tasks(), along with
      being bogus for CONTROL_SG_IO_CDB type payloads.
      
      So far this bugfix has been tested with tcm_qla2xxx and iblock backends
      in (task_count > 1)( and (task_count == 1) operation.
      Reported-by: NKiran Patil <kiran.patil@intel.com>
      Cc: Kiran Patil <kiran.patil@intel.com>
      Cc: Andy Grover <agrover@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      c3c74c7a
    • N
      target: Fix task count > 1 handling breakage and use max_sector page alignment · 525a48a2
      Nicholas Bellinger 提交于
      This patch addresses recent breakage with multiple se_task (task_count > 1)
      operation following backend dev->se_sub_dev->se_dev_attrib.max_sectors in new
      transport_allocate_data_tasks() code.  The initial bug here was a bogus
      task->task_sg_nents assignment in transport_allocate_data_tasks() based on
      the passed parameter, which now uses DIV_ROUND_UP(task_size, PAGE_SIZE) to
      determine the proper number of per task SGL entries for the (task_count > 1)
      case.
      
      This also means we now need to enforce a PAGE_SIZE aligned max_sector count
      value for this to work as expected without bringing back the pre v3.1
      transport_map_mem_to_sg() logic to handle SGL offsets across multiple tasks.
      So this patch adds se_dev_align_max_sectors() to round down max_sectors as
      necessary to ensure this alignment via se_dev_set_default_attribs() and
      se_dev_align_max_sectors() and keeps it simple for (task_count > 1)
      operation.
      
      So far this bugfix has been tested with (task_count > 1) operation
      using iscsi-target and iblock backends.
      Reported-by: NChris Boot <bootc@bootc.net>
      Cc: Kiran Patil <kiran.patil@intel.com>
      Cc: Andy Grover <agrover@redhat.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      525a48a2
    • N
      target: Add missing DATA_SG_IO transport_cmd_get_valid_sectors check · 01cde4d5
      Nicholas Bellinger 提交于
      This patch adds the missing transport_cmd_get_valid_sectors() check for
      SCF_SCSI_DATA_SG_IO_CDB type payloads to ensure that a received LBA + range
      does not exeed past the end of associated backend struct se_device.
      
      This patch also fixes a bug in the failure path of transport_new_cmd_obj()
      where this check can fail, so change to use a signed 'rc' and return '-EINVAL'
      to signal proper transport_generic_request_failure() handling.
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      01cde4d5
    • N
      target: Fix SYNCHRONIZE_CACHE zero LBA + range breakage · 7abbe7f3
      Nicholas Bellinger 提交于
      This patch fixes a SYNCHRONIZE_CACHE CDB handling bug with IBLOCK/FILEIO
      backends where transport_cmd_get_valid_sectors() was incorrectly rejecting
      a zero LBA + range CDB from being processed, and returning CHECK_CONDITION.
      
      This includes changing transport_cmd_get_valid_sectors() to return '0' on
      success and '-EINVAL' on failure (this makes more sense than sectors),
      and to only check transport_cmd_get_valid_sectors() when a non zero LBA +
      range SYNCHRONIZE_CACHE operation has been receieved for the non passthrough
      case.
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      7abbe7f3
    • N
      target: Remove duplicate task completions in transport_emulate_control_cdb · 72f4ba1e
      Nicholas Bellinger 提交于
      This patch removes a duplicate set of transport_complete_task() calls in
      target_emulate_unmap() and target_emulate_write_same() as the completion
      call is already done within transport_emulate_control_cdb()
      
      This patch also adds a check in transport_emulate_control_cdb() for the
      existing SCF_EMULATE_CDB_ASYNC flag currently used by SYNCHRONIZE_CACHE
      in order to handle IMMEDIATE processing.
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      72f4ba1e
    • N
      target: Fix WRITE_SAME usage with transport_get_size · 12850626
      Nicholas Bellinger 提交于
      For all flavours of WRITE_SAME, we only expect to handle a single block
      of data-out buffer payload, regardless of the number of logical blocks
      presented in the CDB.  This patch changes all flavours of WRITE_SAME in
      transport_generic_cmd_sequencer() to pass '1' into transport_get_size()
      instead of the extracted 'sectors' to properly handle the default usage
      of sg_write_same without the --xferlen parameter.
      Reported-by: NEric Seppanen <eric@purestorage.com>
      Signed-off-by: NNicholas Bellinger <nab@risingtidesystems.com>
      12850626
    • N
      target: Add WRITE_SAME (10) parsing and refactor passthrough checks · 706d5860
      Nicholas Bellinger 提交于
      This patch adds initial WRITE_SAME (10) w/ UNMAP=1 support following updates in
      sbcr26 to allow UNMAP=1 for the non 16 + 32 byte CDB case.  It also refactors
      current pSCSI passthrough passthrough checks into target_check_write_same_discard()
      ahead of UNMAP=0 w/ write payload support into target_core_iblock.c.
      
      This includes the support for handling WRITE_SAME in transport_emulate_control_cdb(),
      and converts target_emulate_write_same to accept num_blocks directly for
      WRITE_SAME, WRITE_SAME_16 and WRITE_SAME_32.
      Reported-by: NEric Seppanen <eric@purestorage.com>
      Cc: Roland Dreier <roland@purestorage.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Signed-off-by: NNicholas Bellinger <nab@risingtidesystems.com>
      706d5860
    • N
      target: Fix write payload exception handling with ->new_cmd_map · 16ab8e60
      Nicholas Bellinger 提交于
      This patch fixes a bug for fabrics using tfo->new_cmd_map() that
      are expect transport_generic_request_failure() to be calling
      transport_send_check_condition_and_sense() for both READ and WRITE,
      instead of only for READ exceptions.
      
      This was originally observed with a failed WRITE_SAME_16 w/ unmap=0
      using tcm_loop.
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      16ab8e60
    • D
      iscsi-target: forever loop bug in iscsit_attach_ooo_cmdsn() · 387e96c0
      Dan Carpenter 提交于
      This patch fixes a forever loop bug in iscsit_attach_ooo_cmdsn()
      while walking sess->sess_ooo_cmdsn_list when the received
      CmdSN is less than the tail of the list.
      Signed-off-by: NDan Carpenter <error27@gmail.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      387e96c0
    • D
      iscsi-target: remove duplicate return · c2337c70
      Dan Carpenter 提交于
      We returned on the line before already.
      Signed-off-by: NDan Carpenter <error27@gmail.com>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      c2337c70
    • J
      target: Convert target_core_rd.c to use use BUG_ON · 6fc61488
      Julia Lawall 提交于
      Use BUG_ON(x) rather than if(x) BUG();
      
      The semantic patch that fixes this problem is as follows:
      (http://coccinelle.lip6.fr/)
      
      // <smpl>
      @@ identifier x; @@
      -if (x) BUG();
      +BUG_ON(x);
      
      @@ identifier x; @@
      -if (!x) BUG();
      +BUG_ON(!x);
      // </smpl>
      Signed-off-by: NJulia Lawall <julia@diku.dk>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      6fc61488
    • J
      iscsi-target: Fix leak on failure in iscsi_copy_param_list() · 9be08c58
      Jesper Juhl 提交于
      We leak memory if the allocations for 'new_param->name' or
      'new_param->value' fail in iscsi_target_parameters.c::iscsi_copy_param_list()
      
      We also do a lot of variable assignments that are completely pointless
      if the allocations fail.
      
      So, let's move the allocations before the assignments and also make
      sure that we free whatever was allocated to one if the allocation fail.
      
      There's also some small CodingStyle fixups in there (curly braces on
      both branches of if statement, only one variable per line) since I was
      in the area anyway. And finally, error messages in the function are
      put on a single line for easy grep'abillity.
      Signed-off-by: NJesper Juhl <jj@chaosbits.net>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      9be08c58
    • T
      target: Use ERR_CAST inlined function · e1750ba2
      Thomas Meyer 提交于
      Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...))
      
      The semantic patch that makes this output is available
      in scripts/coccinelle/api/err_cast.cocci.
      
      More information about semantic patching is available at
      http://coccinelle.lip6.fr/Signed-off-by: NThomas Meyer <thomas@m3y3r.de>
      Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
      e1750ba2
    • N
      target: Make standard INQUIRY return 'not connected' for tpg_virt_lun0 · 052605c6
      Nicholas Bellinger 提交于
      This patch changes target_emulate_inquiry_std() to set the 'not connected'
      (0x35) bit in standard INQUIRY response data when we are processing a
      request to a virtual LUN=0 mapping from struct se_device *g_lun0_dev that
      have been setup for us in transport_lookup_cmd_lun().
      
      This addresses an issue where qla2xxx FC clients need to be able
      to create demo-mode I_T FC Nexuses by default, but should not be
      exposing the default set of TPG LUNs to all FC clients.  This includes
      adding an new optional target_core_fabric_ops->tpg_check_demo_mode_login_only()
      caller to allow demo_mode nexuses to skip the old default of bulding
      a demo-mode MappedLUNs list via core_tpg_add_node_to_devs().
      
      (roland: Add missing tpg_check_demo_mode_login_only check in core_dev_add_lun)
      Reported-by: NRoland Dreier <roland@purestorage.com>
      Cc: Andrew Vasquez <andrew.vasquez@qlogic.com>
      Signed-off-by: NNicholas Bellinger <nab@risingtidesystems.com>
      052605c6
  2. 17 8月, 2011 1 次提交
  3. 15 8月, 2011 3 次提交
  4. 14 8月, 2011 16 次提交