Skip to contentSkip to conversation

target: Return an error for WRITE SAME with ANCHOR==1

PATCH Applied Roland Dreier 2 participants 2 messages Oct 14, 2013 – Oct 16, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target: Return an error for WRITE SAME with ANCHOR==1

From: Roland Dreier <[email protected]>

Per SBC-3, since we report ANC_SUP==0 in VPD page B2h, we need to return an error (ILLEGAL REQUEST/INVALID FIELD IN CDB) for all WRITE SAME requests with ANCHOR==1.

---
 drivers/target/target_core_sbc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/target/target_core_sbc.c +5 -0
index 4714c6f8da4b..d9b92b2c524d 100644
@@ -263,6 +263,11 @@ sbc_setup_write_same(struct se_cmd *cmd, unsigned char *flags, struct sbc_ops *o
 			sectors, cmd->se_dev->dev_attrib.max_write_same_len);
 		return TCM_INVALID_CDB_FIELD;
 	}
+	/* We always have ANC_SUP == 0 so setting ANCHOR is always an error */
+	if (flags[0] & 0x10) {
+		pr_warn("WRITE SAME with ANCHOR not supported\n");
+		return TCM_INVALID_CDB_FIELD;
+	}
 	/*
 	 * Special case for WRITE_SAME w/ UNMAP=1 that ends up getting
 	 * translated into block discard requests within backend code.
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 7 lines · Roland Dreier

From: Roland Dreier <[email protected]>

Per SBC-3, since we report ANC_SUP==0 in VPD page B2h, we need to return an error (ILLEGAL REQUEST/INVALID FIELD IN CDB) for all WRITE SAME requests with ANCHOR==1.

Applied to target-pending/master.

Thanks Roland!

--nab

Quoted 20 lines
---
 drivers/target/target_core_sbc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/target/target_core_sbc.c +5 -0
index 4714c6f8da4b..d9b92b2c524d 100644
@@ -263,6 +263,11 @@ sbc_setup_write_same(struct se_cmd *cmd, unsigned char *flags, struct sbc_ops *o
 			sectors, cmd->se_dev->dev_attrib.max_write_same_len);
 		return TCM_INVALID_CDB_FIELD;
 	}
+	/* We always have ANC_SUP == 0 so setting ANCHOR is always an error */
+	if (flags[0] & 0x10) {
+		pr_warn("WRITE SAME with ANCHOR not supported\n");
+		return TCM_INVALID_CDB_FIELD;
+	}
 	/*
 	 * Special case for WRITE_SAME w/ UNMAP=1 that ends up getting
 	 * translated into block discard requests within backend code.