Re: Fwd: Waking up from resume locks up on sr device

From: Christoph Hellwig
Date: Thu Jun 15 2023 - 00:40:25 EST


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.