Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/iscsi/dist Provide function in libiscsi to retu...
details: https://anonhg.NetBSD.org/src/rev/73a7dc196ea4
branches: trunk
changeset: 770161:73a7dc196ea4
user: sborrill <sborrill%NetBSD.org@localhost>
date: Thu Oct 06 13:05:28 2011 +0000
description:
Provide function in libiscsi to return the compile-time limit on number of
targets. Use this function in the initiator, to ensure that the same limit
is used throughout (i.e. stop you attempting to compile the initiator with a
different limit to the library - the initiator uses the library for most of
its functionality).
If truncating the number of targets in the initiator, truncate it to the
correct amount, not half of what it should be.
Obey RFC3720 when determining targets. SendTargets=All MUST be supported
on a discovery session, and MUST NOT be supported on an operational session.
Previously, SendTargets=All was used both in the initial discovery session
and the later session. (from Daisuke Aoyama - author of istgt).
diffstat:
external/bsd/iscsi/dist/include/initiator.h | 8 +++-
external/bsd/iscsi/dist/src/initiator/iscsi-initiator.c | 14 +++++--
external/bsd/iscsi/dist/src/lib/initiator.c | 32 +++++++++++++++-
3 files changed, 45 insertions(+), 9 deletions(-)
diffs (155 lines):
diff -r c04d7d3cf259 -r 73a7dc196ea4 external/bsd/iscsi/dist/include/initiator.h
--- a/external/bsd/iscsi/dist/include/initiator.h Thu Oct 06 12:38:57 2011 +0000
+++ b/external/bsd/iscsi/dist/include/initiator.h Thu Oct 06 13:05:28 2011 +0000
@@ -45,7 +45,9 @@
#include "parameters.h"
#include "defs.h"
+#ifndef CONFIG_INITIATOR_NUM_TARGETS
#define CONFIG_INITIATOR_NUM_TARGETS 16
+#endif
/***********
* Private *
@@ -113,6 +115,8 @@
char targetname[TARGET_HOSTNAME_SIZE];
} initiator_cmd_t;
+DEFINE_ARRAY(strv_t, char *);
+
typedef struct initiator_target_t {
char name[TARGET_HOSTNAME_SIZE];
char ip[TARGET_IP_SIZE];
@@ -121,10 +125,9 @@
initiator_session_t *sess;
int has_session;
char iqnwanted[TARGET_NAME_SIZE];
+ strv_t all_targets;
} initiator_target_t;
-DEFINE_ARRAY(strv_t, char *);
-
/**********
* Public *
@@ -140,5 +143,6 @@
int iscsi_initiator_get_targets(int, strv_t *);
int initiator_set_target_name(int, char *);
+int iscsi_initiator_get_max_targets(void);
#endif /* _INITIATOR_H_ */
diff -r c04d7d3cf259 -r 73a7dc196ea4 external/bsd/iscsi/dist/src/initiator/iscsi-initiator.c
--- a/external/bsd/iscsi/dist/src/initiator/iscsi-initiator.c Thu Oct 06 12:38:57 2011 +0000
+++ b/external/bsd/iscsi/dist/src/initiator/iscsi-initiator.c Thu Oct 06 13:05:28 2011 +0000
@@ -548,6 +548,7 @@
int discover;
int cc;
int i;
+ uint32_t max_targets;
(void) memset(&tinfo, 0x0, sizeof(tinfo));
iscsi_initiator_set_defaults(&ini);
@@ -557,6 +558,8 @@
(void) stat("/etc/hosts", &sti.st);
devtype = 'f';
iscsi_initiator_setvar(&ini, "address family", "4");
+ max_targets = iscsi_initiator_get_max_targets();
+
while ((i = getopt(argc, argv, "46a:bcd:Dfh:p:t:u:v:V")) != -1) {
switch(i) {
case '4':
@@ -663,16 +666,19 @@
exit(EXIT_SUCCESS);
}
- if (all_targets.c/2 > CONFIG_INITIATOR_NUM_TARGETS) {
+ if (all_targets.c/2 > max_targets) {
(void) fprintf(stderr,
"CONFIG_INITIATOR_NUM_TARGETS in initiator.h "
"is too small. %d targets available, "
"only %d configurable.\n",
- all_targets.c/2, CONFIG_INITIATOR_NUM_TARGETS);
+ all_targets.c/2, max_targets);
+ (void) fprintf(stderr,
+ "To increase this value, libiscsi will have be "
+ "recompiled.\n");
(void) fprintf(stderr,
"Truncating number of targets to %d.\n",
- CONFIG_INITIATOR_NUM_TARGETS);
- all_targets.c = CONFIG_INITIATOR_NUM_TARGETS;
+ max_targets);
+ all_targets.c = 2 * max_targets;
}
sti.st.st_ino = 0x15c51;
diff -r c04d7d3cf259 -r 73a7dc196ea4 external/bsd/iscsi/dist/src/lib/initiator.c
--- a/external/bsd/iscsi/dist/src/lib/initiator.c Thu Oct 06 12:38:57 2011 +0000
+++ b/external/bsd/iscsi/dist/src/lib/initiator.c Thu Oct 06 13:05:28 2011 +0000
@@ -155,7 +155,6 @@
static int wait_callback_i(void *);
static int discovery_phase(int, strv_t *);
-
/*
* Private Functions
*/
@@ -623,6 +622,13 @@
int
+iscsi_initiator_get_max_targets(void)
+{
+ return CONFIG_INITIATOR_NUM_TARGETS;
+}
+
+#if 0
+int
iscsi_initiator_get_targets(int target, strv_t *svp)
{
initiator_session_t *sess = g_target[target].sess;
@@ -675,6 +681,27 @@
return 1;
}
+#else
+/* SendTargets=All must be sent in discovery session. */
+int
+iscsi_initiator_get_targets(int target, strv_t *svp)
+{
+ initiator_session_t *sess = g_target[target].sess;
+ strv_t *tp = &g_target[target].all_targets;
+ uint32_t i;
+
+ if (sess == NULL)
+ return -1;
+
+ for (i = 0; i < tp->c; i++) {
+ ALLOC(char *, svp->v, svp->size, svp->c, 10,
+ 10, "igt", return -1);
+ svp->v[svp->c++] = strdup(tp->v[i]);
+ }
+
+ return 1;
+}
+#endif
static int
discovery_phase(int target, strv_t *svp)
@@ -1209,7 +1236,6 @@
iscsi_worker_t *me = (iscsi_worker_t *) arg;
uint64_t target;
uint32_t tag;
- strv_t sv;
int rc;
@@ -1273,7 +1299,7 @@
if (strlen(g_target[(int)target].TargetName) == 0) {
iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: entering Discovery phase with target %llu\n", target);
- rc = discovery_phase((int)target, &sv);
+ rc = discovery_phase((int)target, &g_target[(int)target].all_targets);
iscsi_trace(TRACE_ISCSI_DEBUG, "enqueue_worker: Discovery phase complete\n");
/* Destroy session */
Home |
Main Index |
Thread Index |
Old Index