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 AC5FAEB64D9 for ; Thu, 15 Jun 2023 04:40:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237918AbjFOEkY (ORCPT ); Thu, 15 Jun 2023 00:40:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjFOEkV (ORCPT ); Thu, 15 Jun 2023 00:40:21 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02CFFB3; Wed, 14 Jun 2023 21:40:21 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id DCDA567373; Thu, 15 Jun 2023 06:40:15 +0200 (CEST) Date: Thu, 15 Jun 2023 06:40:15 +0200 From: Christoph Hellwig To: Damien Le Moal Cc: Alan Stern , Christoph Hellwig , 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: <20230615044015.GA4720@lst.de> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41b069c7-8723-4507-3e5a-1d1878db9002@kernel.org> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.