From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73584C00A5A for ; Tue, 17 Jan 2023 22:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbjAQWZE (ORCPT ); Tue, 17 Jan 2023 17:25:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbjAQWYC (ORCPT ); Tue, 17 Jan 2023 17:24:02 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BDE065ECA; Tue, 17 Jan 2023 14:03:34 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 05C4634469; Tue, 17 Jan 2023 22:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1673993005; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cNlI+9UfYWFV0uaPvoECFFSdv2wmbsdPyIUgQd9knbY=; b=PjrYgDT9wxvvYd/YDARNXxg/aCtgXm5tG+TXHfURfJw3vTLOtWAS7lMb9ND1gP0I93OH6C G5QqMyEYqD2IVFJXN7Obzv08misoTK0zuHbZFUBQKcldT/Jvu8DGo05EMG7fivhrpeZVl+ aIJEKCh4CC6ufxQspXOTJxQefX645hI= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B02C513357; Tue, 17 Jan 2023 22:03:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lMl5KSwbx2NNCgAAMHmgww (envelope-from ); Tue, 17 Jan 2023 22:03:24 +0000 Message-ID: <983f47533ee56b2a954de97dc7e02cbcbc4f9841.camel@suse.com> Subject: Re: kernel BUG scsi_dh_alua sleeping from invalid context && kernel WARNING do not call blocking ops when !TASK_RUNNING From: Martin Wilck To: Bart Van Assche , Steffen Maier , linux-scsi Cc: "Martin K. Petersen" , "James E . J . Bottomley" , Sachin Sant , Hannes Reinecke , Benjamin Block , linux-s390 Date: Tue, 17 Jan 2023 23:03:24 +0100 In-Reply-To: <2bea9c3e-2a61-a51e-c13b-796adabe6f71@acm.org> References: <017b6c73f56505e63519e4b79fe69d66abddf810.camel@suse.com> <125f247806396f19fd27dcfa71f530b5b4a529a6.camel@suse.com> <2bea9c3e-2a61-a51e-c13b-796adabe6f71@acm.org> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org On Tue, 2023-01-17 at 13:52 -0800, Bart Van Assche wrote: > On 1/17/23 13:48, Martin Wilck wrote: > > Yes, that was my suggestion. Just defer the scsi_device_put() call > > in > > alua_rtpg_queue() in the case where the actual RTPG handler is not > > queued. I won't have time for that before next week though. >=20 > Hi Martin, >=20 > Do you agree that the call trace shared by Steffen is not sufficient > to=20 > conclude that this change is necessary? Hmm, I suppose I missed your point... to re-iterate my thinking: 1 alua_queue_rtpg() must take a ref to the sdev before queueing work, whether or not the caller already has one 2 queue_delayed_work() can fail 3 if queue_delayed_work() fails, alua_queue_rtpg() must drop the ref it just took 4 BUT (and this is what I guess I missed) this ref can't be the last one dropped, because the caller of alua_rtpg_queue() must still hold a reference. And scsi_device_put() only sleeps if the last ref is dropped. Therefore the issue in Steffen's call stack should indeed be fixed just by removing the might_sleep(). If all callers callers of alua_rtpg_queue() must hold an sdev reference (I believe=A0 they do), we can indeed remove the might_sleep() entirely. Is this correct reasoning, and what you meant previously? If yes, I agree, and I apologize for not realizing it in the first place.=A0 But I think this is subtle enough to deserve a comment in the code. Thanks Martin