[PATCH 1/2] scsi: target: core: Add sense reason for space allocation errors

Konstantin Shelekhin
2021-10-20T18:43:39Z

According to SBC-3 4.7.3.6 this sense reason shall be used in situations
where thin provisioned logical unit cannot satisfy the write request due
to the lack of free blocks.

Signed-off-by: Konstantin Shelekhin <k.shelekhin@yadro.com>
Reviewed-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
drivers/target/target_core_transport.c | 6 ++++++
include/target/target_core_base.h | 1 +
2 files changed, 7 insertions(+)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 14c6f2bb1b01..d8261bd1cb5c 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2025,6 +2025,7 @@ void transport_generic_request_failure(struct se_cmd *cmd,
case TCM_ALUA_TG_PT_UNAVAILABLE:
case TCM_ALUA_STATE_TRANSITION:
case TCM_ALUA_OFFLINE:
+ case TCM_SPACE_ALLOCATION_FAILED:
break;
case TCM_OUT_OF_RESOURCES:
cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
@@ -3369,6 +3370,11 @@ static const struct sense_detail sense_detail_table[] = {
.asc = 0x04,
.ascq = ASCQ_04H_ALUA_OFFLINE,
},
+ [TCM_SPACE_ALLOCATION_FAILED] = {
+ .key = DATA_PROTECT,
+ .asc = 0x27,
+ .ascq = 0x07, /* SPACE ALLOCATION FAILED WRITE PROTECT */
+ },
};

/**
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index fb11c7693b25..fe2f1c5bb1b8 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -192,6 +192,7 @@ enum tcm_sense_reason_table {
TCM_ALUA_TG_PT_UNAVAILABLE = R(0x21),
TCM_ALUA_STATE_TRANSITION = R(0x22),
TCM_ALUA_OFFLINE = R(0x23),
+ TCM_SPACE_ALLOCATION_FAILED = R(0x24),
#undef R
};

--
2.33.0