diff -Nru tgt-1.0.79/debian/changelog tgt-1.0.80/debian/changelog --- tgt-1.0.79/debian/changelog 2020-09-30 11:30:55.000000000 +0000 +++ tgt-1.0.80/debian/changelog 2021-02-24 12:00:56.000000000 +0000 @@ -1,3 +1,30 @@ +tgt (1:1.0.80-1ubuntu1) hirsute; urgency=medium + + * Merge with Debian unstable. Remaining changes: + - d/rules: avoid FTFBS on s390x due to glibc 2.32 triggering more + gcc-10 errors on tgt build + * Dropped changes: + - Drop glusterfs support, package not in main. + [tgt will be demoted after the new cinder-volume migrated] + + debian/control: drop build depends and package + + debian/rules: disable feature + + debian/tests/{control, storage}: remove related tests + + debian/tgt-glusterfs.install (Deleted) + + -- Christian Ehrhardt Wed, 24 Feb 2021 13:00:56 +0100 + +tgt (1:1.0.80-1) unstable; urgency=medium + + * New upstream version 1.0.80 + + Fix build with GCC 10 + + Add helper to fill sense INFORMATION field + + Set INFORMATION field on COMPARE AND WRITE miscompare + * Drop patches merged upstream. + - 0008-Fix-build-with-gcc-10.patch + - 0009-Replace-__packed-with-__attribute__.patch + + -- Apollon Oikonomopoulos Thu, 12 Nov 2020 18:56:52 +0200 + tgt (1:1.0.79-3ubuntu1) groovy; urgency=medium * Merge with Debian unstable. Remaining changes: diff -Nru tgt-1.0.79/debian/control tgt-1.0.80/debian/control --- tgt-1.0.79/debian/control 2020-09-30 11:30:55.000000000 +0000 +++ tgt-1.0.80/debian/control 2021-02-24 12:00:56.000000000 +0000 @@ -4,7 +4,7 @@ Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Apollon Oikonomopoulos Build-Depends: debhelper-compat (= 13), libibverbs-dev, librdmacm-dev (>= 1.0.16), - xsltproc, docbook-xsl, librbd-dev, uuid-dev, + xsltproc, docbook-xsl, librbd-dev, libglusterfs-dev, uuid-dev, bash-completion, libsystemd-dev, libaio-dev, pkg-config Vcs-Git: https://salsa.debian.org/debian/tgt.git Vcs-Browser: https://salsa.debian.org/debian/tgt @@ -15,7 +15,7 @@ Architecture: linux-any Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base, libconfig-general-perl, sg3-utils Pre-Depends: ${misc:Pre-Depends} -Suggests: tgt-rbd +Suggests: tgt-glusterfs, tgt-rbd Description: Linux SCSI target user-space daemon and tools The Linux target framework (tgt) allows a Linux system to provide SCSI devices (targets) over networked SCSI transports. @@ -57,3 +57,26 @@ . This package enables tgt to use Ceph/RADOS block devices (RBD) as backing store for SCSI Logical Units. + +Package: tgt-glusterfs +Architecture: linux-any +Depends: tgt (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Description: Linux SCSI target user-space daemon and tools - GlusterFS support + The Linux target framework (tgt) allows a Linux system to provide SCSI + devices (targets) over networked SCSI transports. + . + tgt consists of a user-space daemon and user-space tools currently + supporting the following transports: + . + - iSCSI (SCSI over IP) + - iSER (iSCSI over RDMA, using Infiniband) + . + tgt also supports different storage types for use as backing stores for SCSI + Logical Units: + . + - Plain files and block devices + - Ceph/RADOS RBD volumes + - GlusterFS volumes + . + This package enables tgt to use GlusterFS volumes as backing store for SCSI + Logical Units. diff -Nru tgt-1.0.79/debian/patches/0008-Fix-build-with-gcc-10.patch tgt-1.0.80/debian/patches/0008-Fix-build-with-gcc-10.patch --- tgt-1.0.79/debian/patches/0008-Fix-build-with-gcc-10.patch 2020-09-30 11:27:52.000000000 +0000 +++ tgt-1.0.80/debian/patches/0008-Fix-build-with-gcc-10.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -From: Apollon Oikonomopoulos -Date: Thu, 17 Sep 2020 12:12:56 +0300 -Subject: Fix build with gcc-10 - -iscsi_add_portal sometimes passes a NULL pointer as a %s argument to -printf. This is considered an error by -Werror=format-overflow and GCC-10 has -become much smarter in detecting these cases: - - In file included from iscsi/iscsid.h:29, - from iscsi/iscsi_tcp.c:35: - In function 'iscsi_add_portal', - inlined from 'iscsi_add_portal' at iscsi/iscsi_tcp.c:408:5, - inlined from 'iscsi_tcp_init' at iscsi/iscsi_tcp.c:449:3: - ./log.h:90:2: error: '%s' directive argument is null [-Werror=format-overflow=] - 90 | log_error("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \ - | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - iscsi/iscsi_tcp.c:411:3: note: in expansion of macro 'eprintf' - 411 | eprintf("failed to create/bind to portal %s:%d\n", addr, port); - | ^~~~~~~ - -Fix this by passing the empty string to eprintf() if addr is NULL. - -Closes: #957874 ---- - usr/iscsi/iscsi_tcp.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c -index 2bb8356..cb4e23c 100644 ---- a/usr/iscsi/iscsi_tcp.c -+++ b/usr/iscsi/iscsi_tcp.c -@@ -407,8 +407,13 @@ int iscsi_tcp_init_portal(char *addr, int port, int tpgt) - - int iscsi_add_portal(char *addr, int port, int tpgt) - { -+ const char *addr_str = ""; -+ - if (iscsi_tcp_init_portal(addr, port, tpgt)) { -- eprintf("failed to create/bind to portal %s:%d\n", addr, port); -+ if (addr) { -+ addr_str = addr; -+ } -+ eprintf("failed to create/bind to portal %s:%d\n", addr_str, port); - return -1; - } - diff -Nru tgt-1.0.79/debian/patches/0009-Replace-__packed-with-__attribute__.patch tgt-1.0.80/debian/patches/0009-Replace-__packed-with-__attribute__.patch --- tgt-1.0.79/debian/patches/0009-Replace-__packed-with-__attribute__.patch 2020-09-30 11:27:52.000000000 +0000 +++ tgt-1.0.80/debian/patches/0009-Replace-__packed-with-__attribute__.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -From: Apollon Oikonomopoulos -Date: Thu, 17 Sep 2020 12:45:19 +0300 -Subject: Replace __packed with __attribute__(...) - -GCC 10 changed the default from -fcommon to -fno-common. This makes the -tgt build fail because of multiple definitions of __packed. Change all -instances of __packed to __attribute__((__packed__)), which is the -canonical attribute form. ---- - usr/iscsi/iscsid.c | 2 +- - usr/iscsi/iser.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c -index a54a46e..476a760 100644 ---- a/usr/iscsi/iscsid.c -+++ b/usr/iscsi/iscsid.c -@@ -1074,7 +1074,7 @@ void iscsi_rsp_set_residual(struct iscsi_cmd_rsp *rsp, struct scsi_cmd *scmd) - struct iscsi_sense_data { - uint16_t length; - uint8_t data[0]; --} __packed; -+} __attribute__((__packed__)); - - static int iscsi_cmd_rsp_build(struct iscsi_task *task) - { -diff --git a/usr/iscsi/iser.c b/usr/iscsi/iser.c -index c7c43b2..2abb872 100644 ---- a/usr/iscsi/iser.c -+++ b/usr/iscsi/iser.c -@@ -92,7 +92,7 @@ char *iser_portal_addr; - struct iscsi_sense_data { - uint16_t length; - uint8_t data[0]; --} __packed; -+} __attribute__((__packed__)); - - static size_t buf_pool_sz_mb = DEFAULT_POOL_SIZE_MB; - static int cq_vector = -1; diff -Nru tgt-1.0.79/debian/patches/series tgt-1.0.80/debian/patches/series --- tgt-1.0.79/debian/patches/series 2020-09-30 11:27:52.000000000 +0000 +++ tgt-1.0.80/debian/patches/series 2021-02-24 12:00:37.000000000 +0000 @@ -5,5 +5,3 @@ 0005-fix-aio-detection.patch 0006-fix-pie-build 0007-Fix-compilation-with-glusterfs-6.patch -0008-Fix-build-with-gcc-10.patch -0009-Replace-__packed-with-__attribute__.patch diff -Nru tgt-1.0.79/debian/rules tgt-1.0.80/debian/rules --- tgt-1.0.79/debian/rules 2020-09-30 11:30:55.000000000 +0000 +++ tgt-1.0.80/debian/rules 2021-02-24 12:00:37.000000000 +0000 @@ -1,7 +1,7 @@ #!/usr/bin/make -f #export DH_VERBOSE=1 -FEATURES = ISCSI_RDMA=1 CEPH_RBD=1 SD_NOTIFY=1 +FEATURES = ISCSI_RDMA=1 CEPH_RBD=1 GLFS_BD=1 SD_NOTIFY=1 export DEB_BUILD_MAINT_OPTIONS = hardening=+all # avoid FTFBS due to glibc 2.32 triggering more gcc-10 errors diff -Nru tgt-1.0.79/debian/tests/control tgt-1.0.80/debian/tests/control --- tgt-1.0.79/debian/tests/control 2020-09-30 11:27:52.000000000 +0000 +++ tgt-1.0.80/debian/tests/control 2021-02-24 12:00:37.000000000 +0000 @@ -2,7 +2,7 @@ Depends: tgt Tests: storage -Depends: tgt, tgt-rbd +Depends: tgt, tgt-rbd, tgt-glusterfs Restrictions: needs-root isolation-container allow-stderr Tests: localtgt diff -Nru tgt-1.0.79/debian/tests/storage tgt-1.0.80/debian/tests/storage --- tgt-1.0.79/debian/tests/storage 2020-09-30 11:27:52.000000000 +0000 +++ tgt-1.0.80/debian/tests/storage 2021-02-24 12:00:37.000000000 +0000 @@ -13,7 +13,7 @@ }') ret=0 -for bs in rbd aio; do +for bs in glfs rbd aio; do if echo "$supported_bs" | grep -q "\b$bs\b"; then echo "OK - $bs supported" else diff -Nru tgt-1.0.79/debian/tgt-glusterfs.install tgt-1.0.80/debian/tgt-glusterfs.install --- tgt-1.0.79/debian/tgt-glusterfs.install 1970-01-01 00:00:00.000000000 +0000 +++ tgt-1.0.80/debian/tgt-glusterfs.install 2021-02-24 12:00:37.000000000 +0000 @@ -0,0 +1 @@ +debian/tgt/usr/lib/tgt/backing-store/bs_glfs.so usr/lib/tgt/backing-store diff -Nru tgt-1.0.79/Makefile tgt-1.0.80/Makefile --- tgt-1.0.79/Makefile 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/Makefile 2020-11-01 13:25:57.000000000 +0000 @@ -1,4 +1,4 @@ -VERSION ?= 1.0.79 +VERSION ?= 1.0.80 CHECK_CC = cgcc CHECK_CC_FLAGS = '$(CHECK_CC) -Wbitwise -Wno-return-void -no-compile $(ARCH)' diff -Nru tgt-1.0.79/scripts/checkpatch.pl tgt-1.0.80/scripts/checkpatch.pl --- tgt-1.0.79/scripts/checkpatch.pl 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/scripts/checkpatch.pl 2020-11-01 13:25:57.000000000 +0000 @@ -2397,8 +2397,8 @@ # function brace can't be on same line, except for #defines of do while, # or if closed on same line - if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and - !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) { + if (($line=~/$Type\s*$Ident\(.*\).*\s\{/) and + !($line=~/\#\s*define.*do\s\{/) and !($line=~/\}/)) { ERROR("OPEN_BRACE", "open brace '{' following function declarations go on the next line\n" . $herecurr); } @@ -2673,8 +2673,8 @@ ## } #need space before brace following if, while, etc - if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) || - $line =~ /do{/) { + if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\){/) || + $line =~ /do\{/) { ERROR("SPACING", "space required before the open brace '{'\n" . $herecurr); } @@ -2964,7 +2964,7 @@ $dstat !~ /^for\s*$Constant$/ && # for (...) $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar() $dstat !~ /^do\s*{/ && # do {... - $dstat !~ /^\({/) # ({... + $dstat !~ /^\(\{/) # ({... { $ctx =~ s/\n*$//; my $herectx = $here . "\n"; diff -Nru tgt-1.0.79/usr/bs_rdwr.c tgt-1.0.80/usr/bs_rdwr.c --- tgt-1.0.79/usr/bs_rdwr.c 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/usr/bs_rdwr.c 2020-11-01 13:25:57.000000000 +0000 @@ -41,30 +41,19 @@ #include "spc.h" #include "bs_thread.h" -static void set_medium_error(int *result, uint8_t *key, uint16_t *asc) +static void cmd_error_sense(struct scsi_cmd *cmd, uint8_t key, uint16_t asc) { - *result = SAM_STAT_CHECK_CONDITION; - *key = MEDIUM_ERROR; - *asc = ASC_READ_ERROR; + scsi_set_result(cmd, SAM_STAT_CHECK_CONDITION); + sense_data_build(cmd, key, asc); } -static void bs_sync_sync_range(struct scsi_cmd *cmd, uint32_t length, - int *result, uint8_t *key, uint16_t *asc) -{ - int ret; - - ret = fdatasync(cmd->dev->fd); - if (ret) - set_medium_error(result, key, asc); -} +#define set_medium_error(cmd) cmd_error_sense(cmd, MEDIUM_ERROR, ASC_READ_ERROR) static void bs_rdwr_request(struct scsi_cmd *cmd) { - int ret, fd = cmd->dev->fd; - uint32_t length; - int result = SAM_STAT_GOOD; - uint8_t key; - uint16_t asc; + int ret = 0; + int fd = cmd->dev->fd; + uint32_t length = 0; char *tmpbuf; size_t blocksize; uint64_t offset = cmd->offset; @@ -73,8 +62,9 @@ int i; char *ptr; const char *write_buf = NULL; - ret = length = 0; - key = asc = 0; + + /* overwritten on error */ + scsi_set_result(cmd, SAM_STAT_GOOD); switch (cmd->scb[0]) { @@ -83,16 +73,15 @@ tmpbuf = malloc(length); if (!tmpbuf) { - result = SAM_STAT_CHECK_CONDITION; - key = HARDWARE_ERROR; - asc = ASC_INTERNAL_TGT_FAILURE; + cmd_error_sense(cmd, HARDWARE_ERROR, + ASC_INTERNAL_TGT_FAILURE); break; } ret = pread64(fd, tmpbuf, length, offset); if (ret != length) { - set_medium_error(&result, &key, &asc); + set_medium_error(cmd); free(tmpbuf); break; } @@ -112,30 +101,28 @@ */ length = scsi_get_out_length(cmd) / 2; if (length != cmd->tl) { - result = SAM_STAT_CHECK_CONDITION; - key = ILLEGAL_REQUEST; - asc = ASC_INVALID_FIELD_IN_CDB; + cmd_error_sense(cmd, ILLEGAL_REQUEST, + ASC_INVALID_FIELD_IN_CDB); break; } tmpbuf = malloc(length); if (!tmpbuf) { - result = SAM_STAT_CHECK_CONDITION; - key = HARDWARE_ERROR; - asc = ASC_INTERNAL_TGT_FAILURE; + cmd_error_sense(cmd, HARDWARE_ERROR, + ASC_INTERNAL_TGT_FAILURE); break; } ret = pread64(fd, tmpbuf, length, offset); if (ret != length) { - set_medium_error(&result, &key, &asc); + set_medium_error(cmd); free(tmpbuf); break; } if (memcmp(scsi_get_out_buffer(cmd), tmpbuf, length)) { - uint32_t pos = 0; + uint64_t pos = 0; char *spos = scsi_get_out_buffer(cmd); char *dpos = tmpbuf; @@ -148,10 +135,10 @@ for (pos = 0; pos < length && *spos++ == *dpos++; pos++) ; - result = SAM_STAT_CHECK_CONDITION; - key = MISCOMPARE; - asc = ASC_MISCOMPARE_DURING_VERIFY_OPERATION; free(tmpbuf); + scsi_set_result(cmd, SAM_STAT_CHECK_CONDITION); + sense_data_build_with_info(cmd, MISCOMPARE, + ASC_MISCOMPARE_DURING_VERIFY_OPERATION, pos); break; } @@ -169,11 +156,13 @@ length = (cmd->scb[0] == SYNCHRONIZE_CACHE) ? 0 : 0; if (cmd->scb[1] & 0x2) { - result = SAM_STAT_CHECK_CONDITION; - key = ILLEGAL_REQUEST; - asc = ASC_INVALID_FIELD_IN_CDB; - } else - bs_sync_sync_range(cmd, length, &result, &key, &asc); + cmd_error_sense(cmd, ILLEGAL_REQUEST, + ASC_INVALID_FIELD_IN_CDB); + } else { + ret = fdatasync(fd); + if (ret) + set_medium_error(cmd); + } break; case WRITE_VERIFY: case WRITE_VERIFY_12: @@ -197,17 +186,18 @@ */ pg = find_mode_page(cmd->dev, 0x08, 0); if (pg == NULL) { - result = SAM_STAT_CHECK_CONDITION; - key = ILLEGAL_REQUEST; - asc = ASC_INVALID_FIELD_IN_CDB; + cmd_error_sense(cmd, ILLEGAL_REQUEST, + ASC_INVALID_FIELD_IN_CDB); break; } if (((cmd->scb[0] != WRITE_6) && (cmd->scb[1] & 0x8)) || - !(pg->mode_data[0] & 0x04)) - bs_sync_sync_range(cmd, length, &result, &key, - &asc); + !(pg->mode_data[0] & 0x04)) { + ret = fdatasync(fd); + if (ret) + set_medium_error(cmd); + } } else - set_medium_error(&result, &key, &asc); + set_medium_error(cmd); if ((cmd->scb[0] != WRITE_6) && (cmd->scb[1] & 0x10)) posix_fadvise(fd, offset, length, @@ -223,9 +213,8 @@ if (ret != 0) { eprintf("Failed to punch hole for WRITE_SAME" " command\n"); - result = SAM_STAT_CHECK_CONDITION; - key = HARDWARE_ERROR; - asc = ASC_INTERNAL_TGT_FAILURE; + cmd_error_sense(cmd, HARDWARE_ERROR, + ASC_INTERNAL_TGT_FAILURE); break; } break; @@ -246,7 +235,7 @@ ret = pwrite64(fd, tmpbuf, blocksize, offset); if (ret != blocksize) - set_medium_error(&result, &key, &asc); + set_medium_error(cmd); offset += blocksize; tl -= blocksize; @@ -261,7 +250,7 @@ offset); if (ret != length) - set_medium_error(&result, &key, &asc); + set_medium_error(cmd); if ((cmd->scb[0] != READ_6) && (cmd->scb[1] & 0x10)) posix_fadvise(fd, offset, length, @@ -274,7 +263,7 @@ POSIX_FADV_WILLNEED); if (ret != 0) - set_medium_error(&result, &key, &asc); + set_medium_error(cmd); break; case VERIFY_10: case VERIFY_12: @@ -284,20 +273,18 @@ tmpbuf = malloc(length); if (!tmpbuf) { - result = SAM_STAT_CHECK_CONDITION; - key = HARDWARE_ERROR; - asc = ASC_INTERNAL_TGT_FAILURE; + cmd_error_sense(cmd, HARDWARE_ERROR, + ASC_INTERNAL_TGT_FAILURE); break; } ret = pread64(fd, tmpbuf, length, offset); if (ret != length) - set_medium_error(&result, &key, &asc); + set_medium_error(cmd); else if (memcmp(scsi_get_out_buffer(cmd), tmpbuf, length)) { - result = SAM_STAT_CHECK_CONDITION; - key = MISCOMPARE; - asc = ASC_MISCOMPARE_DURING_VERIFY_OPERATION; + cmd_error_sense(cmd, MISCOMPARE, + ASC_MISCOMPARE_DURING_VERIFY_OPERATION); } if (cmd->scb[1] & 0x10) @@ -308,9 +295,8 @@ break; case UNMAP: if (!cmd->dev->attrs.thinprovisioning) { - result = SAM_STAT_CHECK_CONDITION; - key = ILLEGAL_REQUEST; - asc = ASC_INVALID_FIELD_IN_CDB; + cmd_error_sense(cmd, ILLEGAL_REQUEST, + ASC_INVALID_FIELD_IN_CDB); break; } @@ -332,9 +318,8 @@ if (offset + tl > cmd->dev->size) { eprintf("UNMAP beyond EOF\n"); - result = SAM_STAT_CHECK_CONDITION; - key = ILLEGAL_REQUEST; - asc = ASC_LBA_OUT_OF_RANGE; + cmd_error_sense(cmd, ILLEGAL_REQUEST, + ASC_LBA_OUT_OF_RANGE); break; } @@ -344,9 +329,8 @@ " UNMAP at offset:%" PRIu64 " length:%d\n", offset, tl); - result = SAM_STAT_CHECK_CONDITION; - key = HARDWARE_ERROR; - asc = ASC_INTERNAL_TGT_FAILURE; + cmd_error_sense(cmd, HARDWARE_ERROR, + ASC_INTERNAL_TGT_FAILURE); break; } } @@ -361,12 +345,9 @@ dprintf("io done %p %x %d %u\n", cmd, cmd->scb[0], ret, length); - scsi_set_result(cmd, result); - - if (result != SAM_STAT_GOOD) { + if (scsi_get_result(cmd) != SAM_STAT_GOOD) { eprintf("io error %p %x %d %d %" PRIu64 ", %m\n", cmd, cmd->scb[0], ret, length, offset); - sense_data_build(cmd, key, asc); } } diff -Nru tgt-1.0.79/usr/iscsi/chap.c tgt-1.0.80/usr/iscsi/chap.c --- tgt-1.0.79/usr/iscsi/chap.c 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/usr/iscsi/chap.c 2020-11-01 13:25:57.000000000 +0000 @@ -476,7 +476,7 @@ goto out; } - conn->state = CHAP_AUTH_STATE_RESPONSE; + conn->auth_state = CHAP_AUTH_STATE_RESPONSE; out: if (his_digest) free(his_digest); diff -Nru tgt-1.0.79/usr/iscsi/iscsid.c tgt-1.0.80/usr/iscsi/iscsid.c --- tgt-1.0.79/usr/iscsi/iscsid.c 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/usr/iscsi/iscsid.c 2020-11-01 13:25:57.000000000 +0000 @@ -1074,7 +1074,7 @@ struct iscsi_sense_data { uint16_t length; uint8_t data[0]; -} __packed; +} __attribute__((__packed__)); static int iscsi_cmd_rsp_build(struct iscsi_task *task) { diff -Nru tgt-1.0.79/usr/iscsi/iscsi_tcp.c tgt-1.0.80/usr/iscsi/iscsi_tcp.c --- tgt-1.0.79/usr/iscsi/iscsi_tcp.c 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/usr/iscsi/iscsi_tcp.c 2020-11-01 13:25:57.000000000 +0000 @@ -407,8 +407,14 @@ int iscsi_add_portal(char *addr, int port, int tpgt) { + const char *addr_str = ""; + if (iscsi_tcp_init_portal(addr, port, tpgt)) { - eprintf("failed to create/bind to portal %s:%d\n", addr, port); + if (addr) { + addr_str = addr; + } + eprintf("failed to create/bind to portal %s:%d\n", + addr_str, port); return -1; } diff -Nru tgt-1.0.79/usr/iscsi/iser.c tgt-1.0.80/usr/iscsi/iser.c --- tgt-1.0.79/usr/iscsi/iser.c 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/usr/iscsi/iser.c 2020-11-01 13:25:57.000000000 +0000 @@ -92,7 +92,7 @@ struct iscsi_sense_data { uint16_t length; uint8_t data[0]; -} __packed; +} __attribute__((__packed__)); static size_t buf_pool_sz_mb = DEFAULT_POOL_SIZE_MB; static int cq_vector = -1; diff -Nru tgt-1.0.79/usr/iscsi/target.c tgt-1.0.80/usr/iscsi/target.c --- tgt-1.0.79/usr/iscsi/target.c 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/usr/iscsi/target.c 2020-11-01 13:25:57.000000000 +0000 @@ -224,7 +224,7 @@ { char *p, *addr, *port; - bzero(buffer, buflen); + memset(buffer, 0, buflen); if (call_program(callback, NULL, NULL, buffer, buflen, 0)) return -1; diff -Nru tgt-1.0.79/usr/log.c tgt-1.0.80/usr/log.c --- tgt-1.0.79/usr/log.c 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/usr/log.c 2020-11-01 13:25:57.000000000 +0000 @@ -197,7 +197,7 @@ } /* not enough space on head : drop msg */ - if (la->head > la->tail && + if (la->head >= la->tail && (len + sizeof(struct logmsg)) > (la->head - la->tail)) { logdbg(stderr, "enqueue: log area overrun, drop msg\n"); diff -Nru tgt-1.0.79/usr/scsi.c tgt-1.0.80/usr/scsi.c --- tgt-1.0.79/usr/scsi.c 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/usr/scsi.c 2020-11-01 13:25:57.000000000 +0000 @@ -29,6 +29,7 @@ #include #include #include +#include #include "list.h" #include "util.h" @@ -338,6 +339,28 @@ } } +void sense_data_build_with_info(struct scsi_cmd *cmd, uint8_t key, uint16_t asc, + uint64_t info) +{ + sense_data_build(cmd, key, asc); + + if (cmd->dev->attrs.sense_format) { + /* descriptor format, append as first sense data descriptor */ + assert(cmd->sense_buffer[7] == 0); + cmd->sense_buffer[7] = 12; /* ADDITIONAL SENSE LENGTH */ + uint8_t *sdd = &cmd->sense_buffer[8]; + sdd[0] = 0x00; /* DESCRIPTOR TYPE */ + sdd[1] = 0x0a; /* ADDITIONAL LENGTH */ + sdd[2] = 0x80; /* VALID */ + put_unaligned_be64(info, &sdd[4]); /* INFORMATION */ + } else if (info <= UINT32_MAX) { + /* fixed format. info field is only 32-bit */ + cmd->sense_buffer[0] |= 0x80; /* VALID */ + put_unaligned_be32((uint32_t)info, + &cmd->sense_buffer[3]); /* INFORMATION */ + } +} + #define TGT_INVALID_DEV_ID ~0ULL static uint64_t __scsi_get_devid(uint8_t *p) diff -Nru tgt-1.0.79/usr/tgtd.h tgt-1.0.80/usr/tgtd.h --- tgt-1.0.79/usr/tgtd.h 2019-07-01 10:50:30.000000000 +0000 +++ tgt-1.0.80/usr/tgtd.h 2020-11-01 13:25:57.000000000 +0000 @@ -331,6 +331,8 @@ extern uint64_t scsi_get_devid(int lid, uint8_t *pdu); extern int scsi_cmd_perform(int host_no, struct scsi_cmd *cmd); extern void sense_data_build(struct scsi_cmd *cmd, uint8_t key, uint16_t asc); +extern void sense_data_build_with_info(struct scsi_cmd *cmd, uint8_t key, + uint16_t asc, uint64_t info); extern uint64_t scsi_rw_offset(uint8_t *scb); extern uint32_t scsi_rw_count(uint8_t *scb); extern int scsi_is_io_opcode(unsigned char op);