SCSI fixes on 20200114

Two simple fixes in the upper drivers (so both fairly core), one in
 enclosures, which fixes replugging a device into an enclosure slot and
 one in the disk driver which fixes revalidating a drive with
 protection information (PI) to make it a non-PI drive ... previously
 we were still remembering the old PI state.  Both fixed issues are
 quite rare in the field.
 
 Signed-off-by: James E.J. Bottomley <jejb@linux.ibm.com>
 -----BEGIN PGP SIGNATURE-----
 
 iJwEABMIAEQWIQTnYEDbdso9F2cI+arnQslM7pishQUCXh3ociYcamFtZXMuYm90
 dG9tbGV5QGhhbnNlbnBhcnRuZXJzaGlwLmNvbQAKCRDnQslM7pishUvhAQDcb5gL
 fuNT0jNkQ54sKUjVKvvJP1ArmfJ1ZIub4bvkMwEA0D+Ho3iE28KOSW1NRtgTe5mz
 4Rrq64iJcAnt1PQ776U=
 =+ANJ
 -----END PGP SIGNATURE-----

Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "Two simple fixes in the upper drivers (so both fairly core), one in
  enclosures, which fixes replugging a device into an enclosure slot and
  one in the disk driver which fixes revalidating a drive with
  protection information (PI) to make it a non-PI drive ... previously
  we were still remembering the old PI state.

  Both fixed issues are quite rare in the field"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: enclosure: Fix stale device oops with hot replug
  scsi: sd: Clear sdkp->protection_type if disk is reformatted without PI
This commit is contained in:
Linus Torvalds 2020-01-14 10:14:06 -08:00
commit c21ed4d9a6
2 changed files with 4 additions and 3 deletions

View File

@ -406,10 +406,9 @@ int enclosure_remove_device(struct enclosure_device *edev, struct device *dev)
cdev = &edev->component[i]; cdev = &edev->component[i];
if (cdev->dev == dev) { if (cdev->dev == dev) {
enclosure_remove_links(cdev); enclosure_remove_links(cdev);
device_del(&cdev->cdev);
put_device(dev); put_device(dev);
cdev->dev = NULL; cdev->dev = NULL;
return device_add(&cdev->cdev); return 0;
} }
} }
return -ENODEV; return -ENODEV;

View File

@ -2211,8 +2211,10 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer
u8 type; u8 type;
int ret = 0; int ret = 0;
if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) {
sdkp->protection_type = 0;
return ret; return ret;
}
type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */ type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */