Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp593016rwd; Wed, 14 Jun 2023 22:18:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ72JgAINu3RU2iHYvMCIIwpiwT5xKZM9tBXhOaqN/WffcEoV7lxPjWI3BKhfm+9q+j3ciVx X-Received: by 2002:a17:90a:c68e:b0:25e:a057:afa with SMTP id n14-20020a17090ac68e00b0025ea0570afamr49046pjt.13.1686806322403; Wed, 14 Jun 2023 22:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686806322; cv=none; d=google.com; s=arc-20160816; b=QVtpZDAKpvENLTOJVipPhaYow3IRvzvMMwj/cFSWOvgQdPk9906pJhifbNSl9azXMu 95r1/58S0nym+0UI34Z/nA+C4VOxHVdJA1e+o0d4clavypJIE/qXG9Z7v5Oz6rJjzn7r azdD/5/Z465dyXSQEXjThesmDZv4SKnq4ufzw0ZTGGh5xHzvtEp4dEdJjvJxSOBZoPXf C3UyzlXSEeqQW6cOrLh7J4KLpQ7eBG08kTh6h9n4Ipt4UFCPvrjbFaN44L+jQAW4Q2Rr SDZD6XwWJhdp+p9tayMKwciBxBMDqE7/pjW6Un6jYgltTThp5903X8SQiowEf2fNYqkx ZiMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=u2wZOh8gB+dqvpCsRBfz6Du/j61elBOaD38ZJ1DuvtY=; b=M8yklZg24QxaezWi0rzl7Cbfd3vjOUCTtx6nRcQIEB3zZFsdM36hovzesk5SjxxLDy 1nlEX/mX+TPGAPv5LyriGgj1ywE6PtnyzpDiMdR/tBt3VEWBY3BWr2y0T5PO0ornJq8s Y4wPhW7lEDdbNs8sEi9QQdoCmbVScA+Y5X4aghjP8RudWyRidG1p/KJqo21avmgtbGWy e9uQ/Kvx5w76ZOZ21rsjnvfYKgyXjX8UCA54BBjLgglM1Vs0b69olzm2fvrEENSKEOgd GfKDVF5wTydAbzbjSsb1yRpF1JlApSne+6sAfbsqlEzvAUdOZvtymR1Fr716h+R6uvFO rvOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020a17090a454b00b002563fbb8a85si12430792pjm.111.2023.06.14.22.18.30; Wed, 14 Jun 2023 22:18:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243145AbjFOFKK (ORCPT + 99 others); Thu, 15 Jun 2023 01:10:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243096AbjFOFKA (ORCPT ); Thu, 15 Jun 2023 01:10:00 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE1272697; Wed, 14 Jun 2023 22:09:53 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 7450167373; Thu, 15 Jun 2023 07:09:47 +0200 (CEST) Date: Thu, 15 Jun 2023 07:09:47 +0200 From: Christoph Hellwig To: Damien Le Moal Cc: Christoph Hellwig , Alan Stern , Hannes Reinecke , Joe Breuer , Bart Van Assche , Bagas Sanjaya , Pavel Machek , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Kees Cook , Tony Luck , "Guilherme G. Piccoli" , Thorsten Leemhuis , "James E.J. Bottomley" , "Martin K. Petersen" , Phillip Potter , Linux Power Management , Linux Kernel Mailing List , Linux Hardening , Linux Regressions , Linux SCSI , Dan Williams , Hannes Reinecke , Adrian Hunter , Martin Kepplinger , Kai-Heng Feng Subject: Re: Fwd: Waking up from resume locks up on sr device Message-ID: <20230615050947.GA5053@lst.de> References: <07d6e2e7-a50a-8cf4-5c5d-200551bd6687@gmail.com> <02e4f87a-80e8-dc5d-0d6e-46939f2c74ac@acm.org> <84f1c51c-86f9-04b3-0cd1-f685ebee7592@kernel.org> <37ed36f0-6f72-115c-85fb-62ef5ad72e76@suse.de> <859f0eda-4984-4489-9851-c9f6ec454a88@rowland.harvard.edu> <41b069c7-8723-4507-3e5a-1d1878db9002@kernel.org> <20230615044015.GA4720@lst.de> <9633f1a6-2e33-4a40-3fdb-0c1c4e4cd720@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9633f1a6-2e33-4a40-3fdb-0c1c4e4cd720@kernel.org> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 15, 2023 at 01:57:37PM +0900, Damien Le Moal wrote: > > No. scsi_device_get just increments a reference count, and thus > > prevents ->release from beeing called. ->remove is not in any way > > affected by the refcount. > > What ->remove cb are you talking about ? The gendev one ? The one for the device locked. > I am trying to understand why the use of device_lock() helps in any way given > that this is not used by any other functions in scsi. And given that The device model locks the device before calling ->remove. > scsi_rescan_device() should always be called with a ref on the scsi device (and > so on the gendev as well) held, why would this function be racy with device remove ? Because ->remove ould otherwise be called at the same time as ->rescan. > Note that I did find a couple of places where scsi_rescan_device() seems to not > be called with a reference to the scsi dev held, e.g. store_rescan_field() and > store_state_field(). You need both a valid reference and ensure ->remove is not called at the same time.