For a completely separate reason I would like to see PQ=1 expose the sd device. ALUA state transitions from unavailable back to another state does not work depending on what state devices are in when they are initially discovered. In the ALUA unavailable state the peripheral qualifier of the device should also be set to 001b. If the device is not in the unavailable state when it is initially discovered (PQ not 001b), it can move to and from the unavailable state with the expected result like this: /dev/sg1 7 0 1 1 0 /dev/sdb PURE FlashArray 8888 root@init106-1 class]# sg_inq /dev/sdb standard INQUIRY: [qualifier indicates no connected LU] PQual=1 Device_type=0 RMB=0 version=0x06 [SPC-4] [AERC=0] [TrmTsk=0] NormACA=1 HiSUP=1 Resp_data_format=2 SCCS=1 ACC=0 TPGS=1 3PC=1 Protect=0 [BQue=0] EncServ=0 MultiP=1 (VS=0) [MChngr=0] [ACKREQQ=0] Addr16=0 RelAdr=0] WBus16=0 Sync=0 Linked=0 [TranDis=0] CmdQue=1 [SPI: Clocking=0x0 QAS=0 IUS=0] length=96 (0x60) Peripheral device type: disk Vendor identification: PURE Product identification: FlashArray Product revision level: 8888 Unit serial number: 1D6DB146171D4E32000113E6 If, however, the device is already in this state when it is initially discovered, no sd device is created like this: /dev/sg2 7 0 1 1 0 PURE FlashArray 8888 Since no sd device is ever created, when the ALUA state changes and the peripheral qualifier is set back to 0, manual intervention is required. The devices peripheral qualifier is correct after another rescan, but no sd device is created. [root@init106-1 ~]# sg_inq /dev/sg2 standard INQUIRY: PQual=0 Device_type=0 RMB=0 version=0x06 [SPC-4] [AERC=0] [TrmTsk=0] NormACA=1 HiSUP=1 Resp_data_format=2 SCCS=1 ACC=0 TPGS=1 3PC=1 Protect=0 [BQue=0] EncServ=0 MultiP=1 (VS=0) [MChngr=0] [ACKREQQ=0] Addr16=0 [RelAdr=0] WBus16=0 Sync=0 Linked=0 [TranDis=0] CmdQue=1 [SPI: Clocking=0x0 QAS=0 IUS=0] length=96 (0x60) Peripheral device type: disk Vendor identification: PURE Product identification: FlashArray Product revision level: 8888 Unit serial number: 1D6DB146171D4E32000113E6 The existing device must first be removed for another initial rediscovery to correct the issue. This hole makes the unavailable ALUA state unattractive. Allowing the peripheral qualifier set to 001b to still create an sd device on discovery corrects this hole. Thanks, Brian On Tue, Jan 24, 2023 at 4:02 PM Martin K. Petersen <martin.petersen@xxxxxxxxxx> wrote: > > > I would like to revert commit 948e922fc446 ("scsi: core: map PQ=1, > PDT=other values to SCSI_SCAN_TARGET_PRESENT"). > > I have been spending quite a bit of time digging through old SCSI and > controller specs. As far as I can tell the original Linux behavior was > correct. Recent SPC specs are very abstract in this department resulting > in unfortunate ambiguity. But originally PQ=1 meant "LUN supports this > peripheral device type but no physical device is currently connected". > > Based on this original definition, PQ=1 has been widely used throughout > the industry as a means to avoid associating an ULD driver with a > device. The LUN is accessible (primary commands, etc.) but no media is > present (no physical device connected). > > Our original algorithm, which I would like to reinstate, is essentially > the following (in slightly unrolled form): > > if (PQ == 3) > /* Don't expose device */ > else if ((PQ == 1 || sdev->pdt_1f_for_no_lun) && PDT == 0x1f) > /* Don't expose device */ > else if (PQ == 1) { > /* Expose device, don't bind ULD */ > } else /* PQ == 0 */ > /* Expose device, bind ULD if PDT is supported */ > > I would like to understand why -- in the case of the IBM 2145 -- > exposing the sg device caused problems. Li: Can you shed some light on > the problems caused by 2145 LUNs reporting PQ=1? > > Thanks! > > -- > Martin K. Petersen Oracle Linux Engineering