From owner-freebsd-scsi@FreeBSD.ORG Mon Mar 12 14:47:02 2012 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 726551065675 for ; Mon, 12 Mar 2012 14:47:02 +0000 (UTC) (envelope-from jwd@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 606368FC17; Mon, 12 Mar 2012 14:47:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q2CEl2lm083423; Mon, 12 Mar 2012 14:47:02 GMT (envelope-from jwd@freefall.freebsd.org) Received: (from jwd@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q2CEl172083421; Mon, 12 Mar 2012 14:47:01 GMT (envelope-from jwd) Date: Mon, 12 Mar 2012 14:47:01 +0000 From: John To: freebsd-scsi Message-ID: <20120312144701.GA74725@FreeBSD.org> References: <20120312002122.GA95330@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120312002122.GA95330@FreeBSD.org> User-Agent: Mutt/1.4.2.3i Cc: aoyama@peach.ne.jp Subject: Re: istgt does not appear to shut down cleanly X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2012 14:47:02 -0000 ----- John's Original Message ----- > Hi Folks, > > I've been putting together a zfs server which exports zvols > via istgt: > > #istgt -V > istgt version 0.4 > istgt extra version 20111008 > > and about a 1 month old 9-stable: > > 9.0-STABLE FreeBSD 9.0-STABLE #0 r231864M: Fri Feb 17 23:21:34 UTC 2012 > > When adding a new LUC/LUN combination, I want to terminate and then > restart the daemon. However, istgt does not appear to completely exit. Hi Folks, Following up on my own posting. It appears that istgt is configured to use kqueue to handle signals. However, it still pthread_create()s the signal handler thread which requires the 2nd signal to get the thread to exit cleanly. Ifdef'ing out the pthread_create() and related code seems to fix the problem. Added NOSIGTHREAD. This seems to fix things nicely. Thanks, John #diff -u istgt.c.orig istgt.c [/usr/ports/net/istgt/work/istgt-20111008/src] --- istgt.c.orig 2012-03-12 12:14:12.000000000 +0000 +++ istgt.c 2012-03-12 14:28:34.000000000 +0000 @@ -1749,6 +1758,7 @@ #endif sigaddset(&signew, ISTGT_SIGWAKEUP); pthread_sigmask(SIG_SETMASK, &signew, &sigold); +#ifdef NOSIGTHREAD #ifdef ISTGT_STACKSIZE rc = pthread_create(&sigthread, &istgt->attr, &istgt_sighandler, #else @@ -1766,8 +1776,11 @@ goto initialize_error; } #endif +#endif #ifdef HAVE_PTHREAD_SET_NAME_NP +#ifdef NOSIGTHREAD pthread_set_name_np(sigthread, "sigthread"); +#endif pthread_set_name_np(pthread_self(), "mainthread"); #endif @@ -1847,12 +1860,14 @@ istgt_free_config(config); istgt_set_state(istgt, ISTGT_STATE_SHUTDOWN); +#ifdef NOSIGTHREAD /* stop signal thread */ rc = pthread_join(sigthread, NULL); if (rc != 0) { ISTGT_ERRLOG("pthread_join() failed\n"); exit (EXIT_FAILURE); } +#endif return 0; }