storvsc: fix auto-sense reporting

I saw a situation where the driver set CAM_AUTOSNS_VALID on a failed ccb
even though SRB_STATUS_AUTOSENSE_VALID was not set in the status.
The actual sense data remained all zeros.
The problem seems to be that create_storvsc_request() always sets
hv_storvsc_request::sense_info_len, so checking for sense_info_len != 0
is not enough to determine if any auto-sense data is actually available.

Reviewed by:	whu, imp
MFC after:	2 weeks
Sponsored by:	CyberSecure
Differential Revision:	https://reviews.freebsd.org/D30124
This commit is contained in:
Andriy Gapon 2021-05-07 10:17:57 +03:00
parent 1ed5f62d61
commit 8afecefd57

View File

@ -2406,7 +2406,8 @@ storvsc_io_done(struct hv_storvsc_request *reqp)
else
ccb->csio.resid = ccb->csio.dxfer_len;
if (reqp->sense_info_len != 0) {
if ((vm_srb->srb_status & SRB_STATUS_AUTOSENSE_VALID) != 0 &&
reqp->sense_info_len != 0) {
csio->sense_resid = csio->sense_len - reqp->sense_info_len;
ccb->ccb_h.status |= CAM_AUTOSNS_VALID;
}