From owner-freebsd-scsi@FreeBSD.ORG Thu Nov 3 23:53:27 2011 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 DB91B106564A for ; Thu, 3 Nov 2011 23:53:27 +0000 (UTC) (envelope-from chuck@tuffli.net) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id A7B8B8FC12 for ; Thu, 3 Nov 2011 23:53:27 +0000 (UTC) Received: by qadb12 with SMTP id b12so185330qad.13 for ; Thu, 03 Nov 2011 16:53:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.7.66 with SMTP id h2mr483342oba.14.1320362947450; Thu, 03 Nov 2011 16:29:07 -0700 (PDT) Received: by 10.182.116.102 with HTTP; Thu, 3 Nov 2011 16:29:07 -0700 (PDT) Date: Thu, 3 Nov 2011 16:29:07 -0700 Message-ID: From: Chuck Tuffli To: freebsd-scsi Content-Type: text/plain; charset=ISO-8859-1 Subject: how to abort an ATIO/INOT 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: Thu, 03 Nov 2011 23:53:27 -0000 Hi - I'm implementing a target mode driver using the scsi_target as a back-end, and am seeing scsi_target hang sometimes when exiting. When it hangs, the call stack appears to be abort_all_pending targdisable targioctl(TARGIOCDISABLE) with the "hang" due to the msleep on the pending_ccb_queue. If I understand the code correctly (which I may not), the msleep is to wait asynchronously for CCBs to abort. But what about cases where the CCB completes prior to the msleep? For example, some drivers call xpt_done on ATIO/INOT CCBs and then return CAM_REQ_CMP for the abort (I copied this in my driver). I believe this results in the hang as the abort request completes (status == CAM_REQ_CMP) triggering the msleep, but the xpt_done that could wake up anything sleeping on the pending_ccb_queue has already run. So, should target drivers not return CAM_REQ_CMP unless a CCB needs to be asynchronously aborted? What about CTIO? Does that have a potential race? ---chuck