Fix incorrect NUMBER OF LOGICAL BLOCKS handling in WRITE SAME command

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5015 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2013-10-02 05:10:56 +00:00
parent 69643b4b5d
commit f27af1b46e
2 changed files with 11 additions and 0 deletions

View File

@@ -2245,6 +2245,11 @@ static enum compl_status_e vdisk_exec_write_same(struct vdisk_cmd_params *p)
goto out;
}
if (unlikely(cmd->data_len <= 0)) {
scst_set_invalid_field_in_cdb(cmd, cmd->len_off, 0);
goto out;
}
if (cmd->cdb[1] & 0x8) {
vdisk_exec_write_same_unmap(p);
goto out;
@@ -2507,6 +2512,7 @@ static enum compl_status_e vdisk_exec_inquiry(struct vdisk_cmd_params *p)
int max_transfer;
buf[1] = 0xB0;
buf[3] = 0x3C;
buf[4] = 1; /* WSNZ set */
/* Optimal transfer granuality is PAGE_SIZE */
put_unaligned_be16(max_t(int, PAGE_SIZE/dev->block_size, 1), &buf[6]);

View File

@@ -4859,6 +4859,11 @@ void scst_write_same(struct scst_cmd *cmd)
TRACE_ENTRY();
if (unlikely(cmd->data_len <= 0)) {
scst_set_invalid_field_in_cdb(cmd, cmd->len_off, 0);
goto out_done;
}
if (cmd->sg_cnt != 1) {
PRINT_ERROR("WRITE SAME must contain only single block of data "
"in a single SG (cmd %p)", cmd);