Message ID | 1437516477-30554-1-git-send-email-sbaugh@catern.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Jul 21, 2015 at 03:07:53PM -0700, Spencer Baugh wrote: > +static sense_reason_t > +sbc_emulate_startstop(struct se_cmd *cmd) > +{ > + unsigned char *cdb = cmd->t_task_cdb; > + > + /* From SBC-3: > + * Immediate bit should be set since there is nothing to complete > + * POWER CONDITION MODIFIER 0h > + */ Mot of the target code mentions the exact document and section, e.g. drivers/target/target_core_alua.c: * See sbc3r35 section 5.23 drivers/target/target_core_sbc.c: * Set Thin Provisioning Enable bit following sbc3r22 in section drivers/target/target_core_sbc.c: * From sbc3r22.pdf section 5.48 XDWRITEREAD (10) command Also if you fix thing up anyway the Linux style is to keep the opening "/*" on a separate line. > + if (!(cdb[1] & 1) || (cdb[2] | cdb[3])) > + return TCM_INVALID_CDB_FIELD; The mix of || and | here is odd, why not just: if (!(cdb[1] & 1) || cdb[2] || cdb[3]) > + if (!(cdb[4] & 1) || ((cdb[4] & 2) | (cdb[4] & 4))) Same here. But except for this nitpicking the patch looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index e318ddb..996e584 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -154,6 +154,35 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd) return 0; } +static sense_reason_t +sbc_emulate_startstop(struct se_cmd *cmd) +{ + unsigned char *cdb = cmd->t_task_cdb; + + /* From SBC-3: + * Immediate bit should be set since there is nothing to complete + * POWER CONDITION MODIFIER 0h + */ + if (!(cdb[1] & 1) || (cdb[2] | cdb[3])) + return TCM_INVALID_CDB_FIELD; + + /* From SBC-3: + * POWER CONDITION 0h START_VALID - process START and LOEJ + */ + if (cdb[4] >> 4 & 0xf) + return TCM_INVALID_CDB_FIELD; + + /* From SBC-3: + * LOEJ 0h - nothing to load or unload + * START 1h - we are ready + */ + if (!(cdb[4] & 1) || ((cdb[4] & 2) | (cdb[4] & 4))) + return TCM_INVALID_CDB_FIELD; + + target_complete_cmd(cmd, SAM_STAT_GOOD); + return 0; +} + sector_t sbc_get_write_same_sectors(struct se_cmd *cmd) { u32 num_blocks; @@ -1069,6 +1098,10 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) size = 0; cmd->execute_cmd = sbc_emulate_noop; break; + case START_STOP: + size = 0; + cmd->execute_cmd = sbc_emulate_startstop; + break; default: ret = spc_parse_cdb(cmd, &size); if (ret)