Hello community, here is the log from the commit of package istgt for openSUSE:Factory checked in at 2012-11-08 08:04:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/istgt (Old) and /work/SRC/openSUSE:Factory/.istgt.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "istgt", Maintainer is "" Changes: -------- --- /work/SRC/openSUSE:Factory/istgt/istgt.changes 2012-09-11 09:08:14.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.istgt.new/istgt.changes 2012-11-08 08:05:18.000000000 +0100 @@ -1,0 +2,15 @@ +Tue Nov 6 13:07:35 UTC 2012 - ddiss@suse.com + +- Update to upstream istgt-20121028.tar.gz release. + +- Japanese -> English ChangeLog.jp via Google Translate: + + Modified to return the (Changeable values) PC = 01b in MODE_SENSE + and modified to use NOTE_LOWAT SO_RCVLOWAT + + Fixed issue an error if you specify no authentication: istgtcontrol + + modified to abort initialization error: istgtcontrol + + Socket system displays an error + + Iqn Show at the PDU error + + Add a time-out error log + + Add the batch code using readv / writev + +------------------------------------------------------------------- Old: ---- istgt-20120901.tar.gz New: ---- istgt-20121028.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ istgt.spec ++++++ --- /var/tmp/diff_new_pack.TKU2hb/_old 2012-11-08 08:05:19.000000000 +0100 +++ /var/tmp/diff_new_pack.TKU2hb/_new 2012-11-08 08:05:19.000000000 +0100 @@ -17,9 +17,9 @@ Name: istgt -Version: 0.8 -Release: 20120901 -%define upstreamrel 20120901 +Version: 0.10 +Release: 20121028 +%define upstreamrel 20121028 Summary: Userspace iSCSI Target License: BSD-2-Clause Group: Productivity/Networking/Other ++++++ istgt-20120901.tar.gz -> istgt-20121028.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/ChangeLog.jp new/istgt-20121028/ChangeLog.jp --- old/istgt-20120901/ChangeLog.jp 2012-09-01 04:19:35.000000000 +0200 +++ new/istgt-20121028/ChangeLog.jp 2012-10-28 00:26:36.000000000 +0200 @@ -1,3 +1,21 @@ +2012/10/28 + 2012/10/28版 + MODE_SENSEでPC=01b(Changeable values)を返すように修正 + SO_RCVLOWATとNOTE_LOWATを使うように修正 + +2012/10/16 + 2012/10/16版 + istgtcontrol:認証なしを指定するとエラーを出すのを修正 + istgtcontrol:初期化エラーで中断するように変更 + +2012/10/06 + ソケット系エラーを表示 + PDUエラー時にiqnを表示 + タイムアウトエラーログに時間を追加 + +2012/10/04 + readv/writevを使った一括処理コードを追加 + 2012/09/01 2012/09/01版 サポート外のMODE_SENSEにINVALID FIELD IN CDBを返すように変更 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/README new/istgt-20121028/README --- old/istgt-20120901/README 2012-08-09 00:48:09.000000000 +0200 +++ new/istgt-20121028/README 2012-10-15 23:40:18.000000000 +0200 @@ -84,18 +84,22 @@ o VMware ESXi 4.0 (builtin) o VMware ESXi 4.1 Update 1 (builtin) o VMware ESXi 5.0 (builtin) + o VMware ESXi 5.1 (builtin) o Xen Server 5.0 Update 3 (builtin) o Xen Server 5.5 (builtin) o FreeBSD 7.1 + iscsi 2.1.3 o FreeBSD 7.2 + iscsi 2.2.3 o FreeBSD 7.3 + iscsi 2.2.4 o FreeBSD 8.2 + isboot 0.2.3 + o FreeBSD 9.1 + isboot 0.2.6 o CentOS 5.2 + Open-iSCSI (package) o Ubuntu 9.10 + Open-iSCSI (package) o gPXE 1.0.0 + VirtualBox 3.1.2 on FreeNAS 0.7.1 + o iPXE 1.0.0 + isboot 0.2.5 + FreeBSD 9.1 o FreeNAS 0.7.1 (FreeBSD 7.2/7.3 + iscsi 2.2.4) o FreeNAS 0.7.2 (FreeBSD 7.3 + iscsi 2.2.4) o FreeNAS 0.7.5 (FreeBSD 9.0 + iscsi 2.3.1.0) + o NAS4Free 9.1.0.1 (FreeBSD 9.1 + iscsi 2.3.1.0) Features: o MCS/MPIO for failover (up to 255 concurrent sessions) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/etc/istgt.conf.in new/istgt-20121028/etc/istgt.conf.in --- old/istgt-20120901/etc/istgt.conf.in 2012-07-25 18:47:13.000000000 +0200 +++ new/istgt-20121028/etc/istgt.conf.in 2012-10-28 00:26:36.000000000 +0200 @@ -163,6 +163,8 @@ # for future use (enabled by default) #LUN0 Option ReadCache Disable + + # control WCE(mode page 8) and O_FSYNC/O_SYNC on the backing store (enabled by default) #LUN0 Option WriteCache Disable #[LogicalUnit2] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/Makefile.in new/istgt-20121028/src/Makefile.in --- old/istgt-20120901/src/Makefile.in 2012-08-09 00:48:09.000000000 +0200 +++ new/istgt-20121028/src/Makefile.in 2012-10-15 23:40:18.000000000 +0200 @@ -46,9 +46,9 @@ document = sample = -ctl_source = istgtcontrol.c istgt_conf.c istgt_sock.c istgt_misc.c \ +ctl_source = istgtcontrol.c istgt_conf.c istgt_log.c istgt_sock.c istgt_misc.c \ istgt_md5.c -ctl_header = istgt_ver.h istgt_conf.h istgt_sock.h istgt_misc.h \ +ctl_header = istgt_ver.h istgt_conf.h istgt_log.h istgt_sock.h istgt_misc.h \ istgt_md5.h ISTGT = $(source:.c=.o) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/istgt_iscsi.c new/istgt-20121028/src/istgt_iscsi.c --- old/istgt-20120901/src/istgt_iscsi.c 2012-08-18 23:04:12.000000000 +0200 +++ new/istgt-20121028/src/istgt_iscsi.c 2012-10-28 00:26:36.000000000 +0200 @@ -117,6 +117,14 @@ static int istgt_iscsi_drop_all_conns(CONN_Ptr conn); static int istgt_iscsi_drop_old_conns(CONN_Ptr conn); +/* Switch to use readv/writev (assume blocking) */ +#define ISTGT_USE_IOVEC + +#if defined (ISTGT_USE_IOVEC) +#include <sys/uio.h> +#endif + +#if !defined (ISTGT_USE_IOVEC) #if 0 #define ISTGT_USE_RECVBLOCK #define ISTGT_USE_SENDBLOCK @@ -376,6 +384,7 @@ #endif /* ISTGT_USE_SENDBLOCK */ return nbytes; } +#endif /* !defined (ISTGT_USE_IOVEC) */ #define MATCH_DIGEST_WORD(BUF, CRC32C) \ ( ((((uint32_t) *((uint8_t *)(BUF)+0)) << 0) \ @@ -417,6 +426,7 @@ } #endif +#if !defined (ISTGT_USE_IOVEC) static int istgt_iscsi_read_pdu(CONN_Ptr conn, ISCSI_PDU_Ptr pdu) { @@ -447,13 +457,14 @@ conn->initiator_name); conn->state = CONN_STATE_EXITING; } else { - ISTGT_ERRLOG("iscsi_read() failed (errno=%d)\n", - errno); + ISTGT_ERRLOG("iscsi_read() failed (errno=%d,%s)\n", + errno, conn->initiator_name); } return -1; } if (rc == 0) { - ISTGT_TRACELOG(ISTGT_TRACE_NET, "iscsi_read() EOF\n"); + ISTGT_TRACELOG(ISTGT_TRACE_NET, "iscsi_read() EOF (%s)\n", + conn->initiator_name); conn->state = CONN_STATE_EXITING; return -1; } @@ -471,7 +482,8 @@ (4 * total_ahs_len)); rc = istgt_iscsi_read(conn, pdu->ahs, (4 * total_ahs_len)); if (rc < 0) { - ISTGT_ERRLOG("iscsi_read() failed\n"); + ISTGT_ERRLOG("iscsi_read() failed (errno=%d,%s)\n", + errno, conn->initiator_name); return -1; } if (rc == 0) { @@ -497,7 +509,8 @@ rc = istgt_iscsi_read(conn, pdu->header_digest, ISCSI_DIGEST_LEN); if (rc < 0) { - ISTGT_ERRLOG("iscsi_read() failed\n"); + ISTGT_ERRLOG("iscsi_read() failed (errno=%d,%s)\n", + errno, conn->initiator_name); { int opcode = BGET8W(&pdu->bhs.opcode, 5, 6); ISTGT_ERRLOG("Header Digest read error (opcode = 0x%x)\n", @@ -540,8 +553,8 @@ data_len); rc = istgt_iscsi_read(conn, pdu->data, data_len); if (rc < 0) { - ISTGT_ERRLOG("iscsi_read() failed (%d,errno=%d)\n", - rc, errno); + ISTGT_ERRLOG("iscsi_read() failed (%d,errno=%d,%s)\n", + rc, errno, conn->initiator_name); return -1; } if (rc == 0) { @@ -577,7 +590,8 @@ rc = istgt_iscsi_read(conn, pdu->data_digest, ISCSI_DIGEST_LEN); if (rc < 0) { - ISTGT_ERRLOG("iscsi_read() failed\n"); + ISTGT_ERRLOG("iscsi_read() failed (errno=%d,%s)\n", + errno, conn->initiator_name); return -1; } if (rc == 0) { @@ -611,7 +625,7 @@ } rc = MATCH_DIGEST_WORD(pdu->header_digest, crc32c); if (rc == 0) { - ISTGT_ERRLOG("header digest error\n"); + ISTGT_ERRLOG("header digest error (%s)\n", conn->initiator_name); return -1; } } @@ -619,13 +633,197 @@ crc32c = istgt_crc32c(pdu->data, data_len); rc = MATCH_DIGEST_WORD(pdu->data_digest, crc32c); if (rc == 0) { - ISTGT_ERRLOG("data digest error\n"); + ISTGT_ERRLOG("data digest error (%s)\n", conn->initiator_name); + return -1; + } + } + + return total; +} +#else /* defined (ISTGT_USE_IOVEC) */ +static int +istgt_iscsi_read_pdu(CONN_Ptr conn, ISCSI_PDU_Ptr pdu) +{ + struct iovec iovec[4]; /* AHS+HD+DATA+DD */ + uint32_t crc32c; + time_t start, now; + int nbytes; + int total_ahs_len; + int data_len; + int segment_len; + int total; + int rc; + int i; + + pdu->ahs = NULL; + pdu->total_ahs_len = 0; + pdu->data = NULL; + pdu->data_segment_len = 0; + total = 0; + + /* BHS (require for all PDU) */ + ISTGT_TRACELOG(ISTGT_TRACE_NET, "BHS read %d\n", + ISCSI_BHS_LEN); + errno = 0; + start = time(NULL); + rc = recv(conn->sock, &pdu->bhs, ISCSI_BHS_LEN, MSG_WAITALL); + if (rc < 0) { + now = time(NULL); + if (errno == ECONNRESET) { + ISTGT_WARNLOG("Connection reset by peer (%s,time=%d)\n", + conn->initiator_name, (int)difftime(now, start)); + conn->state = CONN_STATE_EXITING; + } else if (errno == ETIMEDOUT) { + ISTGT_WARNLOG("Operation timed out (%s,time=%d)\n", + conn->initiator_name, (int)difftime(now, start)); + conn->state = CONN_STATE_EXITING; + } else { + ISTGT_ERRLOG("iscsi_read() failed (errno=%d,%s,time=%d)\n", + errno, conn->initiator_name, (int)difftime(now, start)); + } + return -1; + } + if (rc == 0) { + ISTGT_TRACELOG(ISTGT_TRACE_NET, "recv() EOF (%s)\n", + conn->initiator_name); + conn->state = CONN_STATE_EXITING; + return -1; + } + if (rc != ISCSI_BHS_LEN) { + ISTGT_ERRLOG("invalid BHS length (%d,%s)\n", rc, conn->initiator_name); + return -1; + } + total += ISCSI_BHS_LEN; + + /* AHS */ + total_ahs_len = DGET8(&pdu->bhs.total_ahs_len); + if (total_ahs_len != 0) { + pdu->ahs = xmalloc(ISCSI_ALIGN((4 * total_ahs_len))); + pdu->total_ahs_len = total_ahs_len; + total += (4 * total_ahs_len); + } else { + pdu->ahs = NULL; + pdu->total_ahs_len = 0; + } + iovec[0].iov_base = pdu->ahs; + iovec[0].iov_len = 4 * pdu->total_ahs_len; + + /* Header Digest */ + iovec[1].iov_base = pdu->header_digest; + if (conn->header_digest) { + iovec[1].iov_len = ISCSI_DIGEST_LEN; + total += ISCSI_DIGEST_LEN; + } else { + iovec[1].iov_len = 0; + } + + /* Data Segment */ + data_len = DGET24(&pdu->bhs.data_segment_len[0]); + if (data_len != 0) { + if (conn->sess == NULL) { + segment_len = DEFAULT_FIRSTBURSTLENGTH; + } else { + segment_len = conn->MaxRecvDataSegmentLength; + } + if (data_len > segment_len) { + ISTGT_ERRLOG("Data(%d) > Segment(%d)\n", + data_len, segment_len); + return -1; + } + if (ISCSI_ALIGN(data_len) <= ISTGT_SHORTDATASIZE) { + pdu->data = pdu->shortdata; + } else { + pdu->data = xmalloc(ISCSI_ALIGN(segment_len)); + } + pdu->data_segment_len = data_len; + total += ISCSI_ALIGN(data_len); + } else { + pdu->data = NULL; + pdu->data_segment_len = 0; + } + iovec[2].iov_base = pdu->data; + iovec[2].iov_len = ISCSI_ALIGN(pdu->data_segment_len); + + /* Data Digest */ + iovec[3].iov_base = pdu->data_digest; + if (conn->data_digest && data_len != 0) { + iovec[3].iov_len = ISCSI_DIGEST_LEN; + total += ISCSI_DIGEST_LEN; + } else { + iovec[3].iov_len = 0; + } + + /* read all bytes to iovec */ + nbytes = total - ISCSI_BHS_LEN; + ISTGT_TRACELOG(ISTGT_TRACE_NET, "PDU read %d\n", nbytes); + errno = 0; + start = time(NULL); + while (nbytes > 0) { + rc = readv(conn->sock, &iovec[0], 4); + if (rc < 0) { + now = time(NULL); + ISTGT_ERRLOG("readv() failed (%d,errno=%d,%s,time=%d)\n", + rc, errno, conn->initiator_name, (int)difftime(now, start)); + return -1; + } + if (rc == 0) { + ISTGT_TRACELOG(ISTGT_TRACE_NET, "readv() EOF (%s)\n", + conn->initiator_name); + conn->state = CONN_STATE_EXITING; + return -1; + } + nbytes -= rc; + if (nbytes == 0) + break; + /* adjust iovec length */ + for (i = 0; i < 4; i++) { + if (iovec[i].iov_len != 0 && iovec[i].iov_len > (size_t)rc) { + iovec[i].iov_base + = (void *) (((uintptr_t)iovec[i].iov_base) + rc); + iovec[i].iov_len -= rc; + break; + } else { + rc -= iovec[i].iov_len; + iovec[i].iov_len = 0; + } + } + } + + /* check digest */ + if (conn->header_digest) { + if (total_ahs_len == 0) { + crc32c = istgt_crc32c((uint8_t *) &pdu->bhs, + ISCSI_BHS_LEN); + } else { + int upd_total = 0; + crc32c = ISTGT_CRC32C_INITIAL; + crc32c = istgt_update_crc32c((uint8_t *) &pdu->bhs, + ISCSI_BHS_LEN, crc32c); + upd_total += ISCSI_BHS_LEN; + crc32c = istgt_update_crc32c((uint8_t *) pdu->ahs, + (4 * total_ahs_len), crc32c); + upd_total += (4 * total_ahs_len); + crc32c = istgt_fixup_crc32c(upd_total, crc32c); + crc32c = crc32c ^ ISTGT_CRC32C_XOR; + } + rc = MATCH_DIGEST_WORD(pdu->header_digest, crc32c); + if (rc == 0) { + ISTGT_ERRLOG("header digest error (%s)\n", conn->initiator_name); + return -1; + } + } + if (conn->data_digest && data_len != 0) { + crc32c = istgt_crc32c(pdu->data, ISCSI_ALIGN(data_len)); + rc = MATCH_DIGEST_WORD(pdu->data_digest, crc32c); + if (rc == 0) { + ISTGT_ERRLOG("data digest error (%s)\n", conn->initiator_name); return -1; } } return total; } +#endif /* defined (ISTGT_USE_IOVEC) */ static int istgt_iscsi_write_pdu_internal(CONN_Ptr conn, ISCSI_PDU_Ptr pdu); static int istgt_iscsi_write_pdu_queue(CONN_Ptr conn, ISCSI_PDU_Ptr pdu, int req_type, int I_bit); @@ -787,6 +985,7 @@ return rc; } +#if !defined (ISTGT_USE_IOVEC) static int istgt_iscsi_write_pdu_internal(CONN_Ptr conn, ISCSI_PDU_Ptr pdu) { @@ -843,8 +1042,8 @@ total); rc = istgt_iscsi_write(conn, spp, total); if (rc < 0) { - ISTGT_ERRLOG("iscsi_write() failed (errno=%d)\n", - errno); + ISTGT_ERRLOG("iscsi_write() failed (errno=%d,%s)\n", + errno, conn->initiator_name); return -1; } if (rc != total) { @@ -860,7 +1059,8 @@ ISCSI_BHS_LEN); rc = istgt_iscsi_write(conn, &pdu->bhs, ISCSI_BHS_LEN); if (rc < 0) { - ISTGT_ERRLOG("iscsi_write() failed (errno=%d)\n", errno); + ISTGT_ERRLOG("iscsi_write() failed (errno=%d,%s)\n", errno, + conn->initiator_name); return -1; } if (rc != ISCSI_BHS_LEN) { @@ -875,7 +1075,8 @@ (4 * total_ahs_len)); rc = istgt_iscsi_write(conn, pdu->ahs, (4 * total_ahs_len)); if (rc < 0) { - ISTGT_ERRLOG("iscsi_write() failed\n"); + ISTGT_ERRLOG("iscsi_write() failed (errno=%d,%s)\n", + errno, conn->initiator_name); return -1; } if (rc != (4 * total_ahs_len)) { @@ -909,7 +1110,8 @@ rc = istgt_iscsi_write(conn, pdu->header_digest, ISCSI_DIGEST_LEN); if (rc < 0) { - ISTGT_ERRLOG("iscsi_write() failed\n"); + ISTGT_ERRLOG("iscsi_write() failed (errno=%d,%s)\n", + errno, conn->initiator_name); return -1; } if (rc != ISCSI_DIGEST_LEN) { @@ -926,7 +1128,8 @@ data_len); rc = istgt_iscsi_write(conn, pdu->data, data_len); if (rc < 0) { - ISTGT_ERRLOG("iscsi_write() failed\n"); + ISTGT_ERRLOG("iscsi_write() failed (errno=%d,%s)\n", + errno, conn->initiator_name); return -1; } if (rc != data_len) { @@ -949,7 +1152,8 @@ rc = istgt_iscsi_write(conn, pdu->data_digest, ISCSI_DIGEST_LEN); if (rc < 0) { - ISTGT_ERRLOG("iscsi_write() failed\n"); + ISTGT_ERRLOG("iscsi_write() failed (errno=%d,%s)\n", + errno, conn->initiator_name); return -1; } if (rc != ISCSI_DIGEST_LEN) { @@ -962,6 +1166,121 @@ return total; } +#else /* defined (ISTGT_USE_IOVEC) */ +static int +istgt_iscsi_write_pdu_internal(CONN_Ptr conn, ISCSI_PDU_Ptr pdu) +{ + struct iovec iovec[5]; /* BHS+AHS+HD+DATA+DD */ + uint8_t *cp; + uint32_t crc32c; + time_t start, now; + int nbytes; + int enable_digest; + int opcode; + int total_ahs_len; + int data_len; + int total; + int rc; + int i; + + cp = (uint8_t *) &pdu->bhs; + total_ahs_len = DGET8(&cp[4]); + data_len = DGET24(&cp[5]); + total = 0; + + enable_digest = 1; + opcode = BGET8W(&cp[0], 5, 6); + if (opcode == ISCSI_OP_LOGIN_RSP) { + /* this PDU should be sent without digest */ + enable_digest = 0; + } + + /* BHS */ + iovec[0].iov_base = &pdu->bhs; + iovec[0].iov_len = ISCSI_BHS_LEN; + total += ISCSI_BHS_LEN; + + /* AHS */ + iovec[1].iov_base = pdu->ahs; + iovec[1].iov_len = 4 * total_ahs_len; + total += (4 * total_ahs_len); + + /* Header Digest */ + iovec[2].iov_base = pdu->header_digest; + if (enable_digest && conn->header_digest) { + if (total_ahs_len == 0) { + crc32c = istgt_crc32c((uint8_t *) &pdu->bhs, + ISCSI_BHS_LEN); + } else { + int upd_total = 0; + crc32c = ISTGT_CRC32C_INITIAL; + crc32c = istgt_update_crc32c((uint8_t *) &pdu->bhs, + ISCSI_BHS_LEN, crc32c); + upd_total += ISCSI_BHS_LEN; + crc32c = istgt_update_crc32c((uint8_t *) pdu->ahs, + (4 * total_ahs_len), crc32c); + upd_total += (4 * total_ahs_len); + crc32c = istgt_fixup_crc32c(upd_total, crc32c); + crc32c = crc32c ^ ISTGT_CRC32C_XOR; + } + MAKE_DIGEST_WORD(pdu->header_digest, crc32c); + + iovec[2].iov_len = ISCSI_DIGEST_LEN; + total += ISCSI_DIGEST_LEN; + } else { + iovec[2].iov_len = 0; + } + + /* Data Segment */ + iovec[3].iov_base = pdu->data; + iovec[3].iov_len = ISCSI_ALIGN(data_len); + total += ISCSI_ALIGN(data_len); + + /* Data Digest */ + iovec[4].iov_base = pdu->data_digest; + if (enable_digest && conn->data_digest && data_len != 0) { + crc32c = istgt_crc32c(pdu->data, ISCSI_ALIGN(data_len)); + MAKE_DIGEST_WORD(pdu->data_digest, crc32c); + + iovec[4].iov_len = ISCSI_DIGEST_LEN; + total += ISCSI_DIGEST_LEN; + } else { + iovec[4].iov_len = 0; + } + + /* write all bytes from iovec */ + nbytes = total; + ISTGT_TRACELOG(ISTGT_TRACE_NET, "PDU write %d\n", nbytes); + errno = 0; + start = time(NULL); + while (nbytes > 0) { + rc = writev(conn->sock, &iovec[0], 5); + if (rc < 0) { + now = time(NULL); + ISTGT_ERRLOG("writev() failed (errno=%d,%s,time=%d)\n", + errno, conn->initiator_name, (int)difftime(now, start)); + return -1; + } + nbytes -= rc; + if (nbytes == 0) + break; + /* adjust iovec length */ + for (i = 0; i < 5; i++) { + if (iovec[i].iov_len != 0 && iovec[i].iov_len > (size_t)rc) { + iovec[i].iov_base + = (void *) (((uintptr_t)iovec[i].iov_base) + rc); + iovec[i].iov_len -= rc; + break; + } else { + rc -= iovec[i].iov_len; + iovec[i].iov_len = 0; + } + } + } + + return total; +} +#endif /* defined (ISTGT_USE_IOVEC) */ int istgt_iscsi_copy_pdu(ISCSI_PDU_Ptr dst_pdu, ISCSI_PDU_Ptr src_pdu) @@ -3239,10 +3558,10 @@ if (SN32_GT(CmdSN, conn->sess->ExpCmdSN)) { if (conn->sess->connections > 1) { struct timespec abstime; - time_t now; + time_t start, now; SESS_MTX_UNLOCK(conn); - now = time(NULL); + start = now = time(NULL); memset(&abstime, 0, sizeof abstime); abstime.tv_sec = now + (MAX_MCSREVWAIT / 1000); abstime.tv_nsec = (MAX_MCSREVWAIT % 1000) * 1000000; @@ -3269,8 +3588,11 @@ } } if (rc < 0) { - ISTGT_ERRLOG("MCS: CmdSN(%u) error ExpCmdSN=%u\n", - CmdSN, conn->sess->ExpCmdSN); + now = time(NULL); + ISTGT_ERRLOG("MCS: CmdSN(%u) error ExpCmdSN=%u " + "(time=%d)\n", + CmdSN, conn->sess->ExpCmdSN, + (int)difftime(now, start)); SESS_MTX_UNLOCK(conn); return -1; } @@ -5162,7 +5484,11 @@ return NULL; } conn->kq = kq; +#if defined (ISTGT_USE_IOVEC) && defined (NOTE_LOWAT) + ISTGT_EV_SET(&kev, conn->sock, EVFILT_READ, EV_ADD, NOTE_LOWAT, ISCSI_BHS_LEN, NULL); +#else ISTGT_EV_SET(&kev, conn->sock, EVFILT_READ, EV_ADD, 0, 0, NULL); +#endif rc = kevent(kq, &kev, 1, NULL, 0, NULL); if (rc == -1) { ISTGT_ERRLOG("kevent() failed\n"); @@ -5351,7 +5677,9 @@ conn->pdu.copy_pdu = 0; rc = istgt_iscsi_read_pdu(conn, &conn->pdu); if (rc < 0) { - ISTGT_ERRLOG("conn->state = %d\n", conn->state); + if (conn->state != CONN_STATE_EXITING) { + ISTGT_ERRLOG("conn->state = %d\n", conn->state); + } if (conn->state != CONN_STATE_RUNNING) { if (errno == EINPROGRESS) { sleep(1); @@ -5788,6 +6116,14 @@ ISTGT_ERRLOG("istgt_set_sendtimeo() failed\n"); goto error_return; } +#if defined (ISTGT_USE_IOVEC) + /* set low water mark */ + rc = istgt_set_recvlowat(conn->sock, ISCSI_BHS_LEN); + if (rc != 0) { + ISTGT_ERRLOG("istgt_set_recvlowat() failed\n"); + goto error_return; + } +#endif rc = pipe(conn->task_pipe); if (rc != 0) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/istgt_log.c new/istgt-20121028/src/istgt_log.c --- old/istgt-20120901/src/istgt_log.c 2010-01-02 18:57:26.000000000 +0100 +++ new/istgt-20121028/src/istgt_log.c 2012-10-15 23:40:18.000000000 +0200 @@ -220,6 +220,22 @@ } void +istgtcontrol_open_log(void) +{ + if (g_log_facility != 0) { + openlog("istgtcontrol", LOG_PID, g_log_facility); + } else { + openlog("istgtcontrol", LOG_PID, ISTGT_LOG_FACILITY); + } +} + +void +istgtcontrol_close_log(void) +{ + closelog(); +} + +void istgt_set_trace_flag(int flag) { if (flag == ISTGT_TRACE_NONE) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/istgt_log.h new/istgt-20121028/src/istgt_log.h --- old/istgt-20120901/src/istgt_log.h 2012-07-29 01:00:11.000000000 +0200 +++ new/istgt-20121028/src/istgt_log.h 2012-10-15 23:40:18.000000000 +0200 @@ -91,6 +91,8 @@ void istgt_warnlog(const char *file, const int line, const char *func, const char *format, ...) __attribute__((__format__(__printf__, 4, 5))); void istgt_open_log(void); void istgt_close_log(void); +void istgtcontrol_open_log(void); +void istgtcontrol_close_log(void); void istgt_set_trace_flag(int flag); void istgt_trace_dump(int flag, const char *label, const uint8_t *buf, size_t len); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/istgt_lu_disk.c new/istgt-20121028/src/istgt_lu_disk.c --- old/istgt-20120901/src/istgt_lu_disk.c 2012-09-01 07:30:41.000000000 +0200 +++ new/istgt-20121028/src/istgt_lu_disk.c 2012-10-28 00:26:36.000000000 +0200 @@ -1864,6 +1864,13 @@ plen = 0x12 + 2; MODE_SENSE_PAGE_INIT(cp, plen, page, subpage); BDADD8(&cp[0], 1, 7); /* PS */ + if (pc == 0x01) { + // Changeable values + BDADD8(&cp[2], 1, 2); /* WCE */ + BDADD8(&cp[2], 1, 0); /* RCD */ + len += plen; + break; + } BDADD8(&cp[2], 1, 2); /* WCE */ //BDADD8(&cp[2], 1, 0); /* RCD */ { @@ -5088,7 +5095,7 @@ CONN_Ptr conn; ISTGT_LU_CMD_Ptr lu_cmd; struct timespec abstime; - time_t now; + time_t start, now; uint8_t *iobuf; char tmp[1]; int abort_task = 0; @@ -5257,7 +5264,7 @@ goto error_return; } - now = time(NULL); + start = now = time(NULL); abstime.tv_sec = now + (lu_task->condwait / 1000); abstime.tv_nsec = (lu_task->condwait % 1000) * 1000000; #if 0 @@ -5279,8 +5286,11 @@ spec->wait_lu_task = NULL; MTX_UNLOCK(&spec->wait_lu_task_mutex); MTX_UNLOCK(&lu_task->trans_mutex); - ISTGT_ERRLOG("timeout trans_cond CmdSN=%u\n", - lu_task->lu_cmd.CmdSN); + now = time(NULL); + ISTGT_ERRLOG("timeout trans_cond CmdSN=%u " + "(time=%d)\n", + lu_task->lu_cmd.CmdSN, + (int)difftime(now, start)); /* timeout */ return -1; } @@ -5315,8 +5325,9 @@ } if (rc == ETIMEDOUT) { lu_task->error = 1; - ISTGT_ERRLOG("timeout trans_cond CmdSN=%u\n", - lu_task->lu_cmd.CmdSN); + now = time(NULL); + ISTGT_ERRLOG("timeout trans_cond CmdSN=%u (time=%d)\n", + lu_task->lu_cmd.CmdSN, (int)difftime(now, start)); return -1; } lu_task->error = 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/istgt_lu_dvd.c new/istgt-20121028/src/istgt_lu_dvd.c --- old/istgt-20120901/src/istgt_lu_dvd.c 2012-09-01 04:19:35.000000000 +0200 +++ new/istgt-20121028/src/istgt_lu_dvd.c 2012-10-28 00:26:36.000000000 +0200 @@ -1265,6 +1265,13 @@ plen = 0x12 + 2; MODE_SENSE_PAGE_INIT(cp, plen, page, subpage); BDADD8(&cp[0], 1, 7); /* PS */ + if (pc == 0x01) { + // Changeable values + BDADD8(&cp[2], 1, 2); /* WCE */ + BDADD8(&cp[2], 1, 0); /* RCD */ + len += plen; + break; + } BDADD8(&cp[2], 1, 2); /* WCE */ //BDADD8(&cp[2], 1, 0); /* RCD */ if (spec->write_cache == 1) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/istgt_lu_tape.c new/istgt-20121028/src/istgt_lu_tape.c --- old/istgt-20120901/src/istgt_lu_tape.c 2012-09-01 04:19:35.000000000 +0200 +++ new/istgt-20121028/src/istgt_lu_tape.c 2012-10-28 00:26:36.000000000 +0200 @@ -2368,7 +2368,7 @@ /* Current values */ } else if (pc == 0x01) { /* Changeable values */ - if (page != 0x08) { + if (page != 0x0f) { /* not supported */ return -1; } @@ -2417,6 +2417,17 @@ plen = 0x0e + 2; MODE_SENSE_PAGE_INIT(cp, plen, page, subpage); + if (pc == 0x01) { + // Changeable values + BDADD8(&cp[2], 1, 7); /* DCE data compression enable */ + BDADD8(&cp[2], 1, 6); /* DCC data compression capable */ + BDADD8(&cp[3], 1, 7); /* DDE data decompression enable */ + BDADD8W(&cp[3], 0, 6, 2); /* RED report exception on decompression */ + DSET32(&cp[4], 0xffffffffU); /* COMPRESSION ALGORITHM */ + DSET32(&cp[8], 0xffffffffU); /* DECOMPRESSION ALGORITHM */ + len += plen; + break; + } if (spec->compression) { BDADD8(&cp[2], 1, 7); /* DCE=1 compression enable */ } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/istgt_sock.c new/istgt-20121028/src/istgt_sock.c --- old/istgt-20120901/src/istgt_sock.c 2012-07-29 01:00:11.000000000 +0200 +++ new/istgt-20121028/src/istgt_sock.c 2012-10-28 00:26:36.000000000 +0200 @@ -41,6 +41,7 @@ #include <netinet/tcp.h> #include "istgt.h" +#include "istgt_log.h" #include "istgt_sock.h" #include "istgt_misc.h" @@ -70,11 +71,13 @@ salen = sizeof sa; rc = getsockname(sock, (struct sockaddr *) &sa, &salen); if (rc != 0) { + ISTGT_ERRLOG("getsockname() failed (errno=%d)\n", errno); return -1; } rc = getnameinfo((struct sockaddr *) &sa, salen, saddr, slen, NULL, 0, NI_NUMERICHOST); if (rc != 0) { + ISTGT_ERRLOG("getnameinfo() failed (errno=%d)\n", errno); return -1; } @@ -82,11 +85,13 @@ salen = sizeof sa; rc = getpeername(sock, (struct sockaddr *) &sa, &salen); if (rc != 0) { + ISTGT_ERRLOG("getpeername() failed (errno=%d)\n", errno); return -1; } rc = getnameinfo((struct sockaddr *) &sa, salen, caddr, clen, NULL, 0, NI_NUMERICHOST); if (rc != 0) { + ISTGT_ERRLOG("getnameinfo() failed (errno=%d)\n", errno); return -1; } @@ -131,6 +136,7 @@ hints.ai_flags |= AI_NUMERICHOST; rc = getaddrinfo(ip, portnum, &hints, &res0); if (rc != 0) { + ISTGT_ERRLOG("getaddrinfo() failed (errno=%d)\n", errno); return -1; } @@ -219,6 +225,7 @@ hints.ai_flags = AI_NUMERICSERV; rc = getaddrinfo(host, portnum, &hints, &res0); if (rc != 0) { + ISTGT_ERRLOG("getaddrinfo() failed (errno=%d)\n", errno); return -1; } @@ -288,6 +295,19 @@ if (rc != 0) return -1; return 0; +} + +int +istgt_set_recvlowat(int s, int nbytes) +{ + int val; + int rc; + + val = nbytes; + rc = setsockopt(s, SOL_SOCKET, SO_RCVLOWAT, &val, sizeof val); + if (rc != 0) + return -1; + return 0; } #ifdef USE_POLLWAIT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/istgt_sock.h new/istgt-20121028/src/istgt_sock.h --- old/istgt-20120901/src/istgt_sock.h 2010-01-02 18:57:26.000000000 +0100 +++ new/istgt-20121028/src/istgt_sock.h 2012-10-28 00:26:36.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2010 Daisuke Aoyama <aoyama@peach.ne.jp>. + * Copyright (C) 2008-2012 Daisuke Aoyama <aoyama@peach.ne.jp>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,6 +36,7 @@ int istgt_connect(const char *host, int port); int istgt_set_recvtimeout(int s, int msec); int istgt_set_sendtimeout(int s, int msec); +int istgt_set_recvlowat(int s, int nbytes); ssize_t istgt_read_socket(int s, void *buf, size_t nbytes, int timeout); ssize_t istgt_write_socket(int s, const void *buf, size_t nbytes, int timeout); ssize_t istgt_readline_socket(int sock, char *buf, size_t size, char *tmp, size_t tmpsize, int *tmpidx, int *tmpcnt, int timeout); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/istgt_ver.h new/istgt-20121028/src/istgt_ver.h --- old/istgt-20120901/src/istgt_ver.h 2012-09-01 04:19:35.000000000 +0200 +++ new/istgt-20121028/src/istgt_ver.h 2012-10-28 00:26:36.000000000 +0200 @@ -29,6 +29,6 @@ #define ISTGT_VER_H #define ISTGT_VERSION "0.5" -#define ISTGT_EXTRA_VERSION "20120901" +#define ISTGT_EXTRA_VERSION "20121028" #endif /* ISTGT_VER_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/istgt-20120901/src/istgtcontrol.c new/istgt-20121028/src/istgtcontrol.c --- old/istgt-20120901/src/istgtcontrol.c 2012-08-14 21:52:53.000000000 +0200 +++ new/istgt-20121028/src/istgtcontrol.c 2012-10-15 23:40:18.000000000 +0200 @@ -40,6 +40,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <syslog.h> #include <sys/types.h> #include "istgt.h" @@ -993,6 +994,9 @@ uctl->req_auth_auto = 1; uctl->req_auth = 0; uctl->req_auth_mutual = 0; + } else if (strcasecmp(val, "None") == 0) { + uctl->req_auth = 0; + uctl->req_auth_mutual = 0; } else { fprintf(stderr, "unknown auth\n"); return -1; @@ -1208,6 +1212,8 @@ uctl->config = config; //istgt_print_config(config); + istgtcontrol_open_log(); + /* take specified command */ if (argc < 1) { error_usage_return: @@ -1256,7 +1262,12 @@ } /* build parameters */ - uctl_init(uctl); + rc = uctl_init(uctl); + if (rc < 0) { + fprintf(stderr, "uctl_init() failed\n"); + istgt_free_config(config); + exit(EXIT_FAILURE); + } uctl->recvtmpcnt = 0; uctl->recvtmpidx = 0; uctl->recvtmpsize = sizeof uctl->recvtmp; @@ -1443,6 +1454,7 @@ xfree(banner); xfree(cmd); istgt_free_config(config); + istgtcontrol_close_log(); /* return value as execution result */ if (exec_result != UCTL_CMD_OK) { -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org