[stgt] [PATCH] Implement error checking in VERIFY10/12/16
FUJITA Tomonori
fujita.tomonori at lab.ntt.co.jp
Thu Jan 26 02:00:22 CET 2012
On Thu, 26 Jan 2012 11:17:39 +1100
ronnie sahlberg <ronniesahlberg at gmail.com> wrote:
> From dfb19f35441d137ef4b82cec924a8746cb1c040d Mon Sep 17 00:00:00 2001
> From: Ronnie Sahlberg <ronniesahlberg at gmail.com>
> Date: Thu, 26 Jan 2012 10:35:22 +1100
> Subject: [PATCH] SBC VERIFY: Update VERIFY to check vprotect argument
>
> TGTD does not support formatting protection information so make
> TGTD fail a VERIFY command requesting vprotect != 0 with a proper
> check condition.
>
> Add VERIFY12/VERIFY16. These are both identical to the already existing VERIFY10 as far as we are converned.
>
> See SBC 5.22 VERIFY 10 COMMAND, tables 65 and 66
> If the media is not formatted with protection information (as in TGTD)
> any value of vprotect other than 000b is an error condition and the device h
>
> Signed-off-by: Ronnie Sahlberg <ronniesahlberg at gmail.com>
> ---
> usr/sbc.c | 25 ++++++++++++++++++++++---
> 1 files changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/usr/sbc.c b/usr/sbc.c
> index 53e785b..23b1778 100644
> --- a/usr/sbc.c
> +++ b/usr/sbc.c
> @@ -265,7 +265,26 @@ sense:
>
> static int sbc_verify(int host_no, struct scsi_cmd *cmd)
> {
> - return SAM_STAT_GOOD;
> + unsigned char key;
> + uint16_t asc;
> + int vprotect;
> +
> + vprotect = cmd->scb[1] & 0xe0;
> + if (vprotect != 0) {
> + /* we dont support formatting with protection information,
> + * so all verify with vprotect!=0 is an error condition
> + */
> + key = ILLEGAL_REQUEST;
> + asc = ASC_INVALID_FIELD_IN_CDB;
> + goto sense;
> + }
> +
> + return SAM_STAT_GOOD;
Hmm, should we implement VERIFY (such as data comparison) instead of
returning GOOD if we replace illegal_op?
> +sense:
> + scsi_set_in_resid_by_actual(cmd, 0);
> + sense_data_build(cmd, key, asc);
> + return SAM_STAT_CHECK_CONDITION;
> }
>
> static int sbc_service_action(int host_no, struct scsi_cmd *cmd)
> @@ -506,7 +525,7 @@ static struct device_type_template sbc_template = {
> {spc_illegal_op,},
> {spc_illegal_op,},
> {spc_illegal_op,},
> - {spc_illegal_op,},
> + {sbc_verify, NULL, PR_EA_FA|PR_EA_FN},
>
> /* 0x90 */
> {sbc_rw, NULL, PR_EA_FA|PR_EA_FN}, /*PRE_FETCH_16 */
> @@ -544,7 +563,7 @@ static struct device_type_template sbc_template = {
> {spc_illegal_op,},
> {spc_illegal_op,},
> {spc_illegal_op,},
> - {spc_illegal_op,},
> + {sbc_verify, NULL, PR_EA_FA|PR_EA_FN},
>
> [0xb0 ... 0xff] = {spc_illegal_op},
> }
> --
> 1.7.3.1
>
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list