[stgt] [PATCH 2/2] dynamically link libibverbs and librdma
Doron Shoham
dorons at Voltaire.COM
Sun Oct 12 11:55:27 CEST 2008
> Please send out your updated patch. I'll see if I can fix it up.
>
Hi,
This is the current patch (with your comment about the libdir).
The real problem is how to fix the symboling issue while not
making the rpm to be depended on userspace IB.
Thanks for doing so,
Doron
>From 9d242a38c4469b3e92f71b40dfe6596010ad8c3a Mon Sep 17 00:00:00 2001
From: Doron Shoham <dorons at voltaire.com>
Date: Sun, 12 Oct 2008 11:47:51 +0200
Subject: [PATCH] dynamically link libibverbs and librdma for using
stgt without having userspace IB (e.g tcp mode).
Signed-off-by: Doron Shoham <dorons at voltaire.com>
---
usr/Makefile | 36 +++++++++++++++++++++++++++---------
usr/iscsi/libtgt_rdma.c | 6 +++++-
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/usr/Makefile b/usr/Makefile
index 82ddf07..6070e83 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -1,4 +1,6 @@
mandir = /usr/share/man
+libdir = /usr/lib64
+bindir = /usr/sbin
ifneq ($(IBMVIO),)
CFLAGS += -DIBMVIO -DUSE_KERNEL
@@ -14,11 +16,16 @@ TGTD_OBJS += $(addprefix iscsi/, conn.o param.o session.o \
TGTD_OBJS += bs_rdwr.o bs_aio.o
LIBS += -lcrypto
-ifneq ($(ISCSI_RDMA),)
-CFLAGS += -DISCSI_RDMA
+
+ifneq ($(findstring verbs.h,$(wildcard /usr/include/infiniband/*.h)), )
+ifneq ($(findstring rdma_cma.h,$(wildcard /usr/include/rdma/*.h)), )
TGTD_OBJS += iscsi/iscsi_rdma.o
-LIBS += -libverbs -lrdmacm
+ISER_OBJS = iscsi/libtgt_rdma.o
+SO_NAME = libtgtrdma.so
+SO_LIBS = $(SO_NAME).0.0
+endif
endif
+
endif
ifneq ($(FCP),)
@@ -54,6 +61,7 @@ CFLAGS += -g -O2 -Wall -Wstrict-prototypes -fPIC
LIBS += -lpthread
+
PROGRAMS += tgtd tgtadm
SCRIPTS += ../scripts/tgt-setup-lun ../scripts/tgt-admin
TGTD_OBJS += tgtd.o mgmt.o target.o scsi.o log.o driver.o util.o work.o \
@@ -65,10 +73,10 @@ MANPAGES = ../doc/manpages/tgtadm.8 ../doc/manpages/tgt-admin.8 \
TGTD_DEP = $(TGTD_OBJS:.o=.d)
.PHONY:all
-all: $(PROGRAMS)
+all: $(PROGRAMS) $(SO_LIBS)
tgtd: $(TGTD_OBJS)
- $(CC) $^ -o $@ $(LIBS)
+ $(CC) -Xlinker -E $^ -o $@ $(LIBS)
-include $(TGTD_DEP)
@@ -81,10 +89,20 @@ tgtadm: tgtadm.o
$(CC) -c $(CFLAGS) $*.c -o $*.o
@$(CC) -MM $(CFLAGS) -MF $*.d -MT $*.o $*.c
+$(SO_LIBS): $(ISER_OBJS)
+ rm -f $@ $(SO_NAME)
+ $(LD) -shared -soname $(SO_LIBS) -o $(SO_LIBS) $(ISER_OBJS)
+ ln -s $(SO_LIBS) $(SO_NAME)
+
.PHONY: install
-install: $(PROGRAMS) $(SCRIPTS) install_doc
- install -d -m 755 $(DESTDIR)/usr/sbin
- install -m 755 $(PROGRAMS) $(SCRIPTS) $(DESTDIR)/usr/sbin
+install: $(PROGRAMS) $(SCRIPTS) install_doc install_lib
+ install -d -m 755 $(DESTDIR)$(bindir)
+ install -m 755 $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
+
+install_lib: $(SO_LIBS)
+ rm -f $(DESTDIR)$(libdir)/$(SO_NAME)
+ install -m 755 $(SO_LIBS) $(DESTDIR)$(libdir)
+ ln -s $(DESTDIR)$(libdir)/$(SO_LIBS) $(DESTDIR)$(libdir)/$(SO_NAME)
install_doc: $(MANPAGES)
install -d -m 755 $(DESTDIR)$(mandir)/man8
@@ -92,4 +110,4 @@ install_doc: $(MANPAGES)
.PHONY: clean
clean:
- rm -f *.[od] $(PROGRAMS) iscsi/*.[od] ibmvio/*.[od] fc/*.[od] fcoe/*.[od]
+ rm -f *.[od] $(PROGRAMS) $(SO_LIBS) iscsi/*.[od] ibmvio/*.[od] fc/*.[od] fcoe/*.[od]
diff --git a/usr/iscsi/libtgt_rdma.c b/usr/iscsi/libtgt_rdma.c
index d3b5147..d6ba5fa 100644
--- a/usr/iscsi/libtgt_rdma.c
+++ b/usr/iscsi/libtgt_rdma.c
@@ -30,6 +30,8 @@
#include <sys/epoll.h>
#include <infiniband/verbs.h>
#include <rdma/rdma_cma.h>
+#include <dlfcn.h>
+#include <syslog.h>
#include "util.h"
#include "iscsid.h"
@@ -1754,7 +1756,9 @@ static struct iscsi_transport iscsi_iser = {
.ep_getpeername = iscsi_rdma_getpeername,
};
-__attribute__((constructor)) static void iser_transport_init(void)
+void iser_transport_init(void)
{
+ syslog(LOG_INFO, "iser transport register");
iscsi_transport_register(&iscsi_iser);
+ return;
}
--
1.5.3.8
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list