diff mbox series

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

Message ID 20230517141537.80936-2-k.shelekhin@yadro.com
State New
Headers show
Series scsi: target: iblock: Report space allocation errors | expand

Commit Message

Konstantin Shelekhin May 17, 2023, 2:15 p.m. UTC
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 mbox series

Patch

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 86adff2a86ed..9b41d2d78e98 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2072,6 +2072,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;
@@ -3474,6 +3475,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 5f8e96f1516f..aac475a9184e 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -194,6 +194,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
 };