scsi: fix bug scsi resp sense is 0 when expand disk
PATCH 1/1 scsi: fix bug scsi resp sense is 0 when expand disk
A large number of I/Os are delivered during disk capacity expansion. Many I/Os are extracted from the Vring ring, and each one registers reqops_unit_attention when new scsi req.
If the first registered req takes the ua, the ua is cleared and other registered req is return 0 sense.
Let's add req_has_ua to avoid this kind of thing.
--- hw/scsi/scsi-bus.c | 10 ++++++++-- include/hw/scsi/scsi.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-)
hw/scsi/scsi-bus.c +8 -2
@@ -722,7 +722,13 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,* If we already have a pending unit attention condition, * report this one before triggering another one. */ - !(buf[0] == REQUEST_SENSE && d->sense_is_ua))) { + !(buf[0] == REQUEST_SENSE && d->sense_is_ua)) && +/* +* If we already have a req register ua ops, +* other req can not register. +*/ + !d->req_has_ua) { + d->req_has_ua = true; ops = &reqops_unit_attention; } else if (lun != d->lun || buf[0] == REPORT_LUNS ||
@@ -822,7 +828,7 @@ static void scsi_clear_unit_attention(SCSIRequest *req) ua->ascq == SENSE_CODE(REPORTED_LUNS_CHANGED).ascq)) {return ; } - + req->dev->req_has_ua = false; *ua =SENSE_CODE (NO_SENSE ); }
include/hw/scsi/scsi.h +1 -0
@@ -74,6 +74,7 @@ struct SCSIDeviceBlockConf conf;SCSISense unit_attention;bool sense_is_ua; +bool req_has_ua;uint8_t sense[SCSI_SENSE_BUF_SIZE ];uint32_t sense_len; QTAILQ_HEAD(, SCSIRequest) requests;
Signature · 1 line
2.23.0
ping Re: [PATCH] scsi: fix bug scsi resp sense is 0 when expand disk
ping.
Quoted 56 lines · Jie Wang
A large number of I/Os are delivered during disk capacity expansion. Many I/Os are extracted from the Vring ring, and each one registers
reqops_unit_attentionwhen new scsi req.
If the first registered req takes the ua, the ua is cleared and other registered req is return 0 sense.Let's add
req_has_uato avoid this kind of thing.Signed-off-by suruifeng <[email protected]>Signed-off-by Jie Wang <[email protected]>--- hw/scsi/scsi-bus.c | 10 ++++++++-- include/hw/scsi/scsi.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-)hw/scsi/scsi-bus.c +8
-2@@ -722,7 +722,13 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,* If we already have a pending unit attention condition, * report this one before triggering another one. */ - !(buf[0] == REQUEST_SENSE && d->sense_is_ua))) { + !(buf[0] == REQUEST_SENSE && d->sense_is_ua)) && +/* +* If we already have a req register ua ops, +* other req can not register. +*/ + !d->req_has_ua) { + d->req_has_ua = true; ops = &reqops_unit_attention; } else if (lun != d->lun || buf[0] == REPORT_LUNS ||@@ -822,7 +828,7 @@ static void scsi_clear_unit_attention(SCSIRequest *req) ua->ascq == SENSE_CODE(REPORTED_LUNS_CHANGED).ascq)) {return ; } - + req->dev->req_has_ua = false; *ua =SENSE_CODE (NO_SENSE ); }include/hw/scsi/scsi.h +1
-0@@ -74,6 +74,7 @@ struct SCSIDeviceBlockConf conf;SCSISense unit_attention;bool sense_is_ua; +bool req_has_ua;uint8_t sense[SCSI_SENSE_BUF_SIZE ];uint32_t sense_len; QTAILQ_HEAD(, SCSIRequest) requests;