mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: sd: Update dix config everytime sd_revalidate_disk is called
@ 2022-10-19  8:18 Xingui Yang
  2022-10-20  0:18 ` Martin K. Petersen
  0 siblings, 1 reply; 4+ messages in thread
From: Xingui Yang @ 2022-10-19  8:18 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, linuxarm, yangxingui, prime.zeng,
	kangfenglong, john.garry

When the host protection capabilities are 0x77 and a DIF disk is connected,
the DIX and DIF of the disk are default enabled. Then if that DIF disk is
reformatted as a non-DIF format, per the currently flow, the DIX is kept
enabled which is not correct, which will cause the following errors when
accessing the non-DIF disk:
[root@localhost ~]# lsscsi -p
[7:0:5:0]    disk    xxx    /dev/sdc   DIF/Type3  T10-DIF-TYPE3-CRC
[root@localhost ~]# sg_format -F -s 512 /dev/sdc
[root@localhost ~]# lsscsi -p
[7:0:5:0]    disk    xxx    /dev/sdc   -          T10-DIF-TYPE3-CRC

[142829.032340] hisi_sas_v3_hw 0000:b4:04.0: erroneous completion iptt=2375 task=00000000bea0970c dev id=5 direct-attached phy4 addr=51c20dbaf642a000 CQ hdr: 0x1023 0x50947 0x0 0x20000 Error info: 0x0 0x0 0x4 0x0
[142829.073883] sas: Enter sas_scsi_recover_host busy: 1 failed: 1
[142829.079783] sas: sas_scsi_find_task: aborting task 0x00000000bea0970c
[142829.102342] sas: Internal abort: task to dev 51c20dbaf642a000 response: 0x0 status 0x5
[142829.110319] sas: sas_eh_handle_sas_errors: task 0x00000000bea0970c is done
[142829.117275] sd 7:0:5:0: [sdc] tag#2375 UNKNOWN(0x2003) Result: hostbyte=0x05 driverbyte=DRIVER_OK cmd_age=0s
[142829.127171] sd 7:0:5:0: [sdc] tag#2375 CDB: opcode=0x2a 2a 00 00 00 00 00 00 00 08 00
[142829.135059] I/O error, dev sdc, sector 0 op 0x1:(WRITE) flags 0x18800 phys_seg 1 prio class 2

On the contrary, when a non-DIF disk is connected and formatted as a DIF
disk, it is found that DIX is not enabled. Operation logs as follows:

[root@localhost ~]# lsscsi -p
[7:0:2:0]    disk    xxx    /dev/sdc   -          none
[root@localhost ~]# sg_format --format --fmtpinfo=3 --pfu=1 /dev/sdc
[root@localhost ~]# lsscsi -p
[7:0:2:0]    disk    xxx    /dev/sdc   DIF/Type3  none

This is because dix config is only updated when the first time a disk
is added, in this patch, we fix the issue by with changes:
1. Remove check first_scan when call sd_config_protection().
2. Unregister block integrity profile after DIX becomes to 0.

Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
 drivers/scsi/sd.c     | 3 ---
 drivers/scsi/sd_dif.c | 4 +++-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index eb76ba055021..3844f469b6be 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2199,9 +2199,6 @@ static void sd_config_protection(struct scsi_disk *sdkp)
 {
 	struct scsi_device *sdp = sdkp->device;
 
-	if (!sdkp->first_scan)
-		return;
-
 	sd_dif_config_host(sdkp);
 
 	if (!sdkp->protection_type)
diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index 968993ee6d5d..78db8d85f97e 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -39,8 +39,10 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
 		dif = 0; dix = 1;
 	}
 
-	if (!dix)
+	if (!dix) {
+		blk_integrity_unregister(disk);
 		return;
+	}
 
 	memset(&bi, 0, sizeof(bi));
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: sd: Update dix config everytime sd_revalidate_disk is called
  2022-10-19  8:18 [PATCH] scsi: sd: Update dix config everytime sd_revalidate_disk is called Xingui Yang
@ 2022-10-20  0:18 ` Martin K. Petersen
  2022-10-22  2:52   ` yangxingui
  2022-11-29  2:45   ` yangxingui
  0 siblings, 2 replies; 4+ messages in thread
From: Martin K. Petersen @ 2022-10-20  0:18 UTC (permalink / raw)
  To: Xingui Yang
  Cc: jejb, martin.petersen, linux-scsi, linux-kernel, linuxarm,
	prime.zeng, kangfenglong, john.garry


Xingui,

> When the host protection capabilities are 0x77 and a DIF disk is
> connected, the DIX and DIF of the disk are default enabled. Then if
> that DIF disk is reformatted as a non-DIF format, per the currently
> flow, the DIX is kept enabled which is not correct

DIX is orthogonal to DIF and a host property. DIX should not be disabled
just because the disk is no longer formatted with protection
information.

That said, your patch is probably fine. I'll take a closer look
tomorrow.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: sd: Update dix config everytime sd_revalidate_disk is called
  2022-10-20  0:18 ` Martin K. Petersen
@ 2022-10-22  2:52   ` yangxingui
  2022-11-29  2:45   ` yangxingui
  1 sibling, 0 replies; 4+ messages in thread
From: yangxingui @ 2022-10-22  2:52 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: jejb, linux-scsi, linux-kernel, linuxarm, prime.zeng,
	kangfenglong, john.garry


On 2022/10/20 8:18, Martin K. Petersen wrote:
> Xingui,
>
>> When the host protection capabilities are 0x77 and a DIF disk is
>> connected, the DIX and DIF of the disk are default enabled. Then if
>> that DIF disk is reformatted as a non-DIF format, per the currently
>> flow, the DIX is kept enabled which is not correct
> DIX is orthogonal to DIF and a host property. DIX should not be disabled
> just because the disk is no longer formatted with protection
> information.

As the host protection capabilities are 0x77 and not support DIX between 
OS and HBA only.

If write command is delivered to a non-DIF disk with DIX format this 
time, I/Os will be failed.

DIX status should  be updated when the disk DIF type changes.

>
> That said, your patch is probably fine. I'll take a closer look
> tomorrow.

ok, thanks.

Xingui

>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: sd: Update dix config everytime sd_revalidate_disk is called
  2022-10-20  0:18 ` Martin K. Petersen
  2022-10-22  2:52   ` yangxingui
@ 2022-11-29  2:45   ` yangxingui
  1 sibling, 0 replies; 4+ messages in thread
From: yangxingui @ 2022-11-29  2:45 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: jejb, linux-scsi, linux-kernel, linuxarm, prime.zeng,
	kangfenglong, john.garry



On 2022/10/20 8:18, Martin K. Petersen wrote:
> 
> Xingui,
> 
>> When the host protection capabilities are 0x77 and a DIF disk is
>> connected, the DIX and DIF of the disk are default enabled. Then if
>> that DIF disk is reformatted as a non-DIF format, per the currently
>> flow, the DIX is kept enabled which is not correct
> 
> DIX is orthogonal to DIF and a host property. DIX should not be disabled
> just because the disk is no longer formatted with protection
> information.
> 
> That said, your patch is probably fine. I'll take a closer look
> tomorrow.
> 

Friendly ping... Do you have other suggestions?
Thanks,
Xingui

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-29  2:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19  8:18 [PATCH] scsi: sd: Update dix config everytime sd_revalidate_disk is called Xingui Yang
2022-10-20  0:18 ` Martin K. Petersen
2022-10-22  2:52   ` yangxingui
2022-11-29  2:45   ` yangxingui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®