ata fix for 7.3-rc7

- Set CHECK CONDITION for failed ATAPI commands.
 
    Since commit 2e1d2e65e7 ("ata: libata-scsi: terminate deferred
    commands on time out") failed ATAPI commands incorrectly stopped
    having CHECK CONDITION set for commands that had a SCSI midlayer
    byte set by scsi_check_sense(). SG_IO users therefore saw failed
    ATAPI commands as successful. (Hengyu)
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQRN+ES/c4tHlMch3DzJZDGjmcZNcgUCasTQfAAKCRDJZDGjmcZN
 cnMHAQC6ethce6SCEyq3vR72ndKa/y9YiHjXpdvVczmBw3+oWQD/Q1fQJ47XFI81
 celGTxa7tm+8rV1o30rVZc3S8dy76g8=
 =UXqK
 -----END PGP SIGNATURE-----

Merge tag 'ata-7.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux

Pull ata fix from Niklas Cassel:

 - Set CHECK CONDITION for failed ATAPI commands.

   Since commit 2e1d2e65e7 ("ata: libata-scsi: terminate deferred
   commands on time out") failed ATAPI commands incorrectly stopped
   having CHECK CONDITION set for commands that had a SCSI midlayer
   byte set by scsi_check_sense(). SG_IO users therefore saw failed
   ATAPI commands as successful (Hengyu)

* tag 'ata-7.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux:
  ata: libata-scsi: do not lose CHECK CONDITION for failed ATAPI commands
This commit is contained in:
Linus Torvalds 2026-10-06 16:10:57 +02:00
commit 69f80fef31

View File

@ -3059,10 +3059,15 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev)
qc->dev->sdev->locked = 0;
if (cmd->result)
ata_scsi_qc_done(qc, false, 0);
else
ata_scsi_qc_done(qc, true, SAM_STAT_CHECK_CONDITION);
/*
* Report CHECK CONDITION unless the command was terminated
* with a host byte set. Only set the status byte, so that the
* SCSI midlayer internal byte, which scsi_check_sense() may
* have set from the sense data, is preserved.
*/
if (get_host_byte(cmd) == DID_OK)
set_status_byte(cmd, SAM_STAT_CHECK_CONDITION);
ata_scsi_qc_done(qc, false, 0);
goto schedule_deferred;
}