Hello community,

here is the log from the commit of package istgt for openSUSE:Factory checked 
in at 2012-09-11 09:08:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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-08-14 
14:26:49.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.istgt.new/istgt.changes 2012-09-11 
09:08:14.000000000 +0200
@@ -1,0 +2,28 @@
+Mon Sep  3 16:18:19 UTC 2012 - [email protected]
+
+- Update to upstream istgt-20120901.tar.gz release.
+  + Remove linux init script patches, now upstream.
+
+- Japanese -> English ChangeLog.jp via Google Translate:
+  + Changed to return INVALID FIELD IN CDB to MODE_SENSE unsupported
+  + Change so as to release resources after the end of the confirmation signal
+    thread
+  + Changed to not issue a malloc each time ATS
+  + Add (12) READ DEFECT DATA (10) / READ DEFECT DATA
+  + Add (12) (16) / ATA PASS-THROUGH ATA PASS-THROUGH dummy
+  + Add LOG_SELECT / LOG_SENSE of dummy
+  + Add the init scripts of Linux
+  + If you fail at reload of LU added the processing settings back
+  + Add qcow, qcow2, qed, an extension to handle vhdx
+  + 4.2.X VirtualBox support
+  + Add a poll to display when not in use kqueue
+  + Record usage of atomic functions at startup
+  + investigation gcc configure the built-in function
+  + Fix leak of mutex change
+  + Mistake correction of the error message
+  + Add a dummy signal function
+  + Change the position of the command loop termination
+  + Since the built-in function exclusion gcc gives an error on i386
+  + Fixed a warning will be issued in the gcc parts
+
+-------------------------------------------------------------------

Old:
----
  add-linux-rc.patch
  istgt-20120811.tar.gz
  linux-rc-reload.patch
  no_CMPXCHG_on_i386.patch

New:
----
  istgt-20120901.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ istgt.spec ++++++
--- /var/tmp/diff_new_pack.8K5ZV9/_old  2012-09-11 09:08:17.000000000 +0200
+++ /var/tmp/diff_new_pack.8K5ZV9/_new  2012-09-11 09:08:17.000000000 +0200
@@ -17,9 +17,9 @@
 
 
 Name:           istgt
-Version:        0.7
-Release:        20120811
-%define upstreamrel 20120811
+Version:        0.8
+Release:        20120901
+%define upstreamrel 20120901
 Summary:        Userspace iSCSI Target
 License:        BSD-2-Clause
 Group:          Productivity/Networking/Other
@@ -35,9 +35,6 @@
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 Patch1:                fix-installdir.patch
 Patch2:                add-istgtcontrol-manpage.patch
-Patch6:                add-linux-rc.patch
-Patch7:                linux-rc-reload.patch
-Patch8:                no_CMPXCHG_on_i386.patch
 
 %description
 This software (istgt) is the implementation of iSCSI target
@@ -59,9 +56,6 @@
 %setup -q -n istgt-%{upstreamrel}
 %patch1 -p1
 %patch2 -p1
-%patch6 -p1
-%patch7 -p1
-%patch8 -p1
 autoconf
 %configure
 

++++++ istgt-20120811.tar.gz -> istgt-20120901.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/ChangeLog.jp 
new/istgt-20120901/ChangeLog.jp
--- old/istgt-20120811/ChangeLog.jp     2012-08-10 17:11:54.000000000 +0200
+++ new/istgt-20120901/ChangeLog.jp     2012-09-01 04:19:35.000000000 +0200
@@ -1,3 +1,41 @@
+2012/09/01
+       2012/09/01版
+       サポート外のMODE_SENSEにINVALID FIELD IN CDBを返すように変更
+
+2012/08/28
+       2012/08/28版
+       シグナルスレッドの終了確認後にリソース解放するように変更
+
+2012/08/27
+       ATSで毎回mallocを発行しないよう変更
+
+2012/08/24
+       READ DEFECT DATA(10)/READ DEFECT DATA(12)を追加
+       ダミーのATA PASS-THROUGH(16)/ATA PASS-THROUGH(12)を追加
+       ダミーのLOG_SELECT/LOG_SENSEを追加
+       Linuxのinitスクリプトを追加
+       (Thanks to David Disseldorp)
+
+2012/08/21
+       LUのreload時に失敗した場合は設定を戻す処理を追加
+
+2012/08/19
+       処理する拡張子に qcow, qcow2, qed, vhdx を追加
+       VirtualBox 4.2.X 対応
+       kqueue未使用時にpoll表示を追加
+       起動時にアトミック関数の利用状況を記録
+       gccビルトイン関数をconfigureで調査
+       mutexの変更漏れを修正
+       エラーメッセージの間違い修正
+
+2012/08/13
+       ダミーのシグナル関数を追加
+       ループ終了コマンドの位置を変更
+
+2012/08/12
+       i386でgccビルトイン関数がエラーを出すので除外
+       gccで警告が出る部分を修正
+
 2012/08/11
        2012/08/11版
        shutdown関数をvbox用で分離
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/configure new/istgt-20120901/configure
--- old/istgt-20120811/configure        2012-08-09 14:19:36.000000000 +0200
+++ new/istgt-20120901/configure        2012-08-24 12:19:24.000000000 +0200
@@ -3384,9 +3384,13 @@
 
 case "$host_os" in
 *linux*)
-       vboxinc="/usr/src/virtualbox/*/include"
+       tmp="/usr/src/virtualbox/*/include"
+       if test -d "`echo $tmp`"; then
+           vboxinc=$tmp
+       fi
        vboxlib="/usr/lib/virtualbox"
-       #AC_SUBST([rctemplate], ["istgt_linux.sh.in"])
+       rctemplate="istgt_linux.sh.in"
+
        rcdir='/etc/init.d'
 
 
@@ -4927,6 +4931,27 @@
 
 $as_echo "#define USE_VBOXVD 1" >>confdefs.h
 
+    # define vbox include version
+
+    vbox_major=`$SED -e '/^VBOX_VERSION_MAJOR[         ]*=/!d' -e 
's/.*=[^0-9]*\([0-9]*\).*/\1/' $vboxinc/../Config.kmk`
+    vbox_minor=`$SED -e '/^VBOX_VERSION_MINOR[         ]*=/!d' -e 
's/.*=[^0-9]*\([0-9]*\).*/\1/' $vboxinc/../Config.kmk`
+    vbox_build=`$SED -e '/^VBOX_VERSION_BUILD[         ]*=/!d' -e 
's/.*=[^0-9]*\([0-9]*\).*/\1/' $vboxinc/../Config.kmk`
+
+
+cat >>confdefs.h <<_ACEOF
+#define ISTGT_VBOXINC_VERSION_MAJOR $vbox_major
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define ISTGT_VBOXINC_VERSION_MINOR $vbox_minor
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define ISTGT_VBOXINC_VERSION_BUILD $vbox_build
+_ACEOF
+
 fi
 
 # check for PTHREAD_MUTEX_ADAPTIVE_NP
@@ -5113,6 +5138,75 @@
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $atomic" >&5
 $as_echo "$atomic" >&6; }
 
+# for gcc builtin
+#AC_CHECK_FUNCS([__sync_fetch_and_add __sync_val_compare_and_swap])
+#AC_CHECK_FUNCS([__sync_synchronize])
+
+gcc_atomic="no"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc builtin atomic 
operations" >&5
+$as_echo_n "checking for gcc builtin atomic operations... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+int
+main ()
+{
+
+       unsigned int x, y;
+       y = __sync_fetch_and_add(&x, 0);
+       __sync_val_compare_and_swap(&x, y, 2);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+$as_echo "#define USE_GCC_ATOMIC 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_GCC_ATOMIC_FETCH_AND_ADD_UINT 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_GCC_ATOMIC_VAL_COMPARE_AND_SWAP_UINT 1" >>confdefs.h
+
+gcc_atomic="yes"
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+int
+main ()
+{
+
+       __sync_synchronize();
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+$as_echo "#define HAVE_GCC_ATOMIC_SYNCHRONIZE 1" >>confdefs.h
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_atomic" >&5
+$as_echo "$gcc_atomic" >&6; }
+
 ac_config_files="$ac_config_files Makefile src/Makefile etc/Makefile 
doc/Makefile"
 
 ac_config_files="$ac_config_files src/build.h"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/configure.in 
new/istgt-20120901/configure.in
--- old/istgt-20120811/configure.in     2012-08-09 14:19:36.000000000 +0200
+++ new/istgt-20120901/configure.in     2012-08-24 12:18:04.000000000 +0200
@@ -26,9 +26,12 @@
 AC_CANONICAL_HOST
 case "$host_os" in
 *linux*)
-       vboxinc="/usr/src/virtualbox/*/include"
+       tmp="/usr/src/virtualbox/*/include"
+       if test -d "`echo $tmp`"; then
+           vboxinc=$tmp
+       fi
        vboxlib="/usr/lib/virtualbox"
-       #AC_SUBST([rctemplate], ["istgt_linux.sh.in"])
+       AC_SUBST([rctemplate], ["istgt_linux.sh.in"])
        AC_SUBST([rcdir], ['/etc/init.d'])
        AC_DEFINE([_GNU_SOURCE], 1, [Define if linux host])
        ;;
@@ -260,6 +263,15 @@
     LDFLAGS="$LDFLAGS -Wl,-rpath,$vboxlib"
     LIBS="$LIBS $vboxlib/VBoxDDU.so $vboxlib/VBoxRT.so"
     AC_DEFINE([USE_VBOXVD], 1, [Use vbox virtual disk support])
+    # define vbox include version
+    changequote(<<, >>)
+    vbox_major=`$SED -e '/^VBOX_VERSION_MAJOR[         ]*=/!d' -e 
's/.*=[^0-9]*\([0-9]*\).*/\1/' $vboxinc/../Config.kmk`
+    vbox_minor=`$SED -e '/^VBOX_VERSION_MINOR[         ]*=/!d' -e 
's/.*=[^0-9]*\([0-9]*\).*/\1/' $vboxinc/../Config.kmk`
+    vbox_build=`$SED -e '/^VBOX_VERSION_BUILD[         ]*=/!d' -e 
's/.*=[^0-9]*\([0-9]*\).*/\1/' $vboxinc/../Config.kmk`
+    changequote([, ])
+    AC_DEFINE_UNQUOTED([ISTGT_VBOXINC_VERSION_MAJOR], [$vbox_major], [VBox 
include major])
+    AC_DEFINE_UNQUOTED([ISTGT_VBOXINC_VERSION_MINOR], [$vbox_minor], [VBox 
include minor])
+    AC_DEFINE_UNQUOTED([ISTGT_VBOXINC_VERSION_BUILD], [$vbox_build], [VBox 
include build])
 fi
 
 # check for PTHREAD_MUTEX_ADAPTIVE_NP
@@ -340,6 +352,39 @@
 )
 AC_MSG_RESULT($atomic)
 
+# for gcc builtin
+#AC_CHECK_FUNCS([__sync_fetch_and_add __sync_val_compare_and_swap])
+#AC_CHECK_FUNCS([__sync_synchronize])
+
+gcc_atomic="no"
+AC_MSG_CHECKING([for gcc builtin atomic operations])
+AC_TRY_LINK([
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+],
+[
+       unsigned int x, y;
+       y = __sync_fetch_and_add(&x, 0);
+       __sync_val_compare_and_swap(&x, y, 2);
+],
+[AC_DEFINE([USE_GCC_ATOMIC], [1], [Use gcc builtin atomic])
+AC_DEFINE([HAVE_GCC_ATOMIC_FETCH_AND_ADD_UINT], [1], [Define 1 if you have the 
function.])
+AC_DEFINE([HAVE_GCC_ATOMIC_VAL_COMPARE_AND_SWAP_UINT], [1], [Define 1 if you 
have the function.])
+gcc_atomic="yes"]
+)
+AC_TRY_LINK([
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+],
+[
+       __sync_synchronize();
+],
+[AC_DEFINE([HAVE_GCC_ATOMIC_SYNCHRONIZE], [1], [Define 1 if you have the 
function.])]
+)
+AC_MSG_RESULT($gcc_atomic)
+
 AC_CONFIG_FILES([Makefile src/Makefile etc/Makefile doc/Makefile])
 AC_CONFIG_FILES([src/build.h])
 AC_OUTPUT
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/etc/Makefile.in 
new/istgt-20120901/etc/Makefile.in
--- old/istgt-20120811/etc/Makefile.in  2012-07-28 21:45:50.000000000 +0200
+++ new/istgt-20120901/etc/Makefile.in  2012-08-24 12:18:04.000000000 +0200
@@ -25,7 +25,7 @@
 document = 
 sample   = auth.conf istgtcontrol.conf \
        istgt.large.conf.in istgt.conf.in \
-       istgt.sh.in istgt_netbsd.sh.in # istgt_linux.sh.in
+       istgt.sh.in istgt_netbsd.sh.in istgt_linux.sh.in
 rctemplate = @rctemplate@
 rcdir    = @rcdir@
 rcfile   = $(rctemplate:.sh.in=.sh)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/etc/istgt_linux.sh.in 
new/istgt-20120901/etc/istgt_linux.sh.in
--- old/istgt-20120811/etc/istgt_linux.sh.in    1970-01-01 01:00:00.000000000 
+0100
+++ new/istgt-20120901/etc/istgt_linux.sh.in    2012-08-24 12:18:04.000000000 
+0200
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+### BEGIN INIT INFO
+# Provides:       istgt
+# Required-Start: $remote_fs $syslog $named
+# Required-Stop:  $remote_fs $syslog
+# Should-Start: network-remotefs
+# Should-Stop: network-remotefs
+# Default-Start:  3 5
+# Default-Stop:   0 1 2 6
+# Short-Description: Userspace iSCSI target daemon
+# Description: Userspace iSCSI target daemon
+### END INIT INFO
+
+. /etc/rc.status
+rc_reset
+
+name="istgt"
+
+: ${istgt_config="%%SYSCONFDIR%%/istgt/istgt.conf"}
+: ${istgt_pidfile="/var/run/istgt.pid"}
+: ${istgt_flags=""}
+
+required_files="${istgt_config}"
+pidfile="${istgt_pidfile}"
+command="%%SBINDIR%%/istgt"
+command_args="-c ${istgt_config} ${istgt_flags}"
+
+case "$1" in
+       start)
+               echo "Starting iSCSI target daemon (${name})"
+               startproc $command $command_args
+               rc_status -v
+               ;;
+       stop)
+               echo "Shutting down iSCSI target daemon (${name})"
+               killproc -p $istgt_pidfile -TERM $command
+               rc_status -v
+               rm -f $istgt_pidfile 2>/dev/null
+               ;;
+       restart)
+               $0 stop
+               $0 start
+               rc_status
+               ;;
+       force-reload|reload)
+               echo "Reloading iSCSI target daemon (${name})"
+               killproc -p $istgt_pidfile -HUP $command
+               rc_status -v
+               ;;
+       status)
+               echo "Checking for iSCSI target daemon (${name})"
+               checkproc -p $istgt_pidfile $command
+               rc_status -v
+               ;;
+       *)
+               echo "Usage: $0 {start|stop|restart|status}"
+               exit 1
+               ;;
+esac
+
+rc_exit
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/config.h.in 
new/istgt-20120901/src/config.h.in
--- old/istgt-20120811/src/config.h.in  2012-08-09 14:19:36.000000000 +0200
+++ new/istgt-20120901/src/config.h.in  2012-08-19 06:51:15.000000000 +0200
@@ -39,6 +39,15 @@
 /* Define to 1 if you have the `ftruncate' function. */
 #undef HAVE_FTRUNCATE
 
+/* Define 1 if you have the function. */
+#undef HAVE_GCC_ATOMIC_FETCH_AND_ADD_UINT
+
+/* Define 1 if you have the function. */
+#undef HAVE_GCC_ATOMIC_SYNCHRONIZE
+
+/* Define 1 if you have the function. */
+#undef HAVE_GCC_ATOMIC_VAL_COMPARE_AND_SWAP_UINT
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -192,6 +201,15 @@
 /* Define to 1 if you have the <uuid.h> header file. */
 #undef HAVE_UUID_H
 
+/* VBox include build */
+#undef ISTGT_VBOXINC_VERSION_BUILD
+
+/* VBox include major */
+#undef ISTGT_VBOXINC_VERSION_MAJOR
+
+/* VBox include minor */
+#undef ISTGT_VBOXINC_VERSION_MINOR
+
 /* Define to 1 if `lstat' dereferences a symlink specified with a trailing
    slash. */
 #undef LSTAT_FOLLOWS_SLASHED_SYMLINK
@@ -220,6 +238,9 @@
 /* Use atomic */
 #undef USE_ATOMIC
 
+/* Use gcc builtin atomic */
+#undef USE_GCC_ATOMIC
+
 /* Use vbox virtual disk support */
 #undef USE_VBOXVD
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt.c 
new/istgt-20120901/src/istgt.c
--- old/istgt-20120811/src/istgt.c      2012-08-09 14:19:36.000000000 +0200
+++ new/istgt-20120901/src/istgt.c      2012-08-27 22:19:22.000000000 +0200
@@ -1762,7 +1762,14 @@
        while (istgt->pg_reload == 0) {
                pthread_cond_wait(&istgt->reload_cond, &istgt->reload_mutex);
        }
+       rc = istgt->pg_reload;
        MTX_UNLOCK(&istgt->reload_mutex);
+       if (rc < 0) {
+               if (istgt_get_state(istgt) != ISTGT_STATE_RUNNING) {
+                       ISTGT_WARNLOG("pg_reload abort\n");
+                       return -1;
+               }
+       }
        return 0;
 }
 
@@ -1788,7 +1795,14 @@
        while (istgt->pg_reload == 0) {
                pthread_cond_wait(&istgt->reload_cond, &istgt->reload_mutex);
        }
+       rc = istgt->pg_reload;
        MTX_UNLOCK(&istgt->reload_mutex);
+       if (rc < 0) {
+               if (istgt_get_state(istgt) != ISTGT_STATE_RUNNING) {
+                       ISTGT_WARNLOG("pg_reload abort\n");
+                       return -1;
+               }
+       }
        return 0;
 }
 
@@ -2001,6 +2015,21 @@
 }
 
 
+static void
+istgt_sigint(int signo __attribute__((__unused__)))
+{
+}
+
+static void
+istgt_sigterm(int signo __attribute__((__unused__)))
+{
+}
+
+static void
+istgt_sighup(int signo __attribute__((__unused__)))
+{
+}
+
 #ifdef SIGINFO
 static void
 istgt_siginfo(int signo __attribute__((__unused__)))
@@ -2052,15 +2081,15 @@
                switch (signo) {
                case SIGINT:
                        printf("SIGINT catch\n");
+                       istgt_stop_loop(istgt);
                        istgt_set_state(istgt, ISTGT_STATE_EXITING);
                        istgt_lu_set_all_state(istgt, ISTGT_STATE_EXITING);
-                       istgt_stop_loop(istgt);
                        break;
                case SIGTERM:
                        printf("SIGTERM catch\n");
+                       istgt_stop_loop(istgt);
                        istgt_set_state(istgt, ISTGT_STATE_EXITING);
                        istgt_lu_set_all_state(istgt, ISTGT_STATE_EXITING);
-                       istgt_stop_loop(istgt);
                        break;
                case SIGQUIT:
                        printf("SIGQUIT catch\n");
@@ -2571,6 +2600,7 @@
 #endif /* ISTGT_USE_KQUEUE */
        ISTGT_TRACELOG(ISTGT_TRACE_DEBUG, "loop ended\n");
        istgt_set_state(istgt, ISTGT_STATE_EXITING);
+       istgt_lu_set_all_state(istgt, ISTGT_STATE_EXITING);
 
        return 0;
 }
@@ -2603,7 +2633,8 @@
        const char *logpriority = NULL;
        CONFIG *config;
        pthread_t sigthread;
-       struct sigaction sigact, sigoldact_pipe, sigoldact_info;
+       struct sigaction sigact, sigoldact_pipe, sigoldact_int, sigoldact_term;
+       struct sigaction sigoldact_hup, sigoldact_info;
        struct sigaction sigoldact_wakeup, sigoldact_io;
        sigset_t signew, sigold;
        int retry = 10;
@@ -2738,7 +2769,16 @@
        }
 #ifdef ISTGT_USE_KQUEUE
        ISTGT_NOTICELOG("using kqueue\n");
+#else
+       ISTGT_NOTICELOG("using poll\n");
 #endif /* ISTGT_USE_KQUEUE */
+#ifdef USE_ATOMIC
+       ISTGT_NOTICELOG("using host atomic\n");
+#elif defined (USE_GCC_ATOMIC)
+       ISTGT_NOTICELOG("using gcc atomic\n");
+#else
+       ISTGT_NOTICELOG("using generic atomic\n");
+#endif /* USE_ATOMIC */
 
 #ifdef ISTGT_USE_CRC32C_TABLE
        /* build crc32c table */
@@ -2786,6 +2826,9 @@
        ISTGT_TRACELOG(ISTGT_TRACE_DEBUG, "setup signal handler\n");
        memset(&sigact, 0, sizeof sigact);
        memset(&sigoldact_pipe, 0, sizeof sigoldact_pipe);
+       memset(&sigoldact_int, 0, sizeof sigoldact_int);
+       memset(&sigoldact_term, 0, sizeof sigoldact_term);
+       memset(&sigoldact_hup, 0, sizeof sigoldact_hup);
        memset(&sigoldact_info, 0, sizeof sigoldact_info);
        memset(&sigoldact_wakeup, 0, sizeof sigoldact_wakeup);
        memset(&sigoldact_io, 0, sizeof sigoldact_io);
@@ -2796,6 +2839,27 @@
                ISTGT_ERRLOG("sigaction(SIGPIPE) failed\n");
                goto initialize_error;
        }
+       sigact.sa_handler = istgt_sigint;
+       sigemptyset(&sigact.sa_mask);
+       rc = sigaction(SIGINT, &sigact, &sigoldact_int);
+       if (rc < 0) {
+               ISTGT_ERRLOG("sigaction(SIGINT) failed\n");
+               goto initialize_error;
+       }
+       sigact.sa_handler = istgt_sigterm;
+       sigemptyset(&sigact.sa_mask);
+       rc = sigaction(SIGTERM, &sigact, &sigoldact_term);
+       if (rc < 0) {
+               ISTGT_ERRLOG("sigaction(SIGTERM) failed\n");
+               goto initialize_error;
+       }
+       sigact.sa_handler = istgt_sighup;
+       sigemptyset(&sigact.sa_mask);
+       rc = sigaction(SIGHUP, &sigact, &sigoldact_hup);
+       if (rc < 0) {
+               ISTGT_ERRLOG("sigaction(SIGHUP) failed\n");
+               goto initialize_error;
+       }
 #ifdef SIGINFO
        sigact.sa_handler = istgt_siginfo;
        sigemptyset(&sigact.sa_mask);
@@ -2927,6 +2991,13 @@
        ISTGT_NOTICELOG("istgt version %s (%s) exiting\n", ISTGT_VERSION,
            ISTGT_EXTRA_VERSION);
 
+       /* stop signal thread */
+       rc = pthread_join(sigthread, NULL);
+       if (rc != 0) {
+               ISTGT_ERRLOG("pthread_join() failed\n");
+               exit (EXIT_FAILURE);
+       }
+
        /* cleanup */
        istgt_close_all_portals(istgt);
        istgt_close_uctl_portal(istgt);
@@ -2939,12 +3010,5 @@
        istgt_free_config(config);
        istgt->state = ISTGT_STATE_SHUTDOWN;
 
-       /* stop signal thread */
-       rc = pthread_join(sigthread, NULL);
-       if (rc != 0) {
-               ISTGT_ERRLOG("pthread_join() failed\n");
-               exit (EXIT_FAILURE);
-       }
-
        return 0;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt.h 
new/istgt-20120901/src/istgt.h
--- old/istgt-20120811/src/istgt.h      2012-08-09 14:19:36.000000000 +0200
+++ new/istgt-20120901/src/istgt.h      2012-08-18 23:04:12.000000000 +0200
@@ -311,8 +311,8 @@
 #error "no atomic operation"
 #endif
 }
-#else /* !USE_ATOMIC */
-#if ISTGT_GNUC_PREREQ(4, 1)
+#elif defined (USE_GCC_ATOMIC)
+/* gcc >= 4.1 builtin functions */
 static inline __attribute__((__always_inline__)) int
 istgt_get_state(ISTGT_Ptr istgt)
 {
@@ -328,9 +328,11 @@
                state_old = __sync_fetch_and_add((unsigned int *)&istgt->state, 
0);
        } while (__sync_val_compare_and_swap((unsigned int *)&istgt->state,
                state_old, state) != state_old);
+#if defined (HAVE_GCC_ATOMIC_SYNCHRONIZE)
        __sync_synchronize();
+#endif
 }
-#else /* GCC < 4.1 */
+#else /* !USE_ATOMIC && !USE_GCC_ATOMIC */
 static inline __attribute__((__always_inline__)) int
 istgt_get_state(ISTGT_Ptr istgt)
 {
@@ -348,7 +350,6 @@
        istgt->state = state;
        MTX_UNLOCK(&istgt->state_mutex);
 }
-#endif /* GCC >= 4.1 */
 #endif /* USE_ATOMIC */
 
 #endif /* ISTGT_H */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_conf.c 
new/istgt-20120901/src/istgt_conf.c
--- old/istgt-20120811/src/istgt_conf.c 2010-01-02 18:57:26.000000000 +0100
+++ new/istgt-20120901/src/istgt_conf.c 2012-08-24 12:18:04.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2010 Daisuke Aoyama <[email protected]>.
+ * Copyright (C) 2008-2012 Daisuke Aoyama <[email protected]>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,8 @@
 static void istgt_free_all_cf_section(CF_SECTION *sp);
 static void istgt_free_all_cf_item(CF_ITEM *ip);
 static void istgt_free_all_cf_value(CF_VALUE *vp);
+static void istgt_append_cf_item(CF_SECTION *sp, CF_ITEM *ip);
+static void istgt_append_cf_value(CF_ITEM *ip, CF_VALUE *vp);
 
 CONFIG *
 istgt_allocate_config(void)
@@ -185,6 +187,34 @@
        }
 }
 
+void
+istgt_copy_cf_item(CF_SECTION *sp_dst, CF_SECTION *sp_src)
+{
+       CF_ITEM *ip, *ip_old;
+       CF_VALUE *vp, *vp_old;
+
+       istgt_free_all_cf_item(sp_dst->item);
+       sp_dst->item = NULL;
+
+       ip_old = sp_src->item;
+       while (ip_old != NULL) {
+               ip = istgt_allocate_cf_item();
+               istgt_append_cf_item(sp_dst, ip);
+               ip->key = xstrdup(ip_old->key);
+               ip->val = NULL;
+
+               vp_old = ip_old->val;
+               while (vp_old != NULL) {
+                       vp = istgt_allocate_cf_value();
+                       istgt_append_cf_value(ip, vp);
+                       vp->value = xstrdup(vp_old->value);
+
+                       vp_old = vp_old->next;
+               }
+               ip_old = ip_old->next;
+       }
+}
+
 CF_SECTION *
 istgt_find_cf_section(CONFIG *cp, const char *name)
 {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_conf.h 
new/istgt-20120901/src/istgt_conf.h
--- old/istgt-20120811/src/istgt_conf.h 2010-01-02 18:57:26.000000000 +0100
+++ new/istgt-20120901/src/istgt_conf.h 2012-08-24 12:18:04.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2010 Daisuke Aoyama <[email protected]>.
+ * Copyright (C) 2008-2012 Daisuke Aoyama <[email protected]>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -69,6 +69,7 @@
 
 CONFIG *istgt_allocate_config(void);
 void istgt_free_config(CONFIG *cp);
+void istgt_copy_cf_item(CF_SECTION *sp_dst, CF_SECTION *sp_src);
 CF_SECTION *istgt_find_cf_section(CONFIG *cp, const char *name);
 CF_ITEM *istgt_find_cf_nitem(CF_SECTION *sp, const char *key, int idx);
 CF_ITEM *istgt_find_cf_item(CF_SECTION *sp, const char *key);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_iscsi.c 
new/istgt-20120901/src/istgt_iscsi.c
--- old/istgt-20120811/src/istgt_iscsi.c        2012-08-09 14:19:36.000000000 
+0200
+++ new/istgt-20120901/src/istgt_iscsi.c        2012-08-18 23:04:12.000000000 
+0200
@@ -5821,7 +5821,7 @@
                ISTGT_ERRLOG("cond_init() failed\n");
                goto error_return;
        }
-       rc = pthread_mutex_init(&conn->r2t_mutex, NULL);
+       rc = pthread_mutex_init(&conn->r2t_mutex, &istgt->mutex_attr);
        if (rc != 0) {
                ISTGT_ERRLOG("mutex_init() failed\n");
                goto error_return;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_lu.c 
new/istgt-20120901/src/istgt_lu.c
--- old/istgt-20120811/src/istgt_lu.c   2012-08-09 14:19:36.000000000 +0200
+++ new/istgt-20120901/src/istgt_lu.c   2012-08-24 12:18:04.000000000 +0200
@@ -2281,6 +2281,18 @@
        return 1;
 }
 
+static int
+istgt_lu_copy_sp(CF_SECTION *sp, CONFIG *config_old)
+{
+       CF_SECTION *sp_old;
+
+       sp_old = istgt_find_cf_section(config_old, sp->name);
+       if (sp_old == NULL)
+               return -1;
+       istgt_copy_cf_item(sp, sp_old);
+       return 0;
+}
+
 static int istgt_lu_create_thread(ISTGT_Ptr istgt, ISTGT_LU_Ptr lu);
 
 int
@@ -2361,6 +2373,10 @@
                                                ISTGT_ERRLOG("update active 
LU%d: Name=%s, "
                                                    "# of TSIH=%d\n",
                                                    lu->num, lu->name, 
lu->maxtsih - 1);
+                                               rc = istgt_lu_copy_sp(sp, 
istgt->config_old);
+                                               if (rc < 0) {
+                                                       /* ignore error */
+                                               }
                                                MTX_UNLOCK(&lu->mutex);
                                                MTX_UNLOCK(&istgt->mutex);
                                                goto skip_lu;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_lu.h 
new/istgt-20120901/src/istgt_lu.h
--- old/istgt-20120811/src/istgt_lu.h   2012-08-09 00:48:09.000000000 +0200
+++ new/istgt-20120901/src/istgt_lu.h   2012-08-27 13:46:50.000000000 +0200
@@ -92,6 +92,7 @@
 #define MAX_INQUIRY_SERIAL 16
 
 #define ISTGT_LU_WORK_BLOCK_SIZE (1ULL * 1024ULL * 1024ULL)
+#define ISTGT_LU_WORK_ATS_BLOCK_SIZE (1ULL * 1024ULL * 1024ULL)
 #define ISTGT_LU_MAX_WRITE_CACHE_SIZE (8ULL * 1024ULL * 1024ULL)
 #define ISTGT_LU_MEDIA_SIZE_MIN (1ULL * 1024ULL * 1024ULL)
 #define ISTGT_LU_MEDIA_EXTEND_UNIT (256ULL * 1024ULL * 1024ULL)
@@ -369,6 +370,8 @@
 
        /* for ats */
        pthread_mutex_t ats_mutex;
+       int watssize;
+       uint8_t *watsbuf;
 
        int queue_depth;
        pthread_mutex_t cmd_queue_mutex;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_lu_disk.c 
new/istgt-20120901/src/istgt_lu_disk.c
--- old/istgt-20120811/src/istgt_lu_disk.c      2012-08-10 17:11:54.000000000 
+0200
+++ new/istgt-20120901/src/istgt_lu_disk.c      2012-09-01 07:30:41.000000000 
+0200
@@ -430,6 +430,15 @@
        if (n > 5 && strcasecmp(file + (n - 5), ".vmdk") == 0)
                return "VMDK";
 
+       if (n > 5 && strcasecmp(file + (n - 5), ".qcow") == 0)
+               return "QCOW";
+       if (n > 6 && strcasecmp(file + (n - 6), ".qcow2") == 0)
+               return "QCOW";
+       if (n > 4 && strcasecmp(file + (n - 4), ".qed") == 0)
+               return "QED";
+       if (n > 5 && strcasecmp(file + (n - 5), ".vhdx") == 0)
+               return "VHDX";
+
        return "RAW";
 }
 
@@ -496,6 +505,8 @@
                spec->req_write_cache = 0;
                spec->err_write_cache = 0;
                spec->thin_provisioning = 0;
+               spec->watssize = 0;
+               spec->watsbuf = NULL;
 
                rc = pthread_mutex_init(&spec->ats_mutex, NULL);
                if (rc != 0) {
@@ -557,7 +568,10 @@
                spec->disktype = istgt_get_disktype_by_ext(spec->file);
                if (strcasecmp(spec->disktype, "VDI") == 0
                    || strcasecmp(spec->disktype, "VHD") == 0
-                   || strcasecmp(spec->disktype, "VMDK") == 0) {
+                   || strcasecmp(spec->disktype, "VMDK") == 0
+                   || strcasecmp(spec->disktype, "QCOW") == 0
+                   || strcasecmp(spec->disktype, "QED") == 0
+                   || strcasecmp(spec->disktype, "VHDX") == 0) {
                        rc = istgt_lu_disk_vbox_lun_init(spec, istgt, lu);
                        if (rc < 0) {
                                ISTGT_ERRLOG("LU%d: LUN%d: 
lu_disk_vbox_lun_init() failed\n",
@@ -738,7 +752,10 @@
 
                if (strcasecmp(spec->disktype, "VDI") == 0
                    || strcasecmp(spec->disktype, "VHD") == 0
-                   || strcasecmp(spec->disktype, "VMDK") == 0) {
+                   || strcasecmp(spec->disktype, "VMDK") == 0
+                   || strcasecmp(spec->disktype, "QCOW") == 0
+                   || strcasecmp(spec->disktype, "QED") == 0
+                   || strcasecmp(spec->disktype, "VHDX") == 0) {
                        rc = istgt_lu_disk_vbox_lun_shutdown(spec, istgt, lu);
                        if (rc < 0) {
                                ISTGT_ERRLOG("LU%d: lu_disk_vbox_lun_shutdown() 
failed\n",
@@ -789,6 +806,7 @@
                        //ISTGT_ERRLOG("LU%d: mutex_destroy() failed\n", 
lu->num);
                        /* ignore error */
                }
+               xfree(spec->watsbuf);
                xfree(spec->wbuf);
                xfree(spec);
                lu->lun[i].spec = NULL;
@@ -1552,7 +1570,7 @@
                        /* WSNZ(0) */
                        BDSET8(&data[4], 0, 0); /* support zero length in WRITE 
SAME */
                        /* MAXIMUM COMPARE AND WRITE LENGTH */
-                       blocks = ISTGT_LU_WORK_BLOCK_SIZE / (uint32_t) 
spec->blocklen;
+                       blocks = ISTGT_LU_WORK_ATS_BLOCK_SIZE / (uint32_t) 
spec->blocklen;
                        if (blocks > 0xff) {
                                blocks = 0xff;
                        }
@@ -1785,7 +1803,7 @@
                /* Changeable values */
                if (page != 0x08) {
                        /* not supported */
-                       return 0;
+                       return -1;
                }
        } else if (pc == 0x02) {
                /* Default values */
@@ -2082,6 +2100,9 @@
        data[3] = len;                  /* Block Descripter Length */
 
        plen = istgt_lu_disk_scsi_mode_sense_page(spec, conn, cdb, pc, page, 
subpage, &cp[0], alloc_len);
+       if (plen < 0) {
+               return -1;
+       }
        cp += plen;
 
        total = hlen + len + plen;
@@ -2140,6 +2161,9 @@
        DSET16(&data[6], len);          /* Block Descripter Length */
 
        plen = istgt_lu_disk_scsi_mode_sense_page(spec, conn, cdb, pc, page, 
subpage, &cp[0], alloc_len);
+       if (plen < 0) {
+               return -1;
+       }
        cp += plen;
 
        total = hlen + len + plen;
@@ -2265,6 +2289,72 @@
        return 0;
 }
 
+static int
+istgt_lu_disk_scsi_read_defect10(ISTGT_LU_DISK *spec 
__attribute__((__unused__)), CONN_Ptr conn __attribute__((__unused__)), uint8_t 
*cdb __attribute__((__unused__)), int req_plist, int req_glist, int 
list_format, uint8_t *data, int alloc_len)
+{
+       uint8_t *cp;
+       int hlen = 0, len = 0;
+       int total;
+
+       if (alloc_len < 4) {
+               return -1;
+       }
+
+       data[0] = 0;                            /* Reserved */
+       data[1] = 0;
+       if (req_plist) {
+               BDADD8(&data[1], 1, 4);         /* PLISTV */
+       }
+       if (req_glist) {
+               BDADD8(&data[1], 1, 3);         /* GLISTV */
+       }
+       BDADD8W(&data[1], list_format, 2, 3);   /* DEFECT LIST FORMAT */
+       DSET16(&data[2], 0);                    /* DEFECT LIST LENGTH */
+       hlen = 4;
+
+       cp = &data[4];
+       /* defect list (if any) */
+       len = 0;
+
+       total = hlen + len;
+       DSET16(&data[2], total - hlen);         /* DEFECT LIST LENGTH */
+       return total;
+}
+
+static int
+istgt_lu_disk_scsi_read_defect12(ISTGT_LU_DISK *spec 
__attribute__((__unused__)), CONN_Ptr conn __attribute__((__unused__)), uint8_t 
*cdb __attribute__((__unused__)), int req_plist, int req_glist, int 
list_format, uint8_t *data, int alloc_len)
+{
+       uint8_t *cp;
+       int hlen = 0, len = 0;
+       int total;
+
+       if (alloc_len < 8) {
+               return -1;
+       }
+
+       data[0] = 0;                            /* Reserved */
+       data[1] = 0;
+       if (req_plist) {
+               BDADD8(&data[1], 1, 4);         /* PLISTV */
+       }
+       if (req_glist) {
+               BDADD8(&data[1], 1, 3);         /* GLISTV */
+       }
+       BDADD8W(&data[1], list_format, 2, 3);   /* DEFECT LIST FORMAT */
+       data[2] = 0;                            /* Reserved */
+       data[3] = 0;                            /* Reserved */
+       DSET32(&data[4], 0);                    /* DEFECT LIST LENGTH */
+       hlen = 8;
+
+       cp = &data[8];
+       /* defect list (if any) */
+       len = 0;
+
+       total = hlen + len;
+       DSET32(&data[4], total - hlen);         /* DEFECT LIST LENGTH */
+       return total;
+}
+
 #if 0
 static int
 istgt_lu_disk_scsi_request_sense(ISTGT_LU_DISK *spec, CONN_Ptr conn, uint8_t 
*cdb, int desc, uint8_t *data, int alloc_len)
@@ -4151,7 +4241,6 @@
 static int
 istgt_lu_disk_lbwrite_ats(ISTGT_LU_DISK *spec, CONN_Ptr conn, ISTGT_LU_CMD_Ptr 
lu_cmd, uint64_t lba, uint32_t len)
 {
-       uint8_t *tmp;
        uint8_t *data;
        uint64_t maxlba;
        uint64_t llen;
@@ -4205,7 +4294,16 @@
                return -1;
        }
 
-       tmp = xmalloc(nbytes);
+       if (spec->watsbuf == NULL) {
+               spec->watssize = ISTGT_LU_WORK_ATS_BLOCK_SIZE;
+               spec->watsbuf = xmalloc(spec->watssize);
+       }
+       if (nbytes > (uint64_t) spec->watssize) {
+               ISTGT_ERRLOG("nbytes(%zu) > watssize(%zu)\n",
+                   (size_t) nbytes, (size_t) spec->watssize);
+               return -1;
+       }
+
        spec->req_write_cache = 0;
        /* start atomic test and set */
        MTX_LOCK(&spec->ats_mutex);
@@ -4214,27 +4312,24 @@
        if (rc < 0) {
                MTX_UNLOCK(&spec->ats_mutex);
                ISTGT_ERRLOG("lu_disk_seek() failed\n");
-               xfree(tmp);
                return -1;
        }
 
-       rc = spec->read(spec, tmp, nbytes);
+       rc = spec->read(spec, spec->watsbuf, nbytes);
        if (rc < 0 || (uint64_t) rc != nbytes) {
                MTX_UNLOCK(&spec->ats_mutex);
                ISTGT_ERRLOG("lu_disk_read() failed\n");
-               xfree(tmp);
                return -1;
        }
 
 #if 0
        ISTGT_TRACEDUMP(ISTGT_TRACE_DEBUG, "ATS VERIFY", data, nbytes);
        ISTGT_TRACEDUMP(ISTGT_TRACE_DEBUG, "ATS WRITE", data + nbytes, nbytes);
-       ISTGT_TRACEDUMP(ISTGT_TRACE_DEBUG, "ATS DATA", tmp, nbytes);
+       ISTGT_TRACEDUMP(ISTGT_TRACE_DEBUG, "ATS DATA", spec->watsbuf, nbytes);
 #endif
-       if (memcmp(tmp, data, nbytes) != 0) {
+       if (memcmp(spec->watsbuf, data, nbytes) != 0) {
                MTX_UNLOCK(&spec->ats_mutex);
                //ISTGT_ERRLOG("compare failed\n");
-               xfree(tmp);
                /* MISCOMPARE DURING VERIFY OPERATION */
                BUILD_SENSE(MISCOMPARE, 0x1d, 0x00);
                return -1;
@@ -4244,14 +4339,12 @@
        if (rc < 0) {
                MTX_UNLOCK(&spec->ats_mutex);
                ISTGT_ERRLOG("lu_disk_seek() failed\n");
-               xfree(tmp);
                return -1;
        }
        rc = spec->write(spec, data + nbytes, nbytes);
        if (rc < 0 || (uint64_t) rc != nbytes) {
                MTX_UNLOCK(&spec->ats_mutex);
                ISTGT_ERRLOG("lu_disk_write() failed\n");
-               xfree(tmp);
                return -1;
        }
        ISTGT_TRACELOG(ISTGT_TRACE_SCSI, "Wrote %"PRId64"/%"PRIu64" bytes\n",
@@ -4259,7 +4352,6 @@
 
        MTX_UNLOCK(&spec->ats_mutex);
        /* end atomic test and set */
-       xfree(tmp);
 
        lu_cmd->data_len = nbytes * 2;
 
@@ -5801,6 +5893,8 @@
 
                        data_len = istgt_lu_disk_scsi_mode_sense6(spec, conn, 
cdb, dbd, pc, page, subpage, data, data_alloc_len);
                        if (data_len < 0) {
+                               /* INVALID FIELD IN CDB */
+                               BUILD_SENSE(ILLEGAL_REQUEST, 0x24, 0x00);
                                lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
                                break;
                        }
@@ -5851,6 +5945,8 @@
 
                        data_len = istgt_lu_disk_scsi_mode_sense10(spec, conn, 
cdb, llbaa, dbd, pc, page, subpage, data, data_alloc_len);
                        if (data_len < 0) {
+                               /* INVALID FIELD IN CDB */
+                               BUILD_SENSE(ILLEGAL_REQUEST, 0x24, 0x00);
                                lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
                                break;
                        }
@@ -5862,14 +5958,12 @@
                        break;
                }
 
-#if 0
        case SPC_LOG_SELECT:
        case SPC_LOG_SENSE:
                /* INVALID COMMAND OPERATION CODE */
                BUILD_SENSE(ILLEGAL_REQUEST, 0x20, 0x00);
                lu_cmd->status = ISTGT_SCSI_STATUS_CHECK_CONDITION;
                break;
-#endif
 
        case SPC_REQUEST_SENSE:
                {
@@ -6424,7 +6518,7 @@
                        transfer_len = (uint32_t) DGET8(&cdb[13]);
                        group_no = BGET8W(&cdb[14], 4, 5);
 
-                       maxlen = ISTGT_LU_WORK_BLOCK_SIZE / spec->blocklen;
+                       maxlen = ISTGT_LU_WORK_ATS_BLOCK_SIZE / spec->blocklen;
                        if (maxlen > 0xff) {
                                maxlen = 0xff;
                        }
@@ -6517,6 +6611,74 @@
                        break;
                }
 
+       case SBC_READ_DEFECT_DATA_10:
+               {
+                       int req_plist, req_glist, list_format;
+
+                       if (lu_cmd->R_bit == 0) {
+                               ISTGT_ERRLOG("R_bit == 0\n");
+                               lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
+                               return -1;
+                       }
+
+                       req_plist = BGET8(&cdb[2], 4);
+                       req_glist = BGET8(&cdb[2], 3);
+                       list_format = BGET8W(&cdb[2], 2, 3);
+
+                       allocation_len = (uint32_t) DGET16(&cdb[7]);
+                       if (allocation_len > (size_t) data_alloc_len) {
+                               ISTGT_ERRLOG("data_alloc_len(%d) too small\n",
+                                   data_alloc_len);
+                               lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
+                               return -1;
+                       }
+                       memset(data, 0, allocation_len);
+
+                       data_len = istgt_lu_disk_scsi_read_defect10(spec, conn, 
cdb,
+                           req_plist, req_glist, list_format, data, 
data_alloc_len);
+                       if (data_len < 0) {
+                               lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
+                               break;
+                       }
+                       lu_cmd->data_len = DMIN32((size_t)data_len, 
lu_cmd->transfer_len);
+                       lu_cmd->status = ISTGT_SCSI_STATUS_GOOD;
+                       break;
+               }
+
+       case SBC_READ_DEFECT_DATA_12:
+               {
+                       int req_plist, req_glist, list_format;
+
+                       if (lu_cmd->R_bit == 0) {
+                               ISTGT_ERRLOG("R_bit == 0\n");
+                               lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
+                               return -1;
+                       }
+
+                       req_plist = BGET8(&cdb[2], 4);
+                       req_glist = BGET8(&cdb[2], 3);
+                       list_format = BGET8W(&cdb[2], 2, 3);
+
+                       allocation_len = DGET32(&cdb[6]);
+                       if (allocation_len > (size_t) data_alloc_len) {
+                               ISTGT_ERRLOG("data_alloc_len(%d) too small\n",
+                                   data_alloc_len);
+                               lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
+                               return -1;
+                       }
+                       memset(data, 0, allocation_len);
+
+                       data_len = istgt_lu_disk_scsi_read_defect12(spec, conn, 
cdb,
+                           req_plist, req_glist, list_format, data, 
data_alloc_len);
+                       if (data_len < 0) {
+                               lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
+                               break;
+                       }
+                       lu_cmd->data_len = DMIN32((size_t)data_len, 
lu_cmd->transfer_len);
+                       lu_cmd->status = ISTGT_SCSI_STATUS_GOOD;
+                       break;
+               }
+
        case SCC_MAINTENANCE_IN:
                ISTGT_TRACELOG(ISTGT_TRACE_SCSI, "MAINTENANCE_IN\n");
                switch (BGET8W(&cdb[1], 4, 5)) { /* SERVICE ACTION */
@@ -6698,6 +6860,12 @@
                break;
 
        /* XXX TODO: fix */
+       case 0x85: /* ATA PASS-THROUGH(16) */
+       case 0xA1: /* ATA PASS-THROUGH(12) */
+               /* INVALID COMMAND OPERATION CODE */
+               BUILD_SENSE(ILLEGAL_REQUEST, 0x20, 0x00);
+               lu_cmd->status = ISTGT_SCSI_STATUS_CHECK_CONDITION;
+               break;
        case SPC_EXTENDED_COPY:
                /* INVALID COMMAND OPERATION CODE */
                BUILD_SENSE(ILLEGAL_REQUEST, 0x20, 0x00);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_lu_disk_vbox.c 
new/istgt-20120901/src/istgt_lu_disk_vbox.c
--- old/istgt-20120811/src/istgt_lu_disk_vbox.c 2012-08-10 17:11:54.000000000 
+0200
+++ new/istgt-20120901/src/istgt_lu_disk_vbox.c 2012-08-19 06:51:15.000000000 
+0200
@@ -54,6 +54,7 @@
 
 #ifdef USE_VBOXVD
 #define IN_RING3
+#include "iprt/buildconfig.h"
 #include "VBox/vd.h"
 
 typedef struct istgt_lu_disk_vbox_t {
@@ -86,9 +87,37 @@
 istgt_lu_disk_open_vbox(ISTGT_LU_DISK *spec, int flags, int mode 
__attribute__((__unused__)))
 {
        ISTGT_LU_DISK_VBOX *exspec = (ISTGT_LU_DISK_VBOX *)spec->exspec;
+       PVDINTERFACE pIf;
+       uint32_t major, minor, build;
        unsigned uOpenFlags;
        int rc;
 
+       major = RTBldCfgVersionMajor();
+       minor = RTBldCfgVersionMinor();
+       build = RTBldCfgVersionBuild();
+       if (major > 4 || (major == 4 && minor >= 2)) {
+               // VBoxDDU >= 4.2
+               if (ISTGT_VBOXINC_VERSION_MAJOR < 4 ||
+                   (ISTGT_VBOXINC_VERSION_MAJOR == 4 && 
ISTGT_VBOXINC_VERSION_MINOR < 2)) {
+                       ISTGT_ERRLOG("VBox library is newer than istgt\n");
+                       return -1;
+               }
+       } else {
+               // VBoxDDU < 4.2
+               if (ISTGT_VBOXINC_VERSION_MAJOR > 4 ||
+                   (ISTGT_VBOXINC_VERSION_MAJOR == 4 && 
ISTGT_VBOXINC_VERSION_MINOR >= 2)) {
+                       ISTGT_ERRLOG("VBox library is older than istgt\n");
+                       return -1;
+               }
+               if (strcasecmp(spec->disktype, "QCOW") == 0
+                   || strcasecmp(spec->disktype, "QED") == 0
+                   || strcasecmp(spec->disktype, "VHDX") == 0) {
+                       ISTGT_ERRLOG("VD format(%s) is not supported in this 
version.\n",
+                           spec->disktype);
+                       return -1;
+               }
+       }
+
        if ((flags & O_ACCMODE) == O_RDONLY) {
                uOpenFlags = VD_OPEN_FLAGS_READONLY;
        } else if ((flags & O_ACCMODE) == O_RDWR) {
@@ -103,22 +132,32 @@
        exspec->pVDIfsImage = NULL;
        exspec->enmType = VDTYPE_HDD;
 
+#if ((ISTGT_VBOXINC_VERSION_MAJOR > 4) || (ISTGT_VBOXINC_VERSION_MAJOR == 4 && 
ISTGT_VBOXINC_VERSION_MINOR >= 2))
+       exspec->VDIfError.pfnError = istgt_lu_disk_vbox_error;
+       exspec->VDIfError.pfnMessage = NULL;
+       pIf = (PVDINTERFACE)&exspec->VDIfError;
+
+       rc = VDInterfaceAdd(pIf, "VD interface error", VDINTERFACETYPE_ERROR,
+           spec, sizeof(VDINTERFACEERROR), &exspec->pVDIfs);
+#else /* VBox < 4.2 */
        exspec->VDIfError.cbSize = sizeof(VDINTERFACEERROR);
        exspec->VDIfError.enmInterface = VDINTERFACETYPE_ERROR;
        exspec->VDIfError.pfnError = istgt_lu_disk_vbox_error;
        exspec->VDIfError.pfnMessage = NULL;
+       pIf = &exspec->VDIfsDisk;
 
-       rc = VDInterfaceAdd(&exspec->VDIfsDisk, "VD interface error", 
VDINTERFACETYPE_ERROR,
+       rc = VDInterfaceAdd(pIf, "VD interface error", VDINTERFACETYPE_ERROR,
            &exspec->VDIfError, spec, &exspec->pVDIfs);
+#endif /* VBox >= 4.2 */
        if (RT_FAILURE(rc)) {
                ISTGT_ERRLOG("VDInterfaceAdd error\n");
                return -1;
        }
 
-       rc = VDCreate(&exspec->VDIfsDisk, exspec->enmType, &exspec->pDisk);
+       rc = VDCreate(exspec->pVDIfs, exspec->enmType, &exspec->pDisk);
        if (RT_FAILURE(rc)) {
                ISTGT_ERRLOG("VDCreate error\n");
-               VDInterfaceRemove(&exspec->VDIfsDisk, &exspec->pVDIfs);
+               VDInterfaceRemove(pIf, &exspec->pVDIfs);
                exspec->pDisk = NULL;
                exspec->pVDIfs = NULL;
                exspec->pVDIfsImage = NULL;
@@ -129,7 +168,7 @@
        if (RT_FAILURE(rc)) {
                ISTGT_ERRLOG("VDOpen error\n");
                VDDestroy(exspec->pDisk);
-               VDInterfaceRemove(&exspec->VDIfsDisk, &exspec->pVDIfs);
+               VDInterfaceRemove(pIf, &exspec->pVDIfs);
                exspec->pDisk = NULL;
                exspec->pVDIfs = NULL;
                exspec->pVDIfsImage = NULL;
@@ -142,21 +181,27 @@
 istgt_lu_disk_close_vbox(ISTGT_LU_DISK *spec)
 {
        ISTGT_LU_DISK_VBOX *exspec = (ISTGT_LU_DISK_VBOX *)spec->exspec;
+       PVDINTERFACE pIf;
        bool fDelete = false;
        int rc;
 
+#if ((ISTGT_VBOXINC_VERSION_MAJOR > 4) || (ISTGT_VBOXINC_VERSION_MAJOR == 4 && 
ISTGT_VBOXINC_VERSION_MINOR >= 2))
+       pIf = (PVDINTERFACE)&exspec->VDIfError;
+#else /* VBox < 4.2 */
+       pIf = &exspec->VDIfsDisk;
+#endif /* VBox >= 4.2 */
        rc = VDClose(exspec->pDisk, fDelete);
        if (RT_FAILURE(rc)) {
                ISTGT_ERRLOG("VDClose error\n");
                VDDestroy(exspec->pDisk);
-               VDInterfaceRemove(&exspec->VDIfsDisk, &exspec->pVDIfs);
+               VDInterfaceRemove(pIf, &exspec->pVDIfs);
                exspec->pDisk = NULL;
                exspec->pVDIfs = NULL;
                exspec->pVDIfsImage = NULL;
                return -1;
        }
        VDDestroy(exspec->pDisk);
-       VDInterfaceRemove(&exspec->VDIfsDisk, &exspec->pVDIfs);
+       VDInterfaceRemove(pIf, &exspec->pVDIfs);
        exspec->pDisk = NULL;
        exspec->pVDIfs = NULL;
        exspec->pVDIfsImage = NULL;
@@ -199,7 +244,7 @@
        offset = spec->foffset;
        rc = VDWrite(exspec->pDisk, offset, buf, (size_t)nbytes);
        if (RT_FAILURE(rc)) {
-               ISTGT_ERRLOG("VDRead error\n");
+               ISTGT_ERRLOG("VDWrite error\n");
                return -1;
        }
        spec->foffset += nbytes;
@@ -302,27 +347,30 @@
        printf("LU%d: LUN%d %"PRIu64" blocks, %"PRIu64" bytes/block\n",
            spec->num, spec->lun, spec->blockcnt, spec->blocklen);
 
-       rc = VDGetUuid(exspec->pDisk, 0, &exspec->uuid);
-       if (RT_FAILURE(rc)) {
-               ISTGT_ERRLOG("LU%d: LUN%d: uuid error\n", spec->num, spec->lun);
-               spec->close(spec);
-               return -1;
+       if (strcasecmp(spec->disktype, "VDI") == 0
+           || strcasecmp(spec->disktype, "VHD") == 0
+           || strcasecmp(spec->disktype, "VMDK") == 0) {
+               rc = VDGetUuid(exspec->pDisk, 0, &exspec->uuid);
+               if (RT_FAILURE(rc)) {
+                       ISTGT_ERRLOG("LU%d: LUN%d: uuid error\n", spec->num, 
spec->lun);
+                       spec->close(spec);
+                       return -1;
+               }
+               printf("LU%d: LUN%d UUID="
+                   
"%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
+                   spec->num, spec->lun,
+                   exspec->uuid.Gen.u32TimeLow,
+                   exspec->uuid.Gen.u16TimeMid,
+                   exspec->uuid.Gen.u16TimeHiAndVersion,
+                   exspec->uuid.Gen.u8ClockSeqHiAndReserved,
+                   exspec->uuid.Gen.u8ClockSeqLow,
+                   exspec->uuid.Gen.au8Node[0],
+                   exspec->uuid.Gen.au8Node[1],
+                   exspec->uuid.Gen.au8Node[2],
+                   exspec->uuid.Gen.au8Node[3],
+                   exspec->uuid.Gen.au8Node[4],
+                   exspec->uuid.Gen.au8Node[5]);
        }
-       printf("LU%d: LUN%d UUID="
-           "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
-           spec->num, spec->lun,
-           exspec->uuid.Gen.u32TimeLow,
-           exspec->uuid.Gen.u16TimeMid,
-           exspec->uuid.Gen.u16TimeHiAndVersion,
-           exspec->uuid.Gen.u8ClockSeqHiAndReserved,
-           exspec->uuid.Gen.u8ClockSeqLow,
-           exspec->uuid.Gen.au8Node[0],
-           exspec->uuid.Gen.au8Node[1],
-           exspec->uuid.Gen.au8Node[2],
-           exspec->uuid.Gen.au8Node[3],
-           exspec->uuid.Gen.au8Node[4],
-           exspec->uuid.Gen.au8Node[5]);
-
        return 0;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_lu_dvd.c 
new/istgt-20120901/src/istgt_lu_dvd.c
--- old/istgt-20120811/src/istgt_lu_dvd.c       2012-07-29 01:00:11.000000000 
+0200
+++ new/istgt-20120901/src/istgt_lu_dvd.c       2012-09-01 04:19:35.000000000 
+0200
@@ -1222,7 +1222,7 @@
                /* Changeable values */
                if (page != 0x08) {
                        /* not supported */
-                       return 0;
+                       return -1;
                }
        } else if (pc == 0x02) {
                /* Default values */
@@ -1473,6 +1473,9 @@
        data[3] = len;                  /* Block Descripter Length */
 
        plen = istgt_lu_dvd_scsi_mode_sense_page(spec, conn, cdb, pc, page, 
subpage, &cp[0], alloc_len);
+       if (plen < 0) {
+               return -1;
+       }
        cp += plen;
 
        total = hlen + len + plen;
@@ -1553,6 +1556,9 @@
        DSET16(&data[6], len);          /* Block Descripter Length */
 
        plen = istgt_lu_dvd_scsi_mode_sense_page(spec, conn, cdb, pc, page, 
subpage, &cp[0], alloc_len);
+       if (plen < 0) {
+               return -1;
+       }
        cp += plen;
 
        total = hlen + len + plen;
@@ -3308,6 +3314,8 @@
 
                        data_len = istgt_lu_dvd_scsi_mode_sense6(spec, conn, 
cdb, dbd, pc, page, subpage, data, data_alloc_len);
                        if (data_len < 0) {
+                               /* INVALID FIELD IN CDB */
+                               BUILD_SENSE(ILLEGAL_REQUEST, 0x24, 0x00);
                                lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
                                break;
                        }
@@ -3347,6 +3355,8 @@
 
                        data_len = istgt_lu_dvd_scsi_mode_sense10(spec, conn, 
cdb, llbaa, dbd, pc, page, subpage, data, data_alloc_len);
                        if (data_len < 0) {
+                               /* INVALID FIELD IN CDB */
+                               BUILD_SENSE(ILLEGAL_REQUEST, 0x24, 0x00);
                                lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
                                break;
                        }
@@ -3358,14 +3368,12 @@
                        break;
                }
 
-#if 0
        case SPC_LOG_SELECT:
        case SPC_LOG_SENSE:
                /* INVALID COMMAND OPERATION CODE */
                BUILD_SENSE(ILLEGAL_REQUEST, 0x20, 0x00);
                lu_cmd->status = ISTGT_SCSI_STATUS_CHECK_CONDITION;
                break;
-#endif
 
        case SPC_REQUEST_SENSE:
                ISTGT_TRACELOG(ISTGT_TRACE_SCSI, "REQUEST_SENSE\n");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_lu_tape.c 
new/istgt-20120901/src/istgt_lu_tape.c
--- old/istgt-20120811/src/istgt_lu_tape.c      2012-07-29 01:00:11.000000000 
+0200
+++ new/istgt-20120901/src/istgt_lu_tape.c      2012-09-01 04:19:35.000000000 
+0200
@@ -2370,7 +2370,7 @@
                /* Changeable values */
                if (page != 0x08) {
                        /* not supported */
-                       return 0;
+                       return -1;
                }
        } else if (pc == 0x02) {
                /* Default values */
@@ -2641,6 +2641,9 @@
        data[3] = len;                  /* Block Descripter Length */
 
        plen = istgt_lu_tape_scsi_mode_sense_page(spec, conn, cdb, pc, page, 
subpage, &cp[0], alloc_len);
+       if (plen < 0) {
+               return -1;
+       }
        cp += plen;
 
        total = hlen + len + plen;
@@ -2724,6 +2727,9 @@
        DSET16(&data[6], len);          /* Block Descripter Length */
 
        plen = istgt_lu_tape_scsi_mode_sense_page(spec, conn, cdb, pc, page, 
subpage, &cp[0], alloc_len);
+       if (plen < 0) {
+               return -1;
+       }
        cp += plen;
 
        total = hlen + len + plen;
@@ -4778,6 +4784,8 @@
 
                        data_len = istgt_lu_tape_scsi_mode_sense6(spec, conn, 
cdb, dbd, pc, page, subpage, data, data_alloc_len);
                        if (data_len < 0) {
+                               /* INVALID FIELD IN CDB */
+                               BUILD_SENSE(ILLEGAL_REQUEST, 0x24, 0x00);
                                lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
                                break;
                        }
@@ -4817,6 +4825,8 @@
 
                        data_len = istgt_lu_tape_scsi_mode_sense10(spec, conn, 
cdb, llbaa, dbd, pc, page, subpage, data, data_alloc_len);
                        if (data_len < 0) {
+                               /* INVALID FIELD IN CDB */
+                               BUILD_SENSE(ILLEGAL_REQUEST, 0x24, 0x00);
                                lu_cmd->status = 
ISTGT_SCSI_STATUS_CHECK_CONDITION;
                                break;
                        }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_proto.h 
new/istgt-20120901/src/istgt_proto.h
--- old/istgt-20120811/src/istgt_proto.h        2012-08-09 00:48:09.000000000 
+0200
+++ new/istgt-20120901/src/istgt_proto.h        2012-08-18 23:04:12.000000000 
+0200
@@ -208,8 +208,8 @@
 #error "no atomic operation"
 #endif
 }
-#else /* !USE_ATOMIC */
-#if ISTGT_GNUC_PREREQ(4, 1)
+#elif defined (USE_GCC_ATOMIC)
+/* gcc >= 4.1 builtin functions */
 static inline __attribute__((__always_inline__)) int
 istgt_lu_get_state(ISTGT_LU_Ptr lu)
 {
@@ -225,9 +225,11 @@
                state_old = __sync_fetch_and_add((unsigned int *)&lu->state, 0);
        } while (__sync_val_compare_and_swap((unsigned int *)&lu->state,
                state_old, state) != state_old);
+#if defined (HAVE_GCC_ATOMIC_SYNCHRONIZE)
        __sync_synchronize();
+#endif
 }
-#else /* GCC < 4.1 */
+#else /* !USE_ATOMIC && !USE_GCC_ATOMIC */
 static inline __attribute__((__always_inline__)) int
 istgt_lu_get_state(ISTGT_LU_Ptr lu)
 {
@@ -245,7 +247,6 @@
        lu->state = state;
        MTX_UNLOCK(&lu->state_mutex);
 }
-#endif /* GCC >= 4.1 */
 #endif /* USE_ATOMIC */
 
 #endif /* ISTGT_PROTO_H */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgt_ver.h 
new/istgt-20120901/src/istgt_ver.h
--- old/istgt-20120811/src/istgt_ver.h  2012-08-10 17:11:54.000000000 +0200
+++ new/istgt-20120901/src/istgt_ver.h  2012-09-01 04:19:35.000000000 +0200
@@ -29,6 +29,6 @@
 #define ISTGT_VER_H
 
 #define ISTGT_VERSION "0.5"
-#define ISTGT_EXTRA_VERSION "20120811"
+#define ISTGT_EXTRA_VERSION "20120901"
 
 #endif /* ISTGT_VER_H */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/istgt-20120811/src/istgtcontrol.c 
new/istgt-20120901/src/istgtcontrol.c
--- old/istgt-20120811/src/istgtcontrol.c       2012-07-29 01:00:11.000000000 
+0200
+++ new/istgt-20120901/src/istgtcontrol.c       2012-08-14 21:52:53.000000000 
+0200
@@ -1129,7 +1129,7 @@
                        break;
                case 'l':
                        l = strtol(optarg, NULL, 10);
-                       if (l < 0 || l > 0x3fffU) {
+                       if (l < 0 || l > 0x3fff) {
                                fatal("invalid lun %s\n", optarg);
                        }
                        lun = (int) l;

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to