Re: [PATCH 1/3] iscsi-target: Convert iscsi_thread_set usage to kthread.h

2015-03-26 Thread Nicholas A. Bellinger
On Tue, 2015-03-24 at 18:37 +0200, Sagi Grimberg wrote:
 On 3/23/2015 2:21 PM, Sagi Grimberg wrote:
  On 3/21/2015 8:16 AM, Nicholas A. Bellinger wrote:
  From: Nicholas Bellinger n...@linux-iscsi.org
 
  This patch converts iscsi-target code to use modern kthread.h API
  callers for creating RX/TX threads for each new iscsi_conn descriptor,
  and releasing associated RX/TX threads during connection shutdown.
 
  This is done using iscsit_start_kthreads() - kthread_run() to start
  new kthreads from within iscsi_post_login_handler(), and invoking
  kthread_stop() from existing iscsit_close_connection() code.
 
  Also, convert iscsit_logout_post_handler_closesession() code to use
  cmpxchg when determing when iscsit_cause_connection_reinstatement()
  needs to sleep waiting for completion.
 
  I'll run some tests with this.
 
 Hi Nic,
 
 I can report that this series (minus patch 3/3 and along with some
 patches I'll send out soon) seems to resolve the list corruption issue
 I've seen.
 
 Overall the patches look good to me so feel free to include
 patches 1+2 with:
 
 Tested-by: Sagi Grimberg sa...@mellanox.com
 

Great.  The first two are queued in for-next, and for the moment #1 has
a v3.10+ stable tag as well..

Please let me know if you run into any regressions with these.

Thanks alot Sagi!

--nab

--
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/3] iscsi-target: Convert iscsi_thread_set usage to kthread.h

2015-03-24 Thread Sagi Grimberg

On 3/23/2015 2:21 PM, Sagi Grimberg wrote:

On 3/21/2015 8:16 AM, Nicholas A. Bellinger wrote:

From: Nicholas Bellinger n...@linux-iscsi.org

This patch converts iscsi-target code to use modern kthread.h API
callers for creating RX/TX threads for each new iscsi_conn descriptor,
and releasing associated RX/TX threads during connection shutdown.

This is done using iscsit_start_kthreads() - kthread_run() to start
new kthreads from within iscsi_post_login_handler(), and invoking
kthread_stop() from existing iscsit_close_connection() code.

Also, convert iscsit_logout_post_handler_closesession() code to use
cmpxchg when determing when iscsit_cause_connection_reinstatement()
needs to sleep waiting for completion.


I'll run some tests with this.


Hi Nic,

I can report that this series (minus patch 3/3 and along with some
patches I'll send out soon) seems to resolve the list corruption issue
I've seen.

Overall the patches look good to me so feel free to include
patches 1+2 with:

Tested-by: Sagi Grimberg sa...@mellanox.com

Thanks!
Sagi.
--
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/3] iscsi-target: Convert iscsi_thread_set usage to kthread.h

2015-03-23 Thread Sagi Grimberg

On 3/21/2015 8:16 AM, Nicholas A. Bellinger wrote:

From: Nicholas Bellinger n...@linux-iscsi.org

This patch converts iscsi-target code to use modern kthread.h API
callers for creating RX/TX threads for each new iscsi_conn descriptor,
and releasing associated RX/TX threads during connection shutdown.

This is done using iscsit_start_kthreads() - kthread_run() to start
new kthreads from within iscsi_post_login_handler(), and invoking
kthread_stop() from existing iscsit_close_connection() code.

Also, convert iscsit_logout_post_handler_closesession() code to use
cmpxchg when determing when iscsit_cause_connection_reinstatement()
needs to sleep waiting for completion.


I'll run some tests with this.

two comments below.



Reported-by: Sagi Grimberg sa...@mellanox.com
Cc: Sagi Grimberg sa...@mellanox.com
Cc: Slava Shwartsman valyush...@gmail.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
  drivers/target/iscsi/iscsi_target.c   | 106 +-
  drivers/target/iscsi/iscsi_target_erl0.c  |  13 ++--
  drivers/target/iscsi/iscsi_target_login.c |  59 +++--
  include/target/iscsi/iscsi_target_core.h  |   7 ++
  4 files changed, 116 insertions(+), 69 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index 2accb6e..cb97b59 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -537,7 +537,7 @@ static struct iscsit_transport iscsi_target_transport = {

  static int __init iscsi_target_init_module(void)
  {
-   int ret = 0;
+   int ret = 0, size;

pr_debug(iSCSI-Target ISCSIT_VERSION\n);

@@ -546,6 +546,7 @@ static int __init iscsi_target_init_module(void)
pr_err(Unable to allocate memory for iscsit_global\n);
return -1;
}
+   spin_lock_init(iscsit_global-ts_bitmap_lock);
mutex_init(auth_id_lock);
spin_lock_init(sess_idr_lock);
idr_init(tiqn_idr);
@@ -555,15 +556,11 @@ static int __init iscsi_target_init_module(void)
if (ret  0)
goto out;

-   ret = iscsi_thread_set_init();
-   if (ret  0)
+   size = BITS_TO_LONGS(ISCSIT_BITMAP_BITS) * sizeof(long);
+   iscsit_global-ts_bitmap = vzalloc(size);
+   if (!iscsit_global-ts_bitmap) {
+   pr_err(Unable to allocate iscsit_global-ts_bitmap\n);
goto configfs_out;
-
-   if (iscsi_allocate_thread_sets(TARGET_THREAD_SET_COUNT) !=
-   TARGET_THREAD_SET_COUNT) {
-   pr_err(iscsi_allocate_thread_sets() returned
-unexpected value!\n);
-   goto ts_out1;
}

lio_qr_cache = kmem_cache_create(lio_qr_cache,
@@ -572,7 +569,7 @@ static int __init iscsi_target_init_module(void)
if (!lio_qr_cache) {
pr_err(nable to kmem_cache_create() for
 lio_qr_cache\n);
-   goto ts_out2;
+   goto bitmap_out;
}

lio_dr_cache = kmem_cache_create(lio_dr_cache,
@@ -617,10 +614,8 @@ dr_out:
kmem_cache_destroy(lio_dr_cache);
  qr_out:
kmem_cache_destroy(lio_qr_cache);
-ts_out2:
-   iscsi_deallocate_thread_sets();
-ts_out1:
-   iscsi_thread_set_free();
+bitmap_out:
+   vfree(iscsit_global-ts_bitmap);
  configfs_out:
iscsi_target_deregister_configfs();
  out:
@@ -630,8 +625,6 @@ out:

  static void __exit iscsi_target_cleanup_module(void)
  {
-   iscsi_deallocate_thread_sets();
-   iscsi_thread_set_free();
iscsit_release_discovery_tpg();
iscsit_unregister_transport(iscsi_target_transport);
kmem_cache_destroy(lio_qr_cache);
@@ -641,6 +634,7 @@ static void __exit iscsi_target_cleanup_module(void)

iscsi_target_deregister_configfs();

+   vfree(iscsit_global-ts_bitmap);
kfree(iscsit_global);
  }

@@ -3710,17 +3704,16 @@ static int iscsit_send_reject(

  void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
  {
-   struct iscsi_thread_set *ts = conn-thread_set;
int ord, cpu;
/*
-* thread_id is assigned from iscsit_global-ts_bitmap from
-* within iscsi_thread_set.c:iscsi_allocate_thread_sets()
+* bitmap_id is assigned from iscsit_global-ts_bitmap from
+* within iscsit_start_kthreads()
 *
-* Here we use thread_id to determine which CPU that this
-* iSCSI connection's iscsi_thread_set will be scheduled to
+* Here we use bitmap_id to determine which CPU that this
+* iSCSI connection's RX/TX threads will be scheduled to
 * execute upon.
 */
-   ord = ts-thread_id % cpumask_weight(cpu_online_mask);
+   ord = conn-bitmap_id % cpumask_weight(cpu_online_mask);
for_each_online_cpu(cpu) {
if (ord-- == 0) {
cpumask_set_cpu(cpu, conn-conn_cpumask);
@@ -3909,7 +3902,7 @@ check_rsp_state:
switch 

[PATCH 1/3] iscsi-target: Convert iscsi_thread_set usage to kthread.h

2015-03-21 Thread Nicholas A. Bellinger
From: Nicholas Bellinger n...@linux-iscsi.org

This patch converts iscsi-target code to use modern kthread.h API
callers for creating RX/TX threads for each new iscsi_conn descriptor,
and releasing associated RX/TX threads during connection shutdown.

This is done using iscsit_start_kthreads() - kthread_run() to start
new kthreads from within iscsi_post_login_handler(), and invoking
kthread_stop() from existing iscsit_close_connection() code.

Also, convert iscsit_logout_post_handler_closesession() code to use
cmpxchg when determing when iscsit_cause_connection_reinstatement()
needs to sleep waiting for completion.

Reported-by: Sagi Grimberg sa...@mellanox.com
Cc: Sagi Grimberg sa...@mellanox.com
Cc: Slava Shwartsman valyush...@gmail.com
Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
---
 drivers/target/iscsi/iscsi_target.c   | 106 +-
 drivers/target/iscsi/iscsi_target_erl0.c  |  13 ++--
 drivers/target/iscsi/iscsi_target_login.c |  59 +++--
 include/target/iscsi/iscsi_target_core.h  |   7 ++
 4 files changed, 116 insertions(+), 69 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c 
b/drivers/target/iscsi/iscsi_target.c
index 2accb6e..cb97b59 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -537,7 +537,7 @@ static struct iscsit_transport iscsi_target_transport = {
 
 static int __init iscsi_target_init_module(void)
 {
-   int ret = 0;
+   int ret = 0, size;
 
pr_debug(iSCSI-Target ISCSIT_VERSION\n);
 
@@ -546,6 +546,7 @@ static int __init iscsi_target_init_module(void)
pr_err(Unable to allocate memory for iscsit_global\n);
return -1;
}
+   spin_lock_init(iscsit_global-ts_bitmap_lock);
mutex_init(auth_id_lock);
spin_lock_init(sess_idr_lock);
idr_init(tiqn_idr);
@@ -555,15 +556,11 @@ static int __init iscsi_target_init_module(void)
if (ret  0)
goto out;
 
-   ret = iscsi_thread_set_init();
-   if (ret  0)
+   size = BITS_TO_LONGS(ISCSIT_BITMAP_BITS) * sizeof(long);
+   iscsit_global-ts_bitmap = vzalloc(size);
+   if (!iscsit_global-ts_bitmap) {
+   pr_err(Unable to allocate iscsit_global-ts_bitmap\n);
goto configfs_out;
-
-   if (iscsi_allocate_thread_sets(TARGET_THREAD_SET_COUNT) !=
-   TARGET_THREAD_SET_COUNT) {
-   pr_err(iscsi_allocate_thread_sets() returned
-unexpected value!\n);
-   goto ts_out1;
}
 
lio_qr_cache = kmem_cache_create(lio_qr_cache,
@@ -572,7 +569,7 @@ static int __init iscsi_target_init_module(void)
if (!lio_qr_cache) {
pr_err(nable to kmem_cache_create() for
 lio_qr_cache\n);
-   goto ts_out2;
+   goto bitmap_out;
}
 
lio_dr_cache = kmem_cache_create(lio_dr_cache,
@@ -617,10 +614,8 @@ dr_out:
kmem_cache_destroy(lio_dr_cache);
 qr_out:
kmem_cache_destroy(lio_qr_cache);
-ts_out2:
-   iscsi_deallocate_thread_sets();
-ts_out1:
-   iscsi_thread_set_free();
+bitmap_out:
+   vfree(iscsit_global-ts_bitmap);
 configfs_out:
iscsi_target_deregister_configfs();
 out:
@@ -630,8 +625,6 @@ out:
 
 static void __exit iscsi_target_cleanup_module(void)
 {
-   iscsi_deallocate_thread_sets();
-   iscsi_thread_set_free();
iscsit_release_discovery_tpg();
iscsit_unregister_transport(iscsi_target_transport);
kmem_cache_destroy(lio_qr_cache);
@@ -641,6 +634,7 @@ static void __exit iscsi_target_cleanup_module(void)
 
iscsi_target_deregister_configfs();
 
+   vfree(iscsit_global-ts_bitmap);
kfree(iscsit_global);
 }
 
@@ -3710,17 +3704,16 @@ static int iscsit_send_reject(
 
 void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
 {
-   struct iscsi_thread_set *ts = conn-thread_set;
int ord, cpu;
/*
-* thread_id is assigned from iscsit_global-ts_bitmap from
-* within iscsi_thread_set.c:iscsi_allocate_thread_sets()
+* bitmap_id is assigned from iscsit_global-ts_bitmap from
+* within iscsit_start_kthreads()
 *
-* Here we use thread_id to determine which CPU that this
-* iSCSI connection's iscsi_thread_set will be scheduled to
+* Here we use bitmap_id to determine which CPU that this
+* iSCSI connection's RX/TX threads will be scheduled to
 * execute upon.
 */
-   ord = ts-thread_id % cpumask_weight(cpu_online_mask);
+   ord = conn-bitmap_id % cpumask_weight(cpu_online_mask);
for_each_online_cpu(cpu) {
if (ord-- == 0) {
cpumask_set_cpu(cpu, conn-conn_cpumask);
@@ -3909,7 +3902,7 @@ check_rsp_state:
switch (state) {
case ISTATE_SEND_LOGOUTRSP:
if (!iscsit_logout_post_handler(cmd, conn))
-