Skip to content

Commit

Permalink
iscsi-target: Initial traditional TCP conversion to iscsit_transport
Browse files Browse the repository at this point in the history
This patch performs the initial conversion of existing traditional iscsi
to use iscsit_transport API callers.  This includes:

- iscsi-np cleanups for iscsit_transport_type
- Add iscsi-np transport calls w/ ->iscsit_setup_up() and ->iscsit_free_np()
- Convert login thread process context to use ->iscsit_accept_np() for
  connections with pre-allocated struct iscsi_conn
- Convert existing socket accept code to iscsit_accept_np()
- Convert login RX/TX callers to use ->iscsit_get_login_rx() and
  ->iscsit_put_login_tx() to exchange request/response PDUs
- Convert existing socket login RX/TX calls into iscsit_get_login_rx()
  and iscsit_put_login_tx()
- Change iscsit_close_connection() to invoke ->iscsit_free_conn() +
  iscsit_put_transport() calls.
- Add iscsit_register_transport() + iscsit_unregister_transport() calls
  to module init/exit

v4 changes:

- Add missing iscsit_put_transport() call in iscsi_target_setup_login_socket()
  failure case

v2 changes:

- Update module init/exit to use register_transport() + unregister_transport()

Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Nicholas Bellinger committed Apr 25, 2013
1 parent 3f99306 commit baa4d64
Show file tree
Hide file tree
Showing 9 changed files with 380 additions and 315 deletions.
35 changes: 28 additions & 7 deletions drivers/target/iscsi/iscsi_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#include "iscsi_target_device.h"
#include "iscsi_target_stat.h"

#include <target/iscsi/iscsi_transport.h>

static LIST_HEAD(g_tiqn_list);
static LIST_HEAD(g_np_list);
static DEFINE_SPINLOCK(tiqn_lock);
Expand Down Expand Up @@ -401,8 +403,7 @@ struct iscsi_np *iscsit_add_np(
spin_unlock_bh(&np_lock);

pr_debug("CORE[0] - Added Network Portal: %s:%hu on %s\n",
np->np_ip, np->np_port, (np->np_network_transport == ISCSI_TCP) ?
"TCP" : "SCTP");
np->np_ip, np->np_port, np->np_transport->name);

return np;
}
Expand Down Expand Up @@ -441,11 +442,10 @@ int iscsit_reset_np_thread(
return 0;
}

static int iscsit_del_np_comm(struct iscsi_np *np)
static void iscsit_free_np(struct iscsi_np *np)
{
if (np->np_socket)
sock_release(np->np_socket);
return 0;
}

int iscsit_del_np(struct iscsi_np *np)
Expand All @@ -467,20 +467,32 @@ int iscsit_del_np(struct iscsi_np *np)
send_sig(SIGINT, np->np_thread, 1);
kthread_stop(np->np_thread);
}
iscsit_del_np_comm(np);

np->np_transport->iscsit_free_np(np);

spin_lock_bh(&np_lock);
list_del(&np->np_list);
spin_unlock_bh(&np_lock);

pr_debug("CORE[0] - Removed Network Portal: %s:%hu on %s\n",
np->np_ip, np->np_port, (np->np_network_transport == ISCSI_TCP) ?
"TCP" : "SCTP");
np->np_ip, np->np_port, np->np_transport->name);

iscsit_put_transport(np->np_transport);
kfree(np);
return 0;
}

static struct iscsit_transport iscsi_target_transport = {
.name = "iSCSI/TCP",
.transport_type = ISCSI_TCP,
.owner = NULL,
.iscsit_setup_np = iscsit_setup_np,
.iscsit_accept_np = iscsit_accept_np,
.iscsit_free_np = iscsit_free_np,
.iscsit_get_login_rx = iscsit_get_login_rx,
.iscsit_put_login_tx = iscsit_put_login_tx,
};

static int __init iscsi_target_init_module(void)
{
int ret = 0;
Expand Down Expand Up @@ -557,6 +569,8 @@ static int __init iscsi_target_init_module(void)
goto ooo_out;
}

iscsit_register_transport(&iscsi_target_transport);

if (iscsit_load_discovery_tpg() < 0)
goto r2t_out;

Expand Down Expand Up @@ -587,6 +601,7 @@ 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_cmd_cache);
kmem_cache_destroy(lio_qr_cache);
kmem_cache_destroy(lio_dr_cache);
Expand Down Expand Up @@ -4053,6 +4068,12 @@ int iscsit_close_connection(

if (conn->sock)
sock_release(conn->sock);

if (conn->conn_transport->iscsit_free_conn)
conn->conn_transport->iscsit_free_conn(conn);

iscsit_put_transport(conn->conn_transport);

conn->thread_set = NULL;

pr_debug("Moving to TARG_CONN_STATE_FREE.\n");
Expand Down
15 changes: 12 additions & 3 deletions drivers/target/iscsi/iscsi_target_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

#define ISCSI_IOV_DATA_BUFFER 5

enum tpg_np_network_transport_table {
enum iscsit_transport_type {
ISCSI_TCP = 0,
ISCSI_SCTP_TCP = 1,
ISCSI_SCTP_UDP = 2,
Expand Down Expand Up @@ -503,6 +503,7 @@ struct iscsi_conn {
u16 login_port;
u16 local_port;
int net_size;
int login_family;
u32 auth_id;
u32 conn_flags;
/* Used for iscsi_tx_login_rsp() */
Expand Down Expand Up @@ -562,9 +563,12 @@ struct iscsi_conn {
struct list_head immed_queue_list;
struct list_head response_queue_list;
struct iscsi_conn_ops *conn_ops;
struct iscsi_login *conn_login;
struct iscsit_transport *conn_transport;
struct iscsi_param_list *param_list;
/* Used for per connection auth state machine */
void *auth_protocol;
void *context;
struct iscsi_login_thread_s *login_thread;
struct iscsi_portal_group *tpg;
/* Pointer to parent session */
Expand Down Expand Up @@ -663,17 +667,20 @@ struct iscsi_login {
u8 first_request;
u8 version_min;
u8 version_max;
u8 login_complete;
u8 login_failed;
char isid[6];
u32 cmd_sn;
itt_t init_task_tag;
u32 initial_exp_statsn;
u32 rsp_length;
u16 cid;
u16 tsih;
char *req;
char *rsp;
char req[ISCSI_HDR_LEN];
char rsp[ISCSI_HDR_LEN];
char *req_buf;
char *rsp_buf;
struct iscsi_conn *conn;
} ____cacheline_aligned;

struct iscsi_node_attrib {
Expand Down Expand Up @@ -754,6 +761,8 @@ struct iscsi_np {
struct task_struct *np_thread;
struct timer_list np_login_timer;
struct iscsi_portal_group *np_login_tpg;
void *np_context;
struct iscsit_transport *np_transport;
struct list_head np_list;
} ____cacheline_aligned;

Expand Down
Loading

0 comments on commit baa4d64

Please sign in to comment.