Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp588570rwd; Wed, 14 Jun 2023 22:13:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zrwxCUxshlhREvd2rQZo8pR97Mnb4emUGqi4mYvqIiLyU5kiQlrCLxcNyUUWCHE90P8pQ X-Received: by 2002:a05:620a:6506:b0:760:9274:e61 with SMTP id qb6-20020a05620a650600b0076092740e61mr11697544qkn.47.1686805998145; Wed, 14 Jun 2023 22:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686805998; cv=none; d=google.com; s=arc-20160816; b=kZM2qmEOqjbadR/94zAy7cCfe/xvwpnvmvVwJZ4MsRHJu9zwH3muyCFzyYie+3sW5e 8oAlKCT4EjRZ/GWqDkHo47ahjweQRb8hkjOdR5p2ueIckCJ2AcCEOZlVXG/07oUHh1Io XIkEdcL+tzJWJtjrg9vnvPlTHp5skV9ZUlwVTufTwjISUa8FV6uy9pf0Hh7QdjORPg+Z KFcQGxnowwLPUr5poJA5Q8WqSb02NncfCf5Zy0waeSyk4PvCQsl6aQ3SmrhHlrOxM7p4 aJERmlJ2GV3Ij1BSUXs6VRjh0WGzyHR3eHwh40adJKmtUBNUF/qHEbYDheBmgkVL7DRM roEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=+gr5A+Uq95ooVIvw04ryCROtpAAz6YlfhwK+IwFF2a8=; b=KDhXQTb3oVzFBybfHileqeF4yiHl82v7qEqjahmItLI42ZnZOs9l/FVTRKxhDUqvYb YCimyNgSJiVIB++yAdt/UN7HQCBGh7g3ZCO7Rg82FI3zaF6zjRsptR/uAij0/Vy5XRAj lL3KL6v8kpyBvr/pItkYHJUoRb9Y8jRbO+zWHxAZlcropmO2gHIS6bRyQYspzd/0jIp9 Fg3Upxr/1T1RPIMlHx4r50wt1CT2y9tW99k/bSmz1gldXqEqzVNKxIG16ht0Ucpfu3PS kOCELXmQ3Sxkx9OSNMFQcbsvWwjaPoMDQkrTRJjZR2Uk9X0E1rATGGB5Yh3uyyjAVqJ0 luxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PlwlekPq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b24-20020a637158000000b00534866eb2c2si11960941pgn.835.2023.06.14.22.13.05; Wed, 14 Jun 2023 22:13:18 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PlwlekPq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242654AbjFOE5p (ORCPT + 99 others); Thu, 15 Jun 2023 00:57:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229812AbjFOE5n (ORCPT ); Thu, 15 Jun 2023 00:57:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90FA92121; Wed, 14 Jun 2023 21:57:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1EC566135A; Thu, 15 Jun 2023 04:57:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85D6DC433C0; Thu, 15 Jun 2023 04:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686805061; bh=NI50AhFx7ZUwE6ybmdWA7qMYMJyQVxtZkX6gjLq3zPM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=PlwlekPq2XT7vEW0OSLt6fILJ7HBbX5t13BYhYUVaP6OaTqAonp6H0nfvQfsh4I+y rfwrm3vjfptTqULiByp//aPmWQsj//9fB/WSM5zAyIx59nURG0NzGXfXi8QQBqcAqZ gK3K9mVhnMa4oKX6lwF6DMuhZK4Hh63QgQdvy93QFMqozZxa/m/44Z4DQcHJ+gWPJp t+Elf11F/GOBooDDlOEqqA7miWU0oa0GYhEHnh55Zp/+z6LSvEEW6fbIq66hZO3dNT x/7/P4JFxUCzGPdPEStb9Ssh0QekmsX7m9A9IoVfuUdvHr7SVgFIDlBlwdsnzQl4ln MVOsd5zDwMWIA== Message-ID: <9633f1a6-2e33-4a40-3fdb-0c1c4e4cd720@kernel.org> Date: Thu, 15 Jun 2023 13:57:37 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: Fwd: Waking up from resume locks up on sr device Content-Language: en-US To: Christoph Hellwig Cc: 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 References: <5513e29d-955a-f795-21d6-ec02a2e2e128@gmail.com> <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> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20230615044015.GA4720@lst.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,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 6/15/23 13:40, Christoph Hellwig wrote: > On Thu, Jun 15, 2023 at 09:10:28AM +0900, Damien Le Moal wrote: >>> Here's what commit e27829dc92e5 ("scsi: serialize ->rescan against >>> ->remove", written by Christoph Hellwig) says: >>> >>> Lock the device embedded in the scsi_device to protect against >>> concurrent calls to ->remove. >>> >>> That's the commit which added the device_lock() call. >> >> Thanks for the information. >> >> +Christoph >> >> Why is adding the device_lock() needed ? We could just do a >> scsi_device_get()+scsi_device_put() to serialize against remove. No ? > > 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 ? 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 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 ? 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(). -- Damien Le Moal Western Digital Research