Re: [PATCH v2 1/5] ata: libata: rename ata_dev_is_zac()

[email protected]
Newsgroups org.kernel.vger.linux-ide
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incomplete refactoring of ZBC checks leaves SCSI emulation in an inconsistent state for Device Managed drives.
--

commit 8a69ac9e4f68da535d403caef5279dfdb19419f2
Author: Damien Le Moal <[email protected]>

ata: libata: rename ata_dev_is_zac()

The helper function ata_dev_is_zac() is renamed to ata_dev_is_zoned() to
better reflect its checks. Existing callers and an open-coded check are
updated to use the renamed helper.

> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index d54ec1631e9a6..8811bfc373697 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c

[ ... ]

> @@ -3656,8 +3656,7 @@ static unsigned int ata_scsi_report_supported_opcodes(struct ata_device *dev,
>  		break;
>  	case ZBC_IN:
>  	case ZBC_OUT:
> -		if (ata_id_zoned_cap(dev->id) ||
> -		    dev->class == ATA_DEV_ZAC)
> +		if (ata_dev_is_zoned(dev))

[Severity: High]
Should this refactoring also be applied to ata_scsiop_inq_std() and
ata_scsiop_read_cap() to prevent an inconsistent state for Device Managed
drives?

They still use the identical open-coded check:

drivers/ata/libata-scsi.c:ata_scsiop_inq_std() {
        ...
        if (ata_id_zoned_cap(dev->id) || dev->class == ATA_DEV_ZAC)
                memcpy(rbuf + 58, versions_zbc, sizeof(versions_zbc));
        ...
}

drivers/ata/libata-scsi.c:ata_scsiop_read_cap() {
        ...
        if (ata_id_zoned_cap(dev->id) || dev->class == ATA_DEV_ZAC)
                rbuf[12] = (1 << 4); /* RC_BASIS */
        ...
}

By only replacing the check here in ata_scsi_report_supported_opcodes(),
Device Managed zoned drives (ata_id_zoned_cap == 0x02) will correctly no
longer report support for ZBC commands, but will still incorrectly claim ZBC
capabilities in standard INQUIRY and set the ZBC-specific RC_BASIS bit in
READ CAPACITY (16).

>  			supported = 3;
>  		break;
>  	case SECURITY_PROTOCOL_IN:

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.