[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-193-gde2c0e7
Mike Christie
michaelc at cs.wisc.edu
Sat Apr 7 15:44:08 UTC 2012
The following commit has been merged in the upstream-mnc branch:
commit cdef1d1faf5028cbdd2b7600ef4d4b5bd1ebdd7f
Author: Mike Christie <michaelc at cs.wisc.edu>
Date: Sat Mar 10 01:50:31 2012 -0600
iscsi tools: have iscsid/iscsiadm load modules as needed
Instead of having the init scripts load all the modules
this patch has iscsiadm/iscsistart/iscsid load the module
in the iface.transport_name field when the module is
requested.
diff --git a/usr/Makefile b/usr/Makefile
index d94ed86..ba96613 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -33,7 +33,7 @@ endif
OPTFLAGS ?= -O2 -g
WARNFLAGS ?= -Wall -Wstrict-prototypes
CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -I../include -I. -I../utils/open-isns \
- -D$(OSNAME) $(IPC_CFLAGS)
+ -l kmod -D$(OSNAME) $(IPC_CFLAGS)
PROGRAMS = iscsid iscsiadm iscsistart
# libc compat files
@@ -56,7 +56,7 @@ all: $(PROGRAMS)
iscsid: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(DISCOVERY_SRCS) \
iscsid.o session_mgmt.o discoveryd.o
- $(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns
+ $(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns
iscsiadm: $(ISCSI_LIB_SRCS) $(DISCOVERY_SRCS) iscsiadm.o session_mgmt.o
$(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index beca42f..984ea95 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -1147,7 +1147,9 @@ static uint32_t get_target_no_from_sid(uint32_t sid, int *err)
struct iscsi_transport *iscsi_sysfs_get_transport_by_name(char *transport_name)
{
struct iscsi_transport *t;
+ int retry = 0;
+retry:
/* sync up kernel and userspace */
if (read_transports())
return NULL;
@@ -1158,6 +1160,13 @@ struct iscsi_transport *iscsi_sysfs_get_transport_by_name(char *transport_name)
ISCSI_TRANSPORT_NAME_MAXLEN))
return t;
}
+
+ if (retry < 1) {
+ retry++;
+ if (!transport_load_kmod(transport_name))
+ goto retry;
+ }
+
return NULL;
}
diff --git a/usr/transport.c b/usr/transport.c
index e04157e..b435537 100644
--- a/usr/transport.c
+++ b/usr/transport.c
@@ -19,7 +19,9 @@
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
+#include <libkmod.h>
+#include "iscsi_err.h"
#include "initiator.h"
#include "transport.h"
#include "log.h"
@@ -98,6 +100,51 @@ static struct iscsi_transport_template *iscsi_transport_templates[] = {
NULL
};
+int transport_load_kmod(char *transport_name)
+{
+ struct kmod_ctx *ctx;
+ struct kmod_module *mod;
+ int rc;
+
+ ctx = kmod_new(NULL, NULL);
+ if (!ctx) {
+ log_error("Could not load transport module %s. Out of "
+ "memory.", transport_name);
+ return ISCSI_ERR_NOMEM;
+ }
+
+ kmod_load_resources(ctx);
+
+ /*
+ * dumb dumb dumb - named iscsi_tcp and ib_iser differently from
+ * transport name
+ */
+ if (!strcmp(transport_name, "tcp"))
+ rc = kmod_module_new_from_name(ctx, "iscsi_tcp", &mod);
+ else if (!strcmp(transport_name, "iser"))
+ rc = kmod_module_new_from_name(ctx, "ib_iser", &mod);
+ else
+ rc = kmod_module_new_from_name(ctx, transport_name, &mod);
+ if (rc) {
+ log_error("Failed to load module %s.", transport_name);
+ rc = ISCSI_ERR_TRANS_NOT_FOUND;
+ goto unref_mod;
+ }
+
+ rc = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST,
+ NULL, NULL, NULL, NULL);
+ if (rc) {
+ log_error("Could not insert module %s. Kmod error %d",
+ transport_name, rc);
+ rc = ISCSI_ERR_TRANS_NOT_FOUND;
+ }
+ kmod_module_unref(mod);
+
+unref_mod:
+ kmod_unref(ctx);
+ return rc;
+}
+
int set_transport_template(struct iscsi_transport *t)
{
struct iscsi_transport_template *tmpl;
diff --git a/usr/transport.h b/usr/transport.h
index 5ceedb3..4c46587 100644
--- a/usr/transport.h
+++ b/usr/transport.h
@@ -48,5 +48,6 @@ struct iscsi_transport {
};
extern int set_transport_template(struct iscsi_transport *t);
+extern int transport_load_kmod(char *transport_name);
#endif
--
Debian Open-iSCSI Packaging
More information about the Pkg-iscsi-maintainers
mailing list