[PATCH-v2 0/9] target: se_node_acl + se_lun RCU conversions

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

Hi all,

Here is -v2 series for converting LIO target se_node_acl + se_lun
mapping tables from fixed size arrays to dynamic RCU hlist_heads.

This turns fast-path I/O into a lock-less RCU reader using existing
percpu based se_lun-lun_ref logic, and converts the RCU updater
path to allow for an arbitrary number of LUNs for both types of
mappings within target-core.

This series also squashes a number of previous se_node_acl RCU
related changes into a single commit (#1) for easier review,
and to avoid potential bisect issues.

There have been a number of changes since -v1, including:

  - Mirror port-sep_rtpi in lun-lun_rtpi for RCU
  - Drop unnecessary synchronize_rcu() usage
  - Convert call_rcu() to kfree_rcu() usage
  - Move hlist_del_rcu head of rcu_assign_pointer in se_dev_entry
  - Drop unnecessary lookup deve in target_fabric_mappedlun_unlink()
  - Add target_lun_is_rdonly helper
  - Acquire lun_entry_mutex during core_disable_device_list_for_node
  - Drop TRANSPORT_LUNFLAGS_*_ACCESS usage
  - Pass se_dev_entry directly to core_disable_device_list_for_node
  - Convert sbp-target se_lun usage to use -login_lun
  - Fix se_session dereference in spc_emulate_report_luns 
  - Fix testing for NULL instead of IS_ERR in fabric_make_lun()
  - Convert BUG_ON to EINVAL for wrong dynamic - explicit ACL conversion 
  - Add missing hlist_del_rcu when swapping orig with new
  - Add HBA_FLAGS_INTERNAL_USE checks in add/remove lun

Please review.

--nab

Christoph Hellwig (1):
  target/pr: cleanup core_scsi3_pr_seq_non_holder

Nicholas Bellinger (8):
  target: Convert se_node_acl-device_list[] to RCU hlist
  target/pr: Use atomic bitop for se_dev_entry-pr_reg reservation check
  target/pr: Change alloc_registration to avoid pr_reg_tg_pt_lun
  target: Convert se_portal_group-tpg_lun_list[] to RCU hlist
  target: Convert se_tpg-acl_node_lock to -acl_node_mutex
  target: Convert core_tpg_deregister to use list splice
  target: Drop unused se_lun-lun_acl_list
  target: Only reset specific dynamic entries during lun_group creation

 drivers/target/iscsi/iscsi_target_tpg.c  |   2 -
 drivers/target/sbp/sbp_target.c  |  97 +++---
 drivers/target/sbp/sbp_target.h  |   2 +-
 drivers/target/target_core_configfs.c|   6 +-
 drivers/target/target_core_device.c  | 452 +++
 drivers/target/target_core_fabric_configfs.c |  75 +++--
 drivers/target/target_core_internal.h|  17 +-
 drivers/target/target_core_pr.c  | 217 +++--
 drivers/target/target_core_pscsi.c   |   7 +-
 drivers/target/target_core_spc.c |  18 +-
 drivers/target/target_core_stat.c| 180 +--
 drivers/target/target_core_tpg.c | 269 
 drivers/target/target_core_transport.c   |  20 +-
 drivers/target/target_core_ua.c  |  51 ++-
 drivers/target/tcm_fc/tfc_conf.c |   4 +-
 drivers/xen/xen-scsiback.c   |  27 +-
 include/target/target_core_backend.h |   2 +-
 include/target/target_core_base.h|  38 +--
 include/target/target_core_fabric.h  |   1 -
 19 files changed, 634 insertions(+), 851 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH-v2 2/9] target/pr: Use atomic bitop for se_dev_entry-pr_reg reservation check

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

This patch converts the core_scsi3_pr_seq_non_holder() check for non
reservation holding registrations to use an atomic bitop.

It also includes associated set_bit() in __core_scsi3_add_registration()
and clear_bit() __core_scsi3_free_registration() for the updater path.

Reported-by: Christoph Hellwig h...@lst.de
Cc: Hannes Reinecke h...@suse.de
Cc: Sagi Grimberg sa...@mellanox.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_device.c |  1 +
 drivers/target/target_core_pr.c | 57 -
 include/target/target_core_base.h   |  4 +--
 3 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index cfe5cd3..6432d26 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -405,6 +405,7 @@ void core_disable_device_list_for_node(
core_scsi3_ua_release_all(orig);
 
hlist_del_rcu(orig-link);
+   clear_bit(1, orig-pr_reg);
rcu_assign_pointer(orig-se_lun, NULL);
rcu_assign_pointer(orig-se_lun_acl, NULL);
orig-lun_flags = 0;
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index c0b593a..d29b39c 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -327,9 +327,13 @@ static int core_scsi3_pr_seq_non_holder(
int we = 0; /* Write Exclusive */
int legacy = 0; /* Act like a legacy device and return
 * RESERVATION CONFLICT on some CDBs */
+   bool registered = false;
 
rcu_read_lock();
se_deve = target_nacl_find_deve(nacl, cmd-orig_fe_lun);
+   if (se_deve)
+   registered = test_bit(1, se_deve-pr_reg);
+   rcu_read_unlock();
/*
 * Determine if the registration should be ignored due to
 * non-matching ISIDs in target_scsi3_pr_reservation_check().
@@ -346,7 +350,7 @@ static int core_scsi3_pr_seq_non_holder(
 * Some commands are only allowed for the persistent reservation
 * holder.
 */
-   if ((se_deve-def_pr_registered)  !(ignore_reg))
+   if ((registered)  !(ignore_reg))
registered_nexus = 1;
break;
case PR_TYPE_WRITE_EXCLUSIVE_REGONLY:
@@ -356,7 +360,7 @@ static int core_scsi3_pr_seq_non_holder(
 * Some commands are only allowed for registered I_T Nexuses.
 */
reg_only = 1;
-   if ((se_deve-def_pr_registered)  !(ignore_reg))
+   if ((registered)  !(ignore_reg))
registered_nexus = 1;
break;
case PR_TYPE_WRITE_EXCLUSIVE_ALLREG:
@@ -366,14 +370,12 @@ static int core_scsi3_pr_seq_non_holder(
 * Each registered I_T Nexus is a reservation holder.
 */
all_reg = 1;
-   if ((se_deve-def_pr_registered)  !(ignore_reg))
+   if ((registered)  !(ignore_reg))
registered_nexus = 1;
break;
default:
-   rcu_read_unlock();
return -EINVAL;
}
-   rcu_read_unlock();
/*
 * Referenced from spc4r17 table 45 for *NON* PR holder access
 */
@@ -1009,10 +1011,6 @@ static void __core_scsi3_dump_registration(
pr_reg-pr_reg_aptpl);
 }
 
-/*
- * this function can be called with struct se_device-dev_reservation_lock
- * when register_move = 1
- */
 static void __core_scsi3_add_registration(
struct se_device *dev,
struct se_node_acl *nacl,
@@ -1023,6 +1021,7 @@ static void __core_scsi3_add_registration(
const struct target_core_fabric_ops *tfo = nacl-se_tpg-se_tpg_tfo;
struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe;
struct t10_reservation *pr_tmpl = dev-t10_pr;
+   struct se_dev_entry *deve;
 
/*
 * Increment PRgeneration counter for struct se_device upon a successful
@@ -1039,10 +1038,16 @@ static void __core_scsi3_add_registration(
 
spin_lock(pr_tmpl-registration_lock);
list_add_tail(pr_reg-pr_reg_list, pr_tmpl-registration_list);
-   pr_reg-pr_reg_deve-def_pr_registered = 1;
 
__core_scsi3_dump_registration(tfo, dev, nacl, pr_reg, register_type);
spin_unlock(pr_tmpl-registration_lock);
+
+   mutex_lock(nacl-lun_entry_mutex);
+   deve = target_nacl_find_deve(nacl, pr_reg-pr_res_mapped_lun);
+   if (deve)
+   set_bit(1, deve-pr_reg);
+   mutex_unlock(nacl-lun_entry_mutex);
+
/*
 * Skip extra processing for ALL_TG_PT=0 or REGISTER_AND_MOVE.
 */
@@ -1054,6 +1059,8 @@ static void __core_scsi3_add_registration(
 */
list_for_each_entry_safe(pr_reg_tmp, pr_reg_tmp_safe,

Re: [PATCH 2/4] target: Drop lun_sep_lock for se_lun-lun_se_dev RCU usage

2015-05-22 Thread Hannes Reinecke
On 05/22/2015 09:06 AM, Nicholas A. Bellinger wrote:
 From: Nicholas Bellinger n...@linux-iscsi.org
 
 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.
 
 Also, convert se_lun-lun_stats to use atomic_long_t within the
 target_complete_ok_work() completion callback.
 
 Reported-by: Christoph Hellwig h...@lst.de
 Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
 ---
  drivers/target/target_core_device.c|  1 -
  drivers/target/target_core_stat.c  | 65 
 +-
  drivers/target/target_core_tpg.c   |  8 ++---
  drivers/target/target_core_transport.c | 22 
  include/target/target_core_base.h  |  9 +++--
  5 files changed, 46 insertions(+), 59 deletions(-)
 

[ .. ]

 diff --git a/drivers/target/target_core_tpg.c 
 b/drivers/target/target_core_tpg.c
 index 8764f1c..f60b74e 100644
 --- a/drivers/target/target_core_tpg.c
 +++ b/drivers/target/target_core_tpg.c
 @@ -601,7 +601,6 @@ struct se_lun *core_tpg_alloc_lun(
   lun-lun_link_magic = SE_LUN_LINK_MAGIC;
   lun-lun_status = TRANSPORT_LUN_STATUS_FREE;
   atomic_set(lun-lun_acl_count, 0);
 - spin_lock_init(lun-lun_sep_lock);
   init_completion(lun-lun_ref_comp);
   INIT_LIST_HEAD(lun-lun_deve_list);
   INIT_LIST_HEAD(lun-lun_dev_link);
 @@ -638,10 +637,7 @@ int core_tpg_add_lun(
   target_attach_tg_pt_gp(lun, dev-t10_alua.default_tg_pt_gp);
  
   mutex_lock(tpg-tpg_lun_mutex);
 -
 - spin_lock(lun-lun_sep_lock);
 - lun-lun_se_dev = dev;
 - spin_unlock(lun-lun_sep_lock);
 + rcu_assign_pointer(lun-lun_se_dev, dev);
  
   spin_lock(dev-se_port_lock);
   dev-export_count++;
 @@ -683,7 +679,7 @@ void core_tpg_remove_lun(
   dev-export_count--;
   spin_unlock(dev-se_port_lock);
  
 - lun-lun_se_dev = NULL;
 + rcu_assign_pointer(lun-lun_se_dev, NULL);
   }
  
   lun-lun_status = TRANSPORT_LUN_STATUS_FREE;
Doesn't this need to go under 'dev-se_port_lock' like in
core_tgp_add_lun() ?

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries  Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH-v2 5/9] target: Convert se_portal_group-tpg_lun_list[] to RCU hlist

2015-05-22 Thread Christoph Hellwig
 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.
 
 Also 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.

Still doesn't explain why core_tpg_clear_object_luns also disappears.

 + hlist_for_each_entry_rcu(lun, tpg-tpg_lun_hlist, link) {
   if (lun-lun_status != TRANSPORT_LUN_STATUS_ACTIVE)
   continue;

lun_status will always be active here as that's set and cleared at the
same time as the list addition / removal.  Which means that lun_status
should go away in this patch.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH-v2 8/9] target: Drop unused se_lun-lun_acl_list

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

Cc: Hannes Reinecke h...@suse.de
Cc: Christoph Hellwig h...@lst.de
Cc: Sagi Grimberg sa...@mellanox.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_device.c | 15 ---
 drivers/target/target_core_tpg.c|  4 
 include/target/target_core_base.h   |  3 ---
 3 files changed, 22 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index 99a60e6..7674c8f 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -1232,7 +1232,6 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
return NULL;
}
 
-   INIT_LIST_HEAD(lacl-lacl_list);
lacl-mapped_lun = mapped_lun;
lacl-se_lun_nacl = nacl;
snprintf(lacl-initiatorname, TRANSPORT_IQN_LEN, %s,
@@ -1262,11 +1261,6 @@ int core_dev_add_initiator_node_lun_acl(
lun_access, nacl, tpg)  0)
return -EINVAL;
 
-   spin_lock(lun-lun_acl_lock);
-   list_add_tail(lacl-lacl_list, lun-lun_acl_list);
-   atomic_inc_mb(lun-lun_acl_count);
-   spin_unlock(lun-lun_acl_lock);
-
pr_debug(%s_TPG[%hu]_LUN[%u-%u] - Added %s ACL for 
 InitiatorNode: %s\n, tpg-se_tpg_tfo-get_fabric_name(),
tpg-se_tpg_tfo-tpg_get_tag(tpg), lun-unpacked_lun, 
lacl-mapped_lun,
@@ -1293,19 +1287,12 @@ int core_dev_del_initiator_node_lun_acl(
if (!nacl)
return -EINVAL;
 
-   spin_lock(lun-lun_acl_lock);
-   list_del(lacl-lacl_list);
-   atomic_dec_mb(lun-lun_acl_count);
-   spin_unlock(lun-lun_acl_lock);
-
mutex_lock(nacl-lun_entry_mutex);
deve = target_nacl_find_deve(nacl, lacl-mapped_lun);
if (deve)
core_disable_device_list_for_node(lun, deve, nacl, tpg);
mutex_unlock(nacl-lun_entry_mutex);
 
-   lacl-se_lun = NULL;
-
pr_debug(%s_TPG[%hu]_LUN[%u] - Removed ACL for
 InitiatorNode: %s Mapped LUN: %u\n,
tpg-se_tpg_tfo-get_fabric_name(),
@@ -1435,8 +1422,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, 
const char *name)
xcopy_lun = dev-xcopy_lun;
xcopy_lun-lun_se_dev = dev;
init_completion(xcopy_lun-lun_shutdown_comp);
-   INIT_LIST_HEAD(xcopy_lun-lun_acl_list);
-   spin_lock_init(xcopy_lun-lun_acl_lock);
spin_lock_init(xcopy_lun-lun_sep_lock);
init_completion(xcopy_lun-lun_ref_comp);
 
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index e7745d2..73c25bd 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -495,8 +495,6 @@ static int core_tpg_setup_virtual_lun0(struct 
se_portal_group *se_tpg)
lun-lun_status = TRANSPORT_LUN_STATUS_FREE;
atomic_set(lun-lun_acl_count, 0);
init_completion(lun-lun_shutdown_comp);
-   INIT_LIST_HEAD(lun-lun_acl_list);
-   spin_lock_init(lun-lun_acl_lock);
spin_lock_init(lun-lun_sep_lock);
init_completion(lun-lun_ref_comp);
 
@@ -610,8 +608,6 @@ struct se_lun *core_tpg_alloc_lun(
lun-lun_status = TRANSPORT_LUN_STATUS_FREE;
atomic_set(lun-lun_acl_count, 0);
init_completion(lun-lun_shutdown_comp);
-   INIT_LIST_HEAD(lun-lun_acl_list);
-   spin_lock_init(lun-lun_acl_lock);
spin_lock_init(lun-lun_sep_lock);
init_completion(lun-lun_ref_comp);
 
diff --git a/include/target/target_core_base.h 
b/include/target/target_core_base.h
index f6cf401..25d5ebe 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -632,7 +632,6 @@ struct se_lun_acl {
u32 mapped_lun;
struct se_node_acl  *se_lun_nacl;
struct se_lun   *se_lun;
-   struct list_headlacl_list;
struct config_group se_lun_group;
struct se_ml_stat_grps  ml_stat_grps;
 };
@@ -714,10 +713,8 @@ struct se_lun {
u32 lun_flags;
u32 unpacked_lun;
atomic_tlun_acl_count;
-   spinlock_t  lun_acl_lock;
spinlock_t  lun_sep_lock;
struct completion   lun_shutdown_comp;
-   struct list_headlun_acl_list;
struct se_device*lun_se_dev;
struct se_port  *lun_sep;
struct config_group lun_group;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH-v2 9/9] target: Only reset specific dynamic entries during lun_group creation

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

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.

Cc: Hannes Reinecke h...@suse.de
Cc: Christoph Hellwig h...@lst.de
Cc: Sagi Grimberg sa...@mellanox.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_device.c   | 2 +-
 drivers/target/target_core_internal.h | 3 ++-
 drivers/target/target_core_tpg.c  | 7 +--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index 7674c8f..c80a7a8 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -1186,7 +1186,7 @@ int core_dev_add_lun(
if (acl-dynamic_node_acl 
(!tpg-se_tpg_tfo-tpg_check_demo_mode_login_only ||
 
!tpg-se_tpg_tfo-tpg_check_demo_mode_login_only(tpg))) {
-   core_tpg_add_node_to_devs(acl, tpg);
+   core_tpg_add_node_to_devs(acl, tpg, lun);
}
}
mutex_unlock(tpg-acl_node_mutex);
diff --git a/drivers/target/target_core_internal.h 
b/drivers/target/target_core_internal.h
index 2c160ce..ce80ca7 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -64,7 +64,8 @@ extern struct se_device *g_lun0_dev;
 
 struct se_node_acl *__core_tpg_get_initiator_node_acl(struct se_portal_group 
*tpg,
const char *);
-void   core_tpg_add_node_to_devs(struct se_node_acl *, struct se_portal_group 
*);
+void   core_tpg_add_node_to_devs(struct se_node_acl *, struct se_portal_group 
*,
+ struct se_lun *);
 void   core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *);
 struct se_lun *core_tpg_alloc_lun(struct se_portal_group *, u32);
 intcore_tpg_add_lun(struct se_portal_group *, struct se_lun *,
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 73c25bd..f66c208 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -89,7 +89,8 @@ EXPORT_SYMBOL(core_tpg_get_initiator_node_acl);
  */
 void core_tpg_add_node_to_devs(
struct se_node_acl *acl,
-   struct se_portal_group *tpg)
+   struct se_portal_group *tpg,
+   struct se_lun *lun_orig)
 {
u32 lun_access = 0;
struct se_lun *lun;
@@ -99,6 +100,8 @@ void core_tpg_add_node_to_devs(
hlist_for_each_entry_rcu(lun, tpg-tpg_lun_hlist, link) {
if (lun-lun_status != TRANSPORT_LUN_STATUS_ACTIVE)
continue;
+   if (lun_orig  lun != lun_orig)
+   continue;
 
dev = lun-lun_se_dev;
/*
@@ -238,7 +241,7 @@ struct se_node_acl *core_tpg_check_initiator_node_acl(
 */
if ((tpg-se_tpg_tfo-tpg_check_demo_mode_login_only == NULL) ||
(tpg-se_tpg_tfo-tpg_check_demo_mode_login_only(tpg) != 1))
-   core_tpg_add_node_to_devs(acl, tpg);
+   core_tpg_add_node_to_devs(acl, tpg, NULL);
 
target_add_node_acl(acl);
return acl;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH-v2 4/9] target/pr: cleanup core_scsi3_pr_seq_non_holder

2015-05-22 Thread Nicholas A. Bellinger
From: Christoph Hellwig h...@lst.de

Clean up the mess of registered variables, and pass the isid mismatch
flag explicitly instead of overloading the registration type.

Signed-off-by: Christoph Hellwig h...@lst.de
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_pr.c | 43 -
 1 file changed, 17 insertions(+), 26 deletions(-)

diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 94a136f..36bcc60 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -312,34 +312,30 @@ out:
  * This function is called by those initiator ports who are *NOT*
  * the active PR reservation holder when a reservation is present.
  */
-static int core_scsi3_pr_seq_non_holder(
-   struct se_cmd *cmd,
-   u32 pr_reg_type)
+static int core_scsi3_pr_seq_non_holder(struct se_cmd *cmd, u32 pr_reg_type,
+   bool isid_mismatch)
 {
unsigned char *cdb = cmd-t_task_cdb;
-   struct se_dev_entry *se_deve;
struct se_session *se_sess = cmd-se_sess;
struct se_node_acl *nacl = se_sess-se_node_acl;
-   int other_cdb = 0, ignore_reg;
+   int other_cdb = 0;
int registered_nexus = 0, ret = 1; /* Conflict by default */
int all_reg = 0, reg_only = 0; /* ALL_REG, REG_ONLY */
int we = 0; /* Write Exclusive */
int legacy = 0; /* Act like a legacy device and return
 * RESERVATION CONFLICT on some CDBs */
-   bool registered = false;
 
-   rcu_read_lock();
-   se_deve = target_nacl_find_deve(nacl, cmd-orig_fe_lun);
-   if (se_deve)
-   registered = test_bit(1, se_deve-pr_reg);
-   rcu_read_unlock();
-   /*
-* Determine if the registration should be ignored due to
-* non-matching ISIDs in target_scsi3_pr_reservation_check().
-*/
-   ignore_reg = (pr_reg_type  0x8000);
-   if (ignore_reg)
-   pr_reg_type = ~0x8000;
+   if (isid_mismatch) {
+   registered_nexus = 0;
+   } else {
+   struct se_dev_entry *se_deve;
+
+   rcu_read_lock();
+   se_deve = target_nacl_find_deve(nacl, cmd-orig_fe_lun);
+   if (se_deve)
+   registered_nexus = test_bit(1, se_deve-pr_reg);
+   rcu_read_unlock();
+   }
 
switch (pr_reg_type) {
case PR_TYPE_WRITE_EXCLUSIVE:
@@ -349,8 +345,6 @@ static int core_scsi3_pr_seq_non_holder(
 * Some commands are only allowed for the persistent reservation
 * holder.
 */
-   if ((registered)  !(ignore_reg))
-   registered_nexus = 1;
break;
case PR_TYPE_WRITE_EXCLUSIVE_REGONLY:
we = 1;
@@ -359,8 +353,6 @@ static int core_scsi3_pr_seq_non_holder(
 * Some commands are only allowed for registered I_T Nexuses.
 */
reg_only = 1;
-   if ((registered)  !(ignore_reg))
-   registered_nexus = 1;
break;
case PR_TYPE_WRITE_EXCLUSIVE_ALLREG:
we = 1;
@@ -369,8 +361,6 @@ static int core_scsi3_pr_seq_non_holder(
 * Each registered I_T Nexus is a reservation holder.
 */
all_reg = 1;
-   if ((registered)  !(ignore_reg))
-   registered_nexus = 1;
break;
default:
return -EINVAL;
@@ -576,6 +566,7 @@ target_scsi3_pr_reservation_check(struct se_cmd *cmd)
struct se_device *dev = cmd-se_dev;
struct se_session *sess = cmd-se_sess;
u32 pr_reg_type;
+   bool isid_mismatch = false;
 
if (!dev-dev_pr_res_holder)
return 0;
@@ -588,7 +579,7 @@ target_scsi3_pr_reservation_check(struct se_cmd *cmd)
if (dev-dev_pr_res_holder-isid_present_at_reg) {
if (dev-dev_pr_res_holder-pr_reg_bin_isid !=
sess-sess_bin_isid) {
-   pr_reg_type |= 0x8000;
+   isid_mismatch = true;
goto check_nonholder;
}
}
@@ -596,7 +587,7 @@ target_scsi3_pr_reservation_check(struct se_cmd *cmd)
return 0;
 
 check_nonholder:
-   if (core_scsi3_pr_seq_non_holder(cmd, pr_reg_type))
+   if (core_scsi3_pr_seq_non_holder(cmd, pr_reg_type, isid_mismatch))
return TCM_RESERVATION_CONFLICT;
return 0;
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] target: Drop lun_sep_lock for se_lun-lun_se_dev RCU usage

2015-05-22 Thread Nicholas A. Bellinger
On Fri, 2015-05-22 at 09:57 +0200, Hannes Reinecke wrote:
 On 05/22/2015 09:06 AM, Nicholas A. Bellinger wrote:
  From: Nicholas Bellinger n...@linux-iscsi.org
  
  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.
  
  Also, convert se_lun-lun_stats to use atomic_long_t within the
  target_complete_ok_work() completion callback.
  
  Reported-by: Christoph Hellwig h...@lst.de
  Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
  ---
   drivers/target/target_core_device.c|  1 -
   drivers/target/target_core_stat.c  | 65 
  +-
   drivers/target/target_core_tpg.c   |  8 ++---
   drivers/target/target_core_transport.c | 22 
   include/target/target_core_base.h  |  9 +++--
   5 files changed, 46 insertions(+), 59 deletions(-)
  
 
 [ .. ]
 
  diff --git a/drivers/target/target_core_tpg.c 
  b/drivers/target/target_core_tpg.c
  index 8764f1c..f60b74e 100644
  --- a/drivers/target/target_core_tpg.c
  +++ b/drivers/target/target_core_tpg.c
  @@ -601,7 +601,6 @@ struct se_lun *core_tpg_alloc_lun(
  lun-lun_link_magic = SE_LUN_LINK_MAGIC;
  lun-lun_status = TRANSPORT_LUN_STATUS_FREE;
  atomic_set(lun-lun_acl_count, 0);
  -   spin_lock_init(lun-lun_sep_lock);
  init_completion(lun-lun_ref_comp);
  INIT_LIST_HEAD(lun-lun_deve_list);
  INIT_LIST_HEAD(lun-lun_dev_link);
  @@ -638,10 +637,7 @@ int core_tpg_add_lun(
  target_attach_tg_pt_gp(lun, dev-t10_alua.default_tg_pt_gp);
   
  mutex_lock(tpg-tpg_lun_mutex);
  -
  -   spin_lock(lun-lun_sep_lock);
  -   lun-lun_se_dev = dev;
  -   spin_unlock(lun-lun_sep_lock);
  +   rcu_assign_pointer(lun-lun_se_dev, dev);
   
  spin_lock(dev-se_port_lock);
  dev-export_count++;
  @@ -683,7 +679,7 @@ void core_tpg_remove_lun(
  dev-export_count--;
  spin_unlock(dev-se_port_lock);
   
  -   lun-lun_se_dev = NULL;
  +   rcu_assign_pointer(lun-lun_se_dev, NULL);
  }
   
  lun-lun_status = TRANSPORT_LUN_STATUS_FREE;
 Doesn't this need to go under 'dev-se_port_lock' like in
 core_tgp_add_lun() ?

Yes, of course.  Adding the following change, and will squash into the
original patch soon.

Thanks for reviewing Hannes!

diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index aa08d6b..a3c9121 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -641,9 +641,9 @@ int core_tpg_add_lun(
target_attach_tg_pt_gp(lun, dev-t10_alua.default_tg_pt_gp);
 
mutex_lock(tpg-tpg_lun_mutex);
-   rcu_assign_pointer(lun-lun_se_dev, dev);
 
spin_lock(dev-se_port_lock);
+   rcu_assign_pointer(lun-lun_se_dev, dev);
dev-export_count++;
list_add_tail(lun-lun_dev_link, dev-dev_sep_list);
spin_unlock(dev-se_port_lock);

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] target: Drop lun_sep_lock for se_lun-lun_se_dev RCU usage

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

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.

Also, convert se_lun-lun_stats to use atomic_long_t within the
target_complete_ok_work() completion callback.

Reported-by: Christoph Hellwig h...@lst.de
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_device.c|  1 -
 drivers/target/target_core_stat.c  | 65 +-
 drivers/target/target_core_tpg.c   |  8 ++---
 drivers/target/target_core_transport.c | 22 
 include/target/target_core_base.h  |  9 +++--
 5 files changed, 46 insertions(+), 59 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index 31133ce..1d98033 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -792,7 +792,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, 
const char *name)
 
xcopy_lun = dev-xcopy_lun;
xcopy_lun-lun_se_dev = dev;
-   spin_lock_init(xcopy_lun-lun_sep_lock);
init_completion(xcopy_lun-lun_ref_comp);
INIT_LIST_HEAD(xcopy_lun-lun_deve_list);
INIT_LIST_HEAD(xcopy_lun-lun_dev_link);
diff --git a/drivers/target/target_core_stat.c 
b/drivers/target/target_core_stat.c
index 5127c67..d38a18e 100644
--- a/drivers/target/target_core_stat.c
+++ b/drivers/target/target_core_stat.c
@@ -545,11 +545,11 @@ static ssize_t target_stat_scsi_port_show_attr_inst(
struct se_device *dev;
ssize_t ret = -ENODEV;
 
-   spin_lock(lun-lun_sep_lock);
+   rcu_read_lock();
dev = lun-lun_se_dev;
if (dev)
ret = snprintf(page, PAGE_SIZE, %u\n, dev-se_hba-hba_index);
-   spin_unlock(lun-lun_sep_lock);
+   rcu_read_unlock();
return ret;
 }
 DEV_STAT_SCSI_PORT_ATTR_RO(inst);
@@ -561,11 +561,11 @@ static ssize_t target_stat_scsi_port_show_attr_dev(
struct se_device *dev;
ssize_t ret = -ENODEV;
 
-   spin_lock(lun-lun_sep_lock);
+   rcu_read_lock();
dev = lun-lun_se_dev;
if (dev)
ret = snprintf(page, PAGE_SIZE, %u\n, dev-dev_index);
-   spin_unlock(lun-lun_sep_lock);
+   rcu_read_unlock();
return ret;
 }
 DEV_STAT_SCSI_PORT_ATTR_RO(dev);
@@ -576,10 +576,10 @@ static ssize_t target_stat_scsi_port_show_attr_indx(
struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
ssize_t ret = -ENODEV;
 
-   spin_lock(lun-lun_sep_lock);
+   rcu_read_lock();
if (lun-lun_se_dev)
ret = snprintf(page, PAGE_SIZE, %u\n, lun-lun_rtpi);
-   spin_unlock(lun-lun_sep_lock);
+   rcu_read_unlock();
return ret;
 }
 DEV_STAT_SCSI_PORT_ATTR_RO(indx);
@@ -591,13 +591,13 @@ static ssize_t target_stat_scsi_port_show_attr_role(
struct se_device *dev;
ssize_t ret = -ENODEV;
 
-   spin_lock(lun-lun_sep_lock);
+   rcu_read_lock();
dev = lun-lun_se_dev;
if (dev) {
ret = snprintf(page, PAGE_SIZE, %s%u\n, Device,
dev-dev_index);
}
-   spin_unlock(lun-lun_sep_lock);
+   rcu_read_unlock();
return ret;
 }
 DEV_STAT_SCSI_PORT_ATTR_RO(role);
@@ -608,12 +608,12 @@ static ssize_t target_stat_scsi_port_show_attr_busy_count(
struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
ssize_t ret = -ENODEV;
 
-   spin_lock(lun-lun_sep_lock);
+   rcu_read_lock();
if (lun-lun_se_dev) {
/* FIXME: scsiPortBusyStatuses  */
ret = snprintf(page, PAGE_SIZE, %u\n, 0);
}
-   spin_unlock(lun-lun_sep_lock);
+   rcu_read_unlock();
return ret;
 }
 DEV_STAT_SCSI_PORT_ATTR_RO(busy_count);
@@ -664,11 +664,11 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_inst(
struct se_device *dev;
ssize_t ret = -ENODEV;
 
-   spin_lock(lun-lun_sep_lock);
+   rcu_read_lock();
dev = lun-lun_se_dev;
if (dev)
ret = snprintf(page, PAGE_SIZE, %u\n, dev-se_hba-hba_index);
-   spin_unlock(lun-lun_sep_lock);
+   rcu_read_unlock();
return ret;
 }
 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(inst);
@@ -680,11 +680,11 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_dev(
struct se_device *dev;
ssize_t ret = -ENODEV;
 
-   spin_lock(lun-lun_sep_lock);
+   rcu_read_lock();
dev = lun-lun_se_dev;
if (dev)
ret = snprintf(page, PAGE_SIZE, %u\n, dev-dev_index);
-   spin_unlock(lun-lun_sep_lock);
+   rcu_read_unlock();
return ret;
 }
 DEV_STAT_SCSI_TGT_PORT_ATTR_RO(dev);
@@ -695,10 +695,10 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_indx(
struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
ssize_t ret = -ENODEV;
 
- 

[PATCH 1/4] target: Subsume se_port + t10_alua_tg_pt_gp_member into se_lun

2015-05-22 Thread Nicholas A. Bellinger
From: Christoph Hellwig h...@lst.de

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.

(Fix l_tg_pt_gp reference in set_target_port_groups - nab)

Signed-off-by: Christoph Hellwig h...@lst.de
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_alua.c| 392 ++-
 drivers/target/target_core_alua.h|  14 +-
 drivers/target/target_core_configfs.c|  11 +-
 drivers/target/target_core_device.c  | 179 ++--
 drivers/target/target_core_fabric_configfs.c |  32 +--
 drivers/target/target_core_internal.h|  12 +-
 drivers/target/target_core_pr.c  |  49 ++--
 drivers/target/target_core_spc.c |  48 ++--
 drivers/target/target_core_stat.c| 248 +
 drivers/target/target_core_tpg.c |  97 ---
 drivers/target/target_core_transport.c   |  34 +--
 drivers/target/target_core_xcopy.c   |  17 +-
 include/target/target_core_base.h|  73 +++--
 13 files changed, 407 insertions(+), 799 deletions(-)

diff --git a/drivers/target/target_core_alua.c 
b/drivers/target/target_core_alua.c
index 80b43a7..09e89f0 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -43,11 +43,13 @@
 static sense_reason_t core_alua_check_transition(int state, int valid,
 int *primary);
 static int core_alua_set_tg_pt_secondary_state(
-   struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem,
-   struct se_port *port, int explicit, int offline);
+   struct se_lun *lun, int explicit, int offline);
 
 static char *core_alua_dump_state(int state);
 
+static void __target_attach_tg_pt_gp(struct se_lun *lun,
+   struct t10_alua_tg_pt_gp *tg_pt_gp);
+
 static u16 alua_lu_gps_counter;
 static u32 alua_lu_gps_count;
 
@@ -145,9 +147,8 @@ sense_reason_t
 target_emulate_report_target_port_groups(struct se_cmd *cmd)
 {
struct se_device *dev = cmd-se_dev;
-   struct se_port *port;
struct t10_alua_tg_pt_gp *tg_pt_gp;
-   struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
+   struct se_lun *lun;
unsigned char *buf;
u32 rd_len = 0, off;
int ext_hdr = (cmd-t_task_cdb[1]  0x20);
@@ -222,9 +223,8 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd)
rd_len += 8;
 
spin_lock(tg_pt_gp-tg_pt_gp_lock);
-   list_for_each_entry(tg_pt_gp_mem, tg_pt_gp-tg_pt_gp_mem_list,
-   tg_pt_gp_mem_list) {
-   port = tg_pt_gp_mem-tg_pt;
+   list_for_each_entry(lun, tg_pt_gp-tg_pt_gp_lun_list,
+   lun_tg_pt_gp_link) {
/*
 * Start Target Port descriptor format
 *
@@ -234,8 +234,8 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd)
/*
 * Set RELATIVE TARGET PORT IDENTIFIER
 */
-   buf[off++] = ((port-sep_rtpi  8)  0xff);
-   buf[off++] = (port-sep_rtpi  0xff);
+   buf[off++] = ((lun-lun_rtpi  8)  0xff);
+   buf[off++] = (lun-lun_rtpi  0xff);
rd_len += 4;
}
spin_unlock(tg_pt_gp-tg_pt_gp_lock);
@@ -259,15 +259,11 @@ target_emulate_report_target_port_groups(struct se_cmd 
*cmd)
 * this CDB was received upon to determine this value 
individually
 * for ALUA target port group.
 */
-   port = cmd-se_lun-lun_sep;
-   tg_pt_gp_mem = port-sep_alua_tg_pt_gp_mem;
-   if (tg_pt_gp_mem) {
-   spin_lock(tg_pt_gp_mem-tg_pt_gp_mem_lock);
-   tg_pt_gp = tg_pt_gp_mem-tg_pt_gp;
-   if (tg_pt_gp)
-   buf[5] = tg_pt_gp-tg_pt_gp_implicit_trans_secs;
-   spin_unlock(tg_pt_gp_mem-tg_pt_gp_mem_lock);
-   }
+   spin_lock(cmd-se_lun-lun_tg_pt_gp_lock);
+   tg_pt_gp = cmd-se_lun-lun_tg_pt_gp;
+   if (tg_pt_gp)
+   buf[5] = tg_pt_gp-tg_pt_gp_implicit_trans_secs;
+   spin_unlock(cmd-se_lun-lun_tg_pt_gp_lock);
}
transport_kunmap_data_sg(cmd);
 
@@ -284,10 +280,9 

[PATCH 3/4] target: Drop se_lun-lun_active for existing percpu lun_ref

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

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 h...@lst.de
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_alua.c |  5 +++--
 drivers/target/target_core_pr.c   |  9 +
 drivers/target/target_core_tpg.c  | 10 ++
 include/target/target_core_base.h |  1 -
 4 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/target/target_core_alua.c 
b/drivers/target/target_core_alua.c
index 09e89f0..1f196cb 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -969,7 +969,8 @@ static void core_alua_do_transition_tg_pt_work(struct 
work_struct *work)
 * every I_T nexus other than the I_T nexus on which the SET
 * TARGET PORT GROUPS command
 */
-   atomic_inc_mb(lun-lun_active);
+   if (!percpu_ref_tryget_live(lun-lun_ref))
+   continue;
spin_unlock(tg_pt_gp-tg_pt_gp_lock);
 
spin_lock_bh(lun-lun_deve_lock);
@@ -997,7 +998,7 @@ static void core_alua_do_transition_tg_pt_work(struct 
work_struct *work)
spin_unlock_bh(lun-lun_deve_lock);
 
spin_lock(tg_pt_gp-tg_pt_gp_lock);
-   atomic_dec_mb(lun-lun_active);
+   percpu_ref_put(lun-lun_ref);
}
spin_unlock(tg_pt_gp-tg_pt_gp_lock);
/*
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 413ba16..218a003 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -702,7 +702,8 @@ static struct t10_pr_registration 
*__core_scsi3_alloc_registration(
 */
spin_lock(dev-se_port_lock);
list_for_each_entry_safe(lun_tmp, next, dev-dev_sep_list, 
lun_dev_link) {
-   atomic_inc_mb(lun_tmp-lun_active);
+   if (!percpu_ref_tryget_live(lun_tmp-lun_ref))
+   continue;
spin_unlock(dev-se_port_lock);
 
spin_lock_bh(lun_tmp-lun_deve_lock);
@@ -747,7 +748,7 @@ static struct t10_pr_registration 
*__core_scsi3_alloc_registration(
if (ret  0) {
pr_err(core_scsi3_lunacl_depend
_item() failed\n);
-   atomic_dec_mb(lun-lun_active);
+   percpu_ref_put(lun_tmp-lun_ref);
kref_put(deve_tmp-pr_kref, 
target_pr_kref_release);
goto out;
}
@@ -763,7 +764,7 @@ static struct t10_pr_registration 
*__core_scsi3_alloc_registration(
deve_tmp, deve_tmp-mapped_lun,
NULL, sa_res_key, all_tg_pt, 
aptpl);
if (!pr_reg_atp) {
-   atomic_dec_mb(lun_tmp-lun_active);
+   percpu_ref_put(lun_tmp-lun_ref);
core_scsi3_lunacl_undepend_item(deve_tmp);
goto out;
}
@@ -775,7 +776,7 @@ static struct t10_pr_registration 
*__core_scsi3_alloc_registration(
spin_unlock_bh(lun_tmp-lun_deve_lock);
 
spin_lock(dev-se_port_lock);
-   atomic_dec_mb(lun_tmp-lun_active);
+   percpu_ref_put(lun_tmp-lun_ref);
}
spin_unlock(dev-se_port_lock);
 
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index f60b74e..fb81555 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -609,7 +609,6 @@ struct se_lun *core_tpg_alloc_lun(
mutex_init(lun-lun_tg_pt_md_mutex);
INIT_LIST_HEAD(lun-lun_tg_pt_gp_link);
spin_lock_init(lun-lun_tg_pt_gp_lock);
-   atomic_set(lun-lun_active, 0);
lun-lun_tpg = tpg;
 
return lun;
@@ -665,13 +664,16 @@ void core_tpg_remove_lun(
struct se_device *dev = lun-lun_se_dev;
 
core_clear_lun_from_tpg(lun, tpg);
+   /*
+* Wait for any active I/O references to percpu se_lun-lun_ref to
+* be released.  Also, se_lun-lun_ref is now used by PR and ALUA
+* logic when referencing a remote target port during ALL_TGT_PT=1
+* and generating UNIT_ATTENTIONs for ALUA access state transition.
+*/
transport_clear_lun_ref(lun);
 
mutex_lock(tpg-tpg_lun_mutex);
if (lun-lun_se_dev) {
-   while 

[PATCH 4/4] target: Drop unnecessary core_tpg_register TFO parameter

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

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 h...@lst.de
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/infiniband/ulp/srpt/ib_srpt.c|  4 +---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c   |  9 ++---
 drivers/target/iscsi/iscsi_target_configfs.c |  3 +--
 drivers/target/iscsi/iscsi_target_tpg.c  |  8 ++--
 drivers/target/loopback/tcm_loop.c   |  5 +
 drivers/target/sbp/sbp_target.c  |  2 +-
 drivers/target/target_core_tpg.c | 14 +-
 drivers/target/tcm_fc/tfc_conf.c |  5 +
 drivers/usb/gadget/legacy/tcm_usb_gadget.c   |  5 +
 drivers/vhost/scsi.c |  4 +---
 drivers/xen/xen-scsiback.c   |  5 +
 include/target/target_core_fabric.h  |  3 +--
 12 files changed, 26 insertions(+), 41 deletions(-)

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c 
b/drivers/infiniband/ulp/srpt/ib_srpt.c
index dbad5c6..cea207e 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -92,7 +92,6 @@ MODULE_PARM_DESC(srpt_service_guid,
  instead of using the node_guid of the first HCA.);
 
 static struct ib_client srpt_client;
-static const struct target_core_fabric_ops srpt_template;
 static void srpt_release_channel(struct srpt_rdma_ch *ch);
 static int srpt_queue_status(struct se_cmd *cmd);
 
@@ -3733,8 +3732,7 @@ static struct se_portal_group *srpt_make_tpg(struct 
se_wwn *wwn,
int res;
 
/* Initialize sport-port_wwn and sport-port_tpg_1 */
-   res = core_tpg_register(srpt_template, sport-port_wwn,
-   sport-port_tpg_1, SCSI_PROTOCOL_SRP);
+   res = core_tpg_register(sport-port_wwn, sport-port_tpg_1, 
SCSI_PROTOCOL_SRP);
if (res)
return ERR_PTR(res);
 
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index cb53144..e14a7fd 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -52,9 +52,6 @@
 static struct workqueue_struct *tcm_qla2xxx_free_wq;
 static struct workqueue_struct *tcm_qla2xxx_cmd_wq;
 
-static const struct target_core_fabric_ops tcm_qla2xxx_ops;
-static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops;
-
 /*
  * Parse WWN.
  * If strict, we require lower-case hex and colon separators to be sure
@@ -1004,8 +1001,7 @@ static struct se_portal_group *tcm_qla2xxx_make_tpg(
tpg-tpg_attrib.cache_dynamic_acls = 1;
tpg-tpg_attrib.demo_mode_login_only = 1;
 
-   ret = core_tpg_register(tcm_qla2xxx_ops, wwn, tpg-se_tpg,
-   SCSI_PROTOCOL_FCP);
+   ret = core_tpg_register(wwn, tpg-se_tpg, SCSI_PROTOCOL_FCP);
if (ret  0) {
kfree(tpg);
return NULL;
@@ -1124,8 +1120,7 @@ static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg(
tpg-tpg_attrib.cache_dynamic_acls = 1;
tpg-tpg_attrib.demo_mode_login_only = 1;
 
-   ret = core_tpg_register(tcm_qla2xxx_npiv_ops, wwn, tpg-se_tpg,
-   SCSI_PROTOCOL_FCP);
+   ret = core_tpg_register(wwn, tpg-se_tpg, SCSI_PROTOCOL_FCP);
if (ret  0) {
kfree(tpg);
return NULL;
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c 
b/drivers/target/iscsi/iscsi_target_configfs.c
index 523ae55..c1898c8 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -1419,8 +1419,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg(
if (!tpg)
return NULL;
 
-   ret = core_tpg_register(iscsi_ops, wwn, tpg-tpg_se_tpg,
-   SCSI_PROTOCOL_ISCSI);
+   ret = core_tpg_register(wwn, tpg-tpg_se_tpg, SCSI_PROTOCOL_ISCSI);
if (ret  0)
return NULL;
 
diff --git a/drivers/target/iscsi/iscsi_target_tpg.c 
b/drivers/target/iscsi/iscsi_target_tpg.c
index 86f888e..36c52dd 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -66,8 +66,12 @@ int iscsit_load_discovery_tpg(void)
pr_err(Unable to allocate struct iscsi_portal_group\n);
return -1;
}
-
-   ret = core_tpg_register(iscsi_ops, NULL, tpg-tpg_se_tpg, -1);
+   /*
+* Save iscsi_ops pointer for special case discovery TPG that
+* doesn't exist as se_wwn-wwn_group within configfs.
+*/
+   tpg-tpg_se_tpg.se_tpg_tfo = 

Re: [PATCH-v2 0/9] target: se_node_acl + se_lun RCU conversions

2015-05-22 Thread Christoph Hellwig
Can you put up a git branch with these?  Without that or a known
good baseline it's hard to test, or even to do a deep review.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH-v2 5/9] target: Convert se_portal_group-tpg_lun_list[] to RCU hlist

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

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.

Also 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.

Cc: Hannes Reinecke h...@suse.de
Cc: Christoph Hellwig h...@lst.de
Cc: Sagi Grimberg sa...@mellanox.com
Cc: Paul E. McKenney paul...@linux.vnet.ibm.com
Cc: Chris Boot bo...@bootc.net
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/iscsi/iscsi_target_tpg.c  |   2 -
 drivers/target/sbp/sbp_target.c  |  97 +---
 drivers/target/sbp/sbp_target.h  |   2 +-
 drivers/target/target_core_device.c  |  92 ++-
 drivers/target/target_core_fabric_configfs.c |  34 ---
 drivers/target/target_core_internal.h|   6 +-
 drivers/target/target_core_tpg.c | 132 ++-
 drivers/xen/xen-scsiback.c   |  27 +++---
 include/target/target_core_base.h|   6 +-
 include/target/target_core_fabric.h  |   1 -
 10 files changed, 122 insertions(+), 277 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_tpg.c 
b/drivers/target/iscsi/iscsi_target_tpg.c
index 3af76e3..86f888e 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -281,8 +281,6 @@ int iscsit_tpg_del_portal_group(
return -EPERM;
}
 
-   core_tpg_clear_object_luns(tpg-tpg_se_tpg);
-
if (tpg-param_list) {
iscsi_release_param_list(tpg-param_list);
tpg-param_list = NULL;
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index 5d7755e..47fb12f 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -108,13 +108,13 @@ static struct sbp_session *sbp_session_find_by_guid(
 }
 
 static struct sbp_login_descriptor *sbp_login_find_by_lun(
-   struct sbp_session *session, struct se_lun *lun)
+   struct sbp_session *session, u32 unpacked_lun)
 {
struct sbp_login_descriptor *login, *found = NULL;
 
spin_lock_bh(session-lock);
list_for_each_entry(login, session-login_list, link) {
-   if (login-lun == lun)
+   if (login-login_lun == unpacked_lun)
found = login;
}
spin_unlock_bh(session-lock);
@@ -124,7 +124,7 @@ static struct sbp_login_descriptor *sbp_login_find_by_lun(
 
 static int sbp_login_count_all_by_lun(
struct sbp_tpg *tpg,
-   struct se_lun *lun,
+   u32 unpacked_lun,
int exclusive)
 {
struct se_session *se_sess;
@@ -138,7 +138,7 @@ static int sbp_login_count_all_by_lun(
 
spin_lock_bh(sess-lock);
list_for_each_entry(login, sess-login_list, link) {
-   if (login-lun != lun)
+   if (login-login_lun != unpacked_lun)
continue;
 
if (!exclusive || login-exclusive)
@@ -174,23 +174,23 @@ static struct sbp_login_descriptor *sbp_login_find_by_id(
return found;
 }
 
-static struct se_lun *sbp_get_lun_from_tpg(struct sbp_tpg *tpg, int lun)
+static u32 sbp_get_lun_from_tpg(struct sbp_tpg *tpg, u32 login_lun, int *err)
 {
struct se_portal_group *se_tpg = tpg-se_tpg;
struct se_lun *se_lun;
 
-   if (lun = TRANSPORT_MAX_LUNS_PER_TPG)
-   return ERR_PTR(-EINVAL);
-
-   spin_lock(se_tpg-tpg_lun_lock);
-   se_lun = se_tpg-tpg_lun_list[lun];
-
-   if (se_lun-lun_status != TRANSPORT_LUN_STATUS_ACTIVE)
-   se_lun = ERR_PTR(-ENODEV);
-
-   spin_unlock(se_tpg-tpg_lun_lock);
+   rcu_read_lock();
+   hlist_for_each_entry_rcu(se_lun, se_tpg-tpg_lun_hlist, link) {
+   if (se_lun-unpacked_lun == login_lun) {
+   rcu_read_unlock();
+   *err = 0;
+   return login_lun;
+   }
+   }
+   rcu_read_unlock();
 
-   return se_lun;
+   *err = -ENODEV;
+   return login_lun;
 }
 
 static struct sbp_session *sbp_session_create(
@@ -294,17 +294,16 @@ static void sbp_management_request_login(
 {
struct sbp_tport *tport = agent-tport;
struct sbp_tpg *tpg = tport-tpg;
-   struct se_lun *se_lun;
-   int ret;
-   u64 guid;
struct sbp_session *sess;
struct 

[PATCH-v2 1/9] target: Convert se_node_acl-device_list[] to RCU hlist

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

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
references to drop.

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.

Cc: Hannes Reinecke h...@suse.de
Cc: Christoph Hellwig h...@lst.de
Cc: Sagi Grimberg sa...@mellanox.com
Cc: Paul E. McKenney paul...@linux.vnet.ibm.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_device.c  | 326 +--
 drivers/target/target_core_fabric_configfs.c |  43 ++--
 drivers/target/target_core_internal.h|   8 +-
 drivers/target/target_core_pr.c  |  79 ---
 drivers/target/target_core_pscsi.c   |   7 +-
 drivers/target/target_core_spc.c |  18 +-
 drivers/target/target_core_stat.c| 180 +++
 drivers/target/target_core_tpg.c |  75 +-
 drivers/target/target_core_ua.c  |  51 +++--
 include/target/target_core_backend.h |   2 +-
 include/target/target_core_base.h|  19 +-
 11 files changed, 386 insertions(+), 422 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index 6e58976..cfe5cd3 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -59,17 +59,16 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 
unpacked_lun)
 {
struct se_lun *se_lun = NULL;
struct se_session *se_sess = se_cmd-se_sess;
+   struct se_node_acl *nacl = se_sess-se_node_acl;
struct se_device *dev;
-   unsigned long flags;
+   struct se_dev_entry *deve;
 
if (unpacked_lun = TRANSPORT_MAX_LUNS_PER_TPG)
return TCM_NON_EXISTENT_LUN;
 
-   spin_lock_irqsave(se_sess-se_node_acl-device_list_lock, flags);
-   se_cmd-se_deve = se_sess-se_node_acl-device_list[unpacked_lun];
-   if (se_cmd-se_deve-lun_flags  TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
-   struct se_dev_entry *deve = se_cmd-se_deve;
-
+   rcu_read_lock();
+   deve = target_nacl_find_deve(nacl, unpacked_lun);
+   if (deve) {
deve-total_cmds++;
 
if ((se_cmd-data_direction == DMA_TO_DEVICE) 
@@ -78,7 +77,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 
unpacked_lun)
 Access for 0x%08x\n,
se_cmd-se_tfo-get_fabric_name(),
unpacked_lun);
-   
spin_unlock_irqrestore(se_sess-se_node_acl-device_list_lock, flags);
+   rcu_read_unlock();
return TCM_WRITE_PROTECTED;
}
 
@@ -96,7 +95,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 
unpacked_lun)
percpu_ref_get(se_lun-lun_ref);
se_cmd-lun_ref_active = true;
}
-   spin_unlock_irqrestore(se_sess-se_node_acl-device_list_lock, flags);
+   rcu_read_unlock();
 
if (!se_lun) {
/*
@@ -146,24 +145,23 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u32 
unpacked_lun)
struct se_dev_entry *deve;
struct se_lun *se_lun = NULL;
struct se_session *se_sess = se_cmd-se_sess;
+   struct se_node_acl *nacl = se_sess-se_node_acl;
struct se_tmr_req *se_tmr = se_cmd-se_tmr_req;
unsigned long flags;
 
if (unpacked_lun = TRANSPORT_MAX_LUNS_PER_TPG)
return -ENODEV;
 
-   spin_lock_irqsave(se_sess-se_node_acl-device_list_lock, flags);
-   se_cmd-se_deve = se_sess-se_node_acl-device_list[unpacked_lun];
-   deve = se_cmd-se_deve;
-
-   if (deve-lun_flags  TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
+   rcu_read_lock();
+   deve = target_nacl_find_deve(nacl, unpacked_lun);
+   if (deve) {
se_tmr-tmr_lun = 

[PATCH-v2 7/9] target: Convert core_tpg_deregister to use list splice

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

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.

Cc: Hannes Reinecke h...@suse.de
Cc: Christoph Hellwig h...@lst.de
Cc: Sagi Grimberg sa...@mellanox.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_tpg.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 229e827..e7745d2 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -547,6 +547,7 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)
 {
const struct target_core_fabric_ops *tfo = se_tpg-se_tpg_tfo;
struct se_node_acl *nacl, *nacl_tmp;
+   LIST_HEAD(node_list);
 
pr_debug(TARGET_CORE[%s]: Deallocating portal_group for endpoint: %s, 
 Proto: %d, Portal Tag: %u\n, tfo-get_fabric_name(),
@@ -560,25 +561,22 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)
while (atomic_read(se_tpg-tpg_pr_ref_count) != 0)
cpu_relax();
 
+   mutex_lock(se_tpg-acl_node_mutex);
+   list_splice_init(se_tpg-acl_node_list, node_list);
+   mutex_unlock(se_tpg-acl_node_mutex);
/*
 * Release any remaining demo-mode generated se_node_acl that have
 * not been released because of TFO-tpg_check_demo_mode_cache() == 1
 * in transport_deregister_session().
 */
-   mutex_lock(se_tpg-acl_node_mutex);
-   list_for_each_entry_safe(nacl, nacl_tmp, se_tpg-acl_node_list,
-   acl_list) {
+   list_for_each_entry_safe(nacl, nacl_tmp, node_list, acl_list) {
list_del(nacl-acl_list);
se_tpg-num_node_acls--;
-   mutex_unlock(se_tpg-acl_node_mutex);
 
core_tpg_wait_for_nacl_pr_ref(nacl);
core_free_device_list_for_node(nacl, se_tpg);
kfree(nacl);
-
-   mutex_lock(se_tpg-acl_node_mutex);
}
-   mutex_unlock(se_tpg-acl_node_mutex);
 
if (se_tpg-proto_id = 0)
core_tpg_remove_lun(se_tpg, se_tpg-tpg_virt_lun0);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH-v2 3/9] target/pr: Change alloc_registration to avoid pr_reg_tg_pt_lun

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

This patch changes __core_scsi3_do_alloc_registration() code to
drop pr_reg-pr_reg_tg_pt_lun pointer usage in favor of a new
pr_reg RPTI + existing target_lun.

It also includes changes to REGISTER, REGISTER_AND_MOVE and APTPL
feature bit codepaths.

Cc: Hannes Reinecke h...@suse.de
Cc: Christoph Hellwig h...@lst.de
Cc: Sagi Grimberg sa...@mellanox.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_configfs.c |   6 +-
 drivers/target/target_core_pr.c   | 110 +++---
 include/target/target_core_base.h |   4 +-
 3 files changed, 53 insertions(+), 67 deletions(-)

diff --git a/drivers/target/target_core_configfs.c 
b/drivers/target/target_core_configfs.c
index 2768221..67d6d5f 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -817,7 +817,6 @@ static ssize_t 
target_core_dev_pr_show_attr_res_pr_holder_tg_port(
struct se_device *dev, char *page)
 {
struct se_node_acl *se_nacl;
-   struct se_lun *lun;
struct se_portal_group *se_tpg;
struct t10_pr_registration *pr_reg;
const struct target_core_fabric_ops *tfo;
@@ -832,7 +831,6 @@ static ssize_t 
target_core_dev_pr_show_attr_res_pr_holder_tg_port(
 
se_nacl = pr_reg-pr_reg_nacl;
se_tpg = se_nacl-se_tpg;
-   lun = pr_reg-pr_reg_tg_pt_lun;
tfo = se_tpg-se_tpg_tfo;
 
len += sprintf(page+len, SPC-3 Reservation: %s
@@ -840,9 +838,9 @@ static ssize_t 
target_core_dev_pr_show_attr_res_pr_holder_tg_port(
tfo-tpg_get_wwn(se_tpg));
len += sprintf(page+len, SPC-3 Reservation: Relative Port
 Identifier Tag: %hu %s Portal Group Tag: %hu
-%s Logical Unit: %u\n, lun-lun_sep-sep_rtpi,
+%s Logical Unit: %u\n, pr_reg-tg_pt_sep_rtpi,
tfo-get_fabric_name(), tfo-tpg_get_tag(se_tpg),
-   tfo-get_fabric_name(), lun-unpacked_lun);
+   tfo-get_fabric_name(), pr_reg-pr_aptpl_target_lun);
 
 out_unlock:
spin_unlock(dev-dev_reservation_lock);
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index d29b39c..94a136f 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -44,11 +44,10 @@
  * Used for Specify Initiator Ports Capable Bit (SPEC_I_PT)
  */
 struct pr_transport_id_holder {
-   int dest_local_nexus;
struct t10_pr_registration *dest_pr_reg;
struct se_portal_group *dest_tpg;
struct se_node_acl *dest_node_acl;
-   struct se_dev_entry __rcu *dest_se_deve;
+   struct se_dev_entry *dest_se_deve;
struct list_head dest_list;
 };
 
@@ -625,7 +624,9 @@ static u32 core_scsi3_pr_generation(struct se_device *dev)
 static struct t10_pr_registration *__core_scsi3_do_alloc_registration(
struct se_device *dev,
struct se_node_acl *nacl,
+   struct se_lun *lun,
struct se_dev_entry *deve,
+   u32 mapped_lun,
unsigned char *isid,
u64 sa_res_key,
int all_tg_pt,
@@ -647,12 +648,12 @@ static struct t10_pr_registration 
*__core_scsi3_do_alloc_registration(
atomic_set(pr_reg-pr_res_holders, 0);
pr_reg-pr_reg_nacl = nacl;
pr_reg-pr_reg_deve = deve;
-   pr_reg-pr_res_mapped_lun = deve-mapped_lun;
-   pr_reg-pr_aptpl_target_lun = deve-se_lun-unpacked_lun;
+   pr_reg-pr_res_mapped_lun = mapped_lun;
+   pr_reg-pr_aptpl_target_lun = lun-unpacked_lun;
+   pr_reg-tg_pt_sep_rtpi = lun-lun_sep-sep_rtpi;
pr_reg-pr_res_key = sa_res_key;
pr_reg-pr_reg_all_tg_pt = all_tg_pt;
pr_reg-pr_reg_aptpl = aptpl;
-   pr_reg-pr_reg_tg_pt_lun = deve-se_lun;
/*
 * If an ISID value for this SCSI Initiator Port exists,
 * save it to the registration now.
@@ -676,7 +677,9 @@ static void core_scsi3_lunacl_undepend_item(struct 
se_dev_entry *);
 static struct t10_pr_registration *__core_scsi3_alloc_registration(
struct se_device *dev,
struct se_node_acl *nacl,
+   struct se_lun *lun,
struct se_dev_entry *deve,
+   u32 mapped_lun,
unsigned char *isid,
u64 sa_res_key,
int all_tg_pt,
@@ -692,8 +695,9 @@ static struct t10_pr_registration 
*__core_scsi3_alloc_registration(
 * Create a registration for the I_T Nexus upon which the
 * PROUT REGISTER was received.
 */
-   pr_reg = __core_scsi3_do_alloc_registration(dev, nacl, deve, isid,
-   sa_res_key, all_tg_pt, aptpl);
+   pr_reg = __core_scsi3_do_alloc_registration(dev, nacl, lun, deve, 
mapped_lun,
+   isid, sa_res_key, all_tg_pt,
+   aptpl);
if (!pr_reg)
return NULL;
/*
@@ -765,8 +769,9 @@ static struct t10_pr_registration 

[PATCH-v2 6/9] target: Convert se_tpg-acl_node_lock to -acl_node_mutex

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

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.

Cc: Hannes Reinecke h...@suse.de
Cc: Christoph Hellwig h...@lst.de
Cc: Sagi Grimberg sa...@mellanox.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_device.c| 14 --
 drivers/target/target_core_pr.c|  8 +++---
 drivers/target/target_core_tpg.c   | 51 +-
 drivers/target/target_core_transport.c | 20 ++---
 drivers/target/tcm_fc/tfc_conf.c   |  4 +--
 include/target/target_core_base.h  |  2 +-
 6 files changed, 48 insertions(+), 51 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index 5b74c33..99a60e6 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -433,9 +433,8 @@ void core_clear_lun_from_tpg(struct se_lun *lun, struct 
se_portal_group *tpg)
struct se_node_acl *nacl;
struct se_dev_entry *deve;
 
-   spin_lock_irq(tpg-acl_node_lock);
+   mutex_lock(tpg-acl_node_mutex);
list_for_each_entry(nacl, tpg-acl_node_list, acl_list) {
-   spin_unlock_irq(tpg-acl_node_lock);
 
mutex_lock(nacl-lun_entry_mutex);
hlist_for_each_entry_rcu(deve, nacl-lun_entry_hlist, link) {
@@ -445,10 +444,8 @@ void core_clear_lun_from_tpg(struct se_lun *lun, struct 
se_portal_group *tpg)
core_disable_device_list_for_node(lun, deve, nacl, tpg);
}
mutex_unlock(nacl-lun_entry_mutex);
-
-   spin_lock_irq(tpg-acl_node_lock);
}
-   spin_unlock_irq(tpg-acl_node_lock);
+   mutex_unlock(tpg-acl_node_mutex);
 }
 
 static struct se_port *core_alloc_port(struct se_device *dev)
@@ -1183,17 +1180,16 @@ int core_dev_add_lun(
 */
if (tpg-se_tpg_tfo-tpg_check_demo_mode(tpg)) {
struct se_node_acl *acl;
-   spin_lock_irq(tpg-acl_node_lock);
+
+   mutex_lock(tpg-acl_node_mutex);
list_for_each_entry(acl, tpg-acl_node_list, acl_list) {
if (acl-dynamic_node_acl 
(!tpg-se_tpg_tfo-tpg_check_demo_mode_login_only ||
 
!tpg-se_tpg_tfo-tpg_check_demo_mode_login_only(tpg))) {
-   spin_unlock_irq(tpg-acl_node_lock);
core_tpg_add_node_to_devs(acl, tpg);
-   spin_lock_irq(tpg-acl_node_lock);
}
}
-   spin_unlock_irq(tpg-acl_node_lock);
+   mutex_unlock(tpg-acl_node_mutex);
}
 
return 0;
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 36bcc60..cee2b31 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -1582,12 +1582,12 @@ core_scsi3_decode_spec_i_port(
 * from the decoded fabric module specific TransportID
 * at *i_str.
 */
-   spin_lock_irq(tmp_tpg-acl_node_lock);
+   mutex_lock(tmp_tpg-acl_node_mutex);
dest_node_acl = __core_tpg_get_initiator_node_acl(
tmp_tpg, i_str);
if (dest_node_acl)
atomic_inc_mb(dest_node_acl-acl_pr_ref_count);
-   spin_unlock_irq(tmp_tpg-acl_node_lock);
+   mutex_unlock(tmp_tpg-acl_node_mutex);
 
if (!dest_node_acl) {
core_scsi3_tpg_undepend_item(tmp_tpg);
@@ -3298,12 +3298,12 @@ after_iport_check:
/*
 * Locate the destination struct se_node_acl from the received 
Transport ID
 */
-   spin_lock_irq(dest_se_tpg-acl_node_lock);
+   mutex_lock(dest_se_tpg-acl_node_mutex);
dest_node_acl = __core_tpg_get_initiator_node_acl(dest_se_tpg,
initiator_str);
if (dest_node_acl)
atomic_inc_mb(dest_node_acl-acl_pr_ref_count);
-   spin_unlock_irq(dest_se_tpg-acl_node_lock);
+   mutex_unlock(dest_se_tpg-acl_node_mutex);
 
if (!dest_node_acl) {
pr_err(Unable to locate %s dest_node_acl for
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 13d34e2..229e827 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -49,7 +49,7 @@ static LIST_HEAD(tpg_list);
 
 /* __core_tpg_get_initiator_node_acl():
  *
- * 

Re: [PATCH-v2 2/9] target/pr: Use atomic bitop for se_dev_entry-pr_reg reservation check

2015-05-22 Thread Nicholas A. Bellinger
On Fri, 2015-05-22 at 10:26 +0200, Christoph Hellwig wrote:
 On Fri, May 22, 2015 at 06:11:04AM +, Nicholas A. Bellinger wrote:
  +   clear_bit(1, orig-pr_reg);
 
 Can you call it -flags and give the bit a meaningful name?

The bit is signaling if se_dev_entry has a PR registration active.

I don't see how -flags is a more meaningful name without other bits
defined.

 
  diff --git a/drivers/target/target_core_pr.c 
  b/drivers/target/target_core_pr.c
  index c0b593a..d29b39c 100644
  --- a/drivers/target/target_core_pr.c
  +++ b/drivers/target/target_core_pr.c
  @@ -327,9 +327,13 @@ static int core_scsi3_pr_seq_non_holder(
  int we = 0; /* Write Exclusive */
  int legacy = 0; /* Act like a legacy device and return
   * RESERVATION CONFLICT on some CDBs */
  +   bool registered = false;
   
  rcu_read_lock();
  se_deve = target_nacl_find_deve(nacl, cmd-orig_fe_lun);
  +   if (se_deve)
  +   registered = test_bit(1, se_deve-pr_reg);
  +   rcu_read_unlock();
 
 It would be good to just sort out the registered and co variables
 here before the RCU changes, as in:
 
 http://git.infradead.org/users/hch/scsi.git/commitdiff/6372d9f62c83acb30d051387c40deb4dbdcaa376

Why not just keep this patch squashed into the relevant commit in the
context of the larger RCU conversion..?

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 0/2] target: Add TFO-complete_irq queue_work bypass

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

Hi HCH  Co,

Here is RFC code for adding target_core_fabric_ops-complete_irq
bypass that allows fabrics to invoke response callbacks directly
from target_complete_cmd() IRQ context.

It breaks up existing target_complete_ok_work() code into three
pieces:

  - transport_complete_task_attr()
  - target_complete_ok_pre()
  - target_complete_irq()

and allows target_complete_irq() be called directly from IRQ context
if no special case se_cmd handling requirements exist.

The three cases that trigger queue_work() process context are:

  - non GOOD status
  - ORDERED task sync
  - non NULL se_cmd-transport_complete_callback()

It also includes converting target_restart_delayed_cmds() to use
llist_head, and checking within transport_complete_task_attr() to
determine if dev_ordered_sync is non zero, ahead of doing the
llist_del_all() - cmpxchg of outstanding ordered tags.

This allows loopback LLD code to bypass the extra queue_work, and
invoke it's -scsi_done() callback directly from IRQ context.

WDYT..?

--nab

Nicholas Bellinger (2):
  target: Add support for fabric IRQ completion
  loopback: Enable TFO-complete_irq for fast-path -scsi_done

 drivers/target/loopback/tcm_loop.c |   1 +
 drivers/target/target_core_device.c|   2 +-
 drivers/target/target_core_tpg.c   |   1 +
 drivers/target/target_core_transport.c | 165 -
 include/target/target_core_base.h  |   5 +-
 include/target/target_core_fabric.h|   1 +
 6 files changed, 127 insertions(+), 48 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH-v2 1/9] target: Convert se_node_acl-device_list[] to RCU hlist

2015-05-22 Thread Nicholas A. Bellinger
(resending)

On Fri, 2015-05-22 at 01:24 -0700, Christoph Hellwig wrote:
  -   spin_lock_irqsave(se_sess-se_node_acl-device_list_lock, flags);
  -   se_cmd-se_deve = se_sess-se_node_acl-device_list[unpacked_lun];
  -   if (se_cmd-se_deve-lun_flags  TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
  -   struct se_dev_entry *deve = se_cmd-se_deve;
  -
  +   rcu_read_lock();
  +   deve = target_nacl_find_deve(nacl, unpacked_lun);
  +   if (deve) {
  deve-total_cmds++;
 
 This update will now be racy, ditto for the read/write_bytes update
 later.

This should become an atomic_long_t increment, yes..?

 
  +bool target_lun_is_rdonly(struct se_cmd *cmd)
  +{
  +   struct se_session *se_sess = cmd-se_sess;
  +   struct se_dev_entry *deve;
  +   bool ret;
  +
  +   if (cmd-se_lun-lun_access  TRANSPORT_LUNFLAGS_READ_ONLY)
  +   return true;
  +
  +   rcu_read_lock();
  +   deve = target_nacl_find_deve(se_sess-se_node_acl, cmd-orig_fe_lun);
  +   ret = (deve  deve-lun_flags  TRANSPORT_LUNFLAGS_READ_ONLY);
  +   rcu_read_unlock();
  +
  +   return ret;
  +}
  +EXPORT_SYMBOL(target_lun_is_rdonly);
 
 This should be a separate prep patch like, like it was in my original
 version.  I also still think you want this whole patch:
 
 http://git.infradead.org/users/hch/scsi.git/commitdiff/e9a71bda1a120e0488c5c4e4b2f17f14333e2dc6
 
 as storing a pointer to the dev entry without a refcount is bound to
 cause trouble.  I don't have a tree with all the patches applied
 available, but I doubt it fully gets that right.
 

Yes, this helper is from your patch above.

Considering there is a single user of it here, and complexities involved
for a RCU conversion + bisect, is it really work adding as a separate
patch ahead of this one..?

  +void target_pr_kref_release(struct kref *kref)
  +{
  +   struct se_dev_entry *deve = container_of(kref, struct se_dev_entry,
  +pr_kref);
  +   complete(deve-pr_comp);
   }
   
   /*  core_enable_device_list_for_node():
 
  +   kref_put(orig-pr_kref, target_pr_kref_release);
  +   wait_for_completion(orig-pr_comp);
   
 
  +   kref_put(orig-pr_kref, target_pr_kref_release);
  /*
  -* Disable struct se_dev_entry LUN ACL mapping
  +* Before fireing off RCU callback, wait for any in process SPEC_I_PT=1
  +* or REGISTER_AND_MOVE PR operation to complete.
   */
  +   wait_for_completion(orig-pr_comp);
  +   kfree_rcu(orig, rcu_head);
 
 The release callback should just call kfree_rcu, no need to wait for the
 release in the caller.
 

Why doesn't se_dev_entry release this need to wait for the special case
references to drop..?

 Also can you drop the _pr from the name?  It's a generic refcount now
 even if the PR code is the only consumer so far.
 
  +void   target_pr_kref_release(struct kref *);
 
 Instead of exporting the release function it would be much more obvious
 to have a 
 
 void target_deve_put(struct se_dev_entry *deve)
 {
   kref_put(deve-pr_kref, target_deve_release);
 }
 
 helper.  Probably paired with one for the get side.
 

Sure.  Adding this now.

   static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve)
   {
  -   struct se_lun_acl *lun_acl = se_deve-se_lun_acl;
  +   struct se_lun_acl *lun_acl;
  struct se_node_acl *nacl;
  struct se_portal_group *tpg;
  +
  +   if (!se_deve) {
  +   pr_err(core_scsi3_lunacl_undepend_item passed NULL se_deve\n);
  +   dump_stack();
  +   return;
  +   }
 
 How could this happen and how is it related to this patch?
 

Dropped.

  -   if (!deve-se_lun || !deve-se_lun_acl) {
  -   spin_unlock_irq(nacl-device_list_lock);
  +   rcu_read_lock();
  +   deve = target_nacl_find_deve(nacl, lacl-mapped_lun);
  +   if (!deve) {
  +   rcu_read_unlock();
  return -ENODEV;
 
 So previously a lot of these files returned -ENODEV when not having
 an explicit node ACL, and now they don't.  If that was intentional
 it should be documented in the changelog, or preferably moved into
 a preparation patch of its own.
 

Ok, will update the changelog for this.

  +   struct se_node_acl  *se_node_acl;
 
 Where is this field coming from?  It's not documented in the changelog
 and doesn't seem to be actually used either.
 

Nice catch.  Dropping this unused pointer now.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH-v2 0/9] target: se_node_acl + se_lun RCU conversions

2015-05-22 Thread Hannes Reinecke
On 05/22/2015 08:11 AM, Nicholas A. Bellinger wrote:
 From: Nicholas Bellinger n...@linux-iscsi.org
 
 Hi all,
 
 Here is -v2 series for converting LIO target se_node_acl + se_lun
 mapping tables from fixed size arrays to dynamic RCU hlist_heads.
 
 This turns fast-path I/O into a lock-less RCU reader using existing
 percpu based se_lun-lun_ref logic, and converts the RCU updater
 path to allow for an arbitrary number of LUNs for both types of
 mappings within target-core.
 
 This series also squashes a number of previous se_node_acl RCU
 related changes into a single commit (#1) for easier review,
 and to avoid potential bisect issues.
 
 There have been a number of changes since -v1, including:
 
   - Mirror port-sep_rtpi in lun-lun_rtpi for RCU
   - Drop unnecessary synchronize_rcu() usage
   - Convert call_rcu() to kfree_rcu() usage
   - Move hlist_del_rcu head of rcu_assign_pointer in se_dev_entry
   - Drop unnecessary lookup deve in target_fabric_mappedlun_unlink()
   - Add target_lun_is_rdonly helper
   - Acquire lun_entry_mutex during core_disable_device_list_for_node
   - Drop TRANSPORT_LUNFLAGS_*_ACCESS usage
   - Pass se_dev_entry directly to core_disable_device_list_for_node
   - Convert sbp-target se_lun usage to use -login_lun
   - Fix se_session dereference in spc_emulate_report_luns 
   - Fix testing for NULL instead of IS_ERR in fabric_make_lun()
   - Convert BUG_ON to EINVAL for wrong dynamic - explicit ACL conversion 
   - Add missing hlist_del_rcu when swapping orig with new
   - Add HBA_FLAGS_INTERNAL_USE checks in add/remove lun
 
 Please review.
 
Very nice.

Reviewed-by: Hannes Reinecke h...@suse.de

Although it would be _perfect_ if you could move to full 64-bit
LUNs; now that the LUN array is gone there is no need to have a
limitation on the number of LUNs, and we can trivially support
64-bit LUNs ...

But then, I can easily send a patch once this one is in.

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries  Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] target: Eliminate se_port + t10_alua_tg_pt_gp_member

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

Hi folks,

Here is a -v1 series with HCH's recent changes to go ahead and drop
all se_port + t10_alua_tg_pt_gp_member usage within target-core in
favor of direct se_lun pointer dereference.

This includes the original patch + minor fixes, along with two other
improvements for killing off se_lun-lun_sep_lock via RCU pointer
access, and converting the remaining se_lun-lun_active busy-wait
special cases to existing percpu se_lun-lun_ref access.

Also included in the series is a recently discussed change to go
ahead and drop an unnecessary core_tpg_register() parameter, and
all associated target_core_fabric_ops forward declartions within
fabric driver code.

Please review.

--nab

Christoph Hellwig (1):
  target: Subsume se_port + t10_alua_tg_pt_gp_member into se_lun

Nicholas Bellinger (3):
  target: Drop lun_sep_lock for se_lun-lun_se_dev RCU usage
  target: Drop se_lun-lun_active for existing percpu lun_ref
  target: Drop unnecessary core_tpg_register TFO parameter

 drivers/infiniband/ulp/srpt/ib_srpt.c|   4 +-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c   |   9 +-
 drivers/target/iscsi/iscsi_target_configfs.c |   3 +-
 drivers/target/iscsi/iscsi_target_tpg.c  |   8 +-
 drivers/target/loopback/tcm_loop.c   |   5 +-
 drivers/target/sbp/sbp_target.c  |   2 +-
 drivers/target/target_core_alua.c| 393 ++-
 drivers/target/target_core_alua.h|  14 +-
 drivers/target/target_core_configfs.c|  11 +-
 drivers/target/target_core_device.c  | 180 ++--
 drivers/target/target_core_fabric_configfs.c |  32 +--
 drivers/target/target_core_internal.h|  12 +-
 drivers/target/target_core_pr.c  |  50 ++--
 drivers/target/target_core_spc.c |  48 ++--
 drivers/target/target_core_stat.c| 305 +++--
 drivers/target/target_core_tpg.c | 111 +---
 drivers/target/target_core_transport.c   |  46 +---
 drivers/target/target_core_xcopy.c   |  17 +-
 drivers/target/tcm_fc/tfc_conf.c |   5 +-
 drivers/usb/gadget/legacy/tcm_usb_gadget.c   |   5 +-
 drivers/vhost/scsi.c |   4 +-
 drivers/xen/xen-scsiback.c   |   5 +-
 include/target/target_core_base.h|  75 +++--
 include/target/target_core_fabric.h  |   3 +-
 24 files changed, 465 insertions(+), 882 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 2/2] loopback: Enable TFO-complete_irq for fast-path -scsi_done

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

Go ahead and enable TFO-complete_irq for testing with loopback
LLD code, and avoid the extra fast-path queue_work() context
switch if no se_cmd special case handling requirements exist.

Cc: Christoph Hellwig h...@lst.de
Cc: Hannes Reinecke h...@suse.de
CC: Sagi Grimberg sa...@mellanox.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/loopback/tcm_loop.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/target/loopback/tcm_loop.c 
b/drivers/target/loopback/tcm_loop.c
index bd9d11a..562906a 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -1229,6 +1229,7 @@ static struct configfs_attribute *tcm_loop_wwn_attrs[] = {
 static const struct target_core_fabric_ops loop_ops = {
.module = THIS_MODULE,
.name   = loopback,
+   .complete_irq   = true,
.get_fabric_name= tcm_loop_get_fabric_name,
.tpg_get_wwn= tcm_loop_get_endpoint_wwn,
.tpg_get_tag= tcm_loop_get_tag,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] target: Drop unnecessary core_tpg_register TFO parameter

2015-05-22 Thread Hannes Reinecke
On 05/22/2015 09:06 AM, Nicholas A. Bellinger wrote:
 From: Nicholas Bellinger n...@linux-iscsi.org
 
 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 h...@lst.de
 Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
 ---
Reviewed-by: Hannes Reinecke h...@suse.de

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries  Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] target: Subsume se_port + t10_alua_tg_pt_gp_member into se_lun

2015-05-22 Thread Hannes Reinecke
On 05/22/2015 09:06 AM, Nicholas A. Bellinger wrote:
 From: Christoph Hellwig h...@lst.de
 
 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.
 
 (Fix l_tg_pt_gp reference in set_target_port_groups - nab)
 
 Signed-off-by: Christoph Hellwig h...@lst.de
 Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
 ---

Reviewed-by: Hannes Reinecke h...@suse.de

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries  Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] target: Drop se_lun-lun_active for existing percpu lun_ref

2015-05-22 Thread Hannes Reinecke
On 05/22/2015 09:06 AM, Nicholas A. Bellinger wrote:
 From: Nicholas Bellinger n...@linux-iscsi.org
 
 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 h...@lst.de
 Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
 ---
Reviewed-by: Hannes Reinecke h...@suse.de

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries  Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH-v2 2/9] target/pr: Use atomic bitop for se_dev_entry-pr_reg reservation check

2015-05-22 Thread Christoph Hellwig
On Fri, May 22, 2015 at 06:11:04AM +, Nicholas A. Bellinger wrote:
 + clear_bit(1, orig-pr_reg);

Can you call it -flags and give the bit a meaningful name?

 diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
 index c0b593a..d29b39c 100644
 --- a/drivers/target/target_core_pr.c
 +++ b/drivers/target/target_core_pr.c
 @@ -327,9 +327,13 @@ static int core_scsi3_pr_seq_non_holder(
   int we = 0; /* Write Exclusive */
   int legacy = 0; /* Act like a legacy device and return
* RESERVATION CONFLICT on some CDBs */
 + bool registered = false;
  
   rcu_read_lock();
   se_deve = target_nacl_find_deve(nacl, cmd-orig_fe_lun);
 + if (se_deve)
 + registered = test_bit(1, se_deve-pr_reg);
 + rcu_read_unlock();

It would be good to just sort out the registered and co variables
here before the RCU changes, as in:

http://git.infradead.org/users/hch/scsi.git/commitdiff/6372d9f62c83acb30d051387c40deb4dbdcaa376
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH-v2 4/9] target/pr: cleanup core_scsi3_pr_seq_non_holder

2015-05-22 Thread Christoph Hellwig
Oh, you've actually go it - still would make sense to move it the beginning of
the series.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 1/2] target: Add support for fabric IRQ completion

2015-05-22 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

This patch adds support for invoking TFO completion callbacks directly
from IRQ context in target_complete_cmd().

Some fabric drivers like loopback and vhost can invoke their response
callbacks directly from IRQ context, and this patch allows the extra
queue_work() dispatch to a seperate work-queue process context to be
avoided for fast-path operation.

This includes the refactoring of target_complete_ok_work(), so that
transport_complete_task_attr() and target_complete_irq() can be
invoked directly from target_complete_cmd() context.

Also, target_restart_delayed_cmds() has been converted to use llist,
and will only be invoked from !in_interrupt() with a llist_del_all()
compare and exchange when draining the list of ordered tags.

Cc: Christoph Hellwig h...@lst.de
Cc: Hannes Reinecke h...@suse.de
Cc: Sagi Grimberg sa...@mellanox.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/target_core_device.c|   2 +-
 drivers/target/target_core_tpg.c   |   1 +
 drivers/target/target_core_transport.c | 165 -
 include/target/target_core_base.h  |   5 +-
 include/target/target_core_fabric.h|   1 +
 5 files changed, 126 insertions(+), 48 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index 1d98033..70213fa 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -739,7 +739,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, 
const char *name)
INIT_LIST_HEAD(dev-dev_list);
INIT_LIST_HEAD(dev-dev_sep_list);
INIT_LIST_HEAD(dev-dev_tmr_list);
-   INIT_LIST_HEAD(dev-delayed_cmd_list);
+   init_llist_head(dev-delayed_cmd_llist);
INIT_LIST_HEAD(dev-state_list);
INIT_LIST_HEAD(dev-qf_cmd_list);
INIT_LIST_HEAD(dev-g_dev_node);
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 3fbb0d4..aa08d6b 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -37,6 +37,7 @@
 
 #include target/target_core_base.h
 #include target/target_core_backend.h
+#include target/target_core_configfs.h
 #include target/target_core_fabric.h
 
 #include target_core_internal.h
diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index 2ccaeff..a98a23c 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -63,10 +63,11 @@ struct kmem_cache *t10_alua_tg_pt_gp_cache;
 struct kmem_cache *t10_alua_lba_map_cache;
 struct kmem_cache *t10_alua_lba_map_mem_cache;
 
-static void transport_complete_task_attr(struct se_cmd *cmd);
+static bool transport_complete_task_attr(struct se_cmd *cmd);
 static void transport_handle_queue_full(struct se_cmd *cmd,
struct se_device *dev);
 static int transport_put_cmd(struct se_cmd *cmd);
+static void target_complete_irq(struct se_cmd *cmd, bool);
 static void target_complete_ok_work(struct work_struct *work);
 
 int init_se_kmem_caches(void)
@@ -711,16 +712,37 @@ void target_complete_cmd(struct se_cmd *cmd, u8 
scsi_status)
spin_unlock_irqrestore(cmd-t_state_lock, flags);
complete_all(cmd-t_transport_stop_comp);
return;
-   } else if (!success) {
-   INIT_WORK(cmd-work, target_complete_failure_work);
-   } else {
+   }
+   if (success) {
+   /*
+* Invoke TFO completion callback now if fabric driver can
+* queue response in IRQ context, and special case descriptor
+* handling requirements in process context for ORDERED task
+* and friends do not exist.
+*/
+   if (cmd-se_cmd_flags  SCF_COMPLETE_IRQ 
+   !(cmd-se_cmd_flags  SCF_TRANSPORT_TASK_SENSE) 
+   !cmd-transport_complete_callback) {
+
+   cmd-t_state = TRANSPORT_COMPLETE;
+   cmd-transport_state |= (CMD_T_COMPLETE | CMD_T_ACTIVE);
+   spin_unlock_irqrestore(cmd-t_state_lock, flags);
+
+   if (!transport_complete_task_attr(cmd))
+   goto do_work;
+
+   target_complete_irq(cmd, true);
+   return;
+   }
INIT_WORK(cmd-work, target_complete_ok_work);
+   } else {
+   INIT_WORK(cmd-work, target_complete_failure_work);
}
 
cmd-t_state = TRANSPORT_COMPLETE;
cmd-transport_state |= (CMD_T_COMPLETE | CMD_T_ACTIVE);
spin_unlock_irqrestore(cmd-t_state_lock, flags);
-
+do_work:
queue_work(target_completion_wq, cmd-work);
 }
 EXPORT_SYMBOL(target_complete_cmd);
@@ -1145,7 +1167,6 @@ void transport_init_se_cmd(
int task_attr,
unsigned char *sense_buffer)
 {
-   

Re: [PATCH-v2 5/9] target: Convert se_portal_group-tpg_lun_list[] to RCU hlist

2015-05-22 Thread Nicholas A. Bellinger
On Fri, 2015-05-22 at 10:31 +0200, Christoph Hellwig wrote:
  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.
  
  Also 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.
 
 Still doesn't explain why core_tpg_clear_object_luns also disappears.

It's duplicate logic in iscsi-target to delete active TPG LUNs.

Adding a comment to clarify the removal.

 
  +   hlist_for_each_entry_rcu(lun, tpg-tpg_lun_hlist, link) {
  if (lun-lun_status != TRANSPORT_LUN_STATUS_ACTIVE)
  continue;
 
 lun_status will always be active here as that's set and cleared at the
 same time as the list addition / removal.  Which means that lun_status
 should go away in this patch.
 

Yes, thanks for the reminder.  Dropping lun_status now.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] IBM CXL Flash Adapter

2015-05-22 Thread Matthew R. Ochs
v2 Changes:

- Update to candidate upstream CXL APIs
- Add several clarification comments
- Renamed some structures for clarity
- Removed the 'cxlflash' prefix from internal functions
- Address endianness concerns/issues
- Remove unused code
- Revert to using pr_*/dev_* print services
- Remove unneeded locking and barrier instructions

This patch adds support for the IBM CXL flash (cxlflash) adapter. The device
is presented to the system as a SCSI adapter and may be accessed and used via
the normal filesystem paths.

Note that the patch is dependent on support that has not yet been merged
in with the mainline (submission expected shortly).

In the interim, this code may be found on Github:

   https://github.com/mikey/linux/tree/cxl/kernelapi

Matthew R. Ochs (1):
  cxlflash: Base support for IBM CXL Flash Adapter

 drivers/scsi/Kconfig|1 +
 drivers/scsi/Makefile   |1 +
 drivers/scsi/cxlflash/Kconfig   |   11 +
 drivers/scsi/cxlflash/Makefile  |2 +
 drivers/scsi/cxlflash/common.h  |  180 
 drivers/scsi/cxlflash/main.c| 2242 +++
 drivers/scsi/cxlflash/main.h|  111 ++
 drivers/scsi/cxlflash/sislite.h |  465 
 8 files changed, 3013 insertions(+)
 create mode 100644 drivers/scsi/cxlflash/Kconfig
 create mode 100644 drivers/scsi/cxlflash/Makefile
 create mode 100644 drivers/scsi/cxlflash/common.h
 create mode 100644 drivers/scsi/cxlflash/main.c
 create mode 100644 drivers/scsi/cxlflash/main.h
 create mode 100755 drivers/scsi/cxlflash/sislite.h

-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] cxlflash: Base support for IBM CXL Flash Adapter

2015-05-22 Thread Matthew R. Ochs
SCSI device driver to support filesystem access on the IBM CXL Flash adapter.

Signed-off-by: Matthew R. Ochs mro...@linux.vnet.ibm.com
Signed-off-by: Manoj N. Kumar ma...@linux.vnet.ibm.com
---
 drivers/scsi/Kconfig|1 +
 drivers/scsi/Makefile   |1 +
 drivers/scsi/cxlflash/Kconfig   |   11 +
 drivers/scsi/cxlflash/Makefile  |2 +
 drivers/scsi/cxlflash/common.h  |  180 
 drivers/scsi/cxlflash/main.c| 2242 +++
 drivers/scsi/cxlflash/main.h|  111 ++
 drivers/scsi/cxlflash/sislite.h |  465 
 8 files changed, 3013 insertions(+)
 create mode 100644 drivers/scsi/cxlflash/Kconfig
 create mode 100644 drivers/scsi/cxlflash/Makefile
 create mode 100644 drivers/scsi/cxlflash/common.h
 create mode 100644 drivers/scsi/cxlflash/main.c
 create mode 100644 drivers/scsi/cxlflash/main.h
 create mode 100755 drivers/scsi/cxlflash/sislite.h

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index b021bcb..ebb12a7 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -345,6 +345,7 @@ source drivers/scsi/cxgbi/Kconfig
 source drivers/scsi/bnx2i/Kconfig
 source drivers/scsi/bnx2fc/Kconfig
 source drivers/scsi/be2iscsi/Kconfig
+source drivers/scsi/cxlflash/Kconfig
 
 config SGIWD93_SCSI
tristate SGI WD93C93 SCSI Driver
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index dee160a..6a83b17 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -78,6 +78,7 @@ obj-$(CONFIG_SCSI_IN2000) += in2000.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380_MMIO) += g_NCR5380_mmio.o
 obj-$(CONFIG_SCSI_NCR53C406A)  += NCR53c406a.o
+obj-$(CONFIG_CXLFLASH) += cxlflash/
 obj-$(CONFIG_SCSI_NCR_D700)+= 53c700.o NCR_D700.o
 obj-$(CONFIG_SCSI_NCR_Q720)+= NCR_Q720_mod.o
 obj-$(CONFIG_SCSI_SYM53C416)   += sym53c416.o
diff --git a/drivers/scsi/cxlflash/Kconfig b/drivers/scsi/cxlflash/Kconfig
new file mode 100644
index 000..e98c3f6
--- /dev/null
+++ b/drivers/scsi/cxlflash/Kconfig
@@ -0,0 +1,11 @@
+#
+# IBM CXL-attached Flash Accelerator SCSI Driver
+#
+
+config CXLFLASH
+   tristate Support for IBM CAPI Flash
+   depends on CXL
+   default m
+   help
+ Allows CAPI Accelerated IO to Flash
+ If unsure, say N.
diff --git a/drivers/scsi/cxlflash/Makefile b/drivers/scsi/cxlflash/Makefile
new file mode 100644
index 000..dc95e20
--- /dev/null
+++ b/drivers/scsi/cxlflash/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CXLFLASH) += cxlflash.o
+cxlflash-y += main.o
diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h
new file mode 100644
index 000..990a7c4
--- /dev/null
+++ b/drivers/scsi/cxlflash/common.h
@@ -0,0 +1,180 @@
+/*
+ * CXL Flash Device Driver
+ *
+ * Written by: Manoj N. Kumar ma...@linux.vnet.ibm.com, IBM Corporation
+ * Matthew R. Ochs mro...@linux.vnet.ibm.com, IBM Corporation
+ *
+ * Copyright (C) 2015 IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _CXLFLASH_COMMON_H
+#define _CXLFLASH_COMMON_H
+
+#include linux/list.h
+#include linux/types.h
+#include scsi/scsi.h
+#include scsi/scsi_device.h
+
+
+#define MAX_CONTEXT  CXLFLASH_MAX_CONTEXT   /* num contexts per afu */
+
+#define CXLFLASH_BLOCK_SIZE4096/* 4K blocks */
+#define CXLFLASH_MAX_XFER_SIZE 16777216/* 16MB transfer */
+#define CXLFLASH_MAX_SECTORS   (CXLFLASH_MAX_XFER_SIZE/CXLFLASH_BLOCK_SIZE)
+
+#define NUM_RRQ_ENTRY16 /* for master issued cmds */
+#define MAX_RHT_PER_CONTEXT (PAGE_SIZE / sizeof(struct sisl_rht_entry))
+
+/* AFU command retry limit */
+#define MC_RETRY_CNT 5 /* sufficient for SCSI check and
+  certain AFU errors */
+
+/* Command management definitions */
+#define CXLFLASH_NUM_CMDS  (2 * CXLFLASH_MAX_CMDS) /* Must be a pow2 for
+  alignment and more
+  efficient array
+  index derivation
+*/
+
+#define CXLFLASH_MAX_CMDS   16
+#define CXLFLASH_MAX_CMDS_PER_LUN   CXLFLASH_MAX_CMDS
+
+/* Check for power of 2 at compile time */
+#define NOT_POW2(_x) ((_x)  ((_x)  ((_x) - 1)))
+#if NOT_POW2(CXLFLASH_NUM_CMDS)
+#error CXLFLASH_NUM_CMDS is not a power of 2!
+#endif
+
+/* AFU defines a fixed size of 4K for command buffers (borrow 4K page define) 
*/
+#define CMD_BUFSIZE SIZE_4K
+
+/* flags in IOA status area for host use */
+#define B_DONE   0x01
+#define B_ERROR  0x02  /* set with B_DONE */
+#define B_TIMEOUT0x04  /* set with B_DONE  B_ERROR */
+
+enum 

RE: [PATCH 3/9] [SCSI] aacraid: Enable MSI interrupt for series-6 controller

2015-05-22 Thread Rajinikanth Pandurangan
Hello Tomas,

As the function aac_src_init() itself specific to Series-6 controller, change 
applicable only to series-6.

Thanks,
-Raj P.

-Original Message-
From: Tomas Henzl [mailto:the...@redhat.com] 
Sent: Friday, May 22, 2015 6:40 AM
To: Rajinikanth Pandurangan; jbottom...@parallels.com; 
linux-scsi@vger.kernel.org
Cc: aacr...@pmc-sierra.com; Harry Yang; Rich Bono; Achim Leubner; Murthy Bhat
Subject: Re: [PATCH 3/9] [SCSI] aacraid: Enable MSI interrupt for series-6 
controller

On 05/14/2015 02:12 AM, rajinikanth.panduran...@pmcs.com wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Description:
   Enable MSI interrupt mode for series-6 controller.
aac_msi is a driver option, how is it related to series-6 controller?
Tomas
 
 Signed-off-by: Rajinikanth Pandurangan 
 rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/src.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c 
 index b0204d0..ae494c5 100644
 --- a/drivers/scsi/aacraid/src.c
 +++ b/drivers/scsi/aacraid/src.c
 @@ -742,7 +742,7 @@ int aac_src_init(struct aac_dev *dev)
   if (dev-comm_interface != AAC_COMM_MESSAGE_TYPE1)
   goto error_iounmap;
  
 - dev-msi = aac_msi  !pci_enable_msi(dev-pdev);
 + dev-msi = !pci_enable_msi(dev-pdev);
  
   dev-aac_msix[0].vector_no = 0;
   dev-aac_msix[0].dev = dev;
 

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 4/9] [SCSI] aacraid: Enable 64-bit write to controller register

2015-05-22 Thread Rajinikanth Pandurangan
-Original Message-
From: Tomas Henzl [mailto:the...@redhat.com] 
Sent: Friday, May 22, 2015 7:02 AM
To: Rajinikanth Pandurangan; jbottom...@parallels.com; 
linux-scsi@vger.kernel.org
Cc: aacr...@pmc-sierra.com; Harry Yang; Rich Bono; Achim Leubner; Murthy Bhat
Subject: Re: [PATCH 4/9] [SCSI] aacraid: Enable 64-bit write to controller 
register

On 05/14/2015 02:12 AM, rajinikanth.panduran...@pmcs.com wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Description:
 If writeq() not supported, then do atomic two 32bit write
 
 Signed-off-by: Rajinikanth Pandurangan 
 rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/aacraid.h  | 12   
 drivers/scsi/aacraid/comminit.c |  1 +
  drivers/scsi/aacraid/src.c  | 12 ++--
  3 files changed, 23 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/aacraid/aacraid.h 
 b/drivers/scsi/aacraid/aacraid.h index 62b0999..9e69e3e 100644
 --- a/drivers/scsi/aacraid/aacraid.h
 +++ b/drivers/scsi/aacraid/aacraid.h
 @@ -719,6 +719,9 @@ struct sa_registers {
  #define sa_readl(AEP, CSR)   readl(((AEP)-regs.sa-CSR))
  #define sa_writew(AEP, CSR, value)   writew(value, ((AEP)-regs.sa-CSR))
  #define sa_writel(AEP, CSR, value)   writel(value, ((AEP)-regs.sa-CSR))
 +#if defined(writeq)
 +#define  sa_writeq(AEP, CSR, value)  writeq(value, 
 ((AEP)-regs.sa-CSR))
This^ is used nowhere, is it needed?

[rajp] Yes, it's not needed.

 +#endif
  
  /*
   *   Rx Message Unit Registers
 @@ -844,6 +847,10 @@ struct src_registers {
   ((AEP)-regs.src.bar0-CSR))
  #define src_writel(AEP, CSR, value)  writel(value, \
   ((AEP)-regs.src.bar0-CSR))
 +#if defined(writeq)
 +#define  src_writeq(AEP, CSR, value) writeq(value, \
 + ((AEP)-regs.src.bar0-CSR))
 +#endif
  
  #define SRC_ODR_SHIFT12
  #define SRC_IDR_SHIFT9
 @@ -1163,6 +1170,11 @@ struct aac_dev
   struct fsa_dev_info *fsa_dev;
   struct task_struct  *thread;
   int cardtype;
 + /*
 +  *This lock will protect the two 32-bit
 +  *writes to the Inbound Queue
 +  */
 + spinlock_t  iq_lock;
  
   /*
*  The following is the device specific extension.
 diff --git a/drivers/scsi/aacraid/comminit.c 
 b/drivers/scsi/aacraid/comminit.c index 45a0a04..4043245 100644
 --- a/drivers/scsi/aacraid/comminit.c
 +++ b/drivers/scsi/aacraid/comminit.c
 @@ -424,6 +424,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
   dev-management_fib_count = 0;
   spin_lock_init(dev-manage_lock);
   spin_lock_init(dev-sync_lock);
 + spin_lock_init(dev-iq_lock);
   dev-max_fib_size = sizeof(struct hw_fib);
   dev-sg_tablesize = host-sg_tablesize = (dev-max_fib_size
   - sizeof(struct aac_fibhdr)
 diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c 
 index ae494c5..109863a 100644
 --- a/drivers/scsi/aacraid/src.c
 +++ b/drivers/scsi/aacraid/src.c
 @@ -447,6 +447,10 @@ static int aac_src_deliver_message(struct fib *fib)
   u32 fibsize;
   dma_addr_t address;
   struct aac_fib_xporthdr *pFibX;
 +#if !defined(writeq)
 + unsigned long flags;
 +#endif
 +
   u16 hdr_size = le16_to_cpu(fib-hw_fib_va-header.Size);
  
   atomic_inc(q-numpending);
 @@ -511,10 +515,14 @@ static int aac_src_deliver_message(struct fib *fib)
   return -EINVAL;
   address |= fibsize;
   }
 -
 +#if defined(writeq)
 + src_writeq(dev, MUnit.IQ_L, (u64)address);
What about just using the writeq directly without the macro ?
writeq(value, address); ?

[Rajp] All other place we have macro. This is just for the uniformity.

 +#else
 + spin_lock_irqsave(fib-dev-iq_lock, flags);
   src_writel(dev, MUnit.IQ_H, upper_32_bits(address)  0x);
   src_writel(dev, MUnit.IQ_L, address  0x);
 -
 + spin_unlock_irqrestore(fib-dev-iq_lock, flags); #endif
   return 0;
  }
  
 

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH-v2 0/9] target: se_node_acl + se_lun RCU conversions

2015-05-22 Thread Bart Van Assche
On 05/22/15 08:11, Nicholas A. Bellinger wrote:
 Here is -v2 series for converting LIO target se_node_acl + se_lun
 mapping tables from fixed size arrays to dynamic RCU hlist_heads.

The full list of new sparse warnings introduced by this patch series for
source files under drivers/target is as follows:

$ make M=drivers/target C=2
  CHECK   drivers/target/target_core_configfs.c
  CC [M]  drivers/target/target_core_configfs.o
  CHECK   drivers/target/target_core_device.c
drivers/target/target_core_device.c:89:24: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:89:24:expected struct se_lun *se_lun
drivers/target/target_core_device.c:89:24:got struct se_lun [noderef] 
asn:4*se_lun
drivers/target/target_core_device.c:90:32: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:90:32:expected struct se_lun *se_lun
drivers/target/target_core_device.c:90:32:got struct se_lun [noderef] 
asn:4*se_lun
drivers/target/target_core_device.c:130:24: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:130:24:expected struct se_device *se_dev
drivers/target/target_core_device.c:130:24:got struct se_device [noderef] 
asn:4*lun_se_dev
drivers/target/target_core_device.c:132:13: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:132:13:expected struct se_device *dev
drivers/target/target_core_device.c:132:13:got struct se_device [noderef] 
asn:4*lun_se_dev
drivers/target/target_core_device.c:158:33: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:158:33:expected struct se_lun *tmr_lun
drivers/target/target_core_device.c:158:33:got struct se_lun [noderef] 
asn:4*se_lun
drivers/target/target_core_device.c:159:32: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:159:32:expected struct se_lun *se_lun
drivers/target/target_core_device.c:159:32:got struct se_lun [noderef] 
asn:4*se_lun
drivers/target/target_core_device.c:160:24: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:160:24:expected struct se_lun *se_lun
drivers/target/target_core_device.c:160:24:got struct se_lun [noderef] 
asn:4*se_lun
drivers/target/target_core_device.c:175:24: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:175:24:expected struct se_device *se_dev
drivers/target/target_core_device.c:175:24:got struct se_device [noderef] 
asn:4*lun_se_dev
drivers/target/target_core_device.c:176:25: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:176:25:expected struct se_device 
*tmr_dev
drivers/target/target_core_device.c:176:25:got struct se_device [noderef] 
asn:4*lun_se_dev
drivers/target/target_core_device.c:219:21: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:219:21:expected struct se_lun *lun
drivers/target/target_core_device.c:219:21:got struct se_lun [noderef] 
asn:4*se_lun
drivers/target/target_core_device.c:247:55: warning: incorrect type in argument 
1 (different address spaces)
drivers/target/target_core_device.c:247:55:expected struct se_lun *noident
drivers/target/target_core_device.c:247:55:got struct se_lun [noderef] 
asn:4*se_lun
drivers/target/target_core_device.c:335:34: error: incompatible types in 
comparison expression (different address spaces)
drivers/target/target_core_device.c:421:45: warning: incorrect type in argument 
1 (different address spaces)
drivers/target/target_core_device.c:421:45:expected struct se_device 
*noident
drivers/target/target_core_device.c:421:45:got struct se_device [noderef] 
asn:4*lun_se_dev
drivers/target/target_core_device.c:438:33: error: incompatible types in 
comparison expression (different address spaces)
drivers/target/target_core_device.c:519:6: warning: symbol 'se_dev_check_wce' 
was not declared. Should it be static?
drivers/target/target_core_device.c:643:48: warning: incorrect type in argument 
1 (different address spaces)
drivers/target/target_core_device.c:643:48:expected struct se_device 
*noident
drivers/target/target_core_device.c:643:48:got struct se_device [noderef] 
asn:4*lun_se_dev
drivers/target/target_core_device.c:793:31: warning: incorrect type in 
assignment (different address spaces)
drivers/target/target_core_device.c:793:31:expected struct se_device 
[noderef] asn:4*lun_se_dev
drivers/target/target_core_device.c:793:31:got struct se_device *[assigned] 
dev
  CC [M]  drivers/target/target_core_device.o
  CHECK   drivers/target/target_core_fabric_configfs.c
  CC [M]  drivers/target/target_core_fabric_configfs.o
  CHECK   drivers/target/target_core_fabric_lib.c

Re: [PATCH-v2 2/9] target/pr: Use atomic bitop for se_dev_entry-pr_reg reservation check

2015-05-22 Thread Bart Van Assche

On 05/22/15 08:11, Nicholas A. Bellinger wrote:

diff --git a/include/target/target_core_base.h 
b/include/target/target_core_base.h
index e2c0eaf..def5bc8 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -638,7 +638,6 @@ struct se_lun_acl {
  };

  struct se_dev_entry {
-   booldef_pr_registered;
/* See transport_lunflags_table */
u32 lun_flags;
u32 mapped_lun;
@@ -655,7 +654,8 @@ struct se_dev_entry {
struct se_node_acl  *se_node_acl;
struct se_lun_acl __rcu *se_lun_acl;
spinlock_t  ua_lock;
-   struct se_lun   *se_lun;
+   struct se_lun __rcu *se_lun;
+   unsigned long   pr_reg;
struct list_headalua_port_list;
struct list_headua_list;
struct hlist_node   link;


Hello Nic,

This change causes the se_lun = deve-se_lun assignment in 
transport_lookup_cmd_lun() to assign an RCU pointer to a non-RCU 
pointer. Shouldn't such an assignment be protected via rcu_dereference() ?


Thanks,

Bart.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH-v2 2/9] target/pr: Use atomic bitop for se_dev_entry-pr_reg reservation check

2015-05-22 Thread Christoph Hellwig
On Fri, May 22, 2015 at 02:05:57AM -0700, Nicholas A. Bellinger wrote:
 On Fri, 2015-05-22 at 10:26 +0200, Christoph Hellwig wrote:
  On Fri, May 22, 2015 at 06:11:04AM +, Nicholas A. Bellinger wrote:
   + clear_bit(1, orig-pr_reg);
  
  Can you call it -flags and give the bit a meaningful name?
 
 The bit is signaling if se_dev_entry has a PR registration active.
 
 I don't see how -flags is a more meaningful name without other bits
 defined.

It's pretty normal style: define a flags variable for any sort of
bitops state that might show up, and then give the actual bits a meaningful
name.  There's almost no users of using a magic numberic value with
atomic bitops.

Besides being the usual and thus easier to read style it's also good
future proofing.

  It would be good to just sort out the registered and co variables
  here before the RCU changes, as in:
  
  http://git.infradead.org/users/hch/scsi.git/commitdiff/6372d9f62c83acb30d051387c40deb4dbdcaa376
 
 Why not just keep this patch squashed into the relevant commit in the
 context of the larger RCU conversion..?

Because the logic in and aroudn core_scsi3_pr_seq_non_holder right
now is rather confusing.  So before doing changes to it it's better
to clean it up first, document that cleanup in a standalon patch
and then apply the logic change on top.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH kernel] commit 4fbdf9cb (lpfc: Fix for lun discovery issue with saturn adapter.)

2015-05-22 Thread Sebastian Herbszt
Alexey Kardashevskiy wrote:
 On 05/06/2015 07:46 AM, Sebastian Herbszt wrote:
  James Smart wrote:
 
  Reviewed-By: James Smart james.sm...@emulex.com
 
 
  Alexey, Sebastian,
 
  Yes - this section needs to be reverted.  This patch is good.
 
  -- james s
 
  Reviewed-by: Sebastian Herbszt herb...@gmx.de
 
 
 Unfortunately, just this revert is not enough, it fixed one of my machines 
 but I have another machine with Emulex Corporation Saturn-X: LightPulse 
 Fibre Channel Host Adapter (rev 03) which does not boot - the booting 
 process stops at [  OK  ] Reached target Basic System.
 
 Any quick idea what else to revert between 4.0 and current upstream before 
 I dig further? Thanks!

Is the other machine also POWER7?
I tested the revert on x86 and it fixed my issue:

4.1-rc4 (lpfc 10.5.0.0) - broken
4.0 + lpfc 10.5.0.0 - broken
4.1-rc4 (lpfc 10.5.0.0) + revert - ok
4.0 + lpfc 10.5.0.0 + revert - ok

Sebastian
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH-v2 1/9] target: Convert se_node_acl-device_list[] to RCU hlist

2015-05-22 Thread Christoph Hellwig
On Fri, May 22, 2015 at 01:55:30AM -0700, Nicholas A. Bellinger wrote:
  This update will now be racy, ditto for the read/write_bytes update
  later.
 
 This should become an atomic_long_t increment, yes..?

Yes.

 Yes, this helper is from your patch above.
 
 Considering there is a single user of it here, and complexities involved
 for a RCU conversion + bisect, is it really work adding as a separate
 patch ahead of this one..?

The golden Linus style is to put preparatory patches first so that the
actual logic change is as small as possible.  Adding helpers so that
low level accesses that will e changed soon is a very typical case for that.

   + kref_put(orig-pr_kref, target_pr_kref_release);
   + wait_for_completion(orig-pr_comp);

  
   + kref_put(orig-pr_kref, target_pr_kref_release);
 /*
   -  * Disable struct se_dev_entry LUN ACL mapping
   +  * Before fireing off RCU callback, wait for any in process SPEC_I_PT=1
   +  * or REGISTER_AND_MOVE PR operation to complete.
  */
   + wait_for_completion(orig-pr_comp);
   + kfree_rcu(orig, rcu_head);
  
  The release callback should just call kfree_rcu, no need to wait for the
  release in the caller.
  
 
 Why doesn't se_dev_entry release this need to wait for the special case
 references to drop..?

Why would it?  There is no access to the structure at this point, so there
is no point to keep it around localy.  If there were other references to
it they by defintion don't need it anymore by the time they drop the
reference count.  Freeing a structure as soon as the refcount drops
zero is the normal style all over the place.  Waiting for a reference
count only makes sense if it's a drain style operation where you don't
free the structure but you just want to wait for some class of consumers
to stop using it.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH-v2 2/9] target/pr: Use atomic bitop for se_dev_entry-pr_reg reservation check

2015-05-22 Thread Christoph Hellwig
  
 -/*
 - * this function can be called with struct se_device-dev_reservation_lock
 - * when register_move = 1
 - */
  static void __core_scsi3_add_registration(
   struct se_device *dev,
   struct se_node_acl *nacl,
 @@ -1023,6 +1021,7 @@ static void __core_scsi3_add_registration(
   const struct target_core_fabric_ops *tfo = nacl-se_tpg-se_tpg_tfo;
   struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe;
   struct t10_reservation *pr_tmpl = dev-t10_pr;
 + struct se_dev_entry *deve;
  
   /*
* Increment PRgeneration counter for struct se_device upon a successful
 @@ -1039,10 +1038,16 @@ static void __core_scsi3_add_registration(
  
   spin_lock(pr_tmpl-registration_lock);
   list_add_tail(pr_reg-pr_reg_list, pr_tmpl-registration_list);
 - pr_reg-pr_reg_deve-def_pr_registered = 1;
  
   __core_scsi3_dump_registration(tfo, dev, nacl, pr_reg, register_type);
   spin_unlock(pr_tmpl-registration_lock);
 +
 + mutex_lock(nacl-lun_entry_mutex);
 + deve = target_nacl_find_deve(nacl, pr_reg-pr_res_mapped_lun);
 + if (deve)
 + set_bit(1, deve-pr_reg);
 + mutex_unlock(nacl-lun_entry_mutex);

Why can't we rely on pr_reg-pr_reg_deve here?  The way the it's
set up is a bit convoluted, but unless I miss something it needs to
have a reference if it's set (and it it doesn't that needs to be fixed
ASAP).

Also even if we would need a target_nacl_find_deve call here it could
be done under rcu_read_lock as lun_entry_hlist isn't modified.

 + mutex_lock(nacl-lun_entry_mutex);
 + deve = target_nacl_find_deve(nacl_tmp, 
 pr_reg_tmp-pr_res_mapped_lun);
 + if (deve)
 + set_bit(1, deve-pr_reg);
 + mutex_unlock(nacl-lun_entry_mutex);
 +

Same here.

 @@ -1258,6 +1269,8 @@ static void __core_scsi3_free_registration(
*/
   if (dec_holders)
   core_scsi3_put_pr_reg(pr_reg);
 +
 + spin_unlock(pr_tmpl-registration_lock);
   /*
* Wait until all reference from any other I_T nexuses for this
* *pr_reg have been released.  Because list_del() is called above,
 @@ -1265,13 +1278,18 @@ static void __core_scsi3_free_registration(
* count back to zero, and we release *pr_reg.
*/
   while (atomic_read(pr_reg-pr_res_holders) != 0) {
 - spin_unlock(pr_tmpl-registration_lock);
   pr_debug(SPC-3 PR [%s] waiting for pr_res_holders\n,
   tfo-get_fabric_name());
   cpu_relax();
 - spin_lock(pr_tmpl-registration_lock);
   }
  
 + mutex_lock(nacl-lun_entry_mutex);
 + deve = target_nacl_find_deve(nacl, pr_reg-pr_res_mapped_lun);
 + if (deve)
 + clear_bit(1, deve-pr_reg);
 + mutex_unlock(nacl-lun_entry_mutex);

And here.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] target: Drop lun_sep_lock for se_lun-lun_se_dev RCU usage

2015-05-22 Thread Christoph Hellwig
 @@ -683,7 +679,7 @@ void core_tpg_remove_lun(
   dev-export_count--;
   spin_unlock(dev-se_port_lock);
  
 - lun-lun_se_dev = NULL;
 + rcu_assign_pointer(lun-lun_se_dev, NULL);
   }

What guarantees that the se_device stays around for at least a RCU
grace period after this assignment?
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mvsas: always iounmap resources

2015-05-22 Thread Johannes Thumshirn
In case pci_resource_start() or pci_resource_len() reutrn 0, mvsas_ioremap
returns without doing an iounmap() of mvi-regs_ex.

Found by the cocinelle tool.

Signed-off-by: Johannes Thumshirn jthumsh...@suse.de
---
 drivers/scsi/mvsas/mv_init.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 53030b0..04a3205 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -339,8 +339,11 @@ int mvs_ioremap(struct mvs_info *mvi, int bar, int bar_ex)
 
res_start = pci_resource_start(pdev, bar);
res_len = pci_resource_len(pdev, bar);
-   if (!res_start || !res_len)
+   if (!res_start || !res_len) {
+   iounmap(mvi-regs_ex);
+   mvi-regs_ex = NULL;
goto err_out;
+   }
 
res_flag = pci_resource_flags(pdev, bar);
if (res_flag  IORESOURCE_CACHEABLE)
-- 
2.4.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/9] [SCSI] aacraid: Enable MSI interrupt for series-6 controller

2015-05-22 Thread Tomas Henzl
On 05/14/2015 02:12 AM, rajinikanth.panduran...@pmcs.com wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Description:
   Enable MSI interrupt mode for series-6 controller.
aac_msi is a driver option, how is it related to series-6 controller?
Tomas
 
 Signed-off-by: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/src.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c
 index b0204d0..ae494c5 100644
 --- a/drivers/scsi/aacraid/src.c
 +++ b/drivers/scsi/aacraid/src.c
 @@ -742,7 +742,7 @@ int aac_src_init(struct aac_dev *dev)
   if (dev-comm_interface != AAC_COMM_MESSAGE_TYPE1)
   goto error_iounmap;
  
 - dev-msi = aac_msi  !pci_enable_msi(dev-pdev);
 + dev-msi = !pci_enable_msi(dev-pdev);
  
   dev-aac_msix[0].vector_no = 0;
   dev-aac_msix[0].dev = dev;
 

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/9] [SCSI] aacraid: Enable 64-bit write to controller register

2015-05-22 Thread Tomas Henzl
On 05/14/2015 02:12 AM, rajinikanth.panduran...@pmcs.com wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Description:
 If writeq() not supported, then do atomic two 32bit write
 
 Signed-off-by: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/aacraid.h  | 12 
  drivers/scsi/aacraid/comminit.c |  1 +
  drivers/scsi/aacraid/src.c  | 12 ++--
  3 files changed, 23 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
 index 62b0999..9e69e3e 100644
 --- a/drivers/scsi/aacraid/aacraid.h
 +++ b/drivers/scsi/aacraid/aacraid.h
 @@ -719,6 +719,9 @@ struct sa_registers {
  #define sa_readl(AEP, CSR)   readl(((AEP)-regs.sa-CSR))
  #define sa_writew(AEP, CSR, value)   writew(value, ((AEP)-regs.sa-CSR))
  #define sa_writel(AEP, CSR, value)   writel(value, ((AEP)-regs.sa-CSR))
 +#if defined(writeq)
 +#define  sa_writeq(AEP, CSR, value)  writeq(value, 
 ((AEP)-regs.sa-CSR))
This^ is used nowhere, is it needed?
 +#endif
  
  /*
   *   Rx Message Unit Registers
 @@ -844,6 +847,10 @@ struct src_registers {
   ((AEP)-regs.src.bar0-CSR))
  #define src_writel(AEP, CSR, value)  writel(value, \
   ((AEP)-regs.src.bar0-CSR))
 +#if defined(writeq)
 +#define  src_writeq(AEP, CSR, value) writeq(value, \
 + ((AEP)-regs.src.bar0-CSR))
 +#endif
  
  #define SRC_ODR_SHIFT12
  #define SRC_IDR_SHIFT9
 @@ -1163,6 +1170,11 @@ struct aac_dev
   struct fsa_dev_info *fsa_dev;
   struct task_struct  *thread;
   int cardtype;
 + /*
 +  *This lock will protect the two 32-bit
 +  *writes to the Inbound Queue
 +  */
 + spinlock_t  iq_lock;
  
   /*
*  The following is the device specific extension.
 diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
 index 45a0a04..4043245 100644
 --- a/drivers/scsi/aacraid/comminit.c
 +++ b/drivers/scsi/aacraid/comminit.c
 @@ -424,6 +424,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
   dev-management_fib_count = 0;
   spin_lock_init(dev-manage_lock);
   spin_lock_init(dev-sync_lock);
 + spin_lock_init(dev-iq_lock);
   dev-max_fib_size = sizeof(struct hw_fib);
   dev-sg_tablesize = host-sg_tablesize = (dev-max_fib_size
   - sizeof(struct aac_fibhdr)
 diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c
 index ae494c5..109863a 100644
 --- a/drivers/scsi/aacraid/src.c
 +++ b/drivers/scsi/aacraid/src.c
 @@ -447,6 +447,10 @@ static int aac_src_deliver_message(struct fib *fib)
   u32 fibsize;
   dma_addr_t address;
   struct aac_fib_xporthdr *pFibX;
 +#if !defined(writeq)
 + unsigned long flags;
 +#endif
 +
   u16 hdr_size = le16_to_cpu(fib-hw_fib_va-header.Size);
  
   atomic_inc(q-numpending);
 @@ -511,10 +515,14 @@ static int aac_src_deliver_message(struct fib *fib)
   return -EINVAL;
   address |= fibsize;
   }
 -
 +#if defined(writeq)
 + src_writeq(dev, MUnit.IQ_L, (u64)address);
What about just using the writeq directly without the macro ?
writeq(value, address); ?
 +#else
 + spin_lock_irqsave(fib-dev-iq_lock, flags);
   src_writel(dev, MUnit.IQ_H, upper_32_bits(address)  0x);
   src_writel(dev, MUnit.IQ_L, address  0x);
 -
 + spin_unlock_irqrestore(fib-dev-iq_lock, flags);
 +#endif
   return 0;
  }
  
 

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] [SCSI] aacraid: Fix for logical device name and UID not exposed to the OS

2015-05-22 Thread Tomas Henzl
On 05/14/2015 02:12 AM, rajinikanth.panduran...@pmcs.com wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Description:
   Driver sends the right size of the response buffer.
 
 Signed-off-by: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/aachba.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
 index 9b3dd6e..fe59b00 100644
 --- a/drivers/scsi/aacraid/aachba.c
 +++ b/drivers/scsi/aacraid/aachba.c
 @@ -570,7 +570,7 @@ static int aac_get_container_name(struct scsi_cmnd * 
 scsicmd)
  
   status = aac_fib_send(ContainerCommand,
 cmd_fibcontext,
 -   sizeof (struct aac_get_name),
 +   sizeof(struct aac_get_name_resp),
Hi Rajinikanth,
in aac_fib_send the size parameter is used in just one place
and a comment there says Set the size of the Fib we want to send to the
adapter
From that^ it looks like it is the size of the command you sending,
to the hw. Do I miss something?
Cheers,
Tomas
 FsaNormal,
 0, 1,
 (fib_callback)get_container_name_callback,
 @@ -1052,7 +1052,7 @@ static int aac_get_container_serial(struct scsi_cmnd * 
 scsicmd)
  
   status = aac_fib_send(ContainerCommand,
 cmd_fibcontext,
 -   sizeof (struct aac_get_serial),
 +   sizeof(struct aac_get_serial_resp),
 FsaNormal,
 0, 1,
 (fib_callback) get_container_serial_callback,
 

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/9] [SCSI] aacraid: Add Power Management support

2015-05-22 Thread Tomas Henzl
On 05/14/2015 02:12 AM, rajinikanth.panduran...@pmcs.com wrote:
 From: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 
 Description:
   * .suspend() and .resume() routines implemented in the driver
   * aac_release_resources() initiates firmware shutdown
   * aac_acquire_resources re-initializes the host interface
 
 Signed-off-by: Rajinikanth Pandurangan rajinikanth.panduran...@pmcs.com
 ---
  drivers/scsi/aacraid/aacraid.h  |   5 ++
  drivers/scsi/aacraid/comminit.c | 154 
 
  drivers/scsi/aacraid/linit.c| 147 ++
  drivers/scsi/aacraid/rx.c   |   1 +
  drivers/scsi/aacraid/sa.c   |   1 +
  drivers/scsi/aacraid/src.c  |   2 +
  6 files changed, 232 insertions(+), 78 deletions(-)
 
 diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
 index 40fe65c..62b0999 100644
 --- a/drivers/scsi/aacraid/aacraid.h
 +++ b/drivers/scsi/aacraid/aacraid.h
 @@ -547,6 +547,7 @@ struct adapter_ops
   int  (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 
 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, 
 u32 *r4);
   int  (*adapter_check_health)(struct aac_dev *dev);
   int  (*adapter_restart)(struct aac_dev *dev, int bled);
 + void (*adapter_start)(struct aac_dev *dev);
   /* Transport operations */
   int  (*adapter_ioremap)(struct aac_dev * dev, u32 size);
   irq_handler_t adapter_intr;
 @@ -1247,6 +1248,9 @@ struct aac_dev
  #define aac_adapter_restart(dev,bled) \
   (dev)-a_ops.adapter_restart(dev,bled)
  
 +#define aac_adapter_start(dev) \
 + ((dev)-a_ops.adapter_start(dev))
 +
  #define aac_adapter_ioremap(dev, size) \
   (dev)-a_ops.adapter_ioremap(dev, size)
  
 @@ -2127,6 +2131,7 @@ int aac_sa_init(struct aac_dev *dev);
  int aac_src_init(struct aac_dev *dev);
  int aac_srcv_init(struct aac_dev *dev);
  int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib 
 * hw_fib, int wait, struct fib * fibptr, unsigned long *nonotify);
 +void aac_define_int_mode(struct aac_dev *dev);
  unsigned int aac_response_normal(struct aac_queue * q);
  unsigned int aac_command_normal(struct aac_queue * q);
  unsigned int aac_intr_normal(struct aac_dev *dev, u32 Index,
 diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
 index 45db84a..45a0a04 100644
 --- a/drivers/scsi/aacraid/comminit.c
 +++ b/drivers/scsi/aacraid/comminit.c
 @@ -43,8 +43,6 @@
  
  #include aacraid.h
  
 -static void aac_define_int_mode(struct aac_dev *dev);
 -
  struct aac_common aac_config = {
   .irq_mod = 1
  };
 @@ -338,6 +336,82 @@ static int aac_comm_init(struct aac_dev * dev)
   return 0;
  }
  
 +void aac_define_int_mode(struct aac_dev *dev)
 +{
 + int i, msi_count;
 +
 + msi_count = i = 0;
 + /* max. vectors from GET_COMM_PREFERRED_SETTINGS */
 + if (dev-max_msix == 0 ||
 + dev-pdev-device == PMC_DEVICE_S6 ||
 + dev-sync_mode) {
 + dev-max_msix = 1;
 + dev-vector_cap =
 + dev-scsi_host_ptr-can_queue +
 + AAC_NUM_MGT_FIB;
 + return;
 + }
 +
 + /* Don't bother allocating more MSI-X vectors than cpus */
 + msi_count = min(dev-max_msix,
 + (unsigned int)num_online_cpus());
 +
 + dev-max_msix = msi_count;
 +
 + if (msi_count  AAC_MAX_MSIX)
 + msi_count = AAC_MAX_MSIX;
 +
 + for (i = 0; i  msi_count; i++)
 + dev-msixentry[i].entry = i;
 +
 + if (msi_count  1 
 + pci_find_capability(dev-pdev, PCI_CAP_ID_MSIX)) {
 + i = pci_enable_msix(dev-pdev,
 + dev-msixentry,
 + msi_count);
Has the previous series already been accepted? Anyway
please use pci_enable_msix_range instead of pci_enable_msix
Tomas
 +  /* Check how many MSIX vectors are allocated */
 + if (i = 0) {
 + dev-msi_enabled = 1;
 + if (i) {
 + msi_count = i;
 + if (pci_enable_msix(dev-pdev,
 + dev-msixentry,
 + msi_count)) {
 + dev-msi_enabled = 0;
 + printk(KERN_ERR %s%d: MSIX not 
 supported!! Will try MSI 0x%x.\n,
 + dev-name, dev-id, i);
 + }
 + }
 + } else {
 + dev-msi_enabled = 0;
 + printk(KERN_ERR %s%d: MSIX not supported!! Will try 
 MSI 0x%x.\n,
 + dev-name, dev-id, i);
 + }
 + }
 +
 + if (!dev-msi_enabled) {
 + msi_count = 1;
 + i = pci_enable_msi(dev-pdev);
 +
 + if (!i) {
 + 

[PATCH 3/9] lpfc: Devices are not discovered during takeaway/giveback testing

2015-05-22 Thread James Smart

Devices are not discovered during takeaway/giveback testing

When a remote nport changes it's DID, a new ndlp is used.
However, we left the old ndlp state unchanged and still in
a discovery state. The may stall discovery resulting in some
devices not being discovered.  Correct by swapping the state
of the 2 ndlp's when a DID swap is detected.

Signed-off-by: Dick Kennedy dick.kenn...@avagotech.com
Signed-off-by: James Smart james.sm...@avagotech.com
---
 drivers/scsi/lpfc/lpfc_els.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 30021f3..21c4a3d 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -1509,12 +1509,14 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, 
uint32_t *prsp,
 struct lpfc_nodelist *ndlp)
 {
struct lpfc_vport*vport = ndlp-vport;
+   struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
struct lpfc_nodelist *new_ndlp;
struct lpfc_rport_data *rdata;
struct fc_rport *rport;
struct serv_parm *sp;
uint8_t  name[sizeof(struct lpfc_name)];
uint32_t rc, keepDID = 0, keep_nlp_flag = 0;
+   uint16_t keep_nlp_state;
int  put_node;
int  put_rport;
unsigned long *active_rrqs_xri_bitmap = NULL;
@@ -1603,11 +1605,14 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, 
uint32_t *prsp,
   ndlp-active_rrqs_xri_bitmap,
   phba-cfg_rrq_xri_bitmap_sz);
 
+   spin_lock_irq(shost-host_lock);
keep_nlp_flag = new_ndlp-nlp_flag;
new_ndlp-nlp_flag = ndlp-nlp_flag;
ndlp-nlp_flag = keep_nlp_flag;
+   spin_unlock_irq(shost-host_lock);
 
-   /* Set state will put new_ndlp on to node list if not already done */
+   /* Set nlp_states accordingly */
+   keep_nlp_state = new_ndlp-nlp_state;
lpfc_nlp_set_state(vport, new_ndlp, ndlp-nlp_state);
 
/* Move this back to NPR state */
@@ -1668,20 +1673,13 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, 
uint32_t *prsp,
   active_rrqs_xri_bitmap,
   phba-cfg_rrq_xri_bitmap_sz);
 
-   /* Since we are swapping the ndlp passed in with the new one
-* and the did has already been swapped, copy over state.
-* The new WWNs are already in new_ndlp since thats what
-* we looked it up by in the begining of this routine.
-*/
-   new_ndlp-nlp_state = ndlp-nlp_state;
-
-   /* Since we are switching over to the new_ndlp, the old
-* ndlp should be put in the NPR state, unless we have
-* already started re-discovery on it.
+   /* Since we are switching over to the new_ndlp,
+* reset the old ndlp state
 */
if ((ndlp-nlp_state == NLP_STE_UNMAPPED_NODE) ||
(ndlp-nlp_state == NLP_STE_MAPPED_NODE))
-   lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
+   keep_nlp_state = NLP_STE_NPR_NODE;
+   lpfc_nlp_set_state(vport, ndlp, keep_nlp_state);
 
/* Fix up the rport accordingly */
rport = ndlp-rport;
-- 
1.7.11.7

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/9] lpfc: Fix vport deletion failure.

2015-05-22 Thread James Smart

Fix vport deletion failure.

If a vport was deleted while in the middle of discovery, we weren't
clearing the nport discovery flag. Correct by clearing the flag and
cancelling our discovery timeout timer.

Signed-off-by: Dick Kennedy dick.kenn...@avagotech.com
Signed-off-by: James Smart james.sm...@avagotech.com
---
 drivers/scsi/lpfc/lpfc_els.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 3aad09f..30021f3 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -8410,8 +8410,10 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct 
lpfc_iocbq *cmdiocb,
 
if (irsp-ulpStatus == IOSTAT_SUCCESS) {
spin_lock_irq(shost-host_lock);
+   vport-fc_flag = ~FC_NDISC_ACTIVE;
vport-fc_flag = ~FC_FABRIC;
spin_unlock_irq(shost-host_lock);
+   lpfc_can_disctmo(vport);
}
 }
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/9] lpfc: Check for active portpeerbeacon.

2015-05-22 Thread James Smart

Check for active portpeerbeacon.

LCB requests to set Beacon would fail if the beacon was already enabled
internally as the mailbox command used to query the state failes with
an already-set status.

Correct by enhancing the check so we don't fail if if the already set
status comes back.

Signed-off-by: Dick Kennedy dick.kenn...@avagotech.com
Signed-off-by: James Smart james.sm...@avagotech.com
---
 drivers/scsi/lpfc/lpfc_els.c | 19 +++
 drivers/scsi/lpfc/lpfc_hw4.h |  6 ++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 011c8d8..3aad09f 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -5044,25 +5044,36 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t 
*pmb)
struct lpfc_iocbq *elsiocb;
struct lpfc_nodelist *ndlp;
struct ls_rjt *stat;
+   union lpfc_sli4_cfg_shdr *shdr;
struct lpfc_lcb_context *lcb_context;
struct fc_lcb_res_frame *lcb_res;
-   uint32_t cmdsize;
+   uint32_t cmdsize, shdr_status, shdr_add_status;
int rc;
 
mb = pmb-u.mb;
-
lcb_context = (struct lpfc_lcb_context *)pmb-context1;
ndlp = lcb_context-ndlp;
pmb-context1 = NULL;
pmb-context2 = NULL;
 
-   if (mb-mbxStatus) {
+   shdr = (union lpfc_sli4_cfg_shdr *)
+   pmb-u.mqe.un.beacon_config.header.cfg_shdr;
+   shdr_status = bf_get(lpfc_mbox_hdr_status, shdr-response);
+   shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, shdr-response);
+
+   lpfc_printf_log(phba, KERN_INFO, LOG_MBOX,
+   0194 SET_BEACON_CONFIG mailbox 
+   completed with status x%x add_status x%x,
+mbx status x%x\n,
+   shdr_status, shdr_add_status, mb-mbxStatus);
+
+   if (mb-mbxStatus  !(shdr_status 
+   shdr_add_status == ADD_STATUS_OPERATION_ALREADY_ACTIVE)) {
mempool_free(pmb, phba-mbox_mem_pool);
goto error;
}
 
mempool_free(pmb, phba-mbox_mem_pool);
-
cmdsize = sizeof(struct fc_lcb_res_frame);
elsiocb = lpfc_prep_els_iocb(phba-pport, 0, cmdsize,
lpfc_max_els_tries, ndlp,
diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index 7cc7bec..b94fa46 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -1943,6 +1943,12 @@ struct lpfc_mbx_redisc_fcf_tbl {
 #define STATUS_FCF_IN_USE  0x3a
 #define STATUS_FCF_TABLE_EMPTY 0x43
 
+/*
+ * Additional status field for embedded SLI_CONFIG mailbox
+ * command.
+ */
+#define ADD_STATUS_OPERATION_ALREADY_ACTIVE0x67
+
 struct lpfc_mbx_sli4_config {
struct mbox_header header;
 };
-- 
1.7.11.7

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG] hpsa: Controller lockup detected: 0x00150028

2015-05-22 Thread Tomas Henzl
On 05/18/2015 06:11 PM, Peter Zijlstra wrote:
 On Mon, May 18, 2015 at 06:03:45PM +0200, Peter Zijlstra wrote:
 On Mon, May 18, 2015 at 05:20:34PM +0200, Peter Zijlstra wrote:
 On Mon, May 18, 2015 at 01:57:39PM +, Oelke, Mark wrote:
 The P212/P410/P411 firmware was recently spun to address an issue that 
 sounds exactly like this problem.
 Which version of controller firmware are you using?

 Smart Array P212 in Slot 1

Hardware Revision: C
Firmware Version: 6.60

 I've updated to 6.62 and it appears to be working now; or rather, it has
 not locked up yet where I think it would've locked up by now earlier.

 I'll let it run for a few more hours before calling it fixed, I'll let
 you know.
 
 And right after sending this email it went...
 
 [ 1119.052144] hpsa :06:00.0: Controller lockup detected: 0x00150029
 
 So sadly no dice.
 
 Anything else I can do?
An older issue for mptsas seems to handle a similar case
2a1b7e575b [SCSI] mptsas: fix hangs caused by ATA pass-through
that might be for hpsa -
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1067,6 +1067,8 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
if (sd != NULL)
sdev-hostdata = sd;
spin_unlock_irqrestore(h-devlock, flags);
+
+   blk_queue_dma_alignment (sdev-request_queue, 512 - 1);
return 0;
 }
-tm
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/9] lpfc: Fix scsi task management error message.

2015-05-22 Thread James Smart

Fix scsi task management error message.

TMF's were getting error messages on FCP_RSP errors (underrun). Underruns
aren't meaningful in the scenario. Change the error message to filter out
these response check errors, and don't unconditionally mark the cmd as
in error.

Signed-off-by: Dick Kennedy dick.kenn...@avagotech.com
Signed-off-by: James Smart james.sm...@avagotech.com
---
 drivers/scsi/lpfc/lpfc_scsi.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index b3b195f..e5eb40d 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -5011,13 +5011,16 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct 
lpfc_rport_data *rdata,
  iocbq, iocbqrsp, lpfc_cmd-timeout);
if ((status != IOCB_SUCCESS) ||
(iocbqrsp-iocb.ulpStatus != IOSTAT_SUCCESS)) {
-   lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
-0727 TMF %s to TGT %d LUN %llu failed (%d, %d) 
-iocb_flag x%x\n,
-lpfc_taskmgmt_name(task_mgmt_cmd),
-tgt_id, lun_id, iocbqrsp-iocb.ulpStatus,
-iocbqrsp-iocb.un.ulpWord[4],
-iocbq-iocb_flag);
+   if (status != IOCB_SUCCESS ||
+   iocbqrsp-iocb.ulpStatus != IOSTAT_FCP_RSP_ERROR)
+   lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
+0727 TMF %s to TGT %d LUN %llu 
+failed (%d, %d) iocb_flag x%x\n,
+lpfc_taskmgmt_name(task_mgmt_cmd),
+tgt_id, lun_id,
+iocbqrsp-iocb.ulpStatus,
+iocbqrsp-iocb.un.ulpWord[4],
+iocbq-iocb_flag);
/* if ulpStatus != IOCB_SUCCESS, then status == IOCB_SUCCESS */
if (status == IOCB_SUCCESS) {
if (iocbqrsp-iocb.ulpStatus == IOSTAT_FCP_RSP_ERROR)
@@ -5031,7 +5034,6 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct 
lpfc_rport_data *rdata,
} else {
ret = FAILED;
}
-   lpfc_cmd-status = IOSTAT_DRIVER_REJECT;
} else
ret = SUCCESS;
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 8/9] lpfc: Fix to drop PLOGIs from fabric node till LOGO processing completes

2015-05-22 Thread James Smart

Fix to drop PLOGIs from fabric node till LOGO processing completes

The domain controller PLOGI's concurrent with prior LOGO's/unreg_rpi's
completing created a race condition where driver rpi ref count can
inadvertantly hit 0 and the rpi attempted to be freed. This error
sometimes resulted in Warning messages indicating kref.h via
lfpc_nlp_get+0x128.

Correct by dropping any new PLOGI until the prior nport state has settled.

Signed-off-by: Dick Kennedy dick.kenn...@avagotech.com
Signed-off-by: James Smart james.sm...@avagotech.com
---
 drivers/scsi/lpfc/lpfc_els.c   | 14 +++---
 drivers/scsi/lpfc/lpfc_hbadisc.c   | 13 +++--
 drivers/scsi/lpfc/lpfc_nportdisc.c |  2 +-
 drivers/scsi/lpfc/lpfc_sli.c   |  2 +-
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 21c4a3d..36bf58b 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -3668,16 +3668,6 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct 
lpfc_iocbq *cmdiocb,
 * At this point, the driver is done so release the IOCB
 */
lpfc_els_free_iocb(phba, cmdiocb);
-
-   /*
-* Remove the ndlp reference if it's a fabric node that has
-* sent us an unsolicted LOGO.
-*/
-   /* FIXME: this one frees ndlp before breaking rport link */
-   if (ndlp-nlp_type  NLP_FABRIC)
-   lpfc_nlp_put(ndlp);
-
-   return;
 }
 
 /**
@@ -4022,7 +4012,9 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
 ndlp-nlp_rpi, vport-fc_flag);
if (ndlp-nlp_flag  NLP_LOGO_ACC) {
spin_lock_irq(shost-host_lock);
-   ndlp-nlp_flag = ~NLP_LOGO_ACC;
+   if (!(ndlp-nlp_flag  NLP_RPI_REGISTERED ||
+   ndlp-nlp_flag  NLP_REG_LOGIN_SEND))
+   ndlp-nlp_flag = ~NLP_LOGO_ACC;
spin_unlock_irq(shost-host_lock);
elsiocb-iocb_cmpl = lpfc_cmpl_els_logo_acc;
} else {
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 72a69d4..ce96d5b 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -4495,7 +4495,7 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct 
lpfc_nodelist *ndlp)
 {
struct lpfc_hba *phba = vport-phba;
LPFC_MBOXQ_t*mbox;
-   int rc;
+   int rc, acc_plogi = 1;
uint16_t rpi;
 
if (ndlp-nlp_flag  NLP_RPI_REGISTERED ||
@@ -4528,14 +4528,20 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct 
lpfc_nodelist *ndlp)
mbox-context1 = lpfc_nlp_get(ndlp);
mbox-mbox_cmpl =
lpfc_sli4_unreg_rpi_cmpl_clr;
+   /*
+* accept PLOGIs after unreg_rpi_cmpl
+*/
+   acc_plogi = 0;
} else
mbox-mbox_cmpl =
lpfc_sli_def_mbox_cmpl;
}
 
rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
-   if (rc == MBX_NOT_FINISHED)
+   if (rc == MBX_NOT_FINISHED) {
mempool_free(mbox, phba-mbox_mem_pool);
+   acc_plogi = 1;
+   }
}
lpfc_no_rpi(phba, ndlp);
 
@@ -4543,8 +4549,11 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct 
lpfc_nodelist *ndlp)
ndlp-nlp_rpi = 0;
ndlp-nlp_flag = ~NLP_RPI_REGISTERED;
ndlp-nlp_flag = ~NLP_NPR_ADISC;
+   if (acc_plogi)
+   ndlp-nlp_flag = ~NLP_LOGO_ACC;
return 1;
}
+   ndlp-nlp_flag = ~NLP_LOGO_ACC;
return 0;
 }
 
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c 
b/drivers/scsi/lpfc/lpfc_nportdisc.c
index 09de640..af3b38a 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -1874,7 +1874,7 @@ lpfc_rcv_logo_logo_issue(struct lpfc_vport *vport, struct 
lpfc_nodelist *ndlp,
struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg;
 
spin_lock_irq(shost-host_lock);
-   ndlp-nlp_flag = NLP_LOGO_ACC;
+   ndlp-nlp_flag |= NLP_LOGO_ACC;
spin_unlock_irq(shost-host_lock);
lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
return ndlp-nlp_state;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 07df296..4feb931 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -2249,7 +2249,7 @@ lpfc_sli4_unreg_rpi_cmpl_clr(struct lpfc_hba *phba, 
LPFC_MBOXQ_t *pmb)
 

[PATCH 4/9] lpfc: Add support for using block multi-queue

2015-05-22 Thread James Smart

Add support for using block multi-queue

With blk-mq support in the mid-layer, lpfc can do IO steering based
on the information in the request tag.  This patch allows lpfc to use
blk-mq if enabled. If not enabled, we fall back into the emulex-internal
affinity mappings.

This feature can be turned on via CONFIG_SCSI_MQ_DEFAULT or passing
scsi_mod.use_blk_mq=Y as a parameter to the kernel.

Signed-off-by: Dick Kennedy dick.kenn...@avagotech.com
Signed-off-by: James Smart james.sm...@avagotech.com
---
 drivers/scsi/lpfc/lpfc_init.c |  4 ++-
 drivers/scsi/lpfc/lpfc_scsi.c | 43 +
 drivers/scsi/lpfc/lpfc_scsi.h |  3 ++
 drivers/scsi/lpfc/lpfc_sli.c  | 74 ++-
 4 files changed, 72 insertions(+), 52 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 14424e6..f962118 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -3303,6 +3303,7 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, 
struct device *dev)
shost-max_lun = vport-cfg_max_luns;
shost-this_id = -1;
shost-max_cmd_len = 16;
+   shost-nr_hw_queues = phba-cfg_fcp_io_channel;
if (phba-sli_rev == LPFC_SLI_REV4) {
shost-dma_boundary =
phba-sli4_hba.pc_sli4_params.sge_supp_len-1;
@@ -8980,7 +8981,8 @@ lpfc_sli4_enable_msix(struct lpfc_hba *phba)
phba-cfg_fcp_io_channel = vectors;
}
 
-   lpfc_sli4_set_affinity(phba, vectors);
+   if (!shost_use_blk_mq(lpfc_shost_from_vport(phba-pport)))
+   lpfc_sli4_set_affinity(phba, vectors);
return rc;
 
 cfg_fail_out:
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 116df9c..4a2a818 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -3846,6 +3846,49 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct 
lpfc_scsi_buf *lpfc_cmd,
 }
 
 /**
+ * lpfc_sli4_scmd_to_wqidx_distr - scsi command to SLI4 WQ index distribution
+ * @phba: Pointer to HBA context object.
+ *
+ * This routine performs a roundrobin SCSI command to SLI4 FCP WQ index
+ * distribution.  This is called by __lpfc_sli_issue_iocb_s4() with the hbalock
+ * held.
+ * If scsi-mq is enabled, get the default block layer mapping of software 
queues
+ * to hardware queues. This information is saved in request tag.
+ *
+ * Return: index into SLI4 fast-path FCP queue index.
+ **/
+int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba,
+ struct lpfc_scsi_buf *lpfc_cmd)
+{
+   struct scsi_cmnd *cmnd = lpfc_cmd-pCmd;
+   struct lpfc_vector_map_info *cpup;
+   int chann, cpu;
+   uint32_t tag;
+   uint16_t hwq;
+
+   if (shost_use_blk_mq(cmnd-device-host)) {
+   tag = blk_mq_unique_tag(cmnd-request);
+   hwq = blk_mq_unique_tag_to_hwq(tag);
+
+   return hwq;
+   }
+
+   if (phba-cfg_fcp_io_sched == LPFC_FCP_SCHED_BY_CPU
+phba-cfg_fcp_io_channel  1) {
+   cpu = smp_processor_id();
+   if (cpu  phba-sli4_hba.num_present_cpu) {
+   cpup = phba-sli4_hba.cpu_map;
+   cpup += cpu;
+   return cpup-channel_id;
+   }
+   }
+   chann = atomic_add_return(1, phba-fcp_qidx);
+   chann = (chann % phba-cfg_fcp_io_channel);
+   return chann;
+}
+
+
+/**
  * lpfc_scsi_cmd_iocb_cmpl - Scsi cmnd IOCB completion routine
  * @phba: The Hba for which this call is being executed.
  * @pIocbIn: The command IOCBQ for the scsi cmnd.
diff --git a/drivers/scsi/lpfc/lpfc_scsi.h b/drivers/scsi/lpfc/lpfc_scsi.h
index 474e30c..18b9260 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.h
+++ b/drivers/scsi/lpfc/lpfc_scsi.h
@@ -184,3 +184,6 @@ struct lpfc_scsi_buf {
 #define FIND_FIRST_OAS_LUN  0
 #define NO_MORE_OAS_LUN-1
 #define NOT_OAS_ENABLED_LUNNO_MORE_OAS_LUN
+
+int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba,
+ struct lpfc_scsi_buf *lpfc_cmd);
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 41d3370..07df296 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -8138,36 +8138,6 @@ lpfc_sli4_bpl2sgl(struct lpfc_hba *phba, struct 
lpfc_iocbq *piocbq,
 }
 
 /**
- * lpfc_sli4_scmd_to_wqidx_distr - scsi command to SLI4 WQ index distribution
- * @phba: Pointer to HBA context object.
- *
- * This routine performs a roundrobin SCSI command to SLI4 FCP WQ index
- * distribution.  This is called by __lpfc_sli_issue_iocb_s4() with the hbalock
- * held.
- *
- * Return: index into SLI4 fast-path FCP queue index.
- **/
-static inline int
-lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba)
-{
-   struct lpfc_vector_map_info *cpup;
-   int chann, cpu;
-
-   if (phba-cfg_fcp_io_sched == LPFC_FCP_SCHED_BY_CPU
-   

[PATCH 9/9] lpfc: Update version to 10.7.0.0 for upstream patch set.

2015-05-22 Thread James Smart

Update version to 10.7.0.0 for upstream patch set.

Signed-off-by: Dick Kennedy dick.kenn...@avagotech.com
Signed-off-by: James Smart james.sm...@avagotech.com
---
 drivers/scsi/lpfc/lpfc_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index 8b96d10..6258d3d 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -18,7 +18,7 @@
  * included with this package. *
  ***/
 
-#define LPFC_DRIVER_VERSION 10.6.0.1.
+#define LPFC_DRIVER_VERSION 10.7.0.0.
 #define LPFC_DRIVER_NAME   lpfc
 
 /* Used for SLI 2/3 */
-- 
1.7.11.7

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/9] lpfc: Fix scsi prep dma buf error.

2015-05-22 Thread James Smart

Fix scsi prep dma buf error.

Didn't check for less-than-or-equal zero. Means we may later call
scsi_dma_unmap() even though we don't have valid mappings.

Signed-off-by: Dick Kennedy dick.kenn...@avagotech.com
Signed-off-by: James Smart james.sm...@avagotech.com
---
 drivers/scsi/lpfc/lpfc_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 4a2a818..b3b195f 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -3257,7 +3257,7 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct 
lpfc_scsi_buf *lpfc_cmd)
 */
 
nseg = scsi_dma_map(scsi_cmnd);
-   if (unlikely(!nseg))
+   if (unlikely(nseg = 0))
return 1;
sgl += 1;
/* clear the last flag in the fcp_rsp map entry */
-- 
1.7.11.7

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/9] lpfc: Fix cq_id masking problem.

2015-05-22 Thread James Smart

Fix cq_id masking problem.

The driver inadvertainly constrained the id space to 8 bits, when its
a full 16 bits from hw. This resulted in bad id's being written to the
hardware. Resulted in symptoms such as incomplete initialization, no
detection of link events, etc.

Signed-off-by: Dick Kennedy dick.kenn...@avagotech.com
Signed-off-by: James Smart james.sm...@avagotech.com
---
 drivers/scsi/lpfc/lpfc_hw4.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index b94fa46..33ec4fa 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -291,7 +291,7 @@ struct sli4_bls_rsp {
 struct lpfc_eqe {
uint32_t word0;
 #define lpfc_eqe_resource_id_SHIFT 16
-#define lpfc_eqe_resource_id_MASK  0x00FF
+#define lpfc_eqe_resource_id_MASK  0x
 #define lpfc_eqe_resource_id_WORD  word0
 #define lpfc_eqe_minor_code_SHIFT  4
 #define lpfc_eqe_minor_code_MASK   0x0FFF
-- 
1.7.11.7

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: iscsi flashnode bus? Re: [RFC PATCH 2/4] iscsi: sysfs filtering by network namespace

2015-05-22 Thread Mike Christie

On 5/21/15, 3:49 PM, Chris Leech wrote:

On Wed, May 13, 2015 at 03:12:45PM -0700, Chris Leech wrote:

This makes the iscsi_host, iscsi_session, iscsi_connection, and
iscsi_endpoint transport class devices only visible in sysfs under a
matching network namespace.  The network namespace for all of these
objects is tracked in the iscsi_cls_host structure.


I noticed that I didn't change iscsi_iface, but it should probably be
handled the same was as iscsi_endpoint.

I had intentionally skipped over all the flashnode stuff, until I had a
chance to go back and take a closer look.

Is there any particular reason why the flashnode support was implemented
as a bus?  Following the pattern of everything else in
scsi_transport_iscsi it should probably have been two classes
(iscsi_flash_session and iscsi_flash_conn).  It's an issue as sysfs
tagging only works on a per-class basis right now.




At some point upstream started telling us to stop using classes and use 
buses instead. It was around the time the fcoe's fcoe_sysfs stuff was 
being reviewed. In the middle of this mail is the comment about using 
buses instead of classes for fcoe:


http://www.spinics.net/lists/linux-scsi/msg58168.html


I can see a couple of ways forward.

1) Extend sysfs tagging to work with device_type as well as class, and
use that for the two types on the flashnode bus


If we are supposed to be using buses instead of classes then I think is 
correct.




2) Change the flashnode code to use classes instead of a bus.
Keeping a single iscsi_flashnode class and continuing to use the two
device_types for sessions and connections should result in the only
visible change being /sys/bus/iscsi_flashnode moving to
/sys/class/iscsi_flashnode.


If we can use classes, this is fine with me.



I prefer #2, but it looks like the open-iscsi tools would need to be
updated (not all code paths follow the recommendations to ignore
bus/class differences and check all subsystem locations).  And I don't
know for sure that there aren't any other tools using this interface
(it's only implemented for qla4xxx).



Ccing qlogic. I do not think any tools use it. I do not even know if 
anyone uses iscsiadm to manage it. Qlogic?



--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG] hpsa: Controller lockup detected: 0x00150028

2015-05-22 Thread Peter Zijlstra
On Fri, May 22, 2015 at 05:10:44PM +0200, Tomas Henzl wrote:
  I've updated to 6.62 and it appears to be working now; or rather, it has

I've since gotten 6.64 from HP to test; which does not seem public yet.

6.64 actually fixes the issue for me.

 An older issue for mptsas seems to handle a similar case
 2a1b7e575b [SCSI] mptsas: fix hangs caused by ATA pass-through
 that might be for hpsa -

 --- a/drivers/scsi/hpsa.c
 +++ b/drivers/scsi/hpsa.c
 @@ -1067,6 +1067,8 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
 if (sd != NULL)
 sdev-hostdata = sd;
 spin_unlock_irqrestore(h-devlock, flags);
 +
 +   blk_queue_dma_alignment (sdev-request_queue, 512 - 1);
 return 0;
  }

That does indeed seem _very_ similar; I'll have to defer to Mark Oelke
and or Don Brace to say if the above is a useful alternative. Since they
seem to now know what was the root cause.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [BUG] hpsa: Controller lockup detected: 0x00150028

2015-05-22 Thread Handzik, Joe
No, the problem here (iirc) actually dealt with buffers in the firmware.

Don or Mark, agree?

Joe

-Original Message-
From: Peter Zijlstra [mailto:pet...@infradead.org] 
Sent: Friday, May 22, 2015 11:40 AM
To: Tomas Henzl
Cc: Oelke, Mark; don.br...@pmcs.com; ISS StorageDev; storage...@pmcs.com; 
linux-scsi@vger.kernel.org
Subject: Re: [BUG] hpsa: Controller lockup detected: 0x00150028

On Fri, May 22, 2015 at 05:10:44PM +0200, Tomas Henzl wrote:
  I've updated to 6.62 and it appears to be working now; or rather, it has

I've since gotten 6.64 from HP to test; which does not seem public yet.

6.64 actually fixes the issue for me.

 An older issue for mptsas seems to handle a similar case
 2a1b7e575b [SCSI] mptsas: fix hangs caused by ATA pass-through
 that might be for hpsa -

 --- a/drivers/scsi/hpsa.c
 +++ b/drivers/scsi/hpsa.c
 @@ -1067,6 +1067,8 @@ static int hpsa_slave_alloc(struct scsi_device *sdev)
 if (sd != NULL)
 sdev-hostdata = sd;
 spin_unlock_irqrestore(h-devlock, flags);
 +
 +   blk_queue_dma_alignment (sdev-request_queue, 512 - 1);
 return 0;
  }

That does indeed seem _very_ similar; I'll have to defer to Mark Oelke
and or Don Brace to say if the above is a useful alternative. Since they
seem to now know what was the root cause.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [dm-devel] Proposal for annotating _unstable_ pages

2015-05-22 Thread Kent Overstreet
On Fri, May 22, 2015 at 11:17:59AM -0700, Darrick J. Wong wrote:
 Back when I was writing the stable pages patches, I observed that some of the
 filesystems didn't hold the pages containing their own metadata stable during
 writeback on a stable-writes device.  The journalling filesystems were fine
 because they had various means to take care of that.
 
 ISTR ext2 and vfat were the biggest culprits, but both maintainers rejected
 the patches to fix that behavior.  This might no longer be the case; those
 patches were so long ago I can't find them in Google.

Not at all surprised. Yeah, this would solve that problem - we just annotate
those bios so we don't bounce them until we hit a point where we need to.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [dm-devel] Proposal for annotating _unstable_ pages

2015-05-22 Thread Darrick J. Wong
On Thu, May 21, 2015 at 09:21:12PM +0200, Jan Kara wrote:
 On Thu 21-05-15 11:09:55, Kent Overstreet wrote:
  On Thu, May 21, 2015 at 06:54:53PM +0200, Jan Kara wrote:
   On Wed 20-05-15 18:04:40, Kent Overstreet wrote:
 Yeah.  I never figured out a sane way to migrate pages and keep 
 everything
 else happy.  Daniel Phillips is having a go at page forking for tux3; 
 let's
 see if the questions about that get resolved.

That would be great, we need something.

I'd also be really curious what btrfs is doing today - is it just 
bouncing
everything internally, or did they come up with something more clever?
   
   Btrfs is just waiting for IO to complete.
   
  Also, there's probably always going to be situations where we're 
  reading or
  writing to pages user space can stomp on (dio) - IMO we need to add 
  a bio flag
  to annotate this - if you need this to be stable you have to 
  bounce it.
  Otherwise either filesystems/block drivers are going to be stuck 
  bouncing
  everything, or it'll just (continue to be) buggy.
 
 Well, for now there's BIO_SNAP_STABLE that forces the block layer to 
 bounce it,
 but right now ext3 is the last user of it, and afaict btrfs is the 
 only other
 FS that takes care of stable pages on its own.

I have no idea what BIO_SNAP_STABLE was supposed to be for, but I don't 
see how
it's useful for anything sane.
   
   It's for the case where lower layer requests it needs stable pages but
   upper layer isn't able to provide them (as is the case of ext3). Then 
   block
   layer bounces the data for the caller.
   
But that's the complete opposite of the problem stable pages are 
supposed to
solve: stable pages are for when the _lower_ layer (be it filesystem, 
bcache,
md, lvm) needs the memory being either read to or written from (both, 
it's not
just writes) to not be diddled over while the IO is in flight.

Now, a point that I think has been missed is that stable pages are 
_not_ a
complete solution, at least for consumers in the block layer.

The situation today is that if I'm in the block layer, and I get a 
handed a read
or write bio, I _don't know_ if it's from something that's going to 
diddle over
those pages or not. So if I require stable pages - be it for data 
checksumming
or for other things - I've just got to bounce the bio myself.

And then the really annoying thing is that if you've got stacked things 
that all
need stable pages (maybe btrfs on top of bcache on top of md) - they 
_all_ have
to assume the pages aren't going to be stable, so if they need them 
they _all_
have to bounce - even though once the first layer bounced the bio that 
made it
stable for everything underneath it.
   
   The current design is that if you need stable pages for your device, set
   bdi capability BDI_CAP_STABLE_WRITES, fs then takes care of not scribbling
   over your page while it is under writeback or uses BIO_SNAP_STABLE if it
   cannot.
  
  But if I need stable pages, I still have to bounce because that _does not_
  guarantee stable pages, it only gives me stable pages for some of the IOs 
  and in
  the lower layers you can't tell which is which.
  
  Do you see the problem? What good is BDI_CAP_STABLE_WRITES if it's not a
  guarantee and I can't tell if I need to bounce or not?
   So fix the upper layers to make it a guarantee? You mentioned direct IO
 needs fixing. Anything else?

Back when I was writing the stable pages patches, I observed that some of the
filesystems didn't hold the pages containing their own metadata stable during
writeback on a stable-writes device.  The journalling filesystems were fine
because they had various means to take care of that.

ISTR ext2 and vfat were the biggest culprits, but both maintainers rejected
the patches to fix that behavior.  This might no longer be the case; those
patches were so long ago I can't find them in Google.

--D

 
   Honza
 -- 
 Jan Kara j...@suse.cz
 SUSE Labs, CR
 
 --
 dm-devel mailing list
 dm-de...@redhat.com
 https://www.redhat.com/mailman/listinfo/dm-devel
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Backport of a fix for HPSA (Disabling a disabled device problem during kdump) driver

2015-05-22 Thread Vinson Lee
On Sat, May 2, 2015 at 10:56 AM, Greg KH g...@kroah.com wrote:
 On Mon, Apr 27, 2015 at 03:10:35PM +0200, Tomas Henzl wrote:
 On 04/27/2015 02:55 PM, Greg KH wrote:
  On Mon, Apr 27, 2015 at 02:17:32PM +0200, Tomas Henzl wrote:
  On 04/26/2015 11:27 AM, Greg KH wrote:
  On Mon, Apr 13, 2015 at 03:18:44PM +0200, Tomas Henzl wrote:
  On 04/11/2015 12:45 AM, Vinson Lee wrote:
  On Tue, Jan 27, 2015 at 4:18 PM, Greg KH g...@kroah.com wrote:
  On Tue, Jan 06, 2015 at 05:15:19PM +0100, Tomas Henzl wrote:
  On 01/05/2015 07:41 PM, Masoud Sharbiani wrote:
  Dear stable maintainers,
  Can you please backport commitid 
  132aa220b45d60e9b20def1e9d8be9422eed9616
   (hpsa: refine the pci enable/disable handling) to 3.10 stable (and
  earlier, if applicable)?
  Please do not apply this patch isolated from his friend, the
  859c75aba20264d87dd026bab0d0ca3bff385955 hpsa: add missing 
  pci_set_master in kdump path
  needs to be applied together with the 
  132aa220b45d60e9b20def1e9d8be9422eed9616 .
 
  In addition to that, after the original issue goes away you may 
  notice sometimes
  an unhandled irq 16 message, to fix this a patch is posted
  here http://www.spinics.net/lists/linux-scsi/msg80316.html
  This patch still awaits a maintainers review though.
 
  Probably the best idea is to wait until the issue is solved 
  completely.
  I'll wait, when it all gets worked out, please let stable@ know what
  patches to apply where.
 
  thanks,
 
  greg k-h
  --
  To unsubscribe from this list: send the line unsubscribe stable in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html
  Hi, Thomas.
 
  The unhandled irq 16 issue seems to be fixed by 4.0-rc1 commit hpsa:
  turn off interrupts when kdump starts.
 
  Are the following patches suitable for stable now?
  Yes, I believe they are, just note that
  03741d9 hpsa: fix memory leak in kdump hard reset
  is not a part of that group we discussed before, but it may be added
  to stable too.
 
  Cheers,
  Tomas
 
  3b74729 hpsa: turn off interrupts when kdump starts
  03741d9 hpsa: fix memory leak in kdump hard reset
  859c75a hpsa: add missing pci_set_master in kdump path
  132aa22 hpsa: refine the pci enable/disable handling
  So what order, and to what stable tree(s) do you want these applied to?
  They seem to span a number of kernel versions, so I'm not quite sure
  what you are wanting me to do.
  Please add it in this order
  1. 132aa220b4 hpsa: refine the pci enable/disable handling
  2. 859c75aba2 hpsa: add missing pci_set_master in kdump path
 The first two patches create the fix Masoud has asked for originally 
  to port to stable.
  3. 3b74729878 hpsa: turn off interrupts when kdump starts
 The third should be added too, it fixes an issue made visible by the 
  first patch
 
  The fourth patch
  03741d956e hpsa: fix memory leak in kdump hard reset
  is completely unrelated to the first group, so it may be added after or 
  before
  or in the same sequence as it is in the mainline - that is before the 
  third patch.
  This patch is tiny error path fix - not sure if important enough for 
  stable.
  Which stable tree(s) do you want these applied to?  As these span
  different kernel versions, I have no idea of what to do here.

 Masoud has asked for the inclusion, I think that what he wrote was - 3.10 
 stable (and earlier, if applicable),
 I don't know much about stable so I can't decide to which tree(s) the series 
 should be ported.

 Ok, I'll wait for someone to clarify before doing anything here.

 thanks,

 greg k-h


The first and second patches are from upstream 3.18. The third patch
is from upstream 4.0.

Please use the following list of kernels and patches for backporting.

3.18, 3.19
3b74729878 hpsa: turn off interrupts when kdump starts

= 3.17
132aa220b4 hpsa: refine the pci enable/disable handling
859c75aba2 hpsa: add missing pci_set_master in kdump path
3b74729878 hpsa: turn off interrupts when kdump starts

Cheers,
Vinson
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] scsi: add Synology to 1024 sector blacklist

2015-05-22 Thread michaelc
From: Mike Christie micha...@cs.wisc.edu

Another day another iSCSI target that cannot handle large IOs.
The Synology iSCSI targets report:

Block limits VPD page (SBC):
  Write same no zero (WSNZ): 0
  Maximum compare and write length: 0 blocks
  Optimal transfer length granularity: 0 blocks
  Maximum transfer length: 0 blocks
  Optimal transfer length: 0 blocks
  Maximum prefetch length: 0 blocks
  Maximum unmap LBA count: 0
  Maximum unmap block descriptor count: 0
  Optimal unmap granularity: 0
  Unmap granularity alignment valid: 0
  Unmap granularity alignment: 0
  Maximum write same length: 0x0 blocks

and the size of the command it can handle seems to depend on how much
memory it can allocate at the time. This results in IO errors when
handling large IOs. This patch just has us use the old 1024 default
sectors for this target by adding it to the scsi blacklist.

Reported-by: Ancoron Luciferis ancoron.lucife...@googlemail.com
Signed-off-by: Mike Christie micha...@cs.wisc.edu
---
 drivers/scsi/scsi_devinfo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 848c7ca..d2a8bdf 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -227,6 +227,7 @@ static struct {
{Promise, VTrak E610f, NULL, BLIST_SPARSELUN | BLIST_NO_RSOC},
{Promise, , NULL, BLIST_SPARSELUN},
{QNAP, iSCSI Storage, NULL, BLIST_MAX_1024}, 
+   {SYNOLOGY, iSCSI Storage, NULL, BLIST_MAX_1024},
{QUANTUM, XP34301, 1071, BLIST_NOTQ},
{REGAL, CDC-4X, NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
{SanDisk, ImageMate CF-SD1, NULL, BLIST_FORCELUN},
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html