scsi: sshdr and retry fixes
cover scsi: sshdr and retry fixes
The following patches were made over Martin's 6.7 scsi-queue branch. They only contain the sshdr and rdac retry fixes from the "Allow scsi_execute users to control retries" patchset.
The patches in this set are reviewed and tested but the changes to how we do retries will take a little longer and require more testing, so I broke up the series again.
PATCH 1/12 scsi: sd: Fix sshdr use in read_capacity_16
If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0.
--- drivers/scsi/sd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/sd.c +3 -4
@@ -2388,11 +2388,10 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, the_result =scsi_execute_cmd (sdp, cmd,REQ_OP_DRV_IN , buffer,RC16_LEN ,SD_TIMEOUT , sdkp->max_retries, &exec_args); - -if (media_not_present (sdkp, &sshdr)) -return -ENODEV ; -if (the_result >0 ) { +if (media_not_present (sdkp, &sshdr)) +return -ENODEV ; + sense_valid =scsi_sense_valid (&sshdr); if (sense_valid && sshdr.sense_key == ILLEGAL_REQUEST &&
Signature · 1 line
2.34.1
PATCH 2/12 scsi: sd: Fix sshdr use in sd_spinup_disk
In reply to Mike ChristieIf scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0.
--- drivers/scsi/sd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/scsi/sd.c +13 -11
@@ -2180,19 +2180,21 @@ sd_spinup_disk(struct scsi_disk *sdkp) sdkp->max_retries, &exec_args); -/* -* If the drive has indicated to us that it -* doesn't have any media in it, don't bother -* with any more polling. -*/ -if (media_not_present (sdkp, &sshdr)) { -if (media_was_present) -sd_printk (KERN_NOTICE , sdkp,"Media removed, stopped polling\n" ); -return ; - } +if (the_result >0 ) { +/* +* If the drive has indicated to us that it +* doesn't have any media in it, don't bother +* with any more polling. +*/ +if (media_not_present (sdkp, &sshdr)) { +if (media_was_present) +sd_printk (KERN_NOTICE , sdkp, +"Media removed, stopped polling\n" ); +return ; + } -if (the_result) sense_valid =scsi_sense_valid (&sshdr); + } retries++; } while (retries < 3 && (!scsi_status_is_good(the_result) ||
Signature · 1 line
2.34.1
PATCH 3/12 scsi: hp_sw: Fix sshdr use
In reply to Mike ChristieIf scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0.
--- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 79 +++++++++++---------- 1 file changed, 40 insertions(+), 39 deletions(-)
drivers/scsi/device_handler/scsi_dh_hp_sw.c +40 -39
@@ -82,7 +82,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h) {unsigned char cmd[6 ] = {TEST_UNIT_READY };struct scsi_sense_hdr sshdr; -int ret =SCSI_DH_OK , res; +int ret, res;blk_opf_t opf =REQ_OP_DRV_IN |REQ_FAILFAST_DEV |REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;const struct scsi_exec_args exec_args = {
@@ -92,19 +92,18 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h) retry: res =scsi_execute_cmd (sdev, cmd, opf,NULL ,0 ,HP_SW_TIMEOUT ,HP_SW_RETRIES , &exec_args); -if (res) { -if (scsi_sense_valid (&sshdr)) - ret =tur_done (sdev, h, &sshdr); -else { -sdev_printk (KERN_WARNING , sdev, -"%s: sending tur failed with %x\n" , -HP_SW_NAME , res); - ret =SCSI_DH_IO ; - } - }else { +if (res >0 &&scsi_sense_valid (&sshdr)) { + ret =tur_done (sdev, h, &sshdr); + }else if (res ==0 ) { h->path_state =HP_SW_PATH_ACTIVE ; ret =SCSI_DH_OK ; + }else { +sdev_printk (KERN_WARNING , sdev, +"%s: sending tur failed with %x\n" , +HP_SW_NAME , res); + ret =SCSI_DH_IO ; } +if (ret ==SCSI_DH_IMM_RETRY ) goto retry;
@@ -122,7 +121,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)unsigned char cmd[6 ] = {START_STOP ,0 ,0 ,0 ,1 ,0 };struct scsi_sense_hdr sshdr;struct scsi_device *sdev = h->sdev; -int res, rc =SCSI_DH_OK ; +int res, rc;int retry_cnt =HP_SW_RETRIES ;blk_opf_t opf =REQ_OP_DRV_IN |REQ_FAILFAST_DEV |REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;
@@ -133,35 +132,37 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h) retry: res =scsi_execute_cmd (sdev, cmd, opf,NULL ,0 ,HP_SW_TIMEOUT ,HP_SW_RETRIES , &exec_args); -if (res) { -if (!scsi_sense_valid (&sshdr)) { -sdev_printk (KERN_WARNING , sdev, -"%s: sending start_stop_unit failed, " -"no sense available\n" ,HP_SW_NAME ); -return SCSI_DH_IO ; - } -switch (sshdr.sense_key) { -case NOT_READY : -if (sshdr.asc ==0x04 && sshdr.ascq ==3 ) { -/* -* LUN not ready - manual intervention required -* -* Switch-over in progress, retry. -*/ -if (--retry_cnt) - goto retry; - rc =SCSI_DH_RETRY ; -break ; - } - fallthrough; -default : -sdev_printk (KERN_WARNING , sdev, -"%s: sending start_stop_unit failed, " -"sense %x/%x/%x\n" ,HP_SW_NAME , - sshdr.sense_key, sshdr.asc, sshdr.ascq); - rc =SCSI_DH_IO ; +if (!res) { +return SCSI_DH_OK ; + }else if (res <0 || !scsi_sense_valid (&sshdr)) { +sdev_printk (KERN_WARNING , sdev, +"%s: sending start_stop_unit failed, " +"no sense available\n" ,HP_SW_NAME ); +return SCSI_DH_IO ; + } + +switch (sshdr.sense_key) { +case NOT_READY : +if (sshdr.asc ==0x04 && sshdr.ascq ==3 ) { +/* +* LUN not ready - manual intervention required +* +* Switch-over in progress, retry. +*/ +if (--retry_cnt) + goto retry; + rc =SCSI_DH_RETRY ; +break ; } + fallthrough; +default : +sdev_printk (KERN_WARNING , sdev, +"%s: sending start_stop_unit failed, " +"sense %x/%x/%x\n" ,HP_SW_NAME , + sshdr.sense_key, sshdr.asc, sshdr.ascq); + rc =SCSI_DH_IO ; } +return rc; }
Signature · 1 line
2.34.1
PATCH 4/12 scsi: rdac: Fix send_mode_select retry handling
In reply to Mike ChristieIf send_mode_select retries scsi_execute_cmd it will leave err set to SCSI_DH_RETRY/SCSI_DH_IMM_RETRY. If on the retry, the command is successful, then SCSI_DH_RETRY/SCSI_DH_IMM_RETRY will be returned to the scsi_dh activation caller. On the retry, we will then detect the previous MODE SELECT had worked, and so we will return success.
This patch has us return the correct return value, so we can avoid the extra scsi_dh activation call and to avoid failures if the caller had hit its activation retry limit and does not end up retrying.
--- drivers/scsi/device_handler/scsi_dh_rdac.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/scsi/device_handler/scsi_dh_rdac.c +9 -9
@@ -530,7 +530,7 @@ static void send_mode_select(struct work_struct *work) container_of(work, struct rdac_controller, ms_work);struct scsi_device *sdev = ctlr->ms_sdev;struct rdac_dh_data *h = sdev->handler_data; -int err =SCSI_DH_OK , retry_cnt =RDAC_RETRY_COUNT ; +int err, retry_cnt =RDAC_RETRY_COUNT ;struct rdac_queue_data *tmp, *qdata;LIST_HEAD (list);unsigned char cdb[MAX_COMMAND_SIZE ];
@@ -558,20 +558,20 @@ static void send_mode_select(struct work_struct *work) (char *) h->ctlr->array_name, h->ctlr->index, (retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying"); -if (scsi_execute_cmd (sdev, cdb, opf, &h->ctlr->mode_select, data_size, -RDAC_TIMEOUT *HZ ,RDAC_RETRIES , &exec_args)) { +if (!scsi_execute_cmd (sdev, cdb, opf, &h->ctlr->mode_select, data_size, +RDAC_TIMEOUT *HZ ,RDAC_RETRIES , &exec_args)) { + h->state =RDAC_STATE_ACTIVE ; +RDAC_LOG (RDAC_LOG_FAILOVER , sdev,"array %s, ctlr %d, " +"MODE_SELECT completed" , + (char *) h->ctlr->array_name, h->ctlr->index); + err =SCSI_DH_OK ; + }else { err =mode_select_handle_sense (sdev, &sshdr);if (err ==SCSI_DH_RETRY && retry_cnt--) goto retry;if (err ==SCSI_DH_IMM_RETRY ) goto retry; } -if (err ==SCSI_DH_OK ) { - h->state =RDAC_STATE_ACTIVE ; -RDAC_LOG (RDAC_LOG_FAILOVER , sdev,"array %s, ctlr %d, " -"MODE_SELECT completed" , - (char *) h->ctlr->array_name, h->ctlr->index); - }list_for_each_entry_safe (qdata, tmp, &list, entry) {list_del (&qdata->entry);
Signature · 1 line
2.34.1
PATCH 5/12 scsi: rdac: Fix sshdr use
In reply to Mike ChristieIf scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0.
--- drivers/scsi/device_handler/scsi_dh_rdac.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/scsi/device_handler/scsi_dh_rdac.c +6 -3
@@ -530,7 +530,7 @@ static void send_mode_select(struct work_struct *work) container_of(work, struct rdac_controller, ms_work);struct scsi_device *sdev = ctlr->ms_sdev;struct rdac_dh_data *h = sdev->handler_data; -int err, retry_cnt =RDAC_RETRY_COUNT ; +int rc, err, retry_cnt =RDAC_RETRY_COUNT ;struct rdac_queue_data *tmp, *qdata;LIST_HEAD (list);unsigned char cdb[MAX_COMMAND_SIZE ];
@@ -558,13 +558,16 @@ static void send_mode_select(struct work_struct *work) (char *) h->ctlr->array_name, h->ctlr->index, (retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying"); -if (!scsi_execute_cmd (sdev, cdb, opf, &h->ctlr->mode_select, data_size, -RDAC_TIMEOUT *HZ ,RDAC_RETRIES , &exec_args)) { + rc =scsi_execute_cmd (sdev, cdb, opf, &h->ctlr->mode_select, data_size, +RDAC_TIMEOUT *HZ ,RDAC_RETRIES , &exec_args); +if (!rc) { h->state =RDAC_STATE_ACTIVE ;RDAC_LOG (RDAC_LOG_FAILOVER , sdev,"array %s, ctlr %d, " "MODE_SELECT completed" , (char *) h->ctlr->array_name, h->ctlr->index); err =SCSI_DH_OK ; + }else if (rc <0 ) { + err =SCSI_DH_IO ; }else { err =mode_select_handle_sense (sdev, &sshdr);if (err ==SCSI_DH_RETRY && retry_cnt--)
Signature · 1 line
2.34.1
PATCH 6/12 scsi: spi: Fix sshdr use
In reply to Mike ChristieIf scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0.
--- drivers/scsi/scsi_transport_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_transport_spi.c +2 -2
@@ -676,10 +676,10 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,for (r =0 ; r < retries; r++) { result =spi_execute (sdev, spi_write_buffer,REQ_OP_DRV_OUT , buffer, len, &sshdr); -if (result || !scsi_device_online (sdev)) { +if (result || !scsi_device_online (sdev)) {scsi_device_set_state (sdev,SDEV_QUIESCE ); -if (scsi_sense_valid (&sshdr) +if (result >0 &&scsi_sense_valid (&sshdr) && sshdr.sense_key ==ILLEGAL_REQUEST /* INVALID FIELD IN CDB */ && sshdr.asc ==0x24 && sshdr.ascq ==0x00 )
Signature · 1 line
2.34.1
PATCH 7/12 scsi: sd: Fix sshdr use in sd_suspend_common
In reply to Mike ChristieIf scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. sd_sync_cache will only access the sshdr if it's been setup because it calls scsi_status_is_check_condition before accessing it. However, the sd_sync_cache caller, sd_suspend_common, does not check.
sd_suspend_common is only checking for ILLEGAL_REQUEST which it's using to determine if the command is supported. If it's not it just ignores the error. So to fix its sshdr use this patch just moves that check to sd_sync_cache where it converts ILLEGAL_REQUEST to success/0. sd_suspend_common was ignoring that error and sd_shutdown doesn't check for errors so there will be no behavior changes.
--- drivers/scsi/sd.c | 53 ++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 30 deletions(-)
drivers/scsi/sd.c +23 -30
@@ -1564,24 +1564,21 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)return disk_changed ?DISK_EVENT_MEDIA_CHANGE :0 ; } -static int sd_sync_cache (struct scsi_disk *sdkp,struct scsi_sense_hdr *sshdr) +static int sd_sync_cache (struct scsi_disk *sdkp) {int retries, res;struct scsi_device *sdp = sdkp->device;const int timeout = sdp->request_queue->rq_timeout *SD_FLUSH_TIMEOUT_MULTIPLIER ; -struct scsi_sense_hdr my_sshdr; +struct scsi_sense_hdr sshdr;const struct scsi_exec_args exec_args = { .req_flags =BLK_MQ_REQ_PM , -/* caller might not be interested in sense, but we need it */ - .sshdr = sshdr ? : &my_sshdr, + .sshdr = &sshdr, };if (!scsi_device_online (sdp))return -ENODEV ; - sshdr = exec_args.sshdr; -for (retries =3 ; retries >0 ; --retries) {unsigned char cmd[16 ] = {0 };
@@ -1606,15 +1603,23 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)return res;if (scsi_status_is_check_condition (res) && -scsi_sense_valid (sshdr)) { -sd_print_sense_hdr (sdkp, sshdr); +scsi_sense_valid (&sshdr)) { +sd_print_sense_hdr (sdkp, &sshdr);/* we need to evaluate the error return */ -if (sshdr->asc ==0x3a ||/* medium not present */ - sshdr->asc ==0x20 ||/* invalid command */ - (sshdr->asc ==0x74 && sshdr->ascq ==0x71 ))/* drive is password locked */ +if (sshdr.asc ==0x3a ||/* medium not present */ + sshdr.asc ==0x20 ||/* invalid command */ + (sshdr.asc ==0x74 && sshdr.ascq ==0x71 ))/* drive is password locked */ /* this is no error here */ return 0 ; +/* +* This drive doesn't support sync and there's not much +* we can do because this is called during shutdown +* or suspend so just return success so those operations +* can proceed. +*/ +if (sshdr.sense_key ==ILLEGAL_REQUEST ) +return 0 ; }switch (host_byte (res)) {
@@ -3769,7 +3774,7 @@ static void sd_shutdown(struct device *dev)if (sdkp->WCE && sdkp->media_present) {sd_printk (KERN_NOTICE , sdkp,"Synchronizing SCSI cache\n" ); -sd_sync_cache (sdkp,NULL ); +sd_sync_cache (sdkp); }if (system_state !=SYSTEM_RESTART && sdkp->device->manage_start_stop) {
@@ -3781,7 +3786,6 @@ static void sd_shutdown(struct device *dev)static int sd_suspend_common (struct device *dev,bool ignore_stop_errors) {struct scsi_disk *sdkp =dev_get_drvdata (dev); -struct scsi_sense_hdr sshdr;int ret =0 ;if (!sdkp)/* E.g.: runtime suspend following sd_remove() */
@@ -3790,24 +3794,13 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)if (sdkp->WCE && sdkp->media_present) {if (!sdkp->device->silence_suspend)sd_printk (KERN_NOTICE , sdkp,"Synchronizing SCSI cache\n" ); - ret =sd_sync_cache (sdkp, &sshdr); - -if (ret) { -/* ignore OFFLINE device */ -if (ret == -ENODEV ) -return 0 ; - -if (!scsi_sense_valid (&sshdr) || - sshdr.sense_key !=ILLEGAL_REQUEST ) -return ret; + ret =sd_sync_cache (sdkp); +/* ignore OFFLINE device */ +if (ret == -ENODEV ) +return 0 ; -/* -* sshdr.sense_key == ILLEGAL_REQUEST means this drive -* doesn't support sync. There's not much to do and -* suspend shouldn't fail. -*/ - ret =0 ; - } +if (ret) +return ret; }if (sdkp->device->manage_start_stop) {
Signature · 1 line
2.34.1
PATCH 8/12 scsi: sd: Fix scsi_mode_sense caller's sshdr use
In reply to Mike ChristieThe sshdr passed into scsi_execute_cmd is only initialized if scsi_execute_cmd returns >= 0, and scsi_mode_sense will convert all non good statuses like check conditions to -EIO. This has scsi_mode_sense callers that were possibly accessing an uninitialized sshdrs to only access it if we got -EIO.
--- drivers/scsi/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +2 -2
@@ -2895,7 +2895,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) } bad_sense: -if (scsi_sense_valid (&sshdr) && +if (res == -EIO &&scsi_sense_valid (&sshdr) && sshdr.sense_key ==ILLEGAL_REQUEST && sshdr.asc ==0x24 && sshdr.ascq ==0x0 )/* Invalid field in CDB */
@@ -2943,7 +2943,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)sd_first_printk (KERN_WARNING , sdkp,"getting Control mode page failed, assume no ATO\n" ); -if (scsi_sense_valid (&sshdr)) +if (res == -EIO &&scsi_sense_valid (&sshdr))sd_print_sense_hdr (sdkp, &sshdr);return ;
Signature · 1 line
2.34.1
PATCH 9/12 scsi: Fix sshdr use in scsi_test_unit_ready
In reply to Mike ChristieIf scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0.
--- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_lib.c +2 -2
@@ -2299,10 +2299,10 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,do { result =scsi_execute_cmd (sdev, cmd,REQ_OP_DRV_IN ,NULL ,0 , timeout,1 , &exec_args); -if (sdev->removable &&scsi_sense_valid (sshdr) && +if (sdev->removable && result >0 &&scsi_sense_valid (sshdr) && sshdr->sense_key ==UNIT_ATTENTION ) sdev->changed =1 ; - }while (scsi_sense_valid (sshdr) && + }while (result >0 &&scsi_sense_valid (sshdr) && sshdr->sense_key ==UNIT_ATTENTION && --retries);return result;
Signature · 1 line
2.34.1
PATCH 10/12 scsi: Fix sshdr use in scsi_cdl_enable
In reply to Mike ChristieIf scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0.
--- drivers/scsi/scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi.c +1 -1
@@ -692,7 +692,7 @@ int scsi_cdl_enable(struct scsi_device *sdev, bool enable) ret =scsi_mode_select (sdev,1 ,0 , buf_data, len,5 *HZ ,3 , &data, &sshdr);if (ret) { -if (scsi_sense_valid (&sshdr)) +if (ret >0 &&scsi_sense_valid (&sshdr))scsi_print_sense_hdr (sdev,dev_name (&sdev->sdev_gendev), &sshdr);return ret;
Signature · 1 line
2.34.1
PATCH 11/12 scsi: sd: Fix sshdr use in cache_type_store
In reply to Mike ChristieIf scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0.
--- drivers/scsi/sd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/scsi/sd.c +5 -4
@@ -143,7 +143,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr,struct scsi_mode_data data;struct scsi_sense_hdr sshdr;static const char temp[] ="temporary " ; -int len; +int len, ret;if (sdp->type !=TYPE_DISK && sdp->type !=TYPE_ZBC )/* no cache control on RBC devices; theoretically they
@@ -190,9 +190,10 @@ cache_type_store(struct device *dev, struct device_attribute *attr,*/ data.device_specific =0 ; -if (scsi_mode_select (sdp,1 , sp, buffer_data, len,SD_TIMEOUT , - sdkp->max_retries, &data, &sshdr)) { -if (scsi_sense_valid (&sshdr)) + ret =scsi_mode_select (sdp,1 , sp, buffer_data, len,SD_TIMEOUT , + sdkp->max_retries, &data, &sshdr); +if (ret) { +if (ret >0 &&scsi_sense_valid (&sshdr))sd_print_sense_hdr (sdkp, &sshdr);return -EINVAL ; }
Signature · 1 line
2.34.1
PATCH 12/12 scsi: sr: Fix sshdr use in sr_get_events
In reply to Mike ChristieIf scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0.
--- drivers/scsi/sr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/sr.c +2 -1
@@ -177,7 +177,8 @@ static unsigned int sr_get_events(struct scsi_device *sdev) result =scsi_execute_cmd (sdev, cmd,REQ_OP_DRV_IN , buf,sizeof (buf),SR_TIMEOUT ,MAX_RETRIES , &exec_args); -if (scsi_sense_valid (&sshdr) && sshdr.sense_key ==UNIT_ATTENTION ) +if (result >0 &&scsi_sense_valid (&sshdr) && + sshdr.sense_key ==UNIT_ATTENTION )return DISK_EVENT_MEDIA_CHANGE ;if (result ||be16_to_cpu (eh->data_len) <sizeof (*med))
Signature · 1 line
2.34.1
Quoted 1 line · Mike Christie
The following patches were made over Martin's 6.7 scsi-queue branch.
Ignore this patchset. Martin's 6.7 scsi-queue branch is missing some patches in Linus's tree, so the patches will not apply correctly.
Will rebase against Linus's tree.