Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: storvsc: Correctly handle multiple flags in srb_status

Hyper-V is observed to sometimes set multiple flags in the srb_status, such
as ABORTED and ERROR. Current code in storvsc_handle_error() handles only a
single flag being set, and does nothing when multiple flags are set. Fix
this by changing the case statement into a series of "if" statements
testing individual flags. The functionality for handling each flag is
unchanged.

Link: https://lore.kernel.org/r/1622827263-12516-3-git-send-email-mikelley@microsoft.com
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Michael Kelley and committed by
Martin K. Petersen
52e1b3b3 08f76547

+33 -28
+33 -28
drivers/scsi/storvsc_drv.c
··· 1009 1009 struct storvsc_scan_work *wrk; 1010 1010 void (*process_err_fn)(struct work_struct *work); 1011 1011 struct hv_host_device *host_dev = shost_priv(host); 1012 - bool do_work = false; 1013 1012 1014 - switch (SRB_STATUS(vm_srb->srb_status)) { 1015 - case SRB_STATUS_ERROR: 1013 + /* 1014 + * In some situations, Hyper-V sets multiple bits in the 1015 + * srb_status, such as ABORTED and ERROR. So process them 1016 + * individually, with the most specific bits first. 1017 + */ 1018 + 1019 + if (vm_srb->srb_status & SRB_STATUS_INVALID_LUN) { 1020 + set_host_byte(scmnd, DID_NO_CONNECT); 1021 + process_err_fn = storvsc_remove_lun; 1022 + goto do_work; 1023 + } 1024 + 1025 + if (vm_srb->srb_status & SRB_STATUS_ABORTED) { 1026 + if (vm_srb->srb_status & SRB_STATUS_AUTOSENSE_VALID && 1027 + /* Capacity data has changed */ 1028 + (asc == 0x2a) && (ascq == 0x9)) { 1029 + process_err_fn = storvsc_device_scan; 1030 + /* 1031 + * Retry the I/O that triggered this. 1032 + */ 1033 + set_host_byte(scmnd, DID_REQUEUE); 1034 + goto do_work; 1035 + } 1036 + } 1037 + 1038 + if (vm_srb->srb_status & SRB_STATUS_ERROR) { 1016 1039 /* 1017 1040 * Let upper layer deal with error when 1018 1041 * sense message is present. 1019 1042 */ 1020 - 1021 1043 if (vm_srb->srb_status & SRB_STATUS_AUTOSENSE_VALID) 1022 - break; 1044 + return; 1045 + 1023 1046 /* 1024 1047 * If there is an error; offline the device since all 1025 1048 * error recovery strategies would have already been ··· 1055 1032 set_host_byte(scmnd, DID_PASSTHROUGH); 1056 1033 break; 1057 1034 /* 1058 - * On Some Windows hosts TEST_UNIT_READY command can return 1059 - * SRB_STATUS_ERROR, let the upper level code deal with it 1060 - * based on the sense information. 1035 + * On some Hyper-V hosts TEST_UNIT_READY command can 1036 + * return SRB_STATUS_ERROR. Let the upper level code 1037 + * deal with it based on the sense information. 1061 1038 */ 1062 1039 case TEST_UNIT_READY: 1063 1040 break; 1064 1041 default: 1065 1042 set_host_byte(scmnd, DID_ERROR); 1066 1043 } 1067 - break; 1068 - case SRB_STATUS_INVALID_LUN: 1069 - set_host_byte(scmnd, DID_NO_CONNECT); 1070 - do_work = true; 1071 - process_err_fn = storvsc_remove_lun; 1072 - break; 1073 - case SRB_STATUS_ABORTED: 1074 - if (vm_srb->srb_status & SRB_STATUS_AUTOSENSE_VALID && 1075 - (asc == 0x2a) && (ascq == 0x9)) { 1076 - do_work = true; 1077 - process_err_fn = storvsc_device_scan; 1078 - /* 1079 - * Retry the I/O that triggered this. 1080 - */ 1081 - set_host_byte(scmnd, DID_REQUEUE); 1082 - } 1083 - break; 1084 1044 } 1045 + return; 1085 1046 1086 - if (!do_work) 1087 - return; 1088 - 1047 + do_work: 1089 1048 /* 1090 1049 * We need to schedule work to process this error; schedule it. 1091 1050 */