commit f278cad869ea875779d4d7031c0366cd32ec5fdc Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 10:56:47 2019 -0400 Package init diff --git a/0000-Fix-compiler-warning-error-under-gcc7.patch b/0000-Fix-compiler-warning-error-under-gcc7.patch new file mode 100644 index 0000000..99ba46e --- /dev/null +++ b/0000-Fix-compiler-warning-error-under-gcc7.patch @@ -0,0 +1,25 @@ +From: Ronnie Sahlberg +Date: Sat, 3 Jun 2017 11:20:20 -0700 +Subject: [PATCH] Fix compiler warning/error under gcc7 + +Gcc7 complains about falling through from the previous case to the default arm + +Signed-off-by: Ronnie Sahlberg +(cherry picked from commit 854e37aab7d7d2093a0a6620a3257b8f2a1d405c) +--- + test-tool/iscsi-support.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c +index 02367ca..ed00ce7 100644 +--- a/test-tool/iscsi-support.c ++++ b/test-tool/iscsi-support.c +@@ -2930,8 +2930,6 @@ void populate_ident_tgt_desc(unsigned char *buf, struct scsi_device *dev) + tgt_desig = desig; + prev_type = desig->designator_type; + } +- default: +- continue; + } + } + if (tgt_desig == NULL) { diff --git a/0001-Fix-another-compiler-warning.patch b/0001-Fix-another-compiler-warning.patch new file mode 100644 index 0000000..e8aa623 --- /dev/null +++ b/0001-Fix-another-compiler-warning.patch @@ -0,0 +1,43 @@ +From: Ronnie Sahlberg +Date: Sat, 3 Jun 2017 11:33:51 -0700 +Subject: [PATCH] Fix another compiler warning + +We do need a default: arm here as the switch is not supposed to deal with +all possible values for the enum. + +Signed-off-by: Ronnie Sahlberg +(cherry picked from commit fb45f0343e3de45f2bc7516591d36c7466c2184e) +--- + test-tool/iscsi-support.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c +index ed00ce7..3f860ed 100644 +--- a/test-tool/iscsi-support.c ++++ b/test-tool/iscsi-support.c +@@ -2922,14 +2922,17 @@ void populate_ident_tgt_desc(unsigned char *buf, struct scsi_device *dev) + + for (desig = inq_di->designators; desig; desig = desig->next) { + switch (desig->designator_type) { +- case SCSI_DESIGNATOR_TYPE_VENDOR_SPECIFIC: +- case SCSI_DESIGNATOR_TYPE_T10_VENDORT_ID: +- case SCSI_DESIGNATOR_TYPE_EUI_64: +- case SCSI_DESIGNATOR_TYPE_NAA: +- if (prev_type <= desig->designator_type) { +- tgt_desig = desig; +- prev_type = desig->designator_type; +- } ++ case SCSI_DESIGNATOR_TYPE_VENDOR_SPECIFIC: ++ case SCSI_DESIGNATOR_TYPE_T10_VENDORT_ID: ++ case SCSI_DESIGNATOR_TYPE_EUI_64: ++ case SCSI_DESIGNATOR_TYPE_NAA: ++ if (prev_type <= desig->designator_type) { ++ tgt_desig = desig; ++ prev_type = desig->designator_type; ++ } ++ continue; ++ default: ++ continue; + } + } + if (tgt_desig == NULL) { diff --git a/0002-Fix-32bit-build.patch b/0002-Fix-32bit-build.patch new file mode 100644 index 0000000..7f6d462 --- /dev/null +++ b/0002-Fix-32bit-build.patch @@ -0,0 +1,114 @@ +From: Michal Suchanek +Date: Mon, 14 Nov 2016 17:28:31 +0100 +Subject: [PATCH] Fix 32bit build. + +Signed-off-by: Michal Suchanek +(cherry picked from commit a239423a0f9250dad9998152fa4b4b46accdf641) +--- + lib/iser.c | 7 ++++--- + test-tool/test_compareandwrite_invalid_dataout_size.c | 4 ++-- + test-tool/test_writesame10_invalid_dataout_size.c | 4 ++-- + test-tool/test_writesame16_invalid_dataout_size.c | 4 ++-- + 4 files changed, 10 insertions(+), 9 deletions(-) + +diff --git a/lib/iser.c b/lib/iser.c +index ad3adb3..17832c3 100644 +--- a/lib/iser.c ++++ b/lib/iser.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + #include "iscsi.h" + #include "iser-private.h" + #include "iscsi-private.h" +@@ -524,7 +525,7 @@ iser_prepare_read_cmd(struct iser_conn *iser_conn,struct iser_pdu *iser_pdu) + } + + tx_desc->data_dir = DATA_READ; +- hdr->read_va = htobe64((uint64_t)tx_desc->data_buff); ++ hdr->read_va = htobe64((intptr_t)tx_desc->data_buff); + hdr->read_stag = htobe32((uint32_t)tx_desc->data_mr->rkey); + hdr->flags |= ISER_RSV; + +@@ -565,7 +566,7 @@ iser_prepare_write_cmd(struct iser_conn *iser_conn, struct iser_pdu *iser_pdu) + + hdr->flags |= ISER_WSV; + hdr->write_stag = htobe32((uint32_t)(tx_desc->data_mr->rkey)); +- hdr->write_va = htobe64((uint64_t)(tx_desc->data_buff)); ++ hdr->write_va = htobe64((intptr_t)(tx_desc->data_buff)); + + return 0; + } +@@ -1146,7 +1147,7 @@ static int iser_handle_wc(struct ibv_wc *wc,struct iser_conn *iser_conn) + wc->wr_id, wc->status, wc->vendor_err); + return iscsi_service_reconnect_if_loggedin(iscsi); + } else { +- iscsi_set_error(iscsi, "flush error: wr id %lx\n", wc->wr_id); ++ iscsi_set_error(iscsi, "flush error: wr id %" PRIx64 "\n", wc->wr_id); + + return 0; + } +diff --git a/test-tool/test_compareandwrite_invalid_dataout_size.c b/test-tool/test_compareandwrite_invalid_dataout_size.c +index b27b4f8..76da1e0 100644 +--- a/test-tool/test_compareandwrite_invalid_dataout_size.c ++++ b/test-tool/test_compareandwrite_invalid_dataout_size.c +@@ -64,7 +64,7 @@ test_compareandwrite_invalid_dataout_size(void) + + + logging(LOG_VERBOSE, "Check too small DataOut"); +- logging(LOG_VERBOSE, "COMPAREANDWRITE with DataOut==%ld (4 blocks) " ++ logging(LOG_VERBOSE, "COMPAREANDWRITE with DataOut==%zd (4 blocks) " + "and TL == 1 ", 4 * block_size); + + new_tl = 1; +@@ -74,7 +74,7 @@ test_compareandwrite_invalid_dataout_size(void) + EXPECT_STATUS_GENERIC_BAD); + + logging(LOG_VERBOSE, "Check too large DataOut"); +- logging(LOG_VERBOSE, "COMPAREANDWRITE with DataOut==%ld (4 blocks) " ++ logging(LOG_VERBOSE, "COMPAREANDWRITE with DataOut==%zd (4 blocks) " + "and TL == 3 ", 4 * block_size); + + new_tl = 2; +diff --git a/test-tool/test_writesame10_invalid_dataout_size.c b/test-tool/test_writesame10_invalid_dataout_size.c +index f521908..119d786 100644 +--- a/test-tool/test_writesame10_invalid_dataout_size.c ++++ b/test-tool/test_writesame10_invalid_dataout_size.c +@@ -41,13 +41,13 @@ test_writesame10_invalid_dataout_size(void) + memset(scratch, 0xa6, block_size); + + logging(LOG_VERBOSE, "Check too small DataOut"); +- logging(LOG_VERBOSE, "Unmap with DataOut==%ld (block_size==%ld)", ++ logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", + block_size / 2, block_size); + WRITESAME10(sd, 0, block_size / 2, 1, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GENERIC_BAD); + + logging(LOG_VERBOSE, "Check too large DataOut"); +- logging(LOG_VERBOSE, "Unmap with DataOut==%ld (block_size==%ld)", ++ logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", + block_size * 2, block_size); + WRITESAME10(sd, 0, block_size * 2, 1, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GENERIC_BAD); +diff --git a/test-tool/test_writesame16_invalid_dataout_size.c b/test-tool/test_writesame16_invalid_dataout_size.c +index 128673f..a2e22bb 100644 +--- a/test-tool/test_writesame16_invalid_dataout_size.c ++++ b/test-tool/test_writesame16_invalid_dataout_size.c +@@ -41,13 +41,13 @@ test_writesame16_invalid_dataout_size(void) + memset(scratch, 0xa6, block_size); + + logging(LOG_VERBOSE, "Check too small DataOut"); +- logging(LOG_VERBOSE, "Unmap with DataOut==%ld (block_size==%ld)", ++ logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", + block_size / 2, block_size); + WRITESAME16(sd, 0, block_size / 2, 1, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GENERIC_BAD); + + logging(LOG_VERBOSE, "Check too large DataOut"); +- logging(LOG_VERBOSE, "Unmap with DataOut==%ld (block_size==%ld)", ++ logging(LOG_VERBOSE, "Unmap with DataOut==%zd (block_size==%zd)", + block_size * 2, block_size); + WRITESAME16(sd, 0, block_size * 2, 1, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GENERIC_BAD); diff --git a/0003-iser-Use-local-container_of-definition.patch b/0003-iser-Use-local-container_of-definition.patch new file mode 100644 index 0000000..cbf14ae --- /dev/null +++ b/0003-iser-Use-local-container_of-definition.patch @@ -0,0 +1,42 @@ +From: Cole Robinson +Date: Mon, 30 Apr 2018 18:11:05 -0400 +Subject: [PATCH] iser: Use local container_of definition + +The code was implicitly dependent on container_of from +inifiniband/verbs.h, however that's been removed in rdma-core +latest release: + +https://github.com/linux-rdma/rdma-core/commit/ce0274acffc78ed2861a56bdc34cdd3d60c20e1f + +Define container_of locally if it's not already defined + +(cherry picked from commit f1feb218e2823d236569f0ca3cfad07334f2a304) +--- + lib/iser.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/lib/iser.c b/lib/iser.c +index 17832c3..aa7244c 100644 +--- a/lib/iser.c ++++ b/lib/iser.c +@@ -32,6 +32,20 @@ + #include + #include + ++ ++#ifndef container_of ++/** ++ * container_of - cast a member of a structure out to the containing structure ++ * @ptr: the pointer to the member. ++ * @type: the type of the container struct this is embedded in. ++ * @member: the name of the member within the struct. ++ * ++ */ ++#define container_of(ptr, type, member) \ ++ ((type *) ((uint8_t *)(ptr) - offsetof(type, member))) ++#endif ++ ++ + #ifdef __linux + + static int cq_handle(struct iser_conn *iser_conn); diff --git a/1.18.0.tar.gz b/1.18.0.tar.gz new file mode 100644 index 0000000..9d5ecb4 Binary files /dev/null and b/1.18.0.tar.gz differ diff --git a/6000-iscsi-perf-fix-overflow-issue-in-fill_read_queue.patch b/6000-iscsi-perf-fix-overflow-issue-in-fill_read_queue.patch new file mode 100644 index 0000000..316c758 --- /dev/null +++ b/6000-iscsi-perf-fix-overflow-issue-in-fill_read_queue.patch @@ -0,0 +1,41 @@ +From 63cfcd3384f6ab35a7d1f3d82dd824fb1872d657 Mon Sep 17 00:00:00 2001 +From: optimistyzy +Date: Mon, 9 Jan 2017 18:34:12 +0800 +Subject: [PATCH 035/110] iscsi-perf: fix overflow issue in fill_read_queue + +If with int defintion, this statement: + +num_blocks = client->num_blocks - client->pos; + +May not get the exact value we want. + +Signed-off-by: optimistyzy +--- + utils/iscsi-perf.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/utils/iscsi-perf.c b/utils/iscsi-perf.c +index 14c3f49..7e0f145 100644 +--- a/utils/iscsi-perf.c ++++ b/utils/iscsi-perf.c +@@ -186,7 +186,7 @@ out: + + void fill_read_queue(struct client *client) + { +- int num_blocks; ++ int64_t num_blocks; + + if (finished) return; + +@@ -210,7 +210,7 @@ void fill_read_queue(struct client *client) + + task = iscsi_read16_task(client->iscsi, + client->lun, client->pos, +- num_blocks * client->blocksize, ++ (uint32_t)(num_blocks * client->blocksize), + client->blocksize, 0, 0, 0, 0, 0, + cb, client); + if (task == NULL) { +-- +1.8.3.1 + diff --git a/6001-sync-fix-return-value-for-various-sync-commands.patch b/6001-sync-fix-return-value-for-various-sync-commands.patch new file mode 100644 index 0000000..d6b0ace --- /dev/null +++ b/6001-sync-fix-return-value-for-various-sync-commands.patch @@ -0,0 +1,78 @@ +From b5210a1e31afb9f0adf369cde11c612f3365432e Mon Sep 17 00:00:00 2001 +From: Peter Lieven +Date: Mon, 23 Jan 2017 15:40:09 +0100 +Subject: [PATCH 036/110] sync: fix return value for various sync commands + +all sync commands that return an integer value are +supposed to return a negative value on error. +However, state.status is positive non-zero on error. +Fix this by returning -1 if the state.status is +not SCSI_STATUS_GOOD. + +Reported-by: Sitsofe Wheeler +Signed-off-by: Peter Lieven +--- + lib/sync.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/lib/sync.c b/lib/sync.c +index 3b907c0..0e4d42b 100644 +--- a/lib/sync.c ++++ b/lib/sync.c +@@ -111,7 +111,7 @@ iscsi_connect_sync(struct iscsi_context *iscsi, const char *portal) + /* clear connect_data so it doesnt point to our stack */ + iscsi->connect_data = NULL; + +- return state.status; ++ return (state.status == SCSI_STATUS_GOOD) ? 0 : -1; + } + + int +@@ -132,7 +132,7 @@ iscsi_full_connect_sync(struct iscsi_context *iscsi, + + event_loop(iscsi, &state); + +- return state.status; ++ return (state.status == SCSI_STATUS_GOOD) ? 0 : -1; + } + + int iscsi_login_sync(struct iscsi_context *iscsi) +@@ -149,7 +149,7 @@ int iscsi_login_sync(struct iscsi_context *iscsi) + + event_loop(iscsi, &state); + +- return state.status; ++ return (state.status == SCSI_STATUS_GOOD) ? 0 : -1; + } + + int iscsi_logout_sync(struct iscsi_context *iscsi) +@@ -166,7 +166,7 @@ int iscsi_logout_sync(struct iscsi_context *iscsi) + + event_loop(iscsi, &state); + +- return state.status; ++ return (state.status == SCSI_STATUS_GOOD) ? 0 : -1; + } + + static void +@@ -213,7 +213,7 @@ int iscsi_reconnect_sync(struct iscsi_context *iscsi) + + reconnect_event_loop(iscsi, &state); + +- return state.status; ++ return (state.status == SCSI_STATUS_GOOD) ? 0 : -1; + } + + static void +@@ -270,7 +270,7 @@ iscsi_task_mgmt_sync(struct iscsi_context *iscsi, + + event_loop(iscsi, &state); + +- return state.status; ++ return (state.status == SCSI_STATUS_GOOD) ? 0 : -1; + } + + int +-- +1.8.3.1 + diff --git a/libiscsi.spec b/libiscsi.spec new file mode 100644 index 0000000..d1751ec --- /dev/null +++ b/libiscsi.spec @@ -0,0 +1,106 @@ +Name: libiscsi +Version: 1.18.0 +Release: 6 +Summary: Client-side library to implement the iSCSI protocol +License: LGPLv2+ and GPLv2+ +URL: https://github.com/sahlberg/%{name} + +Source: https://github.com/sahlberg/%{name}/archive/%{version}.tar.gz + +Patch0000: 0000-Fix-compiler-warning-error-under-gcc7.patch +Patch0001: 0001-Fix-another-compiler-warning.patch +Patch0002: 0002-Fix-32bit-build.patch +Patch0003: 0003-iser-Use-local-container_of-definition.patch +Patch6000: 6000-iscsi-perf-fix-overflow-issue-in-fill_read_queue.patch +Patch6001: 6001-sync-fix-return-value-for-various-sync-commands.patch + +BuildRequires: gcc git +BuildRequires: autoconf automake libtool popt-devel CUnit-devel libgcrypt-devel rdma-core-devel chrpath + +Provides: %{name}-utils %{name}-utils%{?_isa} + +%description +Libiscsi is a client-side library to implement the iSCSI protocol that can be used +to access the resources of an iSCSI target. + + +####################################################################### + +# Conflict with iscsi-initiator-utils. + +%prep +%autosetup -n %{name}-%{version} -p1 -Sgit + +%build +sh autogen.sh +%configure --libdir=%{_libdir}/iscsi --disable-werror +make %{?_smp_mflags} + +%install +make DESTDIR=$RPM_BUILD_ROOT install pkgconfigdir=%{_libdir}/pkgconfig %{?_smp_mflags} +mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d +echo %{_libdir}/iscsi > $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf +rm $RPM_BUILD_ROOT/%{_libdir}/iscsi/libiscsi.a +rm $RPM_BUILD_ROOT/%{_libdir}/iscsi/libiscsi.la + +# Remove rpath +chrpath --delete $RPM_BUILD_ROOT%{_bindir}/iscsi-perf +chrpath --delete $RPM_BUILD_ROOT%{_bindir}/iscsi-test-cu +chrpath --delete $RPM_BUILD_ROOT%{_bindir}/iscsi-swp +chrpath --delete $RPM_BUILD_ROOT%{_bindir}/iscsi-ls +chrpath --delete $RPM_BUILD_ROOT%{_bindir}/iscsi-inq +chrpath --delete $RPM_BUILD_ROOT%{_bindir}/iscsi-readcapacity16 + +# Remove "*.old" files +find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \; + +# Remove library put in /usr/bin +rm $RPM_BUILD_ROOT/%{_bindir}/ld_iscsi.so + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%package devel +Summary: Development libraries for iSCSI client +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +This package contains the header files for %{name}. + +%package help +Summary: Help info for %{name} +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description help +This package contains the help info for %{name}. + +%files +%license COPYING LICENCE-GPL-2.txt LICENCE-LGPL-2.1.txt +%doc README TODO +%dir %{_libdir}/iscsi +%{_libdir}/iscsi/libiscsi.so.* +%{_bindir}/iscsi-ls +%{_bindir}/iscsi-inq +%{_bindir}/iscsi-readcapacity16 +%{_bindir}/iscsi-swp +%{_bindir}/iscsi-perf +%{_bindir}/iscsi-test-cu +%config /etc/ld.so.conf.d/* + +%files devel +%dir %{_includedir}/iscsi +%{_includedir}/iscsi/iscsi.h +%{_includedir}/iscsi/scsi-lowlevel.h +%{_libdir}/iscsi/libiscsi.so +%{_libdir}/pkgconfig/libiscsi.pc + +%files help +%{_mandir}/man1/iscsi-ls.1.gz +%{_mandir}/man1/iscsi-inq.1.gz +%{_mandir}/man1/iscsi-swp.1.gz +%{_mandir}/man1/iscsi-test-cu.1.gz + +%changelog +* Sat Aug 31 2019 mingfangsen - 1.18.0-6 +- Package init