target: Return an error for WRITE SAME with ANCHOR==1
authorRoland Dreier <roland@purestorage.com>
Mon, 14 Oct 2013 22:49:23 +0000 (15:49 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 16 Oct 2013 20:32:07 +0000 (13:32 -0700)
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.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_sbc.c

index 4714c6f8da4be5fe39e797237fa8a35de0450883..d9b92b2c524d4f055a035f4343175fbdd3877c4c 100644 (file)
@@ -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.