[PATCH] scsi: sd: Clear sdkp->protection_type when the disk isn't DIF in sd_read_protection_type()

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

 



From: Xiang Chen <chenxiang66@xxxxxxxxxxxxx>

For a SAS disk, format it as a SAS DIF disk, then if re-format SAS DIF disk to normal
SAS disk,it will report errors as follows:
...
[root@localhost ~]# [77380.678276] sd 4:0:0:0: [sda] tag#67 UNKNOWN(0x2003) Result:
hostbyte=0x07 driverbyte=0x00
[77380.686511] sd 4:0:0:0: [sda] tag#67 CDB: opcode=0x28 28 20 00 00 00 00 00 00 08 00
[77380.694139] blk_update_request: I/O error, dev sda, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 0
[77380.703929] Buffer I/O error on dev sda, logical block 0, async page read
[77380.790267] sd 4:0:0:0: [sda] tag#72 UNKNOWN(0x2003) Result: hostbyte=0x07
driverbyte=0x00
[77380.798496] sd 4:0:0:0: [sda] tag#72 CDB: opcode=0x28 28 20 00 00 00 00 00 00 08 00
[77380.806123] blk_update_request: I/O error, dev sda, sector 0 op 0x0:(READ) flags 0x0
phys_seg 1 prio class 0
[77380.815907] Buffer I/O error on dev sda, logical block 0, async page read
[77380.822676]  sda: unable to read partition table
...

When re-format SAS disk to normal SAS disk, it will send command READ_CAPACITY to get
protection info. In function sd_read_protection_type(), it checks whether the disk is
DIF from protection info, if not directly return. But if the disk was DIF disk, so
sdkp->protection_type of the disk is still be set. So the system will mistake the normal
disk as DIF disk(from CDB log 0x20 indicates there is DIF info with data).)
To avoid the issue, clear sdkp->protection_type when the disk is not DIF disk in
function sd_read_protection_type().

Fixes: fe542396da73 ("[SCSI] sd: Ensure we correctly disable devices with unknown protection type")
Signed-off-by: Xiang Chen <chenxiang66@xxxxxxxxxxxxx>
---
 drivers/scsi/sd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index cea6259..65ce10c 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2211,8 +2211,10 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer
 	u8 type;
 	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;
+	}
 
 	type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */
 
-- 
2.8.1




[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