From 3b8e996a6ca8860538b5e28de29b973efd940f09 Mon Sep 17 00:00:00 2001 From: Utkarsh Mani Tripathi Date: Mon, 18 Nov 2019 16:30:46 +0530 Subject: [PATCH] Reply with LUN busy when there is a read/write error from backend Signed-off-by: Utkarsh Mani Tripathi --- pkg/scsi/backingstore.go | 4 ++-- pkg/scsi/sbc.go | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/scsi/backingstore.go b/pkg/scsi/backingstore.go index 10adff5..920f97a 100644 --- a/pkg/scsi/backingstore.go +++ b/pkg/scsi/backingstore.go @@ -153,7 +153,7 @@ write: if err != nil { log.Error(err) key = MEDIUM_ERROR - asc = ASC_READ_ERROR + asc = ASC_WRITE_ERROR goto sense } log.Debugf("write data at 0x%x for length %d", offset, len(wbuf)) @@ -172,7 +172,7 @@ write: if ((opcode != api.WRITE_6) && (scb[1]&0x8 != 0)) || (pg.Data[0]&0x04 == 0) { if err = bs.DataSync(int64(offset), tl); err != nil { key = MEDIUM_ERROR - asc = ASC_READ_ERROR + asc = ASC_WRITE_ERROR goto sense } } diff --git a/pkg/scsi/sbc.go b/pkg/scsi/sbc.go index 1cb2c78..13dc242 100644 --- a/pkg/scsi/sbc.go +++ b/pkg/scsi/sbc.go @@ -459,7 +459,9 @@ func SBCReadWrite(host int, cmd *api.SCSICommand) api.SAMStat { err, key, asc = bsPerformCommand(dev.Storage, cmd) if err != nil { - goto sense + log.Errorf("Error from backend: %v", err) + BuildSenseData(cmd, key, asc) + return api.SAMStatBusy } else { return api.SAMStatGood }