scsi: fix accounting of writes
Writes go through scsi_write_complete at least twice, the first time to get some data without having actually written anything. Because of this, the first time scsi_write_complete is called it will call bdrv_acct_done and account a read incorrectly. Fix this by looking at the aiocb. I am doing the same in scsi_read_complete for symmetry, but it is only needed in the (bogus) case of bdrv_aio_readv returning NULL. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
0a4ac106f7
commit
8e321cc622
@ -111,9 +111,10 @@ static void scsi_read_complete(void * opaque, int ret)
|
||||
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
|
||||
int n;
|
||||
|
||||
r->req.aiocb = NULL;
|
||||
|
||||
bdrv_acct_done(s->bs, &r->acct);
|
||||
if (r->req.aiocb != NULL) {
|
||||
r->req.aiocb = NULL;
|
||||
bdrv_acct_done(s->bs, &r->acct);
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_READ)) {
|
||||
@ -235,9 +236,10 @@ static void scsi_write_complete(void * opaque, int ret)
|
||||
uint32_t len;
|
||||
uint32_t n;
|
||||
|
||||
r->req.aiocb = NULL;
|
||||
|
||||
bdrv_acct_done(s->bs, &r->acct);
|
||||
if (r->req.aiocb != NULL) {
|
||||
r->req.aiocb = NULL;
|
||||
bdrv_acct_done(s->bs, &r->acct);
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_WRITE)) {
|
||||
|
Loading…
Reference in New Issue
Block a user