Rather than hardcoding the maximum number of sessions that a target can

serve simultaneously to DEFAULT_TARGET_MAX_SESSIONS, add a -s argument to
iscsi-target(8) to specify the maximum number of sessions.

Also bump default from 4 to 16.
This commit is contained in:
agc 2006-05-27 21:21:04 +00:00
parent 5ff62d8d84
commit 36fad19155
5 changed files with 23 additions and 10 deletions

View File

@ -40,7 +40,7 @@
/* Default configuration */
#define DEFAULT_TARGET_MAX_SESSIONS 4 /* n+1 */
#define DEFAULT_TARGET_MAX_SESSIONS 16 /* n+1 */
#define DEFAULT_TARGET_NUM_LUNS 1
#define DEFAULT_TARGET_BLOCK_LEN 512
#define DEFAULT_TARGET_NUM_BLOCKS 204800
@ -67,6 +67,7 @@ typedef struct globals_t {
char targetaddress[MAX_TGT_NAME_SIZE]; /* iSCSI TargetAddress set after iscsi_sock_accept() */
targv_t *tv; /* array of target devices */
int address_family; /* IP address family */
int max_sessions; /* maximum number of sessions */
} globals_t;
typedef struct target_session_t {

View File

@ -1,4 +1,4 @@
.\" $NetBSD: iscsi-target.8,v 1.5 2006/03/11 11:58:53 wiz Exp $
.\" $NetBSD: iscsi-target.8,v 1.6 2006/05/27 21:21:04 agc Exp $
.\"
.\" Copyright © 2006 Alistair Crooks. All rights reserved.
.\"
@ -26,7 +26,7 @@
.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd March 4, 2006
.Dd May 27, 2006
.Dt ISCSI-TARGET 8
.Os
.Sh NAME
@ -38,6 +38,7 @@
.Op Fl b Ar block length
.Op Fl f Ar configuration file
.Op Fl p Ar port number
.Op Fl s Ar maximum number of sessions
.Op Fl t Ar target name
.Op Fl v Ar verbose arg
.Sh DESCRIPTION
@ -82,6 +83,9 @@ for more information.
Use the port number provided as the argument as the port
on which to listen for iSCSI service requests from
initiators.
.It Fl s Ar maximum number of sessions
Allow the maximum number of sessions to be initiated when
connecting to the target.
.It Fl t Ar filename
The target name (as it appears to the iSCSI initiator) can be specified
using this flag.

View File

@ -1,4 +1,4 @@
/* $NetBSD: iscsi-target.c,v 1.9 2006/03/31 23:22:24 agc Exp $ */
/* $NetBSD: iscsi-target.c,v 1.10 2006/05/27 21:21:04 agc Exp $ */
/*
* Copyright © 2006 Alistair Crooks. All rights reserved.
@ -82,10 +82,11 @@ main(int argc, char **argv)
detach_me_harder = 1;
g.port = ISCSI_PORT;
g.address_family = ISCSI_IPv4;
g.max_sessions = DEFAULT_TARGET_MAX_SESSIONS;
cf = _PATH_ISCSI_TARGETS;
while ((i = getopt(argc, argv, "46b:Df:p:t:Vv:")) != -1) {
while ((i = getopt(argc, argv, "46b:Df:p:s:t:Vv:")) != -1) {
switch (i) {
case '4':
g.address_family = ISCSI_IPv4;
@ -105,6 +106,11 @@ main(int argc, char **argv)
case 'p':
g.port = (uint16_t) atoi(optarg);
break;
case 's':
if ((g.max_sessions = atoi(optarg)) <= 0) {
g.max_sessions = DEFAULT_TARGET_MAX_SESSIONS;
}
break;
case 't':
(void) strlcpy(TargetName, optarg, sizeof(TargetName));
break;

View File

@ -94,7 +94,7 @@ enum {
* Private *
***********/
static target_session_t g_session[DEFAULT_TARGET_MAX_SESSIONS];
static target_session_t *g_session;
static iscsi_queue_t g_session_q;
static iscsi_mutex_t g_session_q_mutex;
@ -1463,18 +1463,19 @@ target_init(globals_t *gp, targv_t *tv, char *TargetName)
{
int i;
NEWARRAY(target_session_t, g_session, gp->max_sessions, "target_init", return -1);
(void) strlcpy(gp->targetname, TargetName, sizeof(gp->targetname));
if (gp->state == TARGET_INITIALIZING || gp->state == TARGET_INITIALIZED) {
iscsi_trace_error(__FILE__, __LINE__, "duplicate target initialization attempted\n");
return -1;
}
gp->state = TARGET_INITIALIZING;
if (iscsi_queue_init(&g_session_q, DEFAULT_TARGET_MAX_SESSIONS) != 0) {
if (iscsi_queue_init(&g_session_q, gp->max_sessions) != 0) {
iscsi_trace_error(__FILE__, __LINE__, "iscsi_queue_init() failed\n");
return -1;
}
gp->tv = tv;
for (i = 0; i < DEFAULT_TARGET_MAX_SESSIONS; i++) {
for (i = 0; i < gp->max_sessions; i++) {
g_session[i].id = i;
if (iscsi_queue_insert(&g_session_q, &g_session[i]) != 0) {
iscsi_trace_error(__FILE__, __LINE__, "iscsi_queue_insert() failed\n");
@ -1513,7 +1514,7 @@ target_shutdown(globals_t *gp)
}
gp->state = TARGET_SHUTTING_DOWN;
iscsi_trace(TRACE_ISCSI_DEBUG, __FILE__, __LINE__, "shutting down target\n");
for (i = 0; i < DEFAULT_TARGET_MAX_SESSIONS; i++) {
for (i = 0; i < gp->max_sessions; i++) {
sess = &g_session[i];
/* Need to replace with a call to session_destroy() */

View File

@ -218,8 +218,9 @@ iscsi_queue_insert(iscsi_queue_t * q, void *ptr)
void *
iscsi_queue_remove(iscsi_queue_t * q)
{
uint32_t flags = 0;
void *ptr;
uint32_t flags = 0;
iscsi_spin_lock_irqsave(&q->lock, &flags);
if (!iscsi_queue_depth(q)) {
iscsi_trace(TRACE_QUEUE, __FILE__, __LINE__, "QUEUE EMPTY\n");