From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753378AbaIHJLg (ORCPT ); Mon, 8 Sep 2014 05:11:36 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:54447 "EHLO baptiste.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753103AbaIHJLe (ORCPT ); Mon, 8 Sep 2014 05:11:34 -0400 Message-ID: <540D72BB.2020100@acm.org> Date: Mon, 08 Sep 2014 11:11:23 +0200 From: Bart Van Assche User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: dgilbert@interlog.com, Christoph Hellwig CC: SCSI development list , linux-kernel , James Bottomley , Milan Broz Subject: Re: [PATCH] scsi_debug: deadlock between completions and surprise module removal References: <5403AB47.3040706@interlog.com> <20140905052402.GA27094@infradead.org> <5409C116.5060702@interlog.com> <5409D5D0.8060801@acm.org> <540B1CC6.8010800@interlog.com> In-Reply-To: <540B1CC6.8010800@interlog.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/06/14 16:40, Douglas Gilbert wrote: > On 14-09-05 11:25 AM, Bart Van Assche wrote: >> An LLD must call scsi_remove_host() directly or indirectly from the >> module >> cleanup path. scsi_remove_host() triggers a call to >> blk_cleanup_queue(). That >> last function sets the flag QUEUE_FLAG_DYING which prevents that new >> I/O is >> queued and waits until previously queued requests have finished before >> returning. > > And they do call scsi_remove_host(). But they do that toward > the end of their clean-up. The problem that I observed has > already happened before that. > > IOW I think the QUEUE_FLAG_DYING state needs to be set and > acknowledged as the first order of business by the code > that implements 'rmmod LLD'. Hello Doug, In the scsi_debug driver scsi_remove_host() is called from inside the sdebug_driver_remove() callback function. Unless I have missed something it is not guaranteed that that callback function is invoked before unloading of the scsi_debug driver has finished. I think most of the code in sdebug_driver_remove() should be moved to sdebug_remove_adapter(). Bart.