- updated to 2.1.1

This commit is contained in:
Dan Horák 2014-03-14 15:43:12 +01:00
parent c89c9b3a5a
commit c9ab4d205c
8 changed files with 56 additions and 338 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/lib-zfcp-hbaapi-2.1.tar.gz
/lib-zfcp-hbaapi-2.1.1.tar.gz

View File

@ -1,69 +0,0 @@
Description: zfcp-hbaapi: Fix crash on HBA_FreeLibrary call.
Symptom: zfcp_ping segmentation fault without any online adapters.
Problem: Segmentation fault happens on libzfcphbaapi if it build as vendor
library at this time when SNIA HBAAPI performs dlclose of
zfcp-hbaapi after clean-up function HBA_FreeLibrary.
zfcp-hbaapi has missing the event thread clean-up.
Solution: zfcp-hbaapi event thread cleanup has been coded using
pthread_cancel and pthread_join in HBA_FreeLibrary function.
Problem-ID: 72524
---
lib-zfcp-hbaapi-2.1/vlib.c | 16 ++++++++++++++++
lib-zfcp-hbaapi-2.1/vlib.h | 2 ++
lib-zfcp-hbaapi-2.1/vlib_events.c | 4 +---
3 files changed, 19 insertions(+), 3 deletions(-)
--- a/lib-zfcp-hbaapi-2.1/vlib.c
+++ b/lib-zfcp-hbaapi-2.1/vlib.c
@@ -169,6 +169,7 @@ HBA_STATUS HBA_LoadLibrary(void)
*/
HBA_STATUS HBA_FreeLibrary(void)
{
+ void *res;
VLIB_MUTEX_LOCK(&vlib_data.mutex);
if (!vlib_data.isLoaded) {
@@ -183,6 +184,21 @@ HBA_STATUS HBA_FreeLibrary(void)
}
vlib_data.unloading = 1;
+ if (pthread_cancel(vlib_data.id) != 0) {
+ VLIB_MUTEX_UNLOCK(&vlib_data.mutex);
+ return HBA_STATUS_ERROR;
+ }
+
+ if (pthread_join(vlib_data.id, &res) != 0) {
+ VLIB_MUTEX_UNLOCK(&vlib_data.mutex);
+ return HBA_STATUS_ERROR;
+ }
+
+ if (res != PTHREAD_CANCELED) {
+ VLIB_MUTEX_UNLOCK(&vlib_data.mutex);
+ return HBA_STATUS_ERROR;
+ }
+
closeAllAdapters();
vlib_data.isLoaded = 0;
--- a/lib-zfcp-hbaapi-2.1/vlib.h
+++ b/lib-zfcp-hbaapi-2.1/vlib.h
@@ -494,6 +494,8 @@ struct vlib_data {
struct block adapters; /**< @brief List of adapters
In fact this is the anchor of
the library's repository. */
+ pthread_t id; /**< @brief Pthread ID of event
+ handling thread*/
pthread_mutex_t mutex; /**< @brief Protects this structure */
};
--- a/lib-zfcp-hbaapi-2.1/vlib_events.c
+++ b/lib-zfcp-hbaapi-2.1/vlib_events.c
@@ -241,7 +241,5 @@ void cleanup_event_thread()
void start_event_thread()
{
- pthread_t id;
-
- pthread_create(&id, NULL, &establish_listener, NULL);
+ pthread_create(&vlib_data.id, NULL, &establish_listener, NULL);
}

View File

@ -1,48 +0,0 @@
---
lib-zfcp-hbaapi-2.1/vlib_sysfs.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
--- a/lib-zfcp-hbaapi-2.1/vlib_sysfs.c
+++ b/lib-zfcp-hbaapi-2.1/vlib_sysfs.c
@@ -310,14 +310,15 @@ HBA_STATUS sysfs_createAndReadConfigAdap
int sysfs_getUnitsFromPort(struct vlib_port *port)
{
char path[PATH_MAX];
- char unitPath[PATH_MAX];
+ char unitPath[PATH_MAX], unitPath2[PATH_MAX];
char attr[ATTR_MAX];
- char *sg;
+ char *sg, *sg2;
struct vlib_unit unit;
struct vlib_adapter *adapter;
- sfhelper_dir *dir, *sg_dir;
+ sfhelper_dir *dir, *sg_dir, *sg_dir2;
char *dirent;
int ret;
+ uint32_t sgindex;
adapter = getAdapterByHostNo(port->host);
if (!adapter)
@@ -369,6 +370,22 @@ int sysfs_getUnitsFromPort(struct vlib_p
if (ret == 1)
/* successful match */
break;
+ /* search match without CONFIG_SYSFS_DEPRECATED[_V2] */
+ if (strncmp(sg, "scsi_generic", 13 /* full */) != 0)
+ continue;
+ snprintf(unitPath2, PATH_MAX, "%s/%s", unitPath, sg);
+ sg_dir2 = sfhelper_opendir(unitPath2);
+ if (sg_dir2 == NULL)
+ continue;
+ while (sg2 = sfhelper_getNextDirEnt(sg_dir2)) {
+ if (sscanf(sg2, "sg%u", &sgindex) != 1)
+ continue;
+ snprintf(unit.sg_dev, sizeof(unit.sg_dev),
+ "%s", sg2);
+ /* successful match */
+ break;
+ }
+ sfhelper_closedir(sg_dir2);
}
sfhelper_closedir(sg_dir);
addUnitToRepos(port, &unit);

View File

@ -1,158 +0,0 @@
---
lib-zfcp-hbaapi-2.1/vlib_sysfs.c | 52 +++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 26 deletions(-)
--- a/lib-zfcp-hbaapi-2.1/vlib_sysfs.c
+++ b/lib-zfcp-hbaapi-2.1/vlib_sysfs.c
@@ -47,13 +47,13 @@ static HBA_STATUS addPortByName(struct v
ret = sfhelper_getProperty(path, "node_name", attr);
if (!ret)
- port.wwnn = strtol(attr, NULL, 16);
+ port.wwnn = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "port_name", attr);
if (!ret)
- port.wwpn = strtol(attr, NULL, 16);
+ port.wwpn = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "port_id", attr);
if (!ret)
- port.did = strtol(attr, NULL, 16);
+ port.did = strtoul(attr, NULL, 16);
addPortToRepos(adapter, &port);
return HBA_STATUS_OK;
@@ -118,13 +118,13 @@ static HBA_STATUS addAdapterByDevPath(ch
ret = sfhelper_getProperty(classpath, "node_name", attr);
if (!ret)
- a.ident.wwnn = strtol(attr, NULL, 16);
+ a.ident.wwnn = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(classpath, "port_name", attr);
if (!ret)
- a.ident.wwpn = strtol(attr, NULL, 16);
+ a.ident.wwpn = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(classpath, "port_id", attr);
if (!ret)
- a.ident.did = strtol(attr, NULL, 16);
+ a.ident.did = strtoul(attr, NULL, 16);
addAdapterToRepos(&a);
@@ -151,17 +151,17 @@ static HBA_STATUS getPortAttributes(HBA_
/* Worldwide Port and Node Name */
ret = sfhelper_getProperty(classpath, "node_name", attr);
if (!ret)
- vlib_wwn_to_HBA_WWN(strtol(attr, NULL, 16),
+ vlib_wwn_to_HBA_WWN(strtoull(attr, NULL, 16),
&(*pPortattributes)->NodeWWN);
ret = sfhelper_getProperty(classpath, "port_name", attr);
if (!ret)
- vlib_wwn_to_HBA_WWN(strtol(attr, NULL, 16),
+ vlib_wwn_to_HBA_WWN(strtoull(attr, NULL, 16),
&(*pPortattributes)->PortWWN);
/* PortFcId */
ret = sfhelper_getProperty(classpath, "port_id", attr);
if (!ret)
- (*pPortattributes)->PortFcId = strtol(attr, NULL, 16);
+ (*pPortattributes)->PortFcId = strtoul(attr, NULL, 16);
/* Port Type */
ret = sfhelper_getProperty(classpath, "port_type", attr);
@@ -361,7 +361,7 @@ int sysfs_getUnitsFromPort(struct vlib_p
strcat(unitPath, dirent);
ret = sfhelper_getProperty(unitPath, "fcp_lun", attr);
if (!ret)
- unit.fcLun = strtol(attr, NULL, 16);
+ unit.fcLun = strtoull(attr, NULL, 16);
sg_dir = sfhelper_opendir(unitPath);
if (sg_dir == NULL)
continue;
@@ -514,7 +514,7 @@ HBA_STATUS sysfs_getAdapterAttributes(HB
ret = sfhelper_getProperty(adapter->ident.sysfsPath, "card_version",
attr);
if (!ret) {
- a = strtol(attr, NULL, 16);
+ a = strtoul(attr, NULL, 16);
strcpy((*pAttrs)->ModelDescription,
"zSeries/System z Fibre Channel Adapter ");
switch (a) {
@@ -612,63 +612,63 @@ HBA_STATUS sysfs_getPortStatistics(HBA_P
ret = sfhelper_getProperty(path, "seconds_since_last_reset", attr);
if (!ret)
- (*pS)->SecondsSinceLastReset = strtol(attr, NULL, 16);
+ (*pS)->SecondsSinceLastReset = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "tx_frames", attr);
if (!ret)
- (*pS)->TxFrames = strtol(attr, NULL, 16);
+ (*pS)->TxFrames = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "tx_words", attr);
if (!ret)
- (*pS)->TxWords = strtol(attr, NULL, 16);
+ (*pS)->TxWords = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "rx_frames", attr);
if (!ret)
- (*pS)->RxFrames = strtol(attr, NULL, 16);
+ (*pS)->RxFrames = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "rx_words", attr);
if (!ret)
- (*pS)->RxWords = strtol(attr, NULL, 16);
+ (*pS)->RxWords = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "lip_count", attr);
if (!ret)
- (*pS)->LIPCount = strtol(attr, NULL, 16);
+ (*pS)->LIPCount = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "nos_count", attr);
if (!ret)
- (*pS)->NOSCount = strtol(attr, NULL, 16);
+ (*pS)->NOSCount = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "error_frames", attr);
if (!ret)
- (*pS)->ErrorFrames = strtol(attr, NULL, 16);
+ (*pS)->ErrorFrames = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "dumped_frames", attr);
if (!ret)
- (*pS)->DumpedFrames = strtol(attr, NULL, 16);
+ (*pS)->DumpedFrames = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "link_failure_count", attr);
if (!ret)
- (*pS)->LinkFailureCount = strtol(attr, NULL, 16);
+ (*pS)->LinkFailureCount = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "loss_of_sync_count", attr);
if (!ret)
- (*pS)->LossOfSyncCount = strtol(attr, NULL, 16);
+ (*pS)->LossOfSyncCount = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "loss_of_signal_count", attr);
if (!ret)
- (*pS)->LossOfSignalCount = strtol(attr, NULL, 16);
+ (*pS)->LossOfSignalCount = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "prim_seq_protocol_err_count", attr);
if (!ret)
- (*pS)->PrimitiveSeqProtocolErrCount = strtol(attr, NULL, 16);
+ (*pS)->PrimitiveSeqProtocolErrCount = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "invalid_tx_word_count", attr);
if (!ret)
- (*pS)->InvalidTxWordCount = strtol(attr, NULL, 16);
+ (*pS)->InvalidTxWordCount = strtoull(attr, NULL, 16);
ret = sfhelper_getProperty(path, "invalid_crc_count", attr);
if (!ret)
- (*pS)->InvalidCRCCount = strtol(attr, NULL, 16);
+ (*pS)->InvalidCRCCount = strtoull(attr, NULL, 16);
return HBA_STATUS_OK;
}

View File

@ -1,37 +0,0 @@
diff -up lib-zfcp-hbaapi-2.1/Makefile.am.vendorlib lib-zfcp-hbaapi-2.1/Makefile.am
--- lib-zfcp-hbaapi-2.1/Makefile.am.vendorlib 2011-01-14 12:10:56.000000000 +0100
+++ lib-zfcp-hbaapi-2.1/Makefile.am 2011-01-14 12:12:02.000000000 +0100
@@ -76,9 +76,15 @@ endif
bin_PROGRAMS = zfcp_ping zfcp_show
zfcp_ping_SOURCES = fc_tools/zfcp_ping.c
-zfcp_ping_LDADD = -lzfcphbaapi
zfcp_show_SOURCES = fc_tools/zfcp_show.c
+
+if VENDORLIB
+zfcp_ping_LDADD = -lHBAAPI
+zfcp_show_LDADD = -lHBAAPI
+else
+zfcp_ping_LDADD = -lzfcphbaapi
zfcp_show_LDADD = -lzfcphbaapi
+endif
if DOCS
diff -up lib-zfcp-hbaapi-2.1/Makefile.in.vendorlib lib-zfcp-hbaapi-2.1/Makefile.in
--- lib-zfcp-hbaapi-2.1/Makefile.in.vendorlib 2011-01-14 12:11:01.000000000 +0100
+++ lib-zfcp-hbaapi-2.1/Makefile.in 2011-01-14 12:13:05.000000000 +0100
@@ -282,9 +282,11 @@ libzfcphbaapi_la_LDFLAGS = \
@VENDORLIB_TRUE@libzfcphbaapi_la_LDFLAGS += -module -avoid-version -release $(VERSION)
zfcp_ping_SOURCES = fc_tools/zfcp_ping.c
-zfcp_ping_LDADD = -lzfcphbaapi
zfcp_show_SOURCES = fc_tools/zfcp_show.c
-zfcp_show_LDADD = -lzfcphbaapi
+@VENDORLIB_TRUE@zfcp_ping_LDADD = -lHBAAPI
+@VENDORLIB_TRUE@zfcp_show_LDADD = -lHBAAPI
+@VENDORLIB_FALSE@zfcp_ping_LDADD = -lzfcphbaapi
+@VENDORLIB_FALSE@zfcp_show_LDADD = -lzfcphbaapi
@DOCS_FALSE@man_MANS = zfcp_show.8 zfcp_ping.8 libzfcphbaapi.3
@DOCS_TRUE@man_MANS = libzfcphbaapi.3 dox/man/man3/SupportedHBAAPIs.3 \
@DOCS_TRUE@ dox/man/man3/UnSupportedHBAAPIs.3 dox/man/man3/hbaapi.h.3 \

View File

@ -0,0 +1,41 @@
From 0cc72f0d807a71e0fdc67d04e0b86b98282db644 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Wed, 29 Jan 2014 14:27:27 +0100
Subject: [PATCH] build the library as a module
---
Makefile.am | 4 ++++
Makefile.in | 2 ++
2 files changed, 6 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index a9a040d..bddc86f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -69,6 +69,10 @@ libzfcphbaapi_la_LDFLAGS = \
-Wl,-init,_initvlib,-fini,_finivlib \
-export-symbols $(SYMFILE)
+if VENDORLIB
+libzfcphbaapi_la_LDFLAGS += -module -avoid-version -release $(VERSION)
+endif
+
bin_PROGRAMS = zfcp_ping zfcp_show
zfcp_ping_SOURCES = fc_tools/zfcp_ping.c
diff --git a/Makefile.in b/Makefile.in
index f459693..b9c7712 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -407,6 +407,8 @@ libzfcphbaapi_la_LDFLAGS = \
-Wl,-init,_initvlib,-fini,_finivlib \
-export-symbols $(SYMFILE)
+@VENDORLIB_TRUE@libzfcphbaapi_la_LDFLAGS += -module -avoid-version -release $(VERSION)
+
zfcp_ping_SOURCES = fc_tools/zfcp_ping.c
zfcp_show_SOURCES = fc_tools/zfcp_show.c
@VENDORLIB_FALSE@zfcp_ping_LDADD = -lzfcphbaapi
--
1.8.5.3

View File

@ -3,12 +3,14 @@
Name: libzfcphbaapi
Summary: HBA API for the zFCP device driver
Group: System Environment/Libraries
Version: 2.1
Release: 3%{?dist}
Version: 2.1.1
Release: 1%{?dist}
License: CPL
URL: http://www.ibm.com/developerworks/linux/linux390/zfcp-hbaapi.html
# http://www.ibm.com/developerworks/linux/linux390/zfcp-hbaapi-%%{hbaapiver}.html
Source0: http://download.boulder.ibm.com/ibmdl/pub/software/dw/linux390/ht_src/%{srcname}-%{version}.tar.gz
Patch1: %{srcname}-2.1.1-fedora.patch
ExclusiveArch: s390 s390x
BuildRequires: automake
@ -25,17 +27,6 @@ Obsoletes: s390utils-libzfcphbaapi <= 2:1.20.0-3
# exclude plugin soname from Provides
%global __provides_exclude ^(libzfcphbaapi-%{version}[.]so.*)$
# build the library as a module
Patch1: %{srcname}-2.1-module.patch
# fix linking of the tools when using vendor library mode
Patch2: %{srcname}-2.1-vendorlib.patch
# fix crash on HBA_FreeLibrary call (#713817)
Patch3: %{srcname}-2.1-HBA_FreeLibrary.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=951586
Patch4: %{srcname}-2.1-parse-u64-as-ull.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=949099
Patch5: %{srcname}-2.1-find-sg-without-sysfs-deprecated.patch
%description
zFCP HBA API Library is an implementation of FC-HBA (see www.t11.org) for
the zFCP device driver.
@ -57,14 +48,7 @@ Documentation for the zFCP HBA API Library.
%prep
%setup -q -n %{srcname}-%{version}
%patch1 -p1 -b .module
%patch2 -p1 -b .vendorlib
%patch3 -p2 -b .HBA_FreeLibrary
%patch4 -p2 -b .parse-as-ull
%patch5 -p2 -b .find-sg
# lib-zfcp-hbaapi: fix perms
chmod a-x *.h AUTHORS README ChangeLog LICENSE
%patch1 -p1 -b .fedora
%build
@ -73,9 +57,9 @@ make EXTRA_CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
%install
%makeinstall docdir=$RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
%makeinstall docdir=$RPM_BUILD_ROOT%{_docdir}/%{name}
# keep only html docs
rm -rf $RPM_BUILD_ROOT%{_docdir}/%{srcname}-%{version}/latex
rm -rf $RPM_BUILD_ROOT%{_docdir}/%{name}/latex
# remove unwanted files
rm -f $RPM_BUILD_ROOT%{_libdir}/%{name}.*
@ -102,13 +86,17 @@ grep -q -e "^libzfcphbaapi" /etc/hba.conf &&
%{_mandir}/man8/zfcp_ping.8*
%{_mandir}/man8/zfcp_show.8*
%exclude %{_mandir}/man3/hbaapi.h.3*
%exclude %{_docdir}/%{name}/html
%files docs
%docdir %{_docdir}/%{name}-%{version}
%{_docdir}/%{name}-%{version}/
%{_docdir}/%{name}/html
%changelog
* Fri Mar 14 2014 Dan Horák <dan[at]danny.cz> - 2.1.1-1
- updated to 2.1.1
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

View File

@ -1 +1 @@
ecf3ff0ac4469db7297ebd6f7607fb48 lib-zfcp-hbaapi-2.1.tar.gz
5031c6620bf5c6be6a69851ba5685971 lib-zfcp-hbaapi-2.1.1.tar.gz