Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp121812ybm; Tue, 26 May 2020 12:18:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8laVB4zFYU3kLuyYphz3iByd8YWzUhKeXjMlALa9m7c4M9GMecViSDxclrjQ/K7+K9mcN X-Received: by 2002:a17:906:aeca:: with SMTP id me10mr2614502ejb.367.1590520733078; Tue, 26 May 2020 12:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590520733; cv=none; d=google.com; s=arc-20160816; b=e5oonIJ78GkZPq0w7y0YlyiGUDmYtz7PmZPsElAwLE48rfONwqMOsJ9EQEErNUitJt RiCa8rLh/hoct+55zHox8kbbkLrWglw+oVwKLTnLj6ZSu1VsbFNpklObbJKt9NyEIKhI bcQuRKWD1pWWFf2B2o+yDxgi/ZaX3iULeAqx7eXlwL9y6zWqj68FpscmVFnUTve2Lu5U S3KALZO+aF3DBX2lb0fWSO3Yo2UosrIJZz6XVQv+z6742AuRoyZWkszHCyNY/sdA4OLl E85s9HNMgQOKzrpXaurkUEcA5yy08RHT5SpKueIWwrzlQZDjjTZ38RdIBuFeKiBr7wq3 zHKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nRXkUje7mmG4QXWm9P/OHC2aPBvG9QDssQ0NxKe9iDE=; b=WSTt1rlv67WObG8ttJpR5XfEVeCx3FVfdH21v4eXtvul+UhTjByjcD+lSBV99H0rwg r6UBzxuo+GWWGT2fhlJl8SmsdAu3Ie8KeLPsaN3ehjDppMTHuJliGf+6JDXS2I5ck+sC 9tH342pyaYZI2dpO0dlmBIzjMr/m3T4Qr8RN7eLVdGHGliEObx7SF5nBFmiT5ckXK+XM 7A7Dp38SHFH0T95zN7lKjHn+RQ+wBKKPWVwtZAGHmddzzsxK9KJp2tgp/9PCEOQdAlcu CHJX9fRYxc4+R3Mr1IgKcbteqw7Gr1YmFmpL5akOAZOaz3bHqiJV+cS6j/f4uR8S/n09 /jeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XIOXt7c9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qk7si429629ejb.571.2020.05.26.12.18.28; Tue, 26 May 2020 12:18:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XIOXt7c9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404372AbgEZTOY (ORCPT + 99 others); Tue, 26 May 2020 15:14:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:44988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404338AbgEZTOP (ORCPT ); Tue, 26 May 2020 15:14:15 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AE297208B6; Tue, 26 May 2020 19:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590520455; bh=hFig9hmtta8baLq9l4NUzE2/ChNeohb5Mi97YN1hjHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XIOXt7c95bmHbZ8819qMrR1361QYOLMjsZXHYEFDS9j/CDtnA+tOydgptCYLBn3mJ a10XEk4VeD5qU05O6nz/SW8yWaHuZuKsyzIPntXQrgPLvfjYpX4XsM7vEbabyu0/wX jwB78Ca+lQZHAYjP9zALYlVfKTUkv+rDMoWXV6ps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Bryant G. Ly" , Bart van Assche , Bodo Stroesser , "Martin K. Petersen" Subject: [PATCH 5.6 069/126] scsi: target: Put lun_ref at end of tmr processing Date: Tue, 26 May 2020 20:53:26 +0200 Message-Id: <20200526183943.975359174@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526183937.471379031@linuxfoundation.org> References: <20200526183937.471379031@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bodo Stroesser commit f2e6b75f6ee82308ef7b00f29e71e5f1c6b3d52a upstream. Testing with Loopback I found that, after a Loopback LUN has executed a TMR, I can no longer unlink the LUN. The rm command hangs in transport_clear_lun_ref() at wait_for_completion(&lun->lun_shutdown_comp) The reason is, that transport_lun_remove_cmd() is not called at the end of target_tmr_work(). It seems, that in other fabrics this call happens implicitly when the fabric drivers call transport_generic_free_cmd() during their ->queue_tm_rsp(). Unfortunately Loopback seems to not comply to the common way of calling transport_generic_free_cmd() from ->queue_*(). Instead it calls transport_generic_free_cmd() from its ->check_stop_free() only. But the ->check_stop_free() is called by transport_cmd_check_stop_to_fabric() after it has reset the se_cmd->se_lun pointer. Therefore the following transport_generic_free_cmd() skips the transport_lun_remove_cmd(). So this patch re-adds the transport_lun_remove_cmd() at the end of target_tmr_work(), which was removed during commit 2c9fa49e100f ("scsi: target/core: Make ABORT and LUN RESET handling synchronous"). For fabrics using transport_generic_free_cmd() in the usual way the double call to transport_lun_remove_cmd() doesn't harm, as transport_lun_remove_cmd() checks for this situation and does not release lun_ref twice. Link: https://lore.kernel.org/r/20200513153443.3554-1-bstroesser@ts.fujitsu.com Fixes: 2c9fa49e100f ("scsi: target/core: Make ABORT and LUN RESET handling synchronous") Cc: stable@vger.kernel.org Tested-by: Bryant G. Ly Reviewed-by: Bart van Assche Signed-off-by: Bodo Stroesser Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/target/target_core_transport.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -3349,6 +3349,7 @@ static void target_tmr_work(struct work_ cmd->se_tfo->queue_tm_rsp(cmd); + transport_lun_remove_cmd(cmd); transport_cmd_check_stop_to_fabric(cmd); return;