Re: [PATCH] scsi: sd: mark the scsi device in shutdown as deleted

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/30/23 19:12, Mike Christie wrote:
> On 3/30/23 11:49 AM, Tomas Henzl wrote:
>> Set the state to deleted in sd_shutdown so that the attached LLD
>> doesn't receive new I/O (can happen when in kexec) later after
>> LLD's shutdown function has been called.
>>
>> Signed-off-by: Tomas Henzl <thenzl@xxxxxxxxxx>
>> ---
>>  drivers/scsi/sd.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
>> index 4f28dd617eca..8095f0302e66 100644
>> --- a/drivers/scsi/sd.c
>> +++ b/drivers/scsi/sd.c
>> @@ -3694,10 +3694,13 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
>>  static void sd_shutdown(struct device *dev)
>>  {
>>  	struct scsi_disk *sdkp = dev_get_drvdata(dev);
>> +	struct scsi_device *sdp;
>>  
>>  	if (!sdkp)
>>  		return;         /* this can happen */
>>  
>> +	sdp = sdkp->device;
>> +
>>  	if (pm_runtime_suspended(dev))
>>  		return;
>>  
>> @@ -3710,6 +3713,10 @@ static void sd_shutdown(struct device *dev)
>>  		sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
>>  		sd_start_stop_device(sdkp, 0);
>>  	}
>> +
>> +	mutex_lock(&sdp->state_mutex);
>> +	scsi_device_set_state(sdp, SDEV_DEL);
>> +	mutex_unlock(&sdp->state_mutex);
>>  }
> 
> If this is run for device removal what state will be in here?
> 
> Are we going to do:
> 1. __scsi_remove_device sets the state to SDEV_CANCEL at the beginning
> of the function
> 2. device_unregister causes sd_remove to be called and sd_shutdown sets
> the state to SDEV_DEL
> 3. then ide sets the state to SDEV_DEL at the bottom,
> so we get "Illegal state transition" errors printed.
> 
Thanks for looking.
A state change from SDEV_DEL to SDEV_DEL isn't illegal (state ==
oldstate) or am I wrong?




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux